Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

104 Zeilen
3.0 KiB

  1. //-------------------------------------------------------------------------
  2. // MODULE INIT FUNCTIONS
  3. //-------------------------------------------------------------------------
  4. function RegisterListener()
  5. {
  6. //Register all the correct functions to the listener
  7. var div_listener = GetiFrameDivEmbed();
  8. if (div_listener)
  9. {
  10. div_listener.addEventListener('loadstart', NaClModuleStartedLoad, true);
  11. div_listener.addEventListener('load', NaClModuleDidLoad, true);
  12. div_listener.addEventListener('error', NaClModuleError, true);
  13. div_listener.addEventListener('progress', NaClModuleLoadUpdate, true);
  14. div_listener.addEventListener('message', NaClModuleSentMessage, true);
  15. div_listener.addEventListener('crash', NaClModuleCrash, true);
  16. window.setTimeout("UpdateTextStatus(0.1)", 100);
  17. }
  18. else if (IsUsingNaCl())
  19. window.setTimeout("RegisterListener()", 200);
  20. }
  21. function NaClInitModuleVar()
  22. {
  23. InitModuleVar();
  24. if (g_embed_module)
  25. g_embed_module['SendMessage'] = function(message) { g_embed_module.postMessage(message); }
  26. }
  27. //-------------------------------------------------------------------------
  28. // MODULE LOADING FUNCTIONS
  29. //-------------------------------------------------------------------------
  30. //Indicate page has been loaded.
  31. function NaClLoadingInit()
  32. {
  33. HideProgressStatus(false);
  34. //Page did load before NaCl module
  35. if (!g_embed_module)
  36. AddTextStatus('Please wait for module loading');
  37. RegisterListener();
  38. }
  39. //Module starts load
  40. function NaClModuleStartedLoad()
  41. {
  42. AddTextStatus('Module Started Loading');
  43. NaClInitModuleVar();
  44. }
  45. //Module progress event
  46. function NaClModuleLoadUpdate(event)
  47. {
  48. if (event.lengthComputable)
  49. UpdateProgressBarValue('Please wait, loading', event.loaded, event.total);
  50. else
  51. UpdateProgressBarValue('Please wait, calculating load balance ...');
  52. }
  53. //Indicate module load success.
  54. function NaClModuleDidLoad()
  55. {
  56. if (!g_embed_module)
  57. NaClInitModuleVar();
  58. //Hide the progress div
  59. AddTextStatus('Module is live, thank you for your patience.');
  60. window.setTimeout('HideProgressStatus(true)', GetMaxStatusTime(0.5) * 1000);
  61. }
  62. //Module did crash
  63. function NaClModuleCrash(event)
  64. {
  65. NaClRestartModule();
  66. AddTextStatus("Module has crashed ! Restarting ...");
  67. }
  68. //Module had an error
  69. function NaClModuleError(event)
  70. {
  71. NaClRestartModule();
  72. AddTextStatus("Module Load/start Error ! Restarting ...");
  73. }
  74. //Used to restart module on crash/error/load fail ....
  75. function NaClRestartModule()
  76. {
  77. var id_frame_embed = GetFrameData();
  78. if (id_frame_embed)
  79. {
  80. HideProgressStatus(false);
  81. window.setTimeout('GetFrameData().contentDocument.location.reload(true)', 1000);
  82. }
  83. }
  84. //-------------------------------------------------------------------------
  85. // MODULE COMMUNICATION FUNCTIONS
  86. //-------------------------------------------------------------------------
  87. //Handle message from the NaCl module
  88. function NaClModuleSentMessage(message)
  89. {
  90. ModuleSentMessage(message);
  91. }