PageRenderTime 53ms CodeModel.GetById 12ms app.highlight 35ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-tds/web/resources/flash/swfobject.js

http://nimbits-server.googlecode.com/
JavaScript | 617 lines | 583 code | 21 blank | 13 comment | 272 complexity | b170a7f6dff73dd6d739ae1d4128b753 MD5 | raw file
  1/*
  2 * Copyright (c) 2010 Tonic Solutions LLC.
  3 *
  4 * http://www.nimbits.com
  5 *
  6 *
  7 * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
  8 *
  9 * http://www.gnu.org/licenses/gpl.html
 10 *
 11 * Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 12 */
 13var swfobject = function() {
 14    var b = "undefined",Q = "object",n = "Shockwave Flash",p = "ShockwaveFlash.ShockwaveFlash",P = "application/x-shockwave-flash",m = "SWFObjectExprInst",j = window,K = document,T = navigator,o = [],N = [],i = [],d = [],J,Z = null,M = null,l = null,e = false,A = false;
 15    var h = function() {
 16        var v = typeof K.getElementById != b && typeof K.getElementsByTagName != b && typeof K.createElement != b,AC = [0,0,0],x = null;
 17        if (typeof T.plugins != b && typeof T.plugins[n] == Q) {
 18            x = T.plugins[n].description;
 19            if (x && !(typeof T.mimeTypes != b && T.mimeTypes[P] && !T.mimeTypes[P].enabledPlugin)) {
 20                x = x.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
 21                AC[0] = parseInt(x.replace(/^(.*)\..*$/, "$1"), 10);
 22                AC[1] = parseInt(x.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
 23                AC[2] = /r/.test(x) ? parseInt(x.replace(/^.*r(.*)$/, "$1"), 10) : 0
 24            }
 25        } else {
 26            if (typeof j.ActiveXObject != b) {
 27                var y = null,AB = false;
 28                try {
 29                    y = new ActiveXObject(p + ".7")
 30                } catch(t) {
 31                    try {
 32                        y = new ActiveXObject(p + ".6");
 33                        AC = [6,0,21];
 34                        y.AllowScriptAccess = "always"
 35                    } catch(t) {
 36                        if (AC[0] == 6) {
 37                            AB = true
 38                        }
 39                    }
 40                    if (!AB) {
 41                        try {
 42                            y = new ActiveXObject(p)
 43                        } catch(t) {
 44                        }
 45                    }
 46                }
 47                if (!AB && y) {
 48                    try {
 49                        x = y.GetVariable("$version");
 50                        if (x) {
 51                            x = x.split(" ")[1].split(",");
 52                            AC = [parseInt(x[0], 10),parseInt(x[1], 10),parseInt(x[2], 10)]
 53                        }
 54                    } catch(t) {
 55                    }
 56                }
 57            }
 58        }
 59        var AD = T.userAgent.toLowerCase(),r = T.platform.toLowerCase(),AA = /webkit/.test(AD) ? parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false,q = false,z = r ? /win/.test(r) : /win/.test(AD),w = r ? /mac/.test(r) : /mac/.test(AD);
 60        /*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/
 61        return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}
 62    }();
 63    var L = function() {
 64        if (!h.w3cdom) {
 65            return
 66        }
 67        f(H);
 68        if (h.ie && h.win) {
 69            try {
 70                K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");
 71                J = C("__ie_ondomload");
 72                if (J) {
 73                    I(J, "onreadystatechange", S)
 74                }
 75            } catch(q) {
 76            }
 77        }
 78        if (h.webkit && typeof K.readyState != b) {
 79            Z = setInterval(function() {
 80                if (/loaded|complete/.test(K.readyState)) {
 81                    E()
 82                }
 83            }, 10)
 84        }
 85        if (typeof K.addEventListener != b) {
 86            K.addEventListener("DOMContentLoaded", E, null)
 87        }
 88        R(E)
 89    }();
 90
 91    function S() {
 92        if (J.readyState == "complete") {
 93            J.parentNode.removeChild(J);
 94            E()
 95        }
 96    }
 97
 98    function E() {
 99        if (e) {
100            return
101        }
102        if (h.ie && h.win) {
103            var v = a("span");
104            try {
105                var u = K.getElementsByTagName("body")[0].appendChild(v);
106                u.parentNode.removeChild(u)
107            } catch(w) {
108                return
109            }
110        }
111        e = true;
112        if (Z) {
113            clearInterval(Z);
114            Z = null
115        }
116        var q = o.length;
117        for (var r = 0; r < q; r++) {
118            o[r]()
119        }
120    }
121
122    function f(q) {
123        if (e) {
124            q()
125        } else {
126            o[o.length] = q
127        }
128    }
129
130    function R(r) {
131        if (typeof j.addEventListener != b) {
132            j.addEventListener("load", r, false)
133        } else {
134            if (typeof K.addEventListener != b) {
135                K.addEventListener("load", r, false)
136            } else {
137                if (typeof j.attachEvent != b) {
138                    I(j, "onload", r)
139                } else {
140                    if (typeof j.onload == "function") {
141                        var q = j.onload;
142                        j.onload = function() {
143                            q();
144                            r()
145                        }
146                    } else {
147                        j.onload = r
148                    }
149                }
150            }
151        }
152    }
153
154    function H() {
155        var t = N.length;
156        for (var q = 0; q < t; q++) {
157            var u = N[q].id;
158            if (h.pv[0] > 0) {
159                var r = C(u);
160                if (r) {
161                    N[q].width = r.getAttribute("width") ? r.getAttribute("width") : "0";
162                    N[q].height = r.getAttribute("height") ? r.getAttribute("height") : "0";
163                    if (c(N[q].swfVersion)) {
164                        if (h.webkit && h.webkit < 312) {
165                            Y(r)
166                        }
167                        W(u, true)
168                    } else {
169                        if (N[q].expressInstall && !A && c("6.0.65") && (h.win || h.mac)) {
170                            k(N[q])
171                        } else {
172                            O(r)
173                        }
174                    }
175                }
176            } else {
177                W(u, true)
178            }
179        }
180    }
181
182    function Y(t) {
183        var q = t.getElementsByTagName(Q)[0];
184        if (q) {
185            var w = a("embed"),y = q.attributes;
186            if (y) {
187                var v = y.length;
188                for (var u = 0; u < v; u++) {
189                    if (y[u].nodeName == "DATA") {
190                        w.setAttribute("src", y[u].nodeValue)
191                    } else {
192                        w.setAttribute(y[u].nodeName, y[u].nodeValue)
193                    }
194                }
195            }
196            var x = q.childNodes;
197            if (x) {
198                var z = x.length;
199                for (var r = 0; r < z; r++) {
200                    if (x[r].nodeType == 1 && x[r].nodeName == "PARAM") {
201                        w.setAttribute(x[r].getAttribute("name"), x[r].getAttribute("value"))
202                    }
203                }
204            }
205            t.parentNode.replaceChild(w, t)
206        }
207    }
208
209    function k(w) {
210        A = true;
211        var u = C(w.id);
212        if (u) {
213            if (w.altContentId) {
214                var y = C(w.altContentId);
215                if (y) {
216                    M = y;
217                    l = w.altContentId
218                }
219            } else {
220                M = G(u)
221            }
222            if (!(/%$/.test(w.width)) && parseInt(w.width, 10) < 310) {
223                w.width = "310"
224            }
225            if (!(/%$/.test(w.height)) && parseInt(w.height, 10) < 137) {
226                w.height = "137"
227            }
228            K.title = K.title.slice(0, 47) + " - Flash Player Installation";
229            var z = h.ie && h.win ? "ActiveX" : "PlugIn",q = K.title,r = "MMredirectURL=" + j.location + "&MMplayerType=" + z + "&MMdoctitle=" + q,x = w.id;
230            if (h.ie && h.win && u.readyState != 4) {
231                var t = a("div");
232                x += "SWFObjectNew";
233                t.setAttribute("id", x);
234                u.parentNode.insertBefore(t, u);
235                u.style.display = "none";
236                var v = function() {
237                    u.parentNode.removeChild(u)
238                };
239                I(j, "onload", v)
240            }
241            U({data:w.expressInstall,id:m,width:w.width,height:w.height}, {flashvars:r}, x)
242        }
243    }
244
245    function O(t) {
246        if (h.ie && h.win && t.readyState != 4) {
247            var r = a("div");
248            t.parentNode.insertBefore(r, t);
249            r.parentNode.replaceChild(G(t), r);
250            t.style.display = "none";
251            var q = function() {
252                t.parentNode.removeChild(t)
253            };
254            I(j, "onload", q)
255        } else {
256            t.parentNode.replaceChild(G(t), t)
257        }
258    }
259
260    function G(v) {
261        var u = a("div");
262        if (h.win && h.ie) {
263            u.innerHTML = v.innerHTML
264        } else {
265            var r = v.getElementsByTagName(Q)[0];
266            if (r) {
267                var w = r.childNodes;
268                if (w) {
269                    var q = w.length;
270                    for (var t = 0; t < q; t++) {
271                        if (!(w[t].nodeType == 1 && w[t].nodeName == "PARAM") && !(w[t].nodeType == 8)) {
272                            u.appendChild(w[t].cloneNode(true))
273                        }
274                    }
275                }
276            }
277        }
278        return u
279    }
280
281    function U(AG, AE, t) {
282        var q,v = C(t);
283        if (v) {
284            if (typeof AG.id == b) {
285                AG.id = t
286            }
287            if (h.ie && h.win) {
288                var AF = "";
289                for (var AB in AG) {
290                    if (AG[AB] != Object.prototype[AB]) {
291                        if (AB.toLowerCase() == "data") {
292                            AE.movie = AG[AB]
293                        } else {
294                            if (AB.toLowerCase() == "styleclass") {
295                                AF += ' class="' + AG[AB] + '"'
296                            } else {
297                                if (AB.toLowerCase() != "classid") {
298                                    AF += " " + AB + '="' + AG[AB] + '"'
299                                }
300                            }
301                        }
302                    }
303                }
304                var AD = "";
305                for (var AA in AE) {
306                    if (AE[AA] != Object.prototype[AA]) {
307                        AD += '<param name="' + AA + '" value="' + AE[AA] + '" />'
308                    }
309                }
310                v.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + AF + ">" + AD + "</object>";
311                i[i.length] = AG.id;
312                q = C(AG.id)
313            } else {
314                if (h.webkit && h.webkit < 312) {
315                    var AC = a("embed");
316                    AC.setAttribute("type", P);
317                    for (var z in AG) {
318                        if (AG[z] != Object.prototype[z]) {
319                            if (z.toLowerCase() == "data") {
320                                AC.setAttribute("src", AG[z])
321                            } else {
322                                if (z.toLowerCase() == "styleclass") {
323                                    AC.setAttribute("class", AG[z])
324                                } else {
325                                    if (z.toLowerCase() != "classid") {
326                                        AC.setAttribute(z, AG[z])
327                                    }
328                                }
329                            }
330                        }
331                    }
332                    for (var y in AE) {
333                        if (AE[y] != Object.prototype[y]) {
334                            if (y.toLowerCase() != "movie") {
335                                AC.setAttribute(y, AE[y])
336                            }
337                        }
338                    }
339                    v.parentNode.replaceChild(AC, v);
340                    q = AC
341                } else {
342                    var u = a(Q);
343                    u.setAttribute("type", P);
344                    for (var x in AG) {
345                        if (AG[x] != Object.prototype[x]) {
346                            if (x.toLowerCase() == "styleclass") {
347                                u.setAttribute("class", AG[x])
348                            } else {
349                                if (x.toLowerCase() != "classid") {
350                                    u.setAttribute(x, AG[x])
351                                }
352                            }
353                        }
354                    }
355                    for (var w in AE) {
356                        if (AE[w] != Object.prototype[w] && w.toLowerCase() != "movie") {
357                            F(u, w, AE[w])
358                        }
359                    }
360                    v.parentNode.replaceChild(u, v);
361                    q = u
362                }
363            }
364        }
365        return q
366    }
367
368    function F(t, q, r) {
369        var u = a("param");
370        u.setAttribute("name", q);
371        u.setAttribute("value", r);
372        t.appendChild(u)
373    }
374
375    function X(r) {
376        var q = C(r);
377        if (q && (q.nodeName == "OBJECT" || q.nodeName == "EMBED")) {
378            if (h.ie && h.win) {
379                if (q.readyState == 4) {
380                    B(r)
381                } else {
382                    j.attachEvent("onload", function() {
383                        B(r)
384                    })
385                }
386            } else {
387                q.parentNode.removeChild(q)
388            }
389        }
390    }
391
392    function B(t) {
393        var r = C(t);
394        if (r) {
395            for (var q in r) {
396                if (typeof r[q] == "function") {
397                    r[q] = null
398                }
399            }
400            r.parentNode.removeChild(r)
401        }
402    }
403
404    function C(t) {
405        var q = null;
406        try {
407            q = K.getElementById(t)
408        } catch(r) {
409        }
410        return q
411    }
412
413    function a(q) {
414        return K.createElement(q)
415    }
416
417    function I(t, q, r) {
418        t.attachEvent(q, r);
419        d[d.length] = [t,q,r]
420    }
421
422    function c(t) {
423        var r = h.pv,q = t.split(".");
424        q[0] = parseInt(q[0], 10);
425        q[1] = parseInt(q[1], 10) || 0;
426        q[2] = parseInt(q[2], 10) || 0;
427        return(r[0] > q[0] || (r[0] == q[0] && r[1] > q[1]) || (r[0] == q[0] && r[1] == q[1] && r[2] >= q[2])) ? true : false
428    }
429
430    function V(v, r) {
431        if (h.ie && h.mac) {
432            return
433        }
434        var u = K.getElementsByTagName("head")[0],t = a("style");
435        t.setAttribute("type", "text/css");
436        t.setAttribute("media", "screen");
437        if (!(h.ie && h.win) && typeof K.createTextNode != b) {
438            t.appendChild(K.createTextNode(v + " {" + r + "}"))
439        }
440        u.appendChild(t);
441        if (h.ie && h.win && typeof K.styleSheets != b && K.styleSheets.length > 0) {
442            var q = K.styleSheets[K.styleSheets.length - 1];
443            if (typeof q.addRule == Q) {
444                q.addRule(v, r)
445            }
446        }
447    }
448
449    function W(t, q) {
450        var r = q ? "visible" : "hidden";
451        if (e && C(t)) {
452            C(t).style.visibility = r
453        } else {
454            V("#" + t, "visibility:" + r)
455        }
456    }
457
458    function g(s) {
459        var r = /[\\\"<>\.;]/;
460        var q = r.exec(s) != null;
461        return q ? encodeURIComponent(s) : s
462    }
463
464    var D = function() {
465        if (h.ie && h.win) {
466            window.attachEvent("onunload", function() {
467                var w = d.length;
468                for (var v = 0; v < w; v++) {
469                    d[v][0].detachEvent(d[v][1], d[v][2])
470                }
471                var t = i.length;
472                for (var u = 0; u < t; u++) {
473                    X(i[u])
474                }
475                for (var r in h) {
476                    h[r] = null
477                }
478                h = null;
479                for (var q in swfobject) {
480                    swfobject[q] = null
481                }
482                swfobject = null
483            })
484        }
485    }();
486    return{registerObject:function(u, q, t) {
487        if (!h.w3cdom || !u || !q) {
488            return
489        }
490        var r = {};
491        r.id = u;
492        r.swfVersion = q;
493        r.expressInstall = t ? t : false;
494        N[N.length] = r;
495        W(u, false)
496    },getObjectById:function(v) {
497        var q = null;
498        if (h.w3cdom) {
499            var t = C(v);
500            if (t) {
501                var u = t.getElementsByTagName(Q)[0];
502                if (!u || (u && typeof t.SetVariable != b)) {
503                    q = t
504                } else {
505                    if (typeof u.SetVariable != b) {
506                        q = u
507                    }
508                }
509            }
510        }
511        return q
512    },embedSWF:function(x, AE, AB, AD, q, w, r, z, AC) {
513        if (!h.w3cdom || !x || !AE || !AB || !AD || !q) {
514            return
515        }
516        AB += "";
517        AD += "";
518        if (c(q)) {
519            W(AE, false);
520            var AA = {};
521            if (AC && typeof AC === Q) {
522                for (var v in AC) {
523                    if (AC[v] != Object.prototype[v]) {
524                        AA[v] = AC[v]
525                    }
526                }
527            }
528            AA.data = x;
529            AA.width = AB;
530            AA.height = AD;
531            var y = {};
532            if (z && typeof z === Q) {
533                for (var u in z) {
534                    if (z[u] != Object.prototype[u]) {
535                        y[u] = z[u]
536                    }
537                }
538            }
539            if (r && typeof r === Q) {
540                for (var t in r) {
541                    if (r[t] != Object.prototype[t]) {
542                        if (typeof y.flashvars != b) {
543                            y.flashvars += "&" + t + "=" + r[t]
544                        } else {
545                            y.flashvars = t + "=" + r[t]
546                        }
547                    }
548                }
549            }
550            f(function() {
551                U(AA, y, AE);
552                if (AA.id == AE) {
553                    W(AE, true)
554                }
555            })
556        } else {
557            if (w && !A && c("6.0.65") && (h.win || h.mac)) {
558                A = true;
559                W(AE, false);
560                f(function() {
561                    var AF = {};
562                    AF.id = AF.altContentId = AE;
563                    AF.width = AB;
564                    AF.height = AD;
565                    AF.expressInstall = w;
566                    k(AF)
567                })
568            }
569        }
570    },getFlashPlayerVersion:function() {
571        return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}
572    },hasFlashPlayerVersion:c,createSWF:function(t, r, q) {
573        if (h.w3cdom) {
574            return U(t, r, q)
575        } else {
576            return undefined
577        }
578    },removeSWF:function(q) {
579        if (h.w3cdom) {
580            X(q)
581        }
582    },createCSS:function(r, q) {
583        if (h.w3cdom) {
584            V(r, q)
585        }
586    },addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v) {
587        var u = K.location.search || K.location.hash;
588        if (v == null) {
589            return g(u)
590        }
591        if (u) {
592            var t = u.substring(1).split("&");
593            for (var r = 0; r < t.length; r++) {
594                if (t[r].substring(0, t[r].indexOf("=")) == v) {
595                    return g(t[r].substring((t[r].indexOf("=") + 1)))
596                }
597            }
598        }
599        return""
600    },expressInstallCallback:function() {
601        if (A && M) {
602            var q = C(m);
603            if (q) {
604                q.parentNode.replaceChild(M, q);
605                if (l) {
606                    W(l, true);
607                    if (h.ie && h.win) {
608                        M.style.display = "block"
609                    }
610                }
611                M = null;
612                l = null;
613                A = false
614            }
615        }
616    }}
617}();