src/js/pop.js
branchpopcorn-port
changeset 445 c2eac11a9053
parent 442 ee6594f6d00d
child 448 fa9400275846
equal deleted inserted replaced
444:9e58d99a4ae4 445:c2eac11a9053
     1 /* wrapper that simulates popcorn.js because
     1 /* wrapper that simulates popcorn.js because
     2    popcorn is a bit unstable at the time */
     2    popcorn is a bit unstable at the time */
     3 
     3 
     4 IriSP.PopcornReplacement = {};
     4 IriSP.PopcornReplacement = {
       
     5   msgPump : {} /* used by jquery to receive and send messages */
       
     6 };
       
     7 
     5 IriSP.PopcornReplacement.media = { 
     8 IriSP.PopcornReplacement.media = { 
     6   "paused": true
     9   "paused": true
     7 };
    10 };
     8 
    11 
     9 IriSP.PopcornReplacement.listen = function(msg, callback) {
    12 IriSP.PopcornReplacement.listen = function(msg, callback) {
    10   IriSP.jQuery(IriSP.PopcornReplacement).bind(msg, function(event, rest) { callback(rest); });
    13 //  IriSP.jQuery(IriSP.PopcornReplacement.msgPump).bind(msg, function(event, rest) { callback(rest); });
       
    14   if (!IriSP.PopcornReplacement.msgPump.hasOwnProperty(msg))
       
    15     IriSP.PopcornReplacement.msgPump[msg] = [];
       
    16 
       
    17   IriSP.PopcornReplacement.msgPump[msg].push(callback);
    11 };
    18 };
    12 
    19 
    13 IriSP.PopcornReplacement.trigger = function(msg, params) {
    20 IriSP.PopcornReplacement.trigger = function(msg, params) {
    14   IriSP.jQuery(IriSP.PopcornReplacement).triggerHandler(msg, params);
    21 //  IriSP.jQuery(IriSP.PopcornReplacement.msgPump).trigger(msg, params);
       
    22   
       
    23   if (!IriSP.PopcornReplacement.msgPump.hasOwnProperty(msg))
       
    24     return;
       
    25 
       
    26   var d = IriSP.PopcornReplacement.msgPump[msg];
       
    27   for(var entry in d) {
       
    28     d[entry].call(window, params);
       
    29   }
       
    30 
    15 };
    31 };
    16 
    32 
    17 IriSP.PopcornReplacement.guid = function(prefix) {
    33 IriSP.PopcornReplacement.guid = function(prefix) {
    18   var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    34   var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    19       var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
    35       var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);