src/js/main.js
author veltr
Mon, 14 May 2012 11:57:05 +0200
changeset 901 12b2cd7e9159
parent 842 4ae2247a59f4
permissions -rw-r--r--
Compatibility for tracemanager
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     1
/* main file */
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
     2
// Why is it called main ? It only loads the libs !
520
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     3
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     4
if ( window.IriSP === undefined && window.__IriSP === undefined ) { 
520
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     5
  /**
531
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
     6
    @class
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
     7
    the object under which everything goes.        
520
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     8
  */
531
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
     9
	IriSP = {}; 
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
    10
  
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
    11
  /** Alias to IriSP for backward compatibility */
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
    12
	__IriSP = IriSP;
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    13
}
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    14
743
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    15
/* underscore comes bundled with the player and we need 
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    16
   it ASAP, so load it that way
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    17
*/
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    18
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    19
IriSP._ = window._.noConflict();
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    20
IriSP.underscore = IriSP._;
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    21
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    22
IriSP.getLib = function(lib) {
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    23
    return (
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    24
        IriSP.libFiles.useCdn && typeof IriSP.libFiles.cdn[lib] == "string"
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    25
        ? IriSP.libFiles.cdn[lib]
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    26
        : (
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    27
            typeof IriSP.libFiles.locations[lib] == "string"
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    28
            ? IriSP.libFiles.locations[lib]
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    29
            : (
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    30
                typeof IriSP.libFiles.inDefaultDir[lib] == "string"
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    31
                ? IriSP.libFiles.defaultDir + IriSP.libFiles.inDefaultDir[lib]
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    32
                : null
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    33
            )
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    34
        )
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    35
    )
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    36
}
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    37
901
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    38
IriSP._cssCache = [];
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    39
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    40
IriSP.loadCss = function(_cssFile) {
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    41
    if (typeof _cssFile === "string" && _cssFile && IriSP._(IriSP._cssCache).indexOf(_cssFile) === -1) {
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    42
        IriSP.jQuery("<link>", {
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    43
            rel : "stylesheet",
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    44
            type : "text/css",
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    45
            href : _cssFile
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    46
        }).appendTo('head');
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    47
        IriSP._cssCache.push(_cssFile);
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    48
    }
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    49
}
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    50
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    51
IriSP.loadLibs = function( config, metadata_url, callback ) {
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    52
    var $L = $LAB.script(IriSP.getLib("jQuery")).script(IriSP.getLib("swfObject")).wait()
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    53
                .script(IriSP.getLib("jQueryUI"));
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    54
                                   
835
a8af9da7c622 Integrated trace manager
veltr
parents: 834
diff changeset
    55
    if (config.player.type === "jwplayer" || config.player.type === "allocine") {
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    56
      // load our popcorn.js lookalike
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    57
      $L.script(IriSP.getLib("jwplayer"));
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    58
    } else {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    59
      // load the real popcorn
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    60
      $L.script(IriSP.getLib("popcorn")).script(IriSP.getLib("popcorn.code"));
501
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    61
      if (config.player.type === "youtube") {
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    62
        $L.script(IriSP.getLib("popcorn.youtube"));
501
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    63
      } 
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    64
      if (config.player.type === "vimeo")
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    65
        $L.script(IriSP.getLib("popcorn.vimeo"));
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    66
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    67
      /* do nothing for html5 */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    68
    }       
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    69
    
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    70
    /* widget specific requirements */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    71
    for (var idx in config.gui.widgets) {
662
5e10069c5c21 load raphael for the stackGraphWidget.
hamidouk
parents: 574
diff changeset
    72
      if (config.gui.widgets[idx].type === "PolemicWidget" ||
834
573c7ca752e0 Adapted Stackgraph for Cinecast
veltr
parents: 743
diff changeset
    73
          config.gui.widgets[idx].type === "StackGraphWidget" ||
573c7ca752e0 Adapted Stackgraph for Cinecast
veltr
parents: 743
diff changeset
    74
          config.gui.widgets[idx].type === "SparklineWidget") {        
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    75
        $L.script(IriSP.getLib("raphael"));
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    76
      }
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    77
    }
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    78
    
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    79
    // same for modules
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    80
    /*
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    81
    for (var idx in config.modules) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    82
      if (config.modules[idx].type === "PolemicWidget")
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 835
diff changeset
    83
        $L.script(IriSP.getLib("raphaelJs"));
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    84
    }
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    85
    */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    86
    $L.wait(function() {
901
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    87
        if (typeof IriSP.jQuery === "undefined" && typeof window.jQuery !== "undefined") {
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    88
            IriSP.jQuery = window.jQuery.noConflict();
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    89
        }
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    90
        IriSP.loadCss(IriSP.getLib("cssjQueryUI"));
12b2cd7e9159 Compatibility for tracemanager
veltr
parents: 842
diff changeset
    91
        IriSP.loadCss(config.gui.css);
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    92
          
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    93
      IriSP.setupDataLoader();
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    94
      IriSP.__dataloader.get(metadata_url, 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    95
          function(data) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    96
            /* save the data so that we could re-use it to
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    97
               configure the video
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    98
            */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    99
            IriSP.__jsonMetadata = data;
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
   100
            callback.call(window) });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
   101
    });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
   102
};