Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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