Created
June 17, 2011 03:15
-
-
Save emilepetrone/1030800 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var v = 0, | |
q = [], | |
o = {}, | |
s = {}, | |
A = { | |
"<": "lt", | |
">": "gt", | |
"&": "amp", | |
'"': "quot", | |
"'": "#39" | |
}, | |
p = /[<>&\"\']/g, | |
z, y = window.setTimeout, | |
x = {}, | |
w; | |
function t() { | |
this.returnValue = false; | |
} | |
function r() { | |
this.cancelBubble = true; | |
}(function (e) { | |
var d = e.split(/,/), | |
c, a, b; | |
for (c = 0; c < d.length; c += 2) { | |
b = d[c + 1].split(/ /); | |
for (a = 0; a < b.length; a++) { | |
s[b[a]] = d[c]; | |
} | |
} | |
})("application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb,application/vnd.ms-powerpoint,ppt pps pot,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats,docx pptx xlsx,audio/mpeg,mpga mpega mp2 mp3,audio/x-wav,wav,audio/mp4,m4a,image/bmp,bmp,image/gif,gif,image/jpeg,jpeg jpg jpe,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/html,htm html xhtml,text/rtf,rtf,video/mpeg,mpeg mpg mpe,video/quicktime,qt mov,video/mp4,mp4,video/x-m4v,m4v,video/x-flv,flv,video/vnd.rn-realvideo,rv,text/plain,asc txt text diff log,application/octet-stream,exe"); | |
var u = { | |
VERSION: "1.4.3.2", | |
STOPPED: 1, | |
STARTED: 2, | |
QUEUED: 1, | |
UPLOADING: 2, | |
FAILED: 4, | |
DONE: 5, | |
GENERIC_ERROR: -100, | |
HTTP_ERROR: -200, | |
IO_ERROR: -300, | |
SECURITY_ERROR: -400, | |
INIT_ERROR: -500, | |
FILE_SIZE_ERROR: -600, | |
FILE_EXTENSION_ERROR: -601, | |
IMAGE_FORMAT_ERROR: -700, | |
IMAGE_MEMORY_ERROR: -701, | |
IMAGE_DIMENSIONS_ERROR: -702, | |
mimeTypes: s, | |
extend: function (a) { | |
u.each(arguments, function (c, b) { | |
if (b > 0) { | |
u.each(c, function (d, e) { | |
a[e] = d; | |
}); | |
} | |
}); | |
return a; | |
}, | |
cleanName: function (c) { | |
var b, a; | |
a = [/[\300-\306]/g, "A", /[\340-\346]/g, "a", /\307/g, "C", /\347/g, "c", /[\310-\313]/g, "E", /[\350-\353]/g, "e", /[\314-\317]/g, "I", /[\354-\357]/g, "i", /\321/g, "N", /\361/g, "n", /[\322-\330]/g, "O", /[\362-\370]/g, "o", /[\331-\334]/g, "U", /[\371-\374]/g, "u"]; | |
for (b = 0; b < a.length; b += 2) { | |
c = c.replace(a[b], a[b + 1]); | |
} | |
c = c.replace(/\s+/g, "_"); | |
c = c.replace(/[^a-z0-9_\-\.]+/gi, ""); | |
return c; | |
}, | |
addRuntime: function (b, a) { | |
a.name = b; | |
q[b] = a; | |
q.push(a); | |
return a; | |
}, | |
guid: function () { | |
var b = new Date().getTime().toString(32), | |
a; | |
for (a = 0; a < 5; a++) { | |
b += Math.floor(Math.random() * 65535).toString(32); | |
} | |
return (u.guidPrefix || "p") + b + (v++).toString(32); | |
}, | |
buildUrl: function (b, c) { | |
var a = ""; | |
u.each(c, function (d, e) { | |
a += (a ? "&" : "") + encodeURIComponent(e) + "=" + encodeURIComponent(d); | |
}); | |
if (a) { | |
b += (b.indexOf("?") > 0 ? "&" : "?") + a; | |
} | |
return b; | |
}, | |
each: function (b, a) { | |
var c, d, e; | |
if (b) { | |
c = b.length; | |
if (c === z) { | |
for (d in b) { | |
if (b.hasOwnProperty(d)) { | |
if (a(b[d], d) === false) { | |
return; | |
} | |
} | |
} | |
} else { | |
for (e = 0; e < c; e++) { | |
if (a(b[e], e) === false) { | |
return; | |
} | |
} | |
} | |
} | |
}, | |
formatSize: function (a) { | |
if (a === z || /\D/.test(a)) { | |
return u.translate("N/A"); | |
} | |
if (a > 1073741824) { | |
return Math.round(a / 1073741824, 1) + " GB"; | |
} | |
if (a > 1048576) { | |
return Math.round(a / 1048576, 1) + " MB"; | |
} | |
if (a > 1024) { | |
return Math.round(a / 1024, 1) + " KB"; | |
} | |
return a + " b"; | |
}, | |
getPos: function (c, h) { | |
var g = 0, | |
j = 0, | |
e, f = document, | |
b, a; | |
c = c; | |
h = h || f.body; | |
function d(n) { | |
var k, E, m = 0, | |
l = 0; | |
if (n) { | |
E = n.getBoundingClientRect(); | |
k = f.compatMode === "CSS1Compat" ? f.documentElement : f.body; | |
m = E.left + k.scrollLeft; | |
l = E.top + k.scrollTop; | |
} | |
return { | |
x: m, | |
y: l | |
}; | |
} | |
if (c && c.getBoundingClientRect && (navigator.userAgent.indexOf("MSIE") > 0 && f.documentMode !== 8)) { | |
b = d(c); | |
a = d(h); | |
return { | |
x: b.x - a.x, | |
y: b.y - a.y | |
}; | |
} | |
e = c; | |
while (e && e != h && e.nodeType) { | |
g += e.offsetLeft || 0; | |
j += e.offsetTop || 0; | |
e = e.offsetParent; | |
} | |
e = c.parentNode; | |
while (e && e != h && e.nodeType) { | |
g -= e.scrollLeft || 0; | |
j -= e.scrollTop || 0; | |
e = e.parentNode; | |
} | |
return { | |
x: g, | |
y: j | |
}; | |
}, | |
getSize: function (a) { | |
return { | |
w: a.offsetWidth || a.clientWidth, | |
h: a.offsetHeight || a.clientHeight | |
}; | |
}, | |
parseSize: function (b) { | |
var a; | |
if (typeof (b) == "string") { | |
b = /^([0-9]+)([mgk]+)$/.exec(b.toLowerCase().replace(/[^0-9mkg]/g, "")); | |
a = b[2]; | |
b = +b[1]; | |
if (a == "g") { | |
b *= 1073741824; | |
} | |
if (a == "m") { | |
b *= 1048576; | |
} | |
if (a == "k") { | |
b *= 1024; | |
} | |
} | |
return b; | |
}, | |
xmlEncode: function (a) { | |
return a ? ("" + a).replace(p, function (b) { | |
return A[b] ? "&" + A[b] + ";" : b; | |
}) : a; | |
}, | |
toArray: function (a) { | |
var b, c = []; | |
for (b = 0; b < a.length; b++) { | |
c[b] = a[b]; | |
} | |
return c; | |
}, | |
addI18n: function (a) { | |
return u.extend(o, a); | |
}, | |
translate: function (a) { | |
return o[a] || a; | |
}, | |
isEmptyObj: function (b) { | |
if (b === z) { | |
return true; | |
} | |
for (var a in b) { | |
return false; | |
} | |
return true; | |
}, | |
hasClass: function (a, b) { | |
var c; | |
if (a.className == "") { | |
return false; | |
} | |
c = new RegExp("(^|\\s+)" + b + "(\\s+|$)"); | |
return c.test(a.className); | |
}, | |
addClass: function (a, b) { | |
if (!u.hasClass(a, b)) { | |
a.className = a.className == "" ? b : a.className.replace(/\s+$/, "") + " " + b; | |
} | |
}, | |
removeClass: function (a, b) { | |
var c = new RegExp("(^|\\s+)" + b + "(\\s+|$)"); | |
a.className = a.className.replace(c, function (e, f, d) { | |
return f === " " && d === " " ? " " : ""; | |
}); | |
}, | |
getStyle: function (a, b) { | |
if (a.currentStyle) { | |
return a.currentStyle[b]; | |
} else { | |
if (window.getComputedStyle) { | |
return window.getComputedStyle(a, null)[b]; | |
} | |
} | |
}, | |
addEvent: function (b, g, a) { | |
var c, d, e, f; | |
f = arguments[3]; | |
g = g.toLowerCase(); | |
if (w === z) { | |
w = "Plupload_" + u.guid(); | |
} | |
if (b.attachEvent) { | |
c = function () { | |
var h = window.event; | |
if (!h.target) { | |
h.target = h.srcElement; | |
} | |
h.preventDefault = t; | |
h.stopPropagation = r; | |
a(h); | |
}; | |
b.attachEvent("on" + g, c); | |
} else { | |
if (b.addEventListener) { | |
c = a; | |
b.addEventListener(g, c, false); | |
} | |
} | |
if (b[w] === z) { | |
b[w] = u.guid(); | |
} | |
if (!x.hasOwnProperty(b[w])) { | |
x[b[w]] = {}; | |
} | |
d = x[b[w]]; | |
if (!d.hasOwnProperty(g)) { | |
d[g] = []; | |
} | |
d[g].push({ | |
func: c, | |
orig: a, | |
key: f | |
}); | |
}, | |
removeEvent: function (b, g) { | |
var d, a, e; | |
if (typeof (arguments[2]) == "function") { | |
a = arguments[2]; | |
} else { | |
e = arguments[2]; | |
} | |
g = g.toLowerCase(); | |
if (b[w] && x[b[w]] && x[b[w]][g]) { | |
d = x[b[w]][g]; | |
} else { | |
return; | |
} | |
for (var f = d.length - 1; f >= 0; f--) { | |
if (d[f].key === e || d[f].orig === a) { | |
if (b.detachEvent) { | |
b.detachEvent("on" + g, d[f].func); | |
} else { | |
if (b.removeEventListener) { | |
b.removeEventListener(g, d[f].func, false); | |
} | |
} | |
d[f].orig = null; | |
d[f].func = null; | |
d.splice(f, 1); | |
if (a !== z) { | |
break; | |
} | |
} | |
} | |
if (!d.length) { | |
delete x[b[w]][g]; | |
} | |
if (u.isEmptyObj(x[b[w]])) { | |
delete x[b[w]]; | |
try { | |
delete b[w]; | |
} catch (c) { | |
b[w] = z; | |
} | |
} | |
}, | |
removeAllEvents: function (a) { | |
var b = arguments[1]; | |
if (a[w] === z || !a[w]) { | |
return; | |
} | |
u.each(x[a[w]], function (c, d) { | |
u.removeEvent(a, d, b); | |
}); | |
} | |
}; | |
u.Uploader = function (d) { | |
var f = {}, | |
a, b = [], | |
e; | |
a = new u.QueueProgress(); | |
d = u.extend({ | |
chunk_size: 0, | |
multipart: true, | |
multi_selection: true, | |
file_data_name: "file", | |
filters: [] | |
}, d); | |
function c() { | |
var j, h = 0, | |
k; | |
if (this.state == u.STARTED) { | |
for (k = 0; k < b.length; k++) { | |
if (!j && b[k].status == u.QUEUED) { | |
j = b[k]; | |
j.status = u.UPLOADING; | |
this.trigger("BeforeUpload", j); | |
this.trigger("UploadFile", j); | |
} else { | |
h++; | |
} | |
} | |
if (h == b.length) { | |
this.trigger("UploadComplete", b); | |
this.stop(); | |
} | |
} | |
} | |
function g() { | |
var h, j; | |
a.reset(); | |
for (h = 0; h < b.length; h++) { | |
j = b[h]; | |
if (j.size !== z) { | |
a.size += j.size; | |
a.loaded += j.loaded; | |
} else { | |
a.size = z; | |
} | |
if (j.status == u.DONE) { | |
a.uploaded++; | |
} else { | |
if (j.status == u.FAILED) { | |
a.failed++; | |
} else { | |
a.queued++; | |
} | |
} | |
} | |
if (a.size === z) { | |
a.percent = b.length > 0 ? Math.ceil(a.uploaded / b.length * 100) : 0; | |
} else { | |
a.bytesPerSec = Math.ceil(a.loaded / ((+new Date() - e || 1) / 1000)); | |
a.percent = a.size > 0 ? Math.ceil(a.loaded / a.size * 100) : 0; | |
} | |
} | |
u.extend(this, { | |
state: u.STOPPED, | |
runtime: "", | |
features: {}, | |
files: b, | |
settings: d, | |
total: a, | |
id: u.guid(), | |
init: function () { | |
var j = this, | |
C, h, k, m = 0, | |
n; | |
if (typeof (d.preinit) == "function") { | |
d.preinit(j); | |
} else { | |
u.each(d.preinit, function (B, E) { | |
j.bind(E, B); | |
}); | |
} | |
d.page_url = d.page_url || document.location.pathname.replace(/\/[^\/]+$/g, "/"); | |
if (!/^(\w+:\/\/|\/)/.test(d.url)) { | |
d.url = d.page_url + d.url; | |
} | |
d.chunk_size = u.parseSize(d.chunk_size); | |
d.max_file_size = u.parseSize(d.max_file_size); | |
j.bind("FilesAdded", function (O, L) { | |
var M, N, J = 0, | |
B, K = d.filters; | |
if (K && K.length) { | |
B = []; | |
u.each(K, function (D) { | |
u.each(D.extensions.split(/,/), function (E) { | |
if (/^\s*\*\s*$/.test(E)) { | |
B.push("\\.*"); | |
} else { | |
B.push("\\." + E.replace(new RegExp("[" + ("/^$.*+?|()[]{}\\".replace(/./g, "\\$&")) + "]", "g"), "\\$&")); | |
} | |
}); | |
}); | |
B = new RegExp(B.join("|") + "$", "i"); | |
} | |
for (M = 0; M < L.length; M++) { | |
N = L[M]; | |
N.loaded = 0; | |
N.percent = 0; | |
N.status = u.QUEUED; | |
if (B && !B.test(N.name)) { | |
O.trigger("Error", { | |
code: u.FILE_EXTENSION_ERROR, | |
message: u.translate("File extension error."), | |
file: N | |
}); | |
continue; | |
} | |
if (N.size !== z && N.size > d.max_file_size) { | |
O.trigger("Error", { | |
code: u.FILE_SIZE_ERROR, | |
message: u.translate("File size error."), | |
file: N | |
}); | |
continue; | |
} | |
b.push(N); | |
J++; | |
} | |
if (J) { | |
y(function () { | |
j.trigger("QueueChanged"); | |
j.refresh(); | |
}, 1); | |
} else { | |
return false; | |
} | |
}); | |
if (d.unique_names) { | |
j.bind("UploadFile", function (I, H) { | |
var B = H.name.match(/\.([^.]+)$/), | |
G = "tmp"; | |
if (B) { | |
G = B[1]; | |
} | |
H.target_name = H.id + "." + G; | |
}); | |
} | |
j.bind("UploadProgress", function (E, B) { | |
B.percent = B.size > 0 ? Math.ceil(B.loaded / B.size * 100) : 100; | |
g(); | |
}); | |
j.bind("StateChanged", function (B) { | |
if (B.state == u.STARTED) { | |
e = (+new Date()); | |
} else { | |
if (B.state == u.STOPPED) { | |
for (C = B.files.length - 1; C >= 0; C--) { | |
if (B.files[C].status == u.UPLOADING) { | |
B.files[C].status = u.QUEUED; | |
g(); | |
} | |
} | |
} | |
} | |
}); | |
j.bind("QueueChanged", g); | |
j.bind("Error", function (E, B) { | |
if (B.file) { | |
B.file.status = u.FAILED; | |
g(); | |
if (E.state == u.STARTED) { | |
y(function () { | |
c.call(j); | |
}, 1); | |
} | |
} | |
}); | |
j.bind("FileUploaded", function (E, B) { | |
B.status = u.DONE; | |
B.loaded = B.size; | |
E.trigger("UploadProgress", B); | |
y(function () { | |
c.call(j); | |
}, 1); | |
}); | |
if (d.runtimes) { | |
h = []; | |
n = d.runtimes.split(/\s?,\s?/); | |
for (C = 0; C < n.length; C++) { | |
if (q[n[C]]) { | |
h.push(q[n[C]]); | |
} | |
} | |
} else { | |
h = q; | |
} | |
function l() { | |
var B = h[m++], | |
G, I, H; | |
if (B) { | |
G = B.getFeatures(); | |
I = j.settings.required_features; | |
if (I) { | |
I = I.split(","); | |
for (H = 0; H < I.length; H++) { | |
if (!G[I[H]]) { | |
l(); | |
return; | |
} | |
} | |
} | |
B.init(j, function (D) { | |
if (D && D.success) { | |
j.features = G; | |
j.runtime = B.name; | |
j.trigger("Init", { | |
runtime: B.name | |
}); | |
j.trigger("PostInit"); | |
j.refresh(); | |
} else { | |
l(); | |
} | |
}); | |
} else { | |
j.trigger("Error", { | |
code: u.INIT_ERROR, | |
message: u.translate("Init error.") | |
}); | |
} | |
} | |
l(); | |
if (typeof (d.init) == "function") { | |
d.init(j); | |
} else { | |
u.each(d.init, function (B, E) { | |
j.bind(E, B); | |
}); | |
} | |
}, | |
refresh: function () { | |
this.trigger("Refresh"); | |
}, | |
start: function () { | |
if (this.state != u.STARTED) { | |
this.state = u.STARTED; | |
this.trigger("StateChanged"); | |
c.call(this); | |
} | |
}, | |
stop: function () { | |
if (this.state != u.STOPPED) { | |
this.state = u.STOPPED; | |
this.trigger("StateChanged"); | |
} | |
}, | |
getFile: function (h) { | |
var j; | |
for (j = b.length - 1; j >= 0; j--) { | |
if (b[j].id === h) { | |
return b[j]; | |
} | |
} | |
}, | |
removeFile: function (h) { | |
var j; | |
for (j = b.length - 1; j >= 0; j--) { | |
if (b[j].id === h.id) { | |
return this.splice(j, 1)[0]; | |
} | |
} | |
}, | |
splice: function (h, k) { | |
var j; | |
j = b.splice(h === z ? 0 : h, k === z ? b.length : k); | |
this.trigger("FilesRemoved", j); | |
this.trigger("QueueChanged"); | |
return j; | |
}, | |
trigger: function (j) { | |
var l = f[j.toLowerCase()], | |
h, k; | |
if (l) { | |
k = Array.prototype.slice.call(arguments); | |
k[0] = this; | |
for (h = 0; h < l.length; h++) { | |
if (l[h].func.apply(l[h].scope, k) === false) { | |
return false; | |
} | |
} | |
} | |
return true; | |
}, | |
bind: function (k, h, j) { | |
var l; | |
k = k.toLowerCase(); | |
l = f[k] || []; | |
l.push({ | |
func: h, | |
scope: j || this | |
}); | |
f[k] = l; | |
}, | |
unbind: function (k) { | |
k = k.toLowerCase(); | |
var l = f[k], | |
j, h = arguments[1]; | |
if (l) { | |
if (h !== z) { | |
for (j = l.length - 1; j >= 0; j--) { | |
if (l[j].func === h) { | |
l.splice(j, 1); | |
break; | |
} | |
} | |
} else { | |
l = []; | |
} | |
if (!l.length) { | |
delete f[k]; | |
} | |
} | |
}, | |
unbindAll: function () { | |
var h = this; | |
u.each(f, function (j, k) { | |
h.unbind(k); | |
}); | |
}, | |
destroy: function () { | |
this.trigger("Destroy"); | |
this.unbindAll(); | |
} | |
}); | |
}; | |
u.File = function (a, c, b) { | |
var d = this; | |
d.id = a; | |
d.name = c; | |
d.size = b; | |
d.loaded = 0; | |
d.percent = 0; | |
d.status = 0; | |
}; | |
u.Runtime = function () { | |
this.getFeatures = function () {}; | |
this.init = function (b, a) {}; | |
}; | |
u.QueueProgress = function () { | |
var a = this; | |
a.size = 0; | |
a.loaded = 0; | |
a.uploaded = 0; | |
a.failed = 0; | |
a.queued = 0; | |
a.percent = 0; | |
a.bytesPerSec = 0; | |
a.reset = function () { | |
a.size = a.loaded = a.uploaded = a.failed = a.queued = a.percent = a.bytesPerSec = 0; | |
}; | |
}; | |
u.runtimes = {}; | |
window.plupload = u; | |
})(); | |
(function () { | |
if (window.google && google.gears) { | |
return; | |
} | |
var d = null; | |
if (typeof GearsFactory != "undefined") { | |
d = new GearsFactory(); | |
} else { | |
try { | |
d = new ActiveXObject("Gears.Factory"); | |
if (d.getBuildInfo().indexOf("ie_mobile") != -1) { | |
d.privateSetGlobalObject(this); | |
} | |
} catch (c) { | |
if ((typeof navigator.mimeTypes != "undefined") && navigator.mimeTypes["application/x-googlegears"]) { | |
d = document.createElement("object"); | |
d.style.display = "none"; | |
d.width = 0; | |
d.height = 0; | |
d.type = "application/x-googlegears"; | |
document.documentElement.appendChild(d); | |
} | |
} | |
} | |
if (!d) { | |
return; | |
} | |
if (!window.google) { | |
window.google = {}; | |
} | |
if (!google.gears) { | |
google.gears = { | |
factory: d | |
}; | |
} | |
})(); | |
(function (k, g, m, l) { | |
var j = {}; | |
function h(e, c, a) { | |
var f, d, b, p; | |
d = google.gears.factory.create("beta.canvas"); | |
try { | |
d.decode(e); | |
if (!c.width) { | |
c.width = d.width; | |
} | |
if (!c.height) { | |
c.height = d.height; | |
} | |
p = Math.min(width / d.width, height / d.height); | |
if (p < 1 || (p === 1 && a === "image/jpeg")) { | |
d.resize(Math.round(d.width * p), Math.round(d.height * p)); | |
if (c.quality) { | |
return d.encode(a, { | |
quality: c.quality / 100 | |
}); | |
} | |
return d.encode(a); | |
} | |
} catch (q) {} | |
return e; | |
} | |
m.runtimes.Gears = m.addRuntime("gears", { | |
getFeatures: function () { | |
return { | |
dragdrop: true, | |
jpgresize: true, | |
pngresize: true, | |
chunks: true, | |
progress: true, | |
multipart: true | |
}; | |
}, | |
init: function (c, a) { | |
var b; | |
if (!k.google || !google.gears) { | |
return a({ | |
success: false | |
}); | |
} | |
try { | |
b = google.gears.factory.create("beta.desktop"); | |
} catch (d) { | |
return a({ | |
success: false | |
}); | |
} | |
function e(t) { | |
var u, f, s = [], | |
r; | |
for (f = 0; f < t.length; f++) { | |
u = t[f]; | |
r = m.guid(); | |
j[r] = u.blob; | |
s.push(new m.File(r, u.name, u.blob.length)); | |
} | |
c.trigger("FilesAdded", s); | |
} | |
c.bind("PostInit", function () { | |
var o = c.settings, | |
f = g.getElementById(o.drop_element); | |
if (f) { | |
m.addEvent(f, "dragover", function (n) { | |
b.setDropEffect(n, "copy"); | |
n.preventDefault(); | |
}, c.id); | |
m.addEvent(f, "drop", function (n) { | |
var q = b.getDragData(n, "application/x-gears-files"); | |
if (q) { | |
e(q.files); | |
} | |
n.preventDefault(); | |
}, c.id); | |
f = 0; | |
} | |
m.addEvent(g.getElementById(o.browse_button), "click", function (n) { | |
var t = [], | |
v, w, u; | |
n.preventDefault(); | |
for (v = 0; v < o.filters.length; v++) { | |
u = o.filters[v].extensions.split(","); | |
for (w = 0; w < u.length; w++) { | |
t.push("." + u[w]); | |
} | |
} | |
b.openFiles(e, { | |
singleFile: !o.multi_selection, | |
filter: t | |
}); | |
}, c.id); | |
}); | |
c.bind("UploadFile", function (C, w) { | |
var A = 0, | |
B, v, f = 0, | |
x = C.settings.resize, | |
z; | |
if (x && /\.(png|jpg|jpeg)$/i.test(w.name)) { | |
j[w.id] = h(j[w.id], x, /\.png$/i.test(w.name) ? "image/png" : "image/jpeg"); | |
} | |
w.size = j[w.id].length; | |
v = C.settings.chunk_size; | |
z = v > 0; | |
B = Math.ceil(w.size / v); | |
if (!z) { | |
v = w.size; | |
B = 1; | |
} | |
function y() { | |
var r, t, p = C.settings.multipart, | |
q = 0, | |
o = { | |
name: w.target_name || w.name | |
}, | |
n = C.settings.url; | |
function s(N) { | |
var O, u = "----pluploadboundary" + m.guid(), | |
L = "--", | |
J = "\r\n", | |
M, K; | |
if (p) { | |
r.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + u); | |
O = google.gears.factory.create("beta.blobbuilder"); | |
m.each(m.extend(o, C.settings.multipart_params), function (D, E) { | |
O.append(L + u + J + 'Content-Disposition: form-data; name="' + E + '"' + J + J); | |
O.append(D + J); | |
}); | |
K = m.mimeTypes[w.name.replace(/^.+\.([^.]+)/, "$1").toLowerCase()] || "application/octet-stream"; | |
O.append(L + u + J + 'Content-Disposition: form-data; name="' + C.settings.file_data_name + '"; filename="' + w.name + '"' + J + "Content-Type: " + K + J + J); | |
O.append(N); | |
O.append(J + L + u + L + J); | |
M = O.getAsBlob(); | |
q = M.length - N.length; | |
N = M; | |
} | |
r.send(N); | |
} | |
if (w.status == m.DONE || w.status == m.FAILED || C.state == m.STOPPED) { | |
return; | |
} | |
if (z) { | |
o.chunk = A; | |
o.chunks = B; | |
} | |
t = Math.min(v, w.size - (A * v)); | |
if (!p) { | |
n = m.buildUrl(C.settings.url, o); | |
} | |
r = google.gears.factory.create("beta.httprequest"); | |
r.open("POST", n); | |
if (!p) { | |
r.setRequestHeader("Content-Disposition", 'attachment; filename="' + w.name + '"'); | |
r.setRequestHeader("Content-Type", "application/octet-stream"); | |
} | |
m.each(C.settings.headers, function (u, E) { | |
r.setRequestHeader(E, u); | |
}); | |
r.upload.onprogress = function (u) { | |
w.loaded = f + u.loaded - q; | |
C.trigger("UploadProgress", w); | |
}; | |
r.onreadystatechange = function () { | |
var u; | |
if (r.readyState == 4) { | |
if (r.status == 200) { | |
u = { | |
chunk: A, | |
chunks: B, | |
response: r.responseText, | |
status: r.status | |
}; | |
C.trigger("ChunkUploaded", w, u); | |
if (u.cancelled) { | |
w.status = m.FAILED; | |
return; | |
} | |
f += t; | |
if (++A >= B) { | |
w.status = m.DONE; | |
C.trigger("FileUploaded", w, { | |
response: r.responseText, | |
status: r.status | |
}); | |
} else { | |
y(); | |
} | |
} else { | |
C.trigger("Error", { | |
code: m.HTTP_ERROR, | |
message: m.translate("HTTP Error."), | |
file: w, | |
chunk: A, | |
chunks: B, | |
status: r.status | |
}); | |
} | |
} | |
}; | |
if (A < B) { | |
s(j[w.id].slice(A * v, t)); | |
} | |
} | |
y(); | |
}); | |
c.bind("Destroy", function (f) { | |
var s, r, q = { | |
browseButton: f.settings.browse_button, | |
dropElm: f.settings.drop_element | |
}; | |
for (s in q) { | |
r = g.getElementById(q[s]); | |
if (r) { | |
m.removeAllEvents(r, f.id); | |
} | |
} | |
}); | |
a({ | |
success: true | |
}); | |
} | |
}); | |
})(window, document, plupload); | |
(function (m, j, p, o) { | |
var k = {}, | |
l = {}; | |
function q(e) { | |
var f, a = typeof e, | |
d, b, c; | |
if (a === "string") { | |
f = "\bb\tt\nn\ff\rr\"\"''\\\\"; | |
return '"' + e.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g, function (g, h) { | |
var s = f.indexOf(h); | |
if (s + 1) { | |
return "\\" + f.charAt(s + 1); | |
} | |
g = h.charCodeAt().toString(16); | |
return "\\u" + "0000".substring(g.length) + g; | |
}) + '"'; | |
} | |
if (a == "object") { | |
d = e.length !== o; | |
f = ""; | |
if (d) { | |
for (b = 0; b < e.length; b++) { | |
if (f) { | |
f += ","; | |
} | |
f += q(e[b]); | |
} | |
f = "[" + f + "]"; | |
} else { | |
for (c in e) { | |
if (e.hasOwnProperty(c)) { | |
if (f) { | |
f += ","; | |
} | |
f += q(c) + ":" + q(e[c]); | |
} | |
} | |
f = "{" + f + "}"; | |
} | |
return f; | |
} | |
if (e === o) { | |
return "null"; | |
} | |
return "" + e; | |
} | |
function n(A) { | |
var x = false, | |
w = null, | |
d = null, | |
h, g, f, y, e, b = 0; | |
try { | |
try { | |
d = new ActiveXObject("AgControl.AgControl"); | |
if (d.IsVersionSupported(A)) { | |
x = true; | |
} | |
d = null; | |
} catch (a) { | |
var c = navigator.plugins["Silverlight Plug-In"]; | |
if (c) { | |
h = c.description; | |
if (h === "1.0.30226.2") { | |
h = "2.0.30226.2"; | |
} | |
g = h.split("."); | |
while (g.length > 3) { | |
g.pop(); | |
} | |
while (g.length < 4) { | |
g.push(0); | |
} | |
f = A.split("."); | |
while (f.length > 4) { | |
f.pop(); | |
} | |
do { | |
y = parseInt(f[b], 10); | |
e = parseInt(g[b], 10); | |
b++; | |
} while (b < f.length && y === e); | |
if (y <= e && !isNaN(y)) { | |
x = true; | |
} | |
} | |
} | |
} catch (z) { | |
x = false; | |
} | |
return x; | |
} | |
p.silverlight = { | |
trigger: function (e, c) { | |
var a = k[e], | |
b, d; | |
if (a) { | |
d = p.toArray(arguments).slice(1); | |
d[0] = "Silverlight:" + c; | |
setTimeout(function () { | |
a.trigger.apply(a, d); | |
}, 0); | |
} | |
} | |
}; | |
p.runtimes.Silverlight = p.addRuntime("silverlight", { | |
getFeatures: function () { | |
return { | |
jpgresize: true, | |
pngresize: true, | |
chunks: true, | |
progress: true, | |
multipart: true | |
}; | |
}, | |
init: function (f, e) { | |
var g, a = "", | |
h = f.settings.filters, | |
b, c = j.body; | |
if (!n("2.0.31005.0") || (m.opera && m.opera.buildNumber)) { | |
e({ | |
success: false | |
}); | |
return; | |
} | |
l[f.id] = false; | |
k[f.id] = f; | |
g = j.createElement("div"); | |
g.id = f.id + "_silverlight_container"; | |
p.extend(g.style, { | |
position: "absolute", | |
top: "0px", | |
background: f.settings.shim_bgcolor || "transparent", | |
zIndex: 99999, | |
width: "100px", | |
height: "100px", | |
overflow: "hidden", | |
opacity: f.settings.shim_bgcolor || j.documentMode > 8 ? "" : 0.01 | |
}); | |
g.className = "plupload silverlight"; | |
if (f.settings.container) { | |
c = j.getElementById(f.settings.container); | |
if (p.getStyle(c, "position") === "static") { | |
c.style.position = "relative"; | |
} | |
} | |
c.appendChild(g); | |
for (b = 0; b < h.length; b++) { | |
a += (a != "" ? "|" : "") + h[b].title + " | *." + h[b].extensions.replace(/,/g, ";*."); | |
} | |
g.innerHTML = '<object id="' + f.id + '_silverlight" data="data:application/x-silverlight," type="application/x-silverlight-2" style="outline:none;" width="1024" height="1024"><param name="source" value="' + f.settings.silverlight_xap_url + '"/><param name="background" value="Transparent"/><param name="windowless" value="true"/><param name="enablehtmlaccess" value="true"/><param name="initParams" value="id=' + f.id + ",filter=" + a + ",multiselect=" + f.settings.multi_selection + '"/></object>'; | |
function d() { | |
return j.getElementById(f.id + "_silverlight").content.Upload; | |
} | |
f.bind("Silverlight:Init", function () { | |
var u, t = {}; | |
if (l[f.id]) { | |
return; | |
} | |
l[f.id] = true; | |
f.bind("Silverlight:StartSelectFiles", function (r) { | |
u = []; | |
}); | |
f.bind("Silverlight:SelectFile", function (A, s, z, y) { | |
var r; | |
r = p.guid(); | |
t[r] = s; | |
t[s] = r; | |
u.push(new p.File(r, z, y)); | |
}); | |
f.bind("Silverlight:SelectSuccessful", function () { | |
if (u.length) { | |
f.trigger("FilesAdded", u); | |
} | |
}); | |
f.bind("Silverlight:UploadChunkError", function (A, s, z, r, y) { | |
f.trigger("Error", { | |
code: p.IO_ERROR, | |
message: "IO Error.", | |
details: y, | |
file: A.getFile(t[s]) | |
}); | |
}); | |
f.bind("Silverlight:UploadFileProgress", function (A, r, z, s) { | |
var y = A.getFile(t[r]); | |
if (y.status != p.FAILED) { | |
y.size = s; | |
y.loaded = z; | |
A.trigger("UploadProgress", y); | |
} | |
}); | |
f.bind("Refresh", function (y) { | |
var x, s, r; | |
x = j.getElementById(y.settings.browse_button); | |
if (x) { | |
s = p.getPos(x, j.getElementById(y.settings.container)); | |
r = p.getSize(x); | |
p.extend(j.getElementById(y.id + "_silverlight_container").style, { | |
top: s.y + "px", | |
left: s.x + "px", | |
width: r.w + "px", | |
height: r.h + "px" | |
}); | |
} | |
}); | |
f.bind("Silverlight:UploadChunkSuccessful", function (C, s, B, D, E) { | |
var r, A = C.getFile(t[s]); | |
r = { | |
chunk: B, | |
chunks: D, | |
response: E | |
}; | |
C.trigger("ChunkUploaded", A, r); | |
if (A.status != p.FAILED) { | |
d().UploadNextChunk(); | |
} | |
if (B == D - 1) { | |
A.status = p.DONE; | |
C.trigger("FileUploaded", A, { | |
response: E | |
}); | |
} | |
}); | |
f.bind("Silverlight:UploadSuccessful", function (y, r, x) { | |
var s = y.getFile(t[r]); | |
s.status = p.DONE; | |
y.trigger("FileUploaded", s, { | |
response: x | |
}); | |
}); | |
f.bind("FilesRemoved", function (w, r) { | |
var s; | |
for (s = 0; s < r.length; s++) { | |
d().RemoveFile(t[r[s].id]); | |
} | |
}); | |
f.bind("UploadFile", function (y, s) { | |
var r = y.settings, | |
x = r.resize || {}; | |
d().UploadFile(t[s.id], y.settings.url, q({ | |
name: s.target_name || s.name, | |
mime: p.mimeTypes[s.name.replace(/^.+\.([^.]+)/, "$1").toLowerCase()] || "application/octet-stream", | |
chunk_size: r.chunk_size, | |
image_width: x.width, | |
image_height: x.height, | |
image_quality: x.quality || 90, | |
multipart: !! r.multipart, | |
multipart_params: r.multipart_params || {}, | |
file_data_name: r.file_data_name, | |
headers: r.headers | |
})); | |
}); | |
f.bind("Silverlight:MouseEnter", function (w) { | |
var s, r; | |
s = j.getElementById(f.settings.browse_button); | |
r = w.settings.browse_button_hover; | |
if (s && r) { | |
p.addClass(s, r); | |
} | |
}); | |
f.bind("Silverlight:MouseLeave", function (w) { | |
var s, r; | |
s = j.getElementById(f.settings.browse_button); | |
r = w.settings.browse_button_hover; | |
if (s && r) { | |
p.removeClass(s, r); | |
} | |
}); | |
f.bind("Silverlight:MouseLeftButtonDown", function (w) { | |
var s, r; | |
s = j.getElementById(f.settings.browse_button); | |
r = w.settings.browse_button_active; | |
if (s && r) { | |
p.addClass(s, r); | |
p.addEvent(j.body, "mouseup", function () { | |
p.removeClass(s, r); | |
}); | |
} | |
}); | |
f.bind("Sliverlight:StartSelectFiles", function (w) { | |
var s, r; | |
s = j.getElementById(f.settings.browse_button); | |
r = w.settings.browse_button_active; | |
if (s && r) { | |
p.removeClass(s, r); | |
} | |
}); | |
f.bind("Destroy", function (s) { | |
var r; | |
p.removeAllEvents(j.body, s.id); | |
delete l[s.id]; | |
delete k[s.id]; | |
r = j.getElementById(s.id + "_silverlight_container"); | |
if (r) { | |
c.removeChild(r); | |
} | |
}); | |
e({ | |
success: true | |
}); | |
}); | |
} | |
}); | |
})(window, document, plupload); | |
(function (l, h, n, m) { | |
var j = {}, | |
k = {}; | |
function o() { | |
var c; | |
try { | |
c = navigator.plugins["Shockwave Flash"]; | |
c = c.description; | |
} catch (a) { | |
try { | |
c = new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version"); | |
} catch (b) { | |
c = "0.0"; | |
} | |
} | |
c = c.match(/\d+/g); | |
return parseFloat(c[0] + "." + c[1]); | |
} | |
n.flash = { | |
trigger: function (a, c, b) { | |
setTimeout(function () { | |
var f = j[a], | |
d, e; | |
if (f) { | |
f.trigger("Flash:" + c, b); | |
} | |
}, 0); | |
} | |
}; | |
n.runtimes.Flash = n.addRuntime("flash", { | |
getFeatures: function () { | |
return { | |
jpgresize: true, | |
pngresize: true, | |
maxWidth: 8091, | |
maxHeight: 8091, | |
chunks: true, | |
progress: true, | |
multipart: true | |
}; | |
}, | |
init: function (g, b) { | |
var c, r, f, a = 0, | |
s = h.body; | |
if (o() < 10) { | |
b({ | |
success: false | |
}); | |
return; | |
} | |
k[g.id] = false; | |
j[g.id] = g; | |
c = h.getElementById(g.settings.browse_button); | |
r = h.createElement("div"); | |
r.id = g.id + "_flash_container"; | |
n.extend(r.style, { | |
position: "absolute", | |
top: "0px", | |
background: g.settings.shim_bgcolor || "transparent", | |
zIndex: 99999, | |
width: "100%", | |
height: "100%" | |
}); | |
r.className = "plupload flash"; | |
if (g.settings.container) { | |
s = h.getElementById(g.settings.container); | |
if (n.getStyle(s, "position") === "static") { | |
s.style.position = "relative"; | |
} | |
} | |
s.appendChild(r); | |
f = "id=" + escape(g.id); | |
r.innerHTML = '<object id="' + g.id + '_flash" width="100%" height="100%" style="outline:0" type="application/x-shockwave-flash" data="' + g.settings.flash_swf_url + '"><param name="movie" value="' + g.settings.flash_swf_url + '" /><param name="flashvars" value="' + f + '" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /></object>'; | |
function d() { | |
return h.getElementById(g.id + "_flash"); | |
} | |
function e() { | |
if (a++ > 5000) { | |
b({ | |
success: false | |
}); | |
return; | |
} | |
if (!k[g.id]) { | |
setTimeout(e, 1); | |
} | |
} | |
e(); | |
c = r = null; | |
g.bind("Flash:Init", function () { | |
var p = {}, | |
q; | |
d().setFileFilters(g.settings.filters, g.settings.multi_selection); | |
if (k[g.id]) { | |
return; | |
} | |
k[g.id] = true; | |
g.bind("UploadFile", function (A, y) { | |
var x = A.settings, | |
z = g.settings.resize || {}; | |
d().uploadFile(p[y.id], x.url, { | |
name: y.target_name || y.name, | |
mime: n.mimeTypes[y.name.replace(/^.+\.([^.]+)/, "$1").toLowerCase()] || "application/octet-stream", | |
chunk_size: x.chunk_size, | |
width: z.width, | |
height: z.height, | |
quality: z.quality, | |
multipart: x.multipart, | |
multipart_params: x.multipart_params || {}, | |
file_data_name: x.file_data_name, | |
format: /\.(jpg|jpeg)$/i.test(y.name) ? "jpg" : "png", | |
headers: x.headers, | |
urlstream_upload: x.urlstream_upload | |
}); | |
}); | |
g.bind("Flash:UploadProcess", function (x, y) { | |
var w = x.getFile(p[y.id]); | |
if (w.status != n.FAILED) { | |
w.loaded = y.loaded; | |
w.size = y.size; | |
x.trigger("UploadProgress", w); | |
} | |
}); | |
g.bind("Flash:UploadChunkComplete", function (A, y) { | |
var x, z = A.getFile(p[y.id]); | |
x = { | |
chunk: y.chunk, | |
chunks: y.chunks, | |
response: y.text | |
}; | |
A.trigger("ChunkUploaded", z, x); | |
if (z.status != n.FAILED) { | |
d().uploadNextChunk(); | |
} | |
if (y.chunk == y.chunks - 1) { | |
z.status = n.DONE; | |
A.trigger("FileUploaded", z, { | |
response: y.text | |
}); | |
} | |
}); | |
g.bind("Flash:SelectFiles", function (D, A) { | |
var B, C, z = [], | |
E; | |
for (C = 0; C < A.length; C++) { | |
B = A[C]; | |
E = n.guid(); | |
p[E] = B.id; | |
p[B.id] = E; | |
z.push(new n.File(E, B.name, B.size)); | |
} | |
if (z.length) { | |
g.trigger("FilesAdded", z); | |
} | |
}); | |
g.bind("Flash:SecurityError", function (w, v) { | |
g.trigger("Error", { | |
code: n.SECURITY_ERROR, | |
message: n.translate("Security error."), | |
details: v.message, | |
file: g.getFile(p[v.id]) | |
}); | |
}); | |
g.bind("Flash:GenericError", function (w, v) { | |
g.trigger("Error", { | |
code: n.GENERIC_ERROR, | |
message: n.translate("Generic error."), | |
details: v.message, | |
file: g.getFile(p[v.id]) | |
}); | |
}); | |
g.bind("Flash:IOError", function (w, v) { | |
g.trigger("Error", { | |
code: n.IO_ERROR, | |
message: n.translate("IO error."), | |
details: v.message, | |
file: g.getFile(p[v.id]) | |
}); | |
}); | |
g.bind("Flash:ImageError", function (w, v) { | |
g.trigger("Error", { | |
code: parseInt(v.code, 10), | |
message: n.translate("Image error."), | |
file: g.getFile(p[v.id]) | |
}); | |
}); | |
g.bind("Flash:StageEvent:rollOver", function (y) { | |
var x, w; | |
x = h.getElementById(g.settings.browse_button); | |
w = y.settings.browse_button_hover; | |
if (x && w) { | |
n.addClass(x, w); | |
} | |
}); | |
g.bind("Flash:StageEvent:rollOut", function (y) { | |
var x, w; | |
x = h.getElementById(g.settings.browse_button); | |
w = y.settings.browse_button_hover; | |
if (x && w) { | |
n.removeClass(x, w); | |
} | |
}); | |
g.bind("Flash:StageEvent:mouseDown", function (y) { | |
var x, w; | |
x = h.getElementById(g.settings.browse_button); | |
w = y.settings.browse_button_active; | |
if (x && w) { | |
n.addClass(x, w); | |
n.addEvent(h.body, "mouseup", function () { | |
n.removeClass(x, w); | |
}, y.id); | |
} | |
}); | |
g.bind("Flash:StageEvent:mouseUp", function (y) { | |
var x, w; | |
x = h.getElementById(g.settings.browse_button); | |
w = y.settings.browse_button_active; | |
if (x && w) { | |
n.removeClass(x, w); | |
} | |
}); | |
g.bind("QueueChanged", function (u) { | |
g.refresh(); | |
}); | |
g.bind("FilesRemoved", function (y, w) { | |
var x; | |
for (x = 0; x < w.length; x++) { | |
d().removeFile(p[w[x].id]); | |
} | |
}); | |
g.bind("StateChanged", function (u) { | |
g.refresh(); | |
}); | |
g.bind("Refresh", function (A) { | |
var z, y, x; | |
d().setFileFilters(g.settings.filters, g.settings.multi_selection); | |
z = h.getElementById(A.settings.browse_button); | |
if (z) { | |
y = n.getPos(z, h.getElementById(A.settings.container)); | |
x = n.getSize(z); | |
n.extend(h.getElementById(A.id + "_flash_container").style, { | |
top: y.y + "px", | |
left: y.x + "px", | |
width: x.w + "px", | |
height: x.h + "px" | |
}); | |
} | |
}); | |
g.bind("Destroy", function (w) { | |
var v; | |
n.removeAllEvents(h.body, w.id); | |
delete k[w.id]; | |
delete j[w.id]; | |
v = h.getElementById(w.id + "_flash_container"); | |
if (v) { | |
s.removeChild(v); | |
} | |
}); | |
b({ | |
success: true | |
}); | |
}); | |
} | |
}); | |
})(window, document, plupload); | |
(function (b) { | |
b.runtimes.BrowserPlus = b.addRuntime("browserplus", { | |
getFeatures: function () { | |
return { | |
dragdrop: true, | |
jpgresize: true, | |
pngresize: true, | |
chunks: true, | |
progress: true, | |
multipart: true | |
}; | |
}, | |
init: function (m, k) { | |
var o = window.BrowserPlus, | |
l = {}, | |
p = m.settings, | |
q = p.resize; | |
function n(g) { | |
var h, c, e = [], | |
d, f; | |
for (c = 0; c < g.length; c++) { | |
d = g[c]; | |
f = b.guid(); | |
l[f] = d; | |
e.push(new b.File(f, d.name, d.size)); | |
} | |
if (c) { | |
m.trigger("FilesAdded", e); | |
} | |
} | |
function a() { | |
m.bind("PostInit", function () { | |
var j, d = p.drop_element, | |
g = m.id + "_droptarget", | |
e = document.getElementById(d), | |
c; | |
function f(t, u) { | |
o.DragAndDrop.AddDropTarget({ | |
id: t | |
}, function (r) { | |
o.DragAndDrop.AttachCallbacks({ | |
id: t, | |
hover: function (s) { | |
if (!s && u) { | |
u(); | |
} | |
}, | |
drop: function (s) { | |
if (u) { | |
u(); | |
} | |
n(s); | |
} | |
}, function () {}); | |
}); | |
} | |
function h() { | |
document.getElementById(g).style.top = "-1000px"; | |
} | |
if (e) { | |
if (document.attachEvent && (/MSIE/gi).test(navigator.userAgent)) { | |
j = document.createElement("div"); | |
j.setAttribute("id", g); | |
b.extend(j.style, { | |
position: "absolute", | |
top: "-1000px", | |
background: "red", | |
filter: "alpha(opacity=0)", | |
opacity: 0 | |
}); | |
document.body.appendChild(j); | |
b.addEvent(e, "dragenter", function (v) { | |
var w, u; | |
w = document.getElementById(d); | |
u = b.getPos(w); | |
b.extend(document.getElementById(g).style, { | |
top: u.y + "px", | |
left: u.x + "px", | |
width: w.offsetWidth + "px", | |
height: w.offsetHeight + "px" | |
}); | |
}); | |
f(g, h); | |
} else { | |
f(d); | |
} | |
} | |
b.addEvent(document.getElementById(p.browse_button), "click", function (x) { | |
var z = [], | |
B, C, y = p.filters, | |
A; | |
x.preventDefault(); | |
for (B = 0; B < y.length; B++) { | |
A = y[B].extensions.split(","); | |
for (C = 0; C < A.length; C++) { | |
z.push(b.mimeTypes[A[C]]); | |
} | |
} | |
o.FileBrowse.OpenBrowseDialog({ | |
mimeTypes: z | |
}, function (r) { | |
if (r.success) { | |
n(r.value); | |
} | |
}); | |
}); | |
e = j = null; | |
}); | |
m.bind("UploadFile", function (g, t) { | |
var h = l[t.id], | |
u = {}, | |
j = g.settings.chunk_size, | |
f, e = []; | |
function c(w, r) { | |
var s; | |
if (t.status == b.FAILED) { | |
return; | |
} | |
u.name = t.target_name || t.name; | |
if (j) { | |
u.chunk = "" + w; | |
u.chunks = "" + r; | |
} | |
s = e.shift(); | |
o.Uploader.upload({ | |
url: g.settings.url, | |
files: { | |
file: s | |
}, | |
cookies: document.cookies, | |
postvars: b.extend(u, g.settings.multipart_params), | |
progressCallback: function (A) { | |
var v, z = 0; | |
f[w] = parseInt(A.filePercent * s.size / 100, 10); | |
for (v = 0; v < f.length; v++) { | |
z += f[v]; | |
} | |
t.loaded = z; | |
g.trigger("UploadProgress", t); | |
} | |
}, function (v) { | |
var z, A; | |
if (v.success) { | |
z = v.value.statusCode; | |
if (j) { | |
g.trigger("ChunkUploaded", t, { | |
chunk: w, | |
chunks: r, | |
response: v.value.body, | |
status: z | |
}); | |
} | |
if (e.length > 0) { | |
c(++w, r); | |
} else { | |
t.status = b.DONE; | |
g.trigger("FileUploaded", t, { | |
response: v.value.body, | |
status: z | |
}); | |
if (z >= 400) { | |
g.trigger("Error", { | |
code: b.HTTP_ERROR, | |
message: b.translate("HTTP Error."), | |
file: t, | |
status: z | |
}); | |
} | |
} | |
} else { | |
g.trigger("Error", { | |
code: b.GENERIC_ERROR, | |
message: b.translate("Generic Error."), | |
file: t, | |
details: v.error | |
}); | |
} | |
}); | |
} | |
function d(r) { | |
t.size = r.size; | |
if (j) { | |
o.FileAccess.chunk({ | |
file: r, | |
chunkSize: j | |
}, function (y) { | |
if (y.success) { | |
var s = y.value, | |
A = s.length; | |
f = Array(A); | |
for (var z = 0; z < A; z++) { | |
f[z] = 0; | |
e.push(s[z]); | |
} | |
c(0, A); | |
} | |
}); | |
} else { | |
f = Array(1); | |
e.push(r); | |
c(0, 1); | |
} | |
} | |
if (q && /\.(png|jpg|jpeg)$/i.test(t.name)) { | |
BrowserPlus.ImageAlter.transform({ | |
file: h, | |
quality: q.quality || 90, | |
actions: [{ | |
scale: { | |
maxwidth: q.width, | |
maxheight: q.height | |
} | |
}] | |
}, function (r) { | |
if (r.success) { | |
d(r.value.file); | |
} | |
}); | |
} else { | |
d(h); | |
} | |
}); | |
k({ | |
success: true | |
}); | |
} | |
if (o) { | |
o.init(function (c) { | |
var d = [{ | |
service: "Uploader", | |
version: "3" | |
}, { | |
service: "DragAndDrop", | |
version: "1" | |
}, { | |
service: "FileBrowse", | |
version: "1" | |
}, { | |
service: "FileAccess", | |
version: "2" | |
}]; | |
if (q) { | |
d.push({ | |
service: "ImageAlter", | |
version: "4" | |
}); | |
} | |
if (c.success) { | |
o.require({ | |
services: d | |
}, function (e) { | |
if (e.success) { | |
a(); | |
} else { | |
k(); | |
} | |
}); | |
} else { | |
k(); | |
} | |
}); | |
} else { | |
k(); | |
} | |
} | |
}); | |
})(plupload); | |
(function (q, o, p, t) { | |
var r; | |
if (q.Uint8Array && q.ArrayBuffer && !XMLHttpRequest.prototype.sendAsBinary) { | |
XMLHttpRequest.prototype.sendAsBinary = function (b) { | |
var a = new Uint8Array(b.length); | |
for (var c = 0; c < b.length; c++) { | |
a[c] = (b.charCodeAt(c) & 255); | |
} | |
this.send(a.buffer); | |
}; | |
} | |
function m(c, b) { | |
var a; | |
if ("FileReader" in q) { | |
a = new FileReader(); | |
a.readAsDataURL(c); | |
a.onload = function () { | |
b(a.result); | |
}; | |
} else { | |
return b(c.getAsDataURL()); | |
} | |
} | |
function n(c, b) { | |
var a; | |
if ("FileReader" in q) { | |
a = new FileReader(); | |
a.readAsBinaryString(c); | |
a.onload = function () { | |
b(a.result); | |
}; | |
} else { | |
return b(c.getAsBinary()); | |
} | |
} | |
function u(e, g, d, b) { | |
var h, f, a, c; | |
m(e, function (j) { | |
h = o.createElement("canvas"); | |
h.style.display = "none"; | |
o.body.appendChild(h); | |
f = h.getContext("2d"); | |
a = new Image(); | |
a.onerror = a.onabort = function () { | |
b({ | |
success: false | |
}); | |
}; | |
a.onload = function () { | |
var D, C, l, B, E; | |
if (!g.width) { | |
g.width = a.width; | |
} | |
if (!g.height) { | |
g.height = a.height; | |
} | |
c = Math.min(g.width / a.width, g.height / a.height); | |
if (c < 1 || (c === 1 && d === "image/jpeg")) { | |
D = Math.round(a.width * c); | |
C = Math.round(a.height * c); | |
h.width = D; | |
h.height = C; | |
f.drawImage(a, 0, 0, D, C); | |
if (d === "image/jpeg") { | |
B = new s(atob(j.substring(j.indexOf("base64,") + 7))); | |
if (B.headers && B.headers.length) { | |
E = new w(); | |
if (E.init(B.get("exif")[0])) { | |
E.setExif("PixelXDimension", D); | |
E.setExif("PixelYDimension", C); | |
B.set("exif", E.getBinary()); | |
} | |
} | |
if (g.quality) { | |
try { | |
j = h.toDataURL(d, g.quality / 100); | |
} catch (k) { | |
j = h.toDataURL(d); | |
} | |
} | |
} else { | |
j = h.toDataURL(d); | |
} | |
j = j.substring(j.indexOf("base64,") + 7); | |
j = atob(j); | |
if (B.headers && B.headers.length) { | |
j = B.restore(j); | |
B.purge(); | |
} | |
h.parentNode.removeChild(h); | |
b({ | |
success: true, | |
data: j | |
}); | |
} else { | |
b({ | |
success: false | |
}); | |
} | |
}; | |
a.src = j; | |
}); | |
} | |
p.runtimes.Html5 = p.addRuntime("html5", { | |
getFeatures: function () { | |
var b, f, c, e, a, d = q; | |
f = c = e = a = false; | |
if (d.XMLHttpRequest) { | |
b = new XMLHttpRequest(); | |
c = !! b.upload; | |
f = !! (b.sendAsBinary || b.upload); | |
} | |
if (f) { | |
e = !! (File && (File.prototype.getAsDataURL || d.FileReader) && b.sendAsBinary); | |
a = !! (File && File.prototype.slice); | |
} | |
r = navigator.userAgent.indexOf("Safari") > 0 && navigator.vendor.indexOf("Apple") !== -1; | |
return { | |
html5: f, | |
dragdrop: d.mozInnerScreenX !== t || a || r, | |
jpgresize: e, | |
pngresize: e, | |
multipart: e || !! d.FileReader || !! d.FormData, | |
progress: c, | |
chunks: a || e, | |
canOpenDialog: navigator.userAgent.indexOf("WebKit") !== -1 | |
}; | |
}, | |
init: function (c, b) { | |
var a = {}, | |
e; | |
function d(g) { | |
var j, k, h = [], | |
f, l = {}; | |
for (k = 0; k < g.length; k++) { | |
j = g[k]; | |
if (l[j.name]) { | |
continue; | |
} | |
l[j.name] = true; | |
f = p.guid(); | |
a[f] = j; | |
h.push(new p.File(f, j.fileName, j.fileSize || j.size)); | |
} | |
if (h.length) { | |
c.trigger("FilesAdded", h); | |
} | |
} | |
e = this.getFeatures(); | |
if (!e.html5) { | |
b({ | |
success: false | |
}); | |
return; | |
} | |
c.bind("Init", function (H) { | |
var J, L, j = [], | |
I, h, M = H.settings.filters, | |
K, k, g = o.body, | |
f; | |
J = o.createElement("div"); | |
J.id = H.id + "_html5_container"; | |
p.extend(J.style, { | |
position: "absolute", | |
background: c.settings.shim_bgcolor || "transparent", | |
width: "100px", | |
height: "100px", | |
overflow: "hidden", | |
zIndex: 99999, | |
opacity: c.settings.shim_bgcolor ? "" : 0 | |
}); | |
J.className = "plupload html5"; | |
if (c.settings.container) { | |
g = o.getElementById(c.settings.container); | |
if (p.getStyle(g, "position") === "static") { | |
g.style.position = "relative"; | |
} | |
} | |
g.appendChild(J); | |
no_type_restriction: for (I = 0; I < M.length; I++) { | |
K = M[I].extensions.split(/,/); | |
for (h = 0; h < K.length; h++) { | |
if (K[h] === "*") { | |
j = []; | |
break no_type_restriction; | |
} | |
k = p.mimeTypes[K[h]]; | |
if (k) { | |
j.push(k); | |
} | |
} | |
} | |
J.innerHTML = '<input id="' + c.id + '_html5" style="width:100%;height:100%;font-size:99px" type="file" accept="' + j.join(",") + '" ' + (c.settings.multi_selection ? 'multiple="multiple"' : "") + " />"; | |
f = o.getElementById(c.id + "_html5"); | |
f.onchange = function () { | |
d(this.files); | |
this.value = ""; | |
}; | |
L = o.getElementById(H.settings.browse_button); | |
if (L) { | |
var y = H.settings.browse_button_hover, | |
l = H.settings.browse_button_active, | |
G = H.features.canOpenDialog ? L : J; | |
if (y) { | |
p.addEvent(G, "mouseover", function () { | |
p.addClass(L, y); | |
}, H.id); | |
p.addEvent(G, "mouseout", function () { | |
p.removeClass(L, y); | |
}, H.id); | |
} | |
if (l) { | |
p.addEvent(G, "mousedown", function () { | |
p.addClass(L, l); | |
}, H.id); | |
p.addEvent(o.body, "mouseup", function () { | |
p.removeClass(L, l); | |
}, H.id); | |
} | |
if (H.features.canOpenDialog) { | |
p.addEvent(L, "click", function (x) { | |
o.getElementById(H.id + "_html5").click(); | |
x.preventDefault(); | |
}, H.id); | |
} | |
} | |
}); | |
c.bind("PostInit", function () { | |
var f = o.getElementById(c.settings.drop_element); | |
if (f) { | |
if (r) { | |
p.addEvent(f, "dragenter", function (g) { | |
var h, k, j; | |
h = o.getElementById(c.id + "_drop"); | |
if (!h) { | |
h = o.createElement("input"); | |
h.setAttribute("type", "file"); | |
h.setAttribute("id", c.id + "_drop"); | |
h.setAttribute("multiple", "multiple"); | |
p.addEvent(h, "change", function () { | |
d(this.files); | |
p.removeEvent(h, "change", c.id); | |
h.parentNode.removeChild(h); | |
}, c.id); | |
f.appendChild(h); | |
} | |
k = p.getPos(f, o.getElementById(c.settings.container)); | |
j = p.getSize(f); | |
if (p.getStyle(f, "position") === "static") { | |
p.extend(f.style, { | |
position: "relative" | |
}); | |
} | |
p.extend(h.style, { | |
position: "absolute", | |
display: "block", | |
top: 0, | |
left: 0, | |
width: j.w + "px", | |
height: j.h + "px", | |
opacity: 0 | |
}); | |
}, c.id); | |
return; | |
} | |
p.addEvent(f, "dragover", function (g) { | |
g.preventDefault(); | |
}, c.id); | |
p.addEvent(f, "drop", function (g) { | |
var h = g.dataTransfer; | |
if (h && h.files) { | |
d(h.files); | |
} | |
g.preventDefault(); | |
}, c.id); | |
} | |
}); | |
c.bind("Refresh", function (l) { | |
var k, h, g, f, j; | |
k = o.getElementById(c.settings.browse_button); | |
if (k) { | |
h = p.getPos(k, o.getElementById(l.settings.container)); | |
g = p.getSize(k); | |
f = o.getElementById(c.id + "_html5_container"); | |
p.extend(f.style, { | |
top: h.y + "px", | |
left: h.x + "px", | |
width: g.w + "px", | |
height: g.h + "px" | |
}); | |
if (c.features.canOpenDialog) { | |
j = parseInt(k.parentNode.style.zIndex, 10); | |
if (isNaN(j)) { | |
j = 0; | |
} | |
p.extend(k.style, { | |
zIndex: j | |
}); | |
if (p.getStyle(k, "position") === "static") { | |
p.extend(k.style, { | |
position: "relative" | |
}); | |
} | |
p.extend(f.style, { | |
zIndex: j - 1 | |
}); | |
} | |
} | |
}); | |
c.bind("UploadFile", function (l, j) { | |
var h = l.settings, | |
f, k; | |
function g(C) { | |
var B = 0, | |
D = 0; | |
function E() { | |
var X = C, | |
Q, A, U, T, S = 0, | |
x = "----pluploadboundary" + p.guid(), | |
Y, W, aa, Z = "--", | |
R = "\r\n", | |
V = "", | |
y, z = l.settings.url; | |
if (j.status == p.DONE || j.status == p.FAILED || l.state == p.STOPPED) { | |
return; | |
} | |
T = { | |
name: j.target_name || j.name | |
}; | |
if (h.chunk_size && e.chunks) { | |
Y = h.chunk_size; | |
U = Math.ceil(j.size / Y); | |
W = Math.min(Y, j.size - (B * Y)); | |
if (typeof (C) == "string") { | |
X = C.substring(B * Y, B * Y + W); | |
} else { | |
X = C.slice(B * Y, W); | |
} | |
T.chunk = B; | |
T.chunks = U; | |
} else { | |
W = j.size; | |
} | |
Q = new XMLHttpRequest(); | |
A = Q.upload; | |
if (A) { | |
A.onprogress = function (F) { | |
j.loaded = Math.min(j.size, D + F.loaded - S); | |
l.trigger("UploadProgress", j); | |
}; | |
} | |
if (!l.settings.multipart || !e.multipart) { | |
z = p.buildUrl(l.settings.url, T); | |
} else { | |
T.name = j.target_name || j.name; | |
} | |
Q.open("post", z, true); | |
Q.onreadystatechange = function () { | |
var H, F; | |
if (Q.readyState == 4) { | |
try { | |
H = Q.status; | |
} catch (G) { | |
H = 0; | |
} | |
if (H >= 400) { | |
l.trigger("Error", { | |
code: p.HTTP_ERROR, | |
message: p.translate("HTTP Error."), | |
file: j, | |
status: H | |
}); | |
} else { | |
if (U) { | |
F = { | |
chunk: B, | |
chunks: U, | |
response: Q.responseText, | |
status: H | |
}; | |
l.trigger("ChunkUploaded", j, F); | |
D += W; | |
if (F.cancelled) { | |
j.status = p.FAILED; | |
return; | |
} | |
j.loaded = Math.min(j.size, (B + 1) * Y); | |
} else { | |
j.loaded = j.size; | |
} | |
l.trigger("UploadProgress", j); | |
if (!U || ++B >= U) { | |
j.status = p.DONE; | |
l.trigger("FileUploaded", j, { | |
response: Q.responseText, | |
status: H | |
}); | |
f = C = a[j.id] = null; | |
} else { | |
E(); | |
} | |
} | |
Q = X = aa = V = null; | |
} | |
}; | |
p.each(l.settings.headers, function (F, G) { | |
Q.setRequestHeader(G, F); | |
}); | |
if (l.settings.multipart && e.multipart) { | |
if (!Q.sendAsBinary) { | |
aa = new FormData(); | |
p.each(p.extend(T, l.settings.multipart_params), function (F, G) { | |
aa.append(G, F); | |
}); | |
aa.append(l.settings.file_data_name, X); | |
Q.send(aa); | |
return; | |
} | |
Q.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + x); | |
p.each(p.extend(T, l.settings.multipart_params), function (F, G) { | |
V += Z + x + R + 'Content-Disposition: form-data; name="' + G + '"' + R + R; | |
V += unescape(encodeURIComponent(F)) + R; | |
}); | |
y = p.mimeTypes[j.name.replace(/^.+\.([^.]+)/, "$1").toLowerCase()] || "application/octet-stream"; | |
V += Z + x + R + 'Content-Disposition: form-data; name="' + l.settings.file_data_name + '"; filename="' + unescape(encodeURIComponent(j.name)) + '"' + R + "Content-Type: " + y + R + R + X + R + Z + x + Z + R; | |
S = V.length - X.length; | |
X = V; | |
} else { | |
Q.setRequestHeader("Content-Type", "application/octet-stream"); | |
} | |
if (Q.sendAsBinary) { | |
Q.sendAsBinary(X); | |
} else { | |
Q.send(X); | |
} | |
} | |
E(); | |
} | |
f = a[j.id]; | |
k = l.settings.resize; | |
if (e.jpgresize) { | |
if (k && /\.(png|jpg|jpeg)$/i.test(j.name)) { | |
u(f, k, /\.png$/i.test(j.name) ? "image/png" : "image/jpeg", function (y) { | |
if (y.success) { | |
j.size = y.data.length; | |
g(y.data); | |
} else { | |
n(f, g); | |
} | |
}); | |
} else { | |
n(f, g); | |
} | |
} else { | |
g(f); | |
} | |
}); | |
c.bind("Destroy", function (k) { | |
var h, g, j = o.body, | |
f = { | |
inputContainer: k.id + "_html5_container", | |
inputFile: k.id + "_html5", | |
browseButton: k.settings.browse_button, | |
dropElm: k.settings.drop_element | |
}; | |
for (h in f) { | |
g = o.getElementById(f[h]); | |
if (g) { | |
p.removeAllEvents(g, k.id); | |
} | |
} | |
p.removeAllEvents(o.body, k.id); | |
if (k.settings.container) { | |
j = o.getElementById(k.settings.container); | |
} | |
j.removeChild(o.getElementById(f.inputContainer)); | |
}); | |
b({ | |
success: true | |
}); | |
} | |
}); | |
function v() { | |
var c = false, | |
e; | |
function b(j, g) { | |
var k = c ? 0 : -8 * (g - 1), | |
f = 0, | |
h; | |
for (h = 0; h < g; h++) { | |
f |= (e.charCodeAt(j + h) << Math.abs(k + h * 8)); | |
} | |
return f; | |
} | |
function a(f, h, g) { | |
var g = arguments.length === 3 ? g : e.length - h - 1; | |
e = e.substr(0, h) + f + e.substr(g + h); | |
} | |
function d(k, j, g) { | |
var f = "", | |
l = c ? 0 : -8 * (g - 1), | |
h; | |
for (h = 0; h < g; h++) { | |
f += String.fromCharCode((j >> Math.abs(l + h * 8)) & 255); | |
} | |
a(f, k, g); | |
} | |
return { | |
II: function (f) { | |
if (f === t) { | |
return c; | |
} else { | |
c = f; | |
} | |
}, | |
init: function (f) { | |
c = false; | |
e = f; | |
}, | |
SEGMENT: function (h, f, g) { | |
switch (arguments.length) { | |
case 1: | |
return e.substr(h, e.length - h - 1); | |
case 2: | |
return e.substr(h, f); | |
case 3: | |
a(g, h, f); | |
break; | |
default: | |
return e; | |
} | |
}, | |
BYTE: function (f) { | |
return b(f, 1); | |
}, | |
SHORT: function (f) { | |
return b(f, 2); | |
}, | |
LONG: function (g, f) { | |
if (f === t) { | |
return b(g, 4); | |
} else { | |
d(g, f, 4); | |
} | |
}, | |
SLONG: function (g) { | |
var f = b(g, 4); | |
return (f > 2147483647 ? f - 4294967296 : f); | |
}, | |
STRING: function (h, g) { | |
var f = ""; | |
for (g += h; h < g; h++) { | |
f += String.fromCharCode(b(h, 1)); | |
} | |
return f; | |
} | |
}; | |
} | |
function s(d) { | |
var b = { | |
65505: { | |
app: "EXIF", | |
name: "APP1", | |
signature: "Exif\0" | |
}, | |
65506: { | |
app: "ICC", | |
name: "APP2", | |
signature: "ICC_PROFILE\0" | |
}, | |
65517: { | |
app: "IPTC", | |
name: "APP13", | |
signature: "Photoshop 3.0\0" | |
} | |
}, | |
c = [], | |
e, a, g = t, | |
f = 0, | |
h; | |
e = new v(); | |
e.init(d); | |
if (e.SHORT(0) !== 65496) { | |
return; | |
} | |
a = 2; | |
h = Math.min(1048576, d.length); | |
while (a <= h) { | |
g = e.SHORT(a); | |
if (g >= 65488 && g <= 65495) { | |
a += 2; | |
continue; | |
} | |
if (g === 65498 || g === 65497) { | |
break; | |
} | |
f = e.SHORT(a + 2) + 2; | |
if (b[g] && e.STRING(a + 4, b[g].signature.length) === b[g].signature) { | |
c.push({ | |
hex: g, | |
app: b[g].app.toUpperCase(), | |
name: b[g].name.toUpperCase(), | |
start: a, | |
length: f, | |
segment: e.SEGMENT(a, f) | |
}); | |
} | |
a += f; | |
} | |
e.init(null); | |
return { | |
headers: c, | |
restore: function (j) { | |
e.init(j); | |
if (e.SHORT(0) !== 65496) { | |
return false; | |
} | |
a = e.SHORT(2) == 65504 ? 4 + e.SHORT(4) : 2; | |
for (var k = 0, l = c.length; k < l; k++) { | |
e.SEGMENT(a, 0, c[k].segment); | |
a += c[k].length; | |
} | |
return e.SEGMENT(); | |
}, | |
get: function (k) { | |
var j = []; | |
for (var l = 0, y = c.length; l < y; l++) { | |
if (c[l].app === k.toUpperCase()) { | |
j.push(c[l].segment); | |
} | |
} | |
return j; | |
}, | |
set: function (j, k) { | |
var A = []; | |
if (typeof (k) === "string") { | |
A.push(k); | |
} else { | |
A = k; | |
} | |
for (var l = ii = 0, z = c.length; l < z; l++) { | |
if (c[l].app === j.toUpperCase()) { | |
c[l].segment = A[ii]; | |
c[l].length = A[ii].length; | |
ii++; | |
} | |
if (ii >= A.length) { | |
break; | |
} | |
} | |
}, | |
purge: function () { | |
c = []; | |
e.init(null); | |
} | |
}; | |
} | |
function w() { | |
var e, a, g = {}, | |
b; | |
e = new v(); | |
a = { | |
tiff: { | |
274: "Orientation", | |
34665: "ExifIFDPointer", | |
34853: "GPSInfoIFDPointer" | |
}, | |
exif: { | |
36864: "ExifVersion", | |
40961: "ColorSpace", | |
40962: "PixelXDimension", | |
40963: "PixelYDimension", | |
36867: "DateTimeOriginal", | |
33434: "ExposureTime", | |
33437: "FNumber", | |
34855: "ISOSpeedRatings", | |
37377: "ShutterSpeedValue", | |
37378: "ApertureValue", | |
37383: "MeteringMode", | |
37384: "LightSource", | |
37385: "Flash", | |
41986: "ExposureMode", | |
41987: "WhiteBalance", | |
41990: "SceneCaptureType", | |
41988: "DigitalZoomRatio", | |
41992: "Contrast", | |
41993: "Saturation", | |
41994: "Sharpness" | |
}, | |
gps: { | |
0: "GPSVersionID", | |
1: "GPSLatitudeRef", | |
2: "GPSLatitude", | |
3: "GPSLongitudeRef", | |
4: "GPSLongitude" | |
} | |
}; | |
b = { | |
ColorSpace: { | |
1: "sRGB", | |
0: "Uncalibrated" | |
}, | |
MeteringMode: { | |
0: "Unknown", | |
1: "Average", | |
2: "CenterWeightedAverage", | |
3: "Spot", | |
4: "MultiSpot", | |
5: "Pattern", | |
6: "Partial", | |
255: "Other" | |
}, | |
LightSource: { | |
1: "Daylight", | |
2: "Fliorescent", | |
3: "Tungsten", | |
4: "Flash", | |
9: "Fine weather", | |
10: "Cloudy weather", | |
11: "Shade", | |
12: "Daylight fluorescent (D 5700 - 7100K)", | |
13: "Day white fluorescent (N 4600 -5400K)", | |
14: "Cool white fluorescent (W 3900 - 4500K)", | |
15: "White fluorescent (WW 3200 - 3700K)", | |
17: "Standard light A", | |
18: "Standard light B", | |
19: "Standard light C", | |
20: "D55", | |
21: "D65", | |
22: "D75", | |
23: "D50", | |
24: "ISO studio tungsten", | |
255: "Other" | |
}, | |
Flash: { | |
0: "Flash did not fire.", | |
1: "Flash fired.", | |
5: "Strobe return light not detected.", | |
7: "Strobe return light detected.", | |
9: "Flash fired, compulsory flash mode", | |
13: "Flash fired, compulsory flash mode, return light not detected", | |
15: "Flash fired, compulsory flash mode, return light detected", | |
16: "Flash did not fire, compulsory flash mode", | |
24: "Flash did not fire, auto mode", | |
25: "Flash fired, auto mode", | |
29: "Flash fired, auto mode, return light not detected", | |
31: "Flash fired, auto mode, return light detected", | |
32: "No flash function", | |
65: "Flash fired, red-eye reduction mode", | |
69: "Flash fired, red-eye reduction mode, return light not detected", | |
71: "Flash fired, red-eye reduction mode, return light detected", | |
73: "Flash fired, compulsory flash mode, red-eye reduction mode", | |
77: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", | |
79: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", | |
89: "Flash fired, auto mode, red-eye reduction mode", | |
93: "Flash fired, auto mode, return light not detected, red-eye reduction mode", | |
95: "Flash fired, auto mode, return light detected, red-eye reduction mode" | |
}, | |
ExposureMode: { | |
0: "Auto exposure", | |
1: "Manual exposure", | |
2: "Auto bracket" | |
}, | |
WhiteBalance: { | |
0: "Auto white balance", | |
1: "Manual white balance" | |
}, | |
SceneCaptureType: { | |
0: "Standard", | |
1: "Landscape", | |
2: "Portrait", | |
3: "Night scene" | |
}, | |
Contrast: { | |
0: "Normal", | |
1: "Soft", | |
2: "Hard" | |
}, | |
Saturation: { | |
0: "Normal", | |
1: "Low saturation", | |
2: "High saturation" | |
}, | |
Sharpness: { | |
0: "Normal", | |
1: "Soft", | |
2: "Hard" | |
}, | |
GPSLatitudeRef: { | |
N: "North latitude", | |
S: "South latitude" | |
}, | |
GPSLongitudeRef: { | |
E: "East longitude", | |
W: "West longitude" | |
} | |
}; | |
function f(N, k) { | |
var K = e.SHORT(N), | |
H, O, M, l, G, L, J, j, h = [], | |
I = {}; | |
for (H = 0; H < K; H++) { | |
J = L = N + 12 * H + 2; | |
M = k[e.SHORT(J)]; | |
if (M === t) { | |
continue; | |
} | |
l = e.SHORT(J += 2); | |
G = e.LONG(J += 2); | |
J += 4; | |
h = []; | |
switch (l) { | |
case 1: | |
case 7: | |
if (G > 4) { | |
J = e.LONG(J) + g.tiffHeader; | |
} | |
for (O = 0; O < G; O++) { | |
h[O] = e.BYTE(J + O); | |
} | |
break; | |
case 2: | |
if (G > 4) { | |
J = e.LONG(J) + g.tiffHeader; | |
} | |
I[M] = e.STRING(J, G - 1); | |
continue; | |
case 3: | |
if (G > 2) { | |
J = e.LONG(J) + g.tiffHeader; | |
} | |
for (O = 0; O < G; O++) { | |
h[O] = e.SHORT(J + O * 2); | |
} | |
break; | |
case 4: | |
if (G > 1) { | |
J = e.LONG(J) + g.tiffHeader; | |
} | |
for (O = 0; O < G; O++) { | |
h[O] = e.LONG(J + O * 4); | |
} | |
break; | |
case 5: | |
J = e.LONG(J) + g.tiffHeader; | |
for (O = 0; O < G; O++) { | |
h[O] = e.LONG(J + O * 4) / e.LONG(J + O * 4 + 4); | |
} | |
break; | |
case 9: | |
J = e.LONG(J) + g.tiffHeader; | |
for (O = 0; O < G; O++) { | |
h[O] = e.SLONG(J + O * 4); | |
} | |
break; | |
case 10: | |
J = e.LONG(J) + g.tiffHeader; | |
for (O = 0; O < G; O++) { | |
h[O] = e.SLONG(J + O * 4) / e.SLONG(J + O * 4 + 4); | |
} | |
break; | |
default: | |
continue; | |
} | |
j = (G == 1 ? h[0] : h); | |
if (b.hasOwnProperty(M) && typeof j != "object") { | |
I[M] = b[M][j]; | |
} else { | |
I[M] = j; | |
} | |
} | |
return I; | |
} | |
function c() { | |
var h = t, | |
j = g.tiffHeader; | |
e.II(e.SHORT(j) == 18761); | |
if (e.SHORT(j += 2) !== 42) { | |
return false; | |
} | |
g.IFD0 = g.tiffHeader + e.LONG(j += 2); | |
h = f(g.IFD0, a.tiff); | |
g.exifIFD = ("ExifIFDPointer" in h ? g.tiffHeader + h.ExifIFDPointer : t); | |
g.gpsIFD = ("GPSInfoIFDPointer" in h ? g.tiffHeader + h.GPSInfoIFDPointer : t); | |
return true; | |
} | |
function d(l, C, E) { | |
var j, h, k, D = 0; | |
if (typeof (C) === "string") { | |
var B = a[l.toLowerCase()]; | |
for (hex in B) { | |
if (B[hex] === C) { | |
C = hex; | |
break; | |
} | |
} | |
} | |
j = g[l.toLowerCase() + "IFD"]; | |
h = e.SHORT(j); | |
for (i = 0; i < h; i++) { | |
k = j + 12 * i + 2; | |
if (e.SHORT(k) == C) { | |
D = k + 8; | |
break; | |
} | |
} | |
if (!D) { | |
return false; | |
} | |
e.LONG(D, E); | |
return true; | |
} | |
return { | |
init: function (h) { | |
g = { | |
tiffHeader: 10 | |
}; | |
if (h === t || !h.length) { | |
return false; | |
} | |
e.init(h); | |
if (e.SHORT(0) === 65505 && e.STRING(4, 5).toUpperCase() === "EXIF\0") { | |
return c(); | |
} | |
return false; | |
}, | |
EXIF: function () { | |
var h; | |
h = f(g.exifIFD, a.exif); | |
h.ExifVersion = String.fromCharCode(h.ExifVersion[0], h.ExifVersion[1], h.ExifVersion[2], h.ExifVersion[3]); | |
return h; | |
}, | |
GPS: function () { | |
var h; | |
h = f(g.gpsIFD, a.gps); | |
h.GPSVersionID = h.GPSVersionID.join("."); | |
return h; | |
}, | |
setExif: function (j, h) { | |
if (j !== "PixelXDimension" && j !== "PixelYDimension") { | |
return false; | |
} | |
return d("exif", j, h); | |
}, | |
getBinary: function () { | |
return e.SEGMENT(); | |
} | |
}; | |
} | |
})(window, document, plupload); | |
(function (j, g, f, k) { | |
function h(a) { | |
return g.getElementById(a); | |
} | |
f.runtimes.Html4 = f.addRuntime("html4", { | |
getFeatures: function () { | |
return { | |
multipart: true, | |
canOpenDialog: navigator.userAgent.indexOf("WebKit") !== -1 | |
}; | |
}, | |
init: function (b, a) { | |
b.bind("Init", function (e) { | |
var E = g.body, | |
A, F = "javascript", | |
D, H, d, G = [], | |
c = /MSIE/.test(navigator.userAgent), | |
L = [], | |
B = e.settings.filters, | |
y, C, M, I; | |
no_type_restriction: for (y = 0; y < B.length; y++) { | |
C = B[y].extensions.split(/,/); | |
for (I = 0; I < C.length; I++) { | |
if (C[I] === "*") { | |
L = []; | |
break no_type_restriction; | |
} | |
M = f.mimeTypes[C[I]]; | |
if (M) { | |
L.push(M); | |
} | |
} | |
} | |
L = L.join(","); | |
function J() { | |
var m, l, o, n; | |
d = f.guid(); | |
G.push(d); | |
m = g.createElement("form"); | |
m.setAttribute("id", "form_" + d); | |
m.setAttribute("method", "post"); | |
m.setAttribute("enctype", "multipart/form-data"); | |
m.setAttribute("encoding", "multipart/form-data"); | |
m.setAttribute("target", e.id + "_iframe"); | |
m.style.position = "absolute"; | |
l = g.createElement("input"); | |
l.setAttribute("id", "input_" + d); | |
l.setAttribute("type", "file"); | |
l.setAttribute("accept", L); | |
l.setAttribute("size", 1); | |
n = h(e.settings.browse_button); | |
if (e.features.canOpenDialog && n) { | |
f.addEvent(h(e.settings.browse_button), "click", function (p) { | |
l.click(); | |
p.preventDefault(); | |
}, e.id); | |
} | |
f.extend(l.style, { | |
width: "100%", | |
height: "100%", | |
opacity: 0, | |
fontSize: "99px" | |
}); | |
f.extend(m.style, { | |
overflow: "hidden" | |
}); | |
o = e.settings.shim_bgcolor; | |
if (o) { | |
m.style.background = o; | |
} | |
if (c) { | |
f.extend(l.style, { | |
filter: "alpha(opacity=0)" | |
}); | |
} | |
f.addEvent(l, "change", function (q) { | |
var s = q.target, | |
t, r = [], | |
p; | |
if (s.value) { | |
h("form_" + d).style.top = -1048575 + "px"; | |
t = s.value.replace(/\\/g, "/"); | |
t = t.substring(t.length, t.lastIndexOf("/") + 1); | |
r.push(new f.File(d, t)); | |
if (!e.features.canOpenDialog) { | |
f.removeAllEvents(m, e.id); | |
} else { | |
f.removeEvent(n, "click", e.id); | |
} | |
f.removeEvent(l, "change", e.id); | |
J(); | |
if (r.length) { | |
b.trigger("FilesAdded", r); | |
} | |
} | |
}, e.id); | |
m.appendChild(l); | |
E.appendChild(m); | |
e.refresh(); | |
} | |
function K() { | |
var l = g.createElement("div"); | |
l.innerHTML = '<iframe id="' + e.id + '_iframe" name="' + e.id + '_iframe" src="' + F + ':""" style="display:none"></iframe>'; | |
A = l.firstChild; | |
E.appendChild(A); | |
f.addEvent(A, "load", function (o) { | |
var n = o.target, | |
p, m; | |
if (!D) { | |
return; | |
} | |
try { | |
p = n.contentWindow.document || n.contentDocument || j.frames[n.id].document; | |
} catch (q) { | |
e.trigger("Error", { | |
code: f.SECURITY_ERROR, | |
message: f.translate("Security error."), | |
file: D | |
}); | |
return; | |
} | |
m = p.documentElement.innerText || p.documentElement.textContent; | |
if (m) { | |
D.status = f.DONE; | |
D.loaded = 1025; | |
D.percent = 100; | |
e.trigger("UploadProgress", D); | |
e.trigger("FileUploaded", D, { | |
response: m | |
}); | |
} | |
}, e.id); | |
} | |
if (e.settings.container) { | |
E = h(e.settings.container); | |
if (f.getStyle(E, "position") === "static") { | |
E.style.position = "relative"; | |
} | |
} | |
e.bind("UploadFile", function (o, n) { | |
var m, l; | |
if (n.status == f.DONE || n.status == f.FAILED || o.state == f.STOPPED) { | |
return; | |
} | |
m = h("form_" + n.id); | |
l = h("input_" + n.id); | |
l.setAttribute("name", o.settings.file_data_name); | |
m.setAttribute("action", o.settings.url); | |
f.each(f.extend({ | |
name: n.target_name || n.name | |
}, o.settings.multipart_params), function (p, r) { | |
var q = g.createElement("input"); | |
f.extend(q, { | |
type: "hidden", | |
name: r, | |
value: p | |
}); | |
m.insertBefore(q, m.firstChild); | |
}); | |
D = n; | |
h("form_" + d).style.top = -1048575 + "px"; | |
m.submit(); | |
m.parentNode.removeChild(m); | |
}); | |
e.bind("FileUploaded", function (l) { | |
l.refresh(); | |
}); | |
e.bind("StateChanged", function (l) { | |
if (l.state == f.STARTED) { | |
K(); | |
} | |
if (l.state == f.STOPPED) { | |
j.setTimeout(function () { | |
f.removeEvent(A, "load", l.id); | |
A.parentNode.removeChild(A); | |
}, 0); | |
} | |
}); | |
e.bind("Refresh", function (n) { | |
var s, m, l, u, p, r, q, t, o; | |
s = h(n.settings.browse_button); | |
if (s) { | |
p = f.getPos(s, h(n.settings.container)); | |
r = f.getSize(s); | |
q = h("form_" + d); | |
t = h("input_" + d); | |
f.extend(q.style, { | |
top: p.y + "px", | |
left: p.x + "px", | |
width: r.w + "px", | |
height: r.h + "px" | |
}); | |
if (n.features.canOpenDialog) { | |
o = parseInt(s.parentNode.style.zIndex, 10); | |
if (isNaN(o)) { | |
o = 0; | |
} | |
f.extend(s.style, { | |
zIndex: o | |
}); | |
if (f.getStyle(s, "position") === "static") { | |
f.extend(s.style, { | |
position: "relative" | |
}); | |
} | |
f.extend(q.style, { | |
zIndex: o - 1 | |
}); | |
} | |
l = n.settings.browse_button_hover; | |
u = n.settings.browse_button_active; | |
m = n.features.canOpenDialog ? s : q; | |
if (l) { | |
f.addEvent(m, "mouseover", function () { | |
f.addClass(s, l); | |
}, n.id); | |
f.addEvent(m, "mouseout", function () { | |
f.removeClass(s, l); | |
}, n.id); | |
} | |
if (u) { | |
f.addEvent(m, "mousedown", function () { | |
f.addClass(s, u); | |
}, n.id); | |
f.addEvent(g.body, "mouseup", function () { | |
f.removeClass(s, u); | |
}, n.id); | |
} | |
} | |
}); | |
b.bind("FilesRemoved", function (o, n) { | |
var l, m; | |
for (l = 0; l < n.length; l++) { | |
m = h("form_" + n[l].id); | |
if (m) { | |
m.parentNode.removeChild(m); | |
} | |
} | |
}); | |
b.bind("Destroy", function (p) { | |
var l, o, n, m = { | |
inputContainer: "form_" + d, | |
inputFile: "input_" + d, | |
browseButton: p.settings.browse_button | |
}; | |
for (l in m) { | |
o = h(m[l]); | |
if (o) { | |
f.removeAllEvents(o, p.id); | |
} | |
} | |
f.removeAllEvents(g.body, p.id); | |
f.each(G, function (q, r) { | |
n = h("form_" + q); | |
if (n) { | |
E.removeChild(n); | |
} | |
}); | |
}); | |
J(); | |
}); | |
a({ | |
success: true | |
}); | |
} | |
}); | |
})(window, document, plupload); | |
var io = this.io = { | |
version: "0.6.2", | |
setPath: function (a) { | |
if (window.console && console.error) { | |
console.error("io.setPath will be removed. Please set the variable WEB_SOCKET_SWF_LOCATION pointing to WebSocketMain.swf"); | |
} | |
this.path = /\/$/.test(a) ? a : a + "/"; | |
WEB_SOCKET_SWF_LOCATION = a + "lib/vendor/web-socket-js/WebSocketMain.swf"; | |
} | |
}; | |
if ("jQuery" in this) { | |
jQuery.io = this.io; | |
} | |
if (typeof window != "undefined") { | |
if (typeof WEB_SOCKET_SWF_LOCATION === "undefined") { | |
WEB_SOCKET_SWF_LOCATION = "/socket.io/lib/vendor/web-socket-js/WebSocketMain.swf"; | |
} | |
}(function () { | |
var b = this.io; | |
var a = false; | |
b.util = { | |
ios: false, | |
load: function (c) { | |
if (/loaded|complete/.test(document.readyState) || a) { | |
return c(); | |
} | |
if ("attachEvent" in window) { | |
window.attachEvent("onload", c); | |
} else { | |
window.addEventListener("load", c, false); | |
} | |
}, | |
inherit: function (e, c) { | |
for (var d in c.prototype) { | |
e.prototype[d] = c.prototype[d]; | |
} | |
}, | |
indexOf: function (c, f, g) { | |
for (var d = c.length, e = (g < 0) ? Math.max(0, d + g) : g || 0; e < d; e++) { | |
if (c[e] === f) { | |
return e; | |
} | |
} | |
return -1; | |
}, | |
isArray: function (c) { | |
return Object.prototype.toString.call(c) === "[object Array]"; | |
}, | |
merge: function (e, c) { | |
for (var d in c) { | |
if (c.hasOwnProperty(d)) { | |
e[d] = c[d]; | |
} | |
} | |
} | |
}; | |
b.util.ios = /iphone|ipad/i.test(navigator.userAgent); | |
b.util.android = /android/i.test(navigator.userAgent); | |
b.util.opera = /opera/i.test(navigator.userAgent); | |
b.util.load(function () { | |
a = true; | |
}); | |
})(); | |
(function () { | |
var c = this.io; | |
var a = "~m~", | |
b = function (d) { | |
if (Object.prototype.toString.call(d) == "[object Object]") { | |
if (!("JSON" in window)) { | |
if ("console" in window && console.error) { | |
console.error("Trying to encode as JSON, but JSON.stringify is missing."); | |
} | |
return '{ "$error": "Invalid message" }'; | |
} | |
return "~j~" + JSON.stringify(d); | |
} else { | |
return String(d); | |
} | |
}; | |
Transport = c.Transport = function (e, d) { | |
this.base = e; | |
this.options = { | |
timeout: 15000 | |
}; | |
c.util.merge(this.options, d); | |
}; | |
Transport.prototype.send = function () { | |
throw new Error("Missing send() implementation"); | |
}; | |
Transport.prototype.connect = function () { | |
throw new Error("Missing connect() implementation"); | |
}; | |
Transport.prototype.disconnect = function () { | |
throw new Error("Missing disconnect() implementation"); | |
}; | |
Transport.prototype._encode = function (h) { | |
var e = "", | |
g, h = c.util.isArray(h) ? h : [h]; | |
for (var f = 0, d = h.length; f < d; f++) { | |
g = h[f] === null || h[f] === undefined ? "" : b(h[f]); | |
e += a + g.length + a + g; | |
} | |
return e; | |
}; | |
Transport.prototype._decode = function (h) { | |
var g = [], | |
f, j; | |
do { | |
if (h.substr(0, 3) !== a) { | |
return g; | |
} | |
h = h.substr(3); | |
f = "", j = ""; | |
for (var e = 0, d = h.length; e < d; e++) { | |
j = Number(h.substr(e, 1)); | |
if (h.substr(e, 1) == j) { | |
f += j; | |
} else { | |
h = h.substr(f.length + a.length); | |
f = Number(f); | |
break; | |
} | |
} | |
g.push(h.substr(0, f)); | |
h = h.substr(f); | |
} while (h !== ""); | |
return g; | |
}; | |
Transport.prototype._onData = function (g) { | |
this._setTimeout(); | |
var f = this._decode(g); | |
if (f && f.length) { | |
for (var e = 0, d = f.length; e < d; e++) { | |
this._onMessage(f[e]); | |
} | |
} | |
}; | |
Transport.prototype._setTimeout = function () { | |
var d = this; | |
if (this._timeout) { | |
clearTimeout(this._timeout); | |
} | |
this._timeout = setTimeout(function () { | |
d._onTimeout(); | |
}, this.options.timeout); | |
}; | |
Transport.prototype._onTimeout = function () { | |
this._onDisconnect(); | |
}; | |
Transport.prototype._onMessage = function (d) { | |
if (!this.sessionid) { | |
this.sessionid = d; | |
this._onConnect(); | |
} else { | |
if (d.substr(0, 3) == "~h~") { | |
this._onHeartbeat(d.substr(3)); | |
} else { | |
if (d.substr(0, 3) == "~j~") { | |
this.base._onMessage(JSON.parse(d.substr(3))); | |
} else { | |
this.base._onMessage(d); | |
} | |
} | |
} | |
}, Transport.prototype._onHeartbeat = function (d) { | |
this.send("~h~" + d); | |
}; | |
Transport.prototype._onConnect = function () { | |
this.connected = true; | |
this.connecting = false; | |
this.base._onConnect(); | |
this._setTimeout(); | |
}; | |
Transport.prototype._onDisconnect = function () { | |
this.connecting = false; | |
this.connected = false; | |
this.sessionid = null; | |
this.base._onDisconnect(); | |
}; | |
Transport.prototype._prepareUrl = function () { | |
return (this.base.options.secure ? "https" : "http") + "://" + this.base.host + ":" + this.base.options.port + "/" + this.base.options.resource + "/" + this.type + (this.sessionid ? ("/" + this.sessionid) : "/"); | |
}; | |
})(); | |
(function () { | |
var e = this.io; | |
var d = new Function, | |
a = (function () { | |
if (!("XMLHttpRequest" in window)) { | |
return false; | |
} | |
var f = new XMLHttpRequest(); | |
return f.withCredentials != undefined; | |
})(), | |
c = function (h) { | |
if ("XDomainRequest" in window && h) { | |
return new XDomainRequest(); | |
} | |
if ("XMLHttpRequest" in window && (!h || a)) { | |
return new XMLHttpRequest(); | |
} | |
if (!h) { | |
try { | |
var g = new ActiveXObject("MSXML2.XMLHTTP"); | |
return g; | |
} catch (i) {} | |
try { | |
var f = new ActiveXObject("Microsoft.XMLHTTP"); | |
return f; | |
} catch (i) {} | |
} | |
return false; | |
}, | |
b = e.Transport.XHR = function () { | |
e.Transport.apply(this, arguments); | |
this._sendBuffer = []; | |
}; | |
e.util.inherit(b, e.Transport); | |
b.prototype.connect = function () { | |
this._get(); | |
return this; | |
}; | |
b.prototype._checkSend = function () { | |
if (!this._posting && this._sendBuffer.length) { | |
var f = this._encode(this._sendBuffer); | |
this._sendBuffer = []; | |
this._send(f); | |
} | |
}; | |
b.prototype.send = function (f) { | |
if (e.util.isArray(f)) { | |
this._sendBuffer.push.apply(this._sendBuffer, f); | |
} else { | |
this._sendBuffer.push(f); | |
} | |
this._checkSend(); | |
return this; | |
}; | |
b.prototype._send = function (g) { | |
var f = this; | |
this._posting = true; | |
this._sendXhr = this._request("send", "POST"); | |
this._sendXhr.onreadystatechange = function () { | |
var h; | |
if (f._sendXhr.readyState == 4) { | |
f._sendXhr.onreadystatechange = d; | |
try { | |
h = f._sendXhr.status; | |
} catch (i) {} | |
f._posting = false; | |
if (h == 200) { | |
f._checkSend(); | |
} else { | |
f._onDisconnect(); | |
} | |
} | |
}; | |
this._sendXhr.send("data=" + encodeURIComponent(g)); | |
}; | |
b.prototype.disconnect = function () { | |
this._onDisconnect(); | |
return this; | |
}; | |
b.prototype._onDisconnect = function () { | |
if (this._xhr) { | |
this._xhr.onreadystatechange = d; | |
try { | |
this._xhr.abort(); | |
} catch (f) {} | |
this._xhr = null; | |
} | |
if (this._sendXhr) { | |
this._sendXhr.onreadystatechange = d; | |
try { | |
this._sendXhr.abort(); | |
} catch (f) {} | |
this._sendXhr = null; | |
} | |
this._sendBuffer = []; | |
e.Transport.prototype._onDisconnect.call(this); | |
}; | |
b.prototype._request = function (g, i, f) { | |
var h = c(this.base._isXDomain()); | |
if (f) { | |
h.multipart = true; | |
} | |
h.open(i || "GET", this._prepareUrl() + (g ? "/" + g : "")); | |
if (i == "POST" && "setRequestHeader" in h) { | |
h.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8"); | |
} | |
return h; | |
}; | |
b.check = function (f) { | |
try { | |
if (c(f)) { | |
return true; | |
} | |
} catch (g) {} | |
return false; | |
}; | |
b.xdomainCheck = function () { | |
return b.check(true); | |
}; | |
b.request = c; | |
})(); | |
(function () { | |
var b = this.io; | |
var a = b.Transport.websocket = function () { | |
b.Transport.apply(this, arguments); | |
}; | |
b.util.inherit(a, b.Transport); | |
a.prototype.type = "websocket"; | |
a.prototype.connect = function () { | |
var c = this; | |
this.socket = new WebSocket(this._prepareUrl()); | |
this.socket.onmessage = function (d) { | |
c._onData(d.data); | |
}; | |
this.socket.onclose = function (d) { | |
c._onClose(); | |
}; | |
this.socket.onerror = function (d) { | |
c._onError(d); | |
}; | |
return this; | |
}; | |
a.prototype.send = function (c) { | |
if (this.socket) { | |
this.socket.send(this._encode(c)); | |
} | |
return this; | |
}; | |
a.prototype.disconnect = function () { | |
if (this.socket) { | |
this.socket.close(); | |
} | |
return this; | |
}; | |
a.prototype._onClose = function () { | |
this._onDisconnect(); | |
return this; | |
}; | |
a.prototype._onError = function (c) { | |
this.base.emit("error", [c]); | |
}; | |
a.prototype._prepareUrl = function () { | |
return (this.base.options.secure ? "wss" : "ws") + "://" + this.base.host + ":" + this.base.options.port + "/" + this.base.options.resource + "/" + this.type + (this.sessionid ? ("/" + this.sessionid) : ""); | |
}; | |
a.check = function () { | |
return "WebSocket" in window && WebSocket.prototype && (WebSocket.prototype.send && !! WebSocket.prototype.send.toString().match(/native/i)) && typeof WebSocket !== "undefined"; | |
}; | |
a.xdomainCheck = function () { | |
return true; | |
}; | |
})(); | |
(function () { | |
var b = this.io; | |
var a = b.Transport.flashsocket = function () { | |
b.Transport.websocket.apply(this, arguments); | |
}; | |
b.util.inherit(a, b.Transport.websocket); | |
a.prototype.type = "flashsocket"; | |
a.prototype.connect = function () { | |
var c = this, | |
d = arguments; | |
WebSocket.__addTask(function () { | |
b.Transport.websocket.prototype.connect.apply(c, d); | |
}); | |
return this; | |
}; | |
a.prototype.send = function () { | |
var c = this, | |
d = arguments; | |
WebSocket.__addTask(function () { | |
b.Transport.websocket.prototype.send.apply(c, d); | |
}); | |
return this; | |
}; | |
a.check = function () { | |
if (typeof WebSocket == "undefined" || !("__addTask" in WebSocket)) { | |
return false; | |
} | |
if (b.util.opera) { | |
return false; | |
} | |
if ("navigator" in window && "plugins" in navigator && navigator.plugins["Shockwave Flash"]) { | |
return !!navigator.plugins["Shockwave Flash"].description; | |
} | |
if ("ActiveXObject" in window) { | |
try { | |
return !!new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version"); | |
} catch (c) {} | |
} | |
return false; | |
}; | |
a.xdomainCheck = function () { | |
return true; | |
}; | |
})(); | |
(function () { | |
var b = this.io; | |
var a = b.Transport.htmlfile = function () { | |
b.Transport.XHR.apply(this, arguments); | |
}; | |
b.util.inherit(a, b.Transport.XHR); | |
a.prototype.type = "htmlfile"; | |
a.prototype._get = function () { | |
var c = this; | |
this._open(); | |
window.attachEvent("onunload", function () { | |
c._destroy(); | |
}); | |
}; | |
a.prototype._open = function () { | |
this._doc = new ActiveXObject("htmlfile"); | |
this._doc.open(); | |
this._doc.write("<html></html>"); | |
this._doc.parentWindow.s = this; | |
this._doc.close(); | |
var c = this._doc.createElement("div"); | |
this._doc.body.appendChild(c); | |
this._iframe = this._doc.createElement("iframe"); | |
c.appendChild(this._iframe); | |
this._iframe.src = this._prepareUrl() + "/" + (+new Date); | |
}; | |
a.prototype._ = function (d, e) { | |
this._onData(d); | |
var c = e.getElementsByTagName("script")[0]; | |
c.parentNode.removeChild(c); | |
}; | |
a.prototype._destroy = function () { | |
if (this._iframe) { | |
this._iframe.src = "about:blank"; | |
this._doc = null; | |
CollectGarbage(); | |
} | |
}; | |
a.prototype.disconnect = function () { | |
this._destroy(); | |
return b.Transport.XHR.prototype.disconnect.call(this); | |
}; | |
a.check = function () { | |
if ("ActiveXObject" in window) { | |
try { | |
var c = new ActiveXObject("htmlfile"); | |
return c && b.Transport.XHR.check(); | |
} catch (d) {} | |
} | |
return false; | |
}; | |
a.xdomainCheck = function () { | |
return false; | |
}; | |
})(); | |
(function () { | |
var b = this.io; | |
var a = b.Transport["xhr-multipart"] = function () { | |
b.Transport.XHR.apply(this, arguments); | |
}; | |
b.util.inherit(a, b.Transport.XHR); | |
a.prototype.type = "xhr-multipart"; | |
a.prototype._get = function () { | |
var c = this; | |
this._xhr = this._request("", "GET", true); | |
this._xhr.onreadystatechange = function () { | |
if (c._xhr.readyState == 4) { | |
c._onData(c._xhr.responseText); | |
} | |
}; | |
this._xhr.send(null); | |
}; | |
a.check = function () { | |
return "XMLHttpRequest" in window && "prototype" in XMLHttpRequest && "multipart" in XMLHttpRequest.prototype; | |
}; | |
a.xdomainCheck = function () { | |
return true; | |
}; | |
})(); | |
(function () { | |
var c = this.io; | |
var a = new Function(), | |
b = c.Transport["xhr-polling"] = function () { | |
c.Transport.XHR.apply(this, arguments); | |
}; | |
c.util.inherit(b, c.Transport.XHR); | |
b.prototype.type = "xhr-polling"; | |
b.prototype.connect = function () { | |
if (c.util.ios || c.util.android) { | |
var d = this; | |
c.util.load(function () { | |
setTimeout(function () { | |
c.Transport.XHR.prototype.connect.call(d); | |
}, 10); | |
}); | |
} else { | |
c.Transport.XHR.prototype.connect.call(this); | |
} | |
}; | |
b.prototype._get = function () { | |
var d = this; | |
this._xhr = this._request(+new Date, "GET"); | |
this._xhr.onreadystatechange = function () { | |
var f; | |
if (d._xhr.readyState == 4) { | |
d._xhr.onreadystatechange = a; | |
try { | |
f = d._xhr.status; | |
} catch (g) {} | |
if (f == 200) { | |
d._onData(d._xhr.responseText); | |
d._get(); | |
} else { | |
d._onDisconnect(); | |
} | |
} | |
}; | |
this._xhr.send(null); | |
}; | |
b.check = function () { | |
return c.Transport.XHR.check(); | |
}; | |
b.xdomainCheck = function () { | |
return c.Transport.XHR.xdomainCheck(); | |
}; | |
})(); | |
(function () { | |
var a = this.io; | |
a.JSONP = []; | |
JSONPPolling = a.Transport["jsonp-polling"] = function () { | |
a.Transport.XHR.apply(this, arguments); | |
this._insertAt = document.getElementsByTagName("script")[0]; | |
this._index = a.JSONP.length; | |
a.JSONP.push(this); | |
}; | |
a.util.inherit(JSONPPolling, a.Transport["xhr-polling"]); | |
JSONPPolling.prototype.type = "jsonp-polling"; | |
JSONPPolling.prototype._send = function (i) { | |
var k = this; | |
if (!("_form" in this)) { | |
var c = document.createElement("FORM"), | |
d = document.createElement("TEXTAREA"), | |
b = this._iframeId = "socket_io_iframe_" + this._index, | |
h; | |
c.style.position = "absolute"; | |
c.style.top = "-1000px"; | |
c.style.left = "-1000px"; | |
c.target = b; | |
c.method = "POST"; | |
c.action = this._prepareUrl() + "/" + (+new Date) + "/" + this._index; | |
d.name = "data"; | |
c.appendChild(d); | |
this._insertAt.parentNode.insertBefore(c, this._insertAt); | |
document.body.appendChild(c); | |
this._form = c; | |
this._area = d; | |
} | |
function f() { | |
g(); | |
k._posting = false; | |
k._checkSend(); | |
} | |
function g() { | |
if (k._iframe) { | |
k._form.removeChild(k._iframe); | |
} | |
try { | |
h = document.createElement('<iframe name="' + k._iframeId + '">'); | |
} catch (l) { | |
h = document.createElement("iframe"); | |
h.name = k._iframeId; | |
} | |
h.id = k._iframeId; | |
k._form.appendChild(h); | |
k._iframe = h; | |
} | |
g(); | |
this._posting = true; | |
this._area.value = i; | |
try { | |
this._form.submit(); | |
} catch (j) {} | |
if (this._iframe.attachEvent) { | |
h.onreadystatechange = function () { | |
if (k._iframe.readyState == "complete") { | |
f(); | |
} | |
}; | |
} else { | |
this._iframe.onload = f; | |
} | |
}; | |
JSONPPolling.prototype._get = function () { | |
var c = this, | |
b = document.createElement("SCRIPT"); | |
if (this._script) { | |
this._script.parentNode.removeChild(this._script); | |
this._script = null; | |
} | |
b.async = true; | |
b.src = this._prepareUrl() + "/" + (+new Date) + "/" + this._index; | |
b.onerror = function () { | |
c._onDisconnect(); | |
}; | |
this._insertAt.parentNode.insertBefore(b, this._insertAt); | |
this._script = b; | |
}; | |
JSONPPolling.prototype._ = function () { | |
this._onData.apply(this, arguments); | |
this._get(); | |
return this; | |
}; | |
JSONPPolling.check = function () { | |
return true; | |
}; | |
JSONPPolling.xdomainCheck = function () { | |
return true; | |
}; | |
})(); | |
(function () { | |
var b = this.io; | |
var a = b.Socket = function (d, c) { | |
this.host = d || document.domain; | |
this.options = { | |
secure: false, | |
document: document, | |
port: document.location.port || 80, | |
resource: "socket.io", | |
transports: ["websocket", "flashsocket", "htmlfile", "xhr-multipart", "xhr-polling", "jsonp-polling"], | |
transportOptions: { | |
"xhr-polling": { | |
timeout: 25000 | |
}, | |
"jsonp-polling": { | |
timeout: 25000 | |
} | |
}, | |
connectTimeout: 5000, | |
reconnect: true, | |
reconnectionDelay: 500, | |
maxReconnectionAttempts: 10, | |
tryTransportsOnConnectTimeout: true, | |
rememberTransport: true | |
}; | |
b.util.merge(this.options, c); | |
this.connected = false; | |
this.connecting = false; | |
this._events = {}; | |
this.transport = this.getTransport(); | |
if (!this.transport && "console" in window) { | |
console.error("No transport available"); | |
} | |
}; | |
a.prototype.getTransport = function (f) { | |
var c = f || this.options.transports, | |
d; | |
if (this.options.rememberTransport && !f) { | |
d = this.options.document.cookie.match("(?:^|;)\\s*socketio=([^;]*)"); | |
if (d) { | |
this._rememberedTransport = true; | |
c = [decodeURIComponent(d[1])]; | |
} | |
} | |
for (var e = 0, g; g = c[e]; e++) { | |
if (b.Transport[g] && b.Transport[g].check() && (!this._isXDomain() || b.Transport[g].xdomainCheck())) { | |
return new b.Transport[g](this, this.options.transportOptions[g] || {}); | |
} | |
} | |
return null; | |
}; | |
a.prototype.connect = function () { | |
if (this.transport && !this.connected) { | |
if (this.connecting) { | |
this.disconnect(true); | |
} | |
this.connecting = true; | |
this.emit("connecting", [this.transport.type]); | |
this.transport.connect(); | |
if (this.options.connectTimeout) { | |
var c = this; | |
this.connectTimeoutTimer = setTimeout(function () { | |
if (!c.connected) { | |
c.disconnect(true); | |
if (c.options.tryTransportsOnConnectTimeout && !c._rememberedTransport) { | |
if (!c._remainingTransports) { | |
c._remainingTransports = c.options.transports.slice(0); | |
} | |
var d = c._remainingTransports; | |
while (d.length > 0 && d.splice(0, 1)[0] != c.transport.type) {} | |
if (d.length) { | |
c.transport = c.getTransport(d); | |
c.connect(); | |
} | |
} | |
if (!c._remainingTransports || c._remainingTransports.length == 0) { | |
c.emit("connect_failed"); | |
} | |
} | |
if (c._remainingTransports && c._remainingTransports.length == 0) { | |
delete c._remainingTransports; | |
} | |
}, this.options.connectTimeout); | |
} | |
} | |
return this; | |
}; | |
a.prototype.send = function (c) { | |
if (!this.transport || !this.transport.connected) { | |
return this._queue(c); | |
} | |
this.transport.send(c); | |
return this; | |
}; | |
a.prototype.disconnect = function (c) { | |
if (this.connectTimeoutTimer) { | |
clearTimeout(this.connectTimeoutTimer); | |
} | |
if (!c) { | |
this.options.reconnect = false; | |
} | |
this.transport.disconnect(); | |
return this; | |
}; | |
a.prototype.on = function (c, d) { | |
if (!(c in this._events)) { | |
this._events[c] = []; | |
} | |
this._events[c].push(d); | |
return this; | |
}; | |
a.prototype.emit = function (d, c) { | |
if (d in this._events) { | |
var f = this._events[d].concat(); | |
for (var e = 0, g = f.length; e < g; e++) { | |
f[e].apply(this, c === undefined ? [] : c); | |
} | |
} | |
return this; | |
}; | |
a.prototype.removeEvent = function (e, f) { | |
if (e in this._events) { | |
for (var d = 0, c = this._events[e].length; d < c; d++) { | |
if (this._events[e][d] == f) { | |
this._events[e].splice(d, 1); | |
} | |
} | |
} | |
return this; | |
}; | |
a.prototype._queue = function (c) { | |
if (!("_queueStack" in this)) { | |
this._queueStack = []; | |
} | |
this._queueStack.push(c); | |
return this; | |
}; | |
a.prototype._doQueue = function () { | |
if (!("_queueStack" in this) || !this._queueStack.length) { | |
return this; | |
} | |
this.transport.send(this._queueStack); | |
this._queueStack = []; | |
return this; | |
}; | |
a.prototype._isXDomain = function () { | |
var c = window.location.port || 80; | |
return this.host !== document.domain || this.options.port != c; | |
}; | |
a.prototype._onConnect = function () { | |
this.connected = true; | |
this.connecting = false; | |
this._doQueue(); | |
if (this.options.rememberTransport) { | |
this.options.document.cookie = "socketio=" + encodeURIComponent(this.transport.type); | |
} | |
this.emit("connect"); | |
}; | |
a.prototype._onMessage = function (c) { | |
this.emit("message", [c]); | |
}; | |
a.prototype._onDisconnect = function () { | |
var c = this.connected; | |
this.connected = false; | |
this.connecting = false; | |
this._queueStack = []; | |
if (c) { | |
this.emit("disconnect"); | |
if (this.options.reconnect && !this.reconnecting) { | |
this._onReconnect(); | |
} | |
} | |
}; | |
a.prototype._onReconnect = function () { | |
this.reconnecting = true; | |
this.reconnectionAttempts = 0; | |
this.reconnectionDelay = this.options.reconnectionDelay; | |
var c = this, | |
e = this.options.tryTransportsOnConnectTimeout, | |
g = this.options.rememberTransport; | |
function d() { | |
if (c.connected) { | |
c.emit("reconnect", [c.transport.type, c.reconnectionAttempts]); | |
} | |
c.removeEvent("connect_failed", f).removeEvent("connect", f); | |
delete c.reconnecting; | |
delete c.reconnectionAttempts; | |
delete c.reconnectionDelay; | |
delete c.reconnectionTimer; | |
delete c.redoTransports; | |
c.options.tryTransportsOnConnectTimeout = e; | |
c.options.rememberTransport = g; | |
return; | |
} | |
function f() { | |
if (!c.reconnecting) { | |
return; | |
} | |
if (!c.connected) { | |
if (c.connecting && c.reconnecting) { | |
return c.reconnectionTimer = setTimeout(f, 1000); | |
} | |
if (c.reconnectionAttempts++ >= c.options.maxReconnectionAttempts) { | |
if (!c.redoTransports) { | |
c.on("connect_failed", f); | |
c.options.tryTransportsOnConnectTimeout = true; | |
c.transport = c.getTransport(c.options.transports); | |
c.redoTransports = true; | |
c.connect(); | |
} else { | |
c.emit("reconnect_failed"); | |
d(); | |
} | |
} else { | |
c.reconnectionDelay *= 2; | |
c.connect(); | |
c.emit("reconnecting", [c.reconnectionDelay, c.reconnectionAttempts]); | |
c.reconnectionTimer = setTimeout(f, c.reconnectionDelay); | |
} | |
} else { | |
d(); | |
} | |
} | |
this.options.tryTransportsOnConnectTimeout = false; | |
this.reconnectionTimer = setTimeout(f, this.reconnectionDelay); | |
this.on("connect", f); | |
}; | |
a.prototype.fire = a.prototype.emit; | |
a.prototype.addListener = a.prototype.addEvent = a.prototype.addEventListener = a.prototype.on; | |
a.prototype.removeListener = a.prototype.removeEventListener = a.prototype.removeEvent; | |
})(); | |
var swfobject = function () { | |
var aq = "undefined", | |
aD = "object", | |
ab = "Shockwave Flash", | |
X = "ShockwaveFlash.ShockwaveFlash", | |
aE = "application/x-shockwave-flash", | |
ac = "SWFObjectExprInst", | |
ax = "onreadystatechange", | |
af = window, | |
aL = document, | |
aB = navigator, | |
aa = false, | |
Z = [aN], | |
aG = [], | |
ag = [], | |
al = [], | |
aJ, ad, ap, at, ak = false, | |
aU = false, | |
aH, an, aI = true, | |
ah = function () { | |
var a = typeof aL.getElementById != aq && typeof aL.getElementsByTagName != aq && typeof aL.createElement != aq, | |
e = aB.userAgent.toLowerCase(), | |
c = aB.platform.toLowerCase(), | |
h = c ? /win/.test(c) : /win/.test(e), | |
j = c ? /mac/.test(c) : /mac/.test(e), | |
g = /webkit/.test(e) ? parseFloat(e.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, | |
d = !+"\v1", | |
f = [0, 0, 0], | |
k = null; | |
if (typeof aB.plugins != aq && typeof aB.plugins[ab] == aD) { | |
k = aB.plugins[ab].description; | |
if (k && !(typeof aB.mimeTypes != aq && aB.mimeTypes[aE] && !aB.mimeTypes[aE].enabledPlugin)) { | |
aa = true; | |
d = false; | |
k = k.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); | |
f[0] = parseInt(k.replace(/^(.*)\..*$/, "$1"), 10); | |
f[1] = parseInt(k.replace(/^.*\.(.*)\s.*$/, "$1"), 10); | |
f[2] = /[a-zA-Z]/.test(k) ? parseInt(k.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; | |
} | |
} else { | |
if (typeof af.ActiveXObject != aq) { | |
try { | |
var i = new ActiveXObject(X); | |
if (i) { | |
k = i.GetVariable("$version"); | |
if (k) { | |
d = true; | |
k = k.split(" ")[1].split(","); | |
f = [parseInt(k[0], 10), parseInt(k[1], 10), parseInt(k[2], 10)]; | |
} | |
} | |
} catch (b) {} | |
} | |
} | |
return { | |
w3: a, | |
pv: f, | |
wk: g, | |
ie: d, | |
win: h, | |
mac: j | |
}; | |
}(), | |
aK = function () { | |
if (!ah.w3) { | |
return; | |
} | |
if ((typeof aL.readyState != aq && aL.readyState == "complete") || (typeof aL.readyState == aq && (aL.getElementsByTagName("body")[0] || aL.body))) { | |
aP(); | |
} | |
if (!ak) { | |
if (typeof aL.addEventListener != aq) { | |
aL.addEventListener("DOMContentLoaded", aP, false); | |
} | |
if (ah.ie && ah.win) { | |
aL.attachEvent(ax, function () { | |
if (aL.readyState == "complete") { | |
aL.detachEvent(ax, arguments.callee); | |
aP(); | |
} | |
}); | |
if (af == top) { | |
(function () { | |
if (ak) { | |
return; | |
} | |
try { | |
aL.documentElement.doScroll("left"); | |
} catch (a) { | |
setTimeout(arguments.callee, 0); | |
return; | |
} | |
aP(); | |
})(); | |
} | |
} | |
if (ah.wk) { | |
(function () { | |
if (ak) { | |
return; | |
} | |
if (!/loaded|complete/.test(aL.readyState)) { | |
setTimeout(arguments.callee, 0); | |
return; | |
} | |
aP(); | |
})(); | |
} | |
aC(aP); | |
} | |
}(); | |
function aP() { | |
if (ak) { | |
return; | |
} | |
try { | |
var b = aL.getElementsByTagName("body")[0].appendChild(ar("span")); | |
b.parentNode.removeChild(b); | |
} catch (a) { | |
return; | |
} | |
ak = true; | |
var d = Z.length; | |
for (var c = 0; c < d; c++) { | |
Z[c](); | |
} | |
} | |
function aj(a) { | |
if (ak) { | |
a(); | |
} else { | |
Z[Z.length] = a; | |
} | |
} | |
function aC(a) { | |
if (typeof af.addEventListener != aq) { | |
af.addEventListener("load", a, false); | |
} else { | |
if (typeof aL.addEventListener != aq) { | |
aL.addEventListener("load", a, false); | |
} else { | |
if (typeof af.attachEvent != aq) { | |
aM(af, "onload", a); | |
} else { | |
if (typeof af.onload == "function") { | |
var b = af.onload; | |
af.onload = function () { | |
b(); | |
a(); | |
}; | |
} else { | |
af.onload = a; | |
} | |
} | |
} | |
} | |
} | |
function aN() { | |
if (aa) { | |
Y(); | |
} else { | |
am(); | |
} | |
} | |
function Y() { | |
var d = aL.getElementsByTagName("body")[0]; | |
var b = ar(aD); | |
b.setAttribute("type", aE); | |
var a = d.appendChild(b); | |
if (a) { | |
var c = 0; | |
(function () { | |
if (typeof a.GetVariable != aq) { | |
var e = a.GetVariable("$version"); | |
if (e) { | |
e = e.split(" ")[1].split(","); | |
ah.pv = [parseInt(e[0], 10), parseInt(e[1], 10), parseInt(e[2], 10)]; | |
} | |
} else { | |
if (c < 10) { | |
c++; | |
setTimeout(arguments.callee, 10); | |
return; | |
} | |
} | |
d.removeChild(b); | |
a = null; | |
am(); | |
})(); | |
} else { | |
am(); | |
} | |
} | |
function am() { | |
var g = aG.length; | |
if (g > 0) { | |
for (var h = 0; h < g; h++) { | |
var c = aG[h].id; | |
var l = aG[h].callbackFn; | |
var a = { | |
success: false, | |
id: c | |
}; | |
if (ah.pv[0] > 0) { | |
var i = aS(c); | |
if (i) { | |
if (ao(aG[h].swfVersion) && !(ah.wk && ah.wk < 312)) { | |
ay(c, true); | |
if (l) { | |
a.success = true; | |
a.ref = av(c); | |
l(a); | |
} | |
} else { | |
if (aG[h].expressInstall && au()) { | |
var e = {}; | |
e.data = aG[h].expressInstall; | |
e.width = i.getAttribute("width") || "0"; | |
e.height = i.getAttribute("height") || "0"; | |
if (i.getAttribute("class")) { | |
e.styleclass = i.getAttribute("class"); | |
} | |
if (i.getAttribute("align")) { | |
e.align = i.getAttribute("align"); | |
} | |
var f = {}; | |
var d = i.getElementsByTagName("param"); | |
var k = d.length; | |
for (var j = 0; j < k; j++) { | |
if (d[j].getAttribute("name").toLowerCase() != "movie") { | |
f[d[j].getAttribute("name")] = d[j].getAttribute("value"); | |
} | |
} | |
ae(e, f, c, l); | |
} else { | |
aF(i); | |
if (l) { | |
l(a); | |
} | |
} | |
} | |
} | |
} else { | |
ay(c, true); | |
if (l) { | |
var b = av(c); | |
if (b && typeof b.SetVariable != aq) { | |
a.success = true; | |
a.ref = b; | |
} | |
l(a); | |
} | |
} | |
} | |
} | |
} | |
function av(b) { | |
var d = null; | |
var c = aS(b); | |
if (c && c.nodeName == "OBJECT") { | |
if (typeof c.SetVariable != aq) { | |
d = c; | |
} else { | |
var a = c.getElementsByTagName(aD)[0]; | |
if (a) { | |
d = a; | |
} | |
} | |
} | |
return d; | |
} | |
function au() { | |
return !aU && ao("6.0.65") && (ah.win || ah.mac) && !(ah.wk && ah.wk < 312); | |
} | |
function ae(f, d, h, e) { | |
aU = true; | |
ap = e || null; | |
at = { | |
success: false, | |
id: h | |
}; | |
var a = aS(h); | |
if (a) { | |
if (a.nodeName == "OBJECT") { | |
aJ = aO(a); | |
ad = null; | |
} else { | |
aJ = a; | |
ad = h; | |
} | |
f.id = ac; | |
if (typeof f.width == aq || (!/%$/.test(f.width) && parseInt(f.width, 10) < 310)) { | |
f.width = "310"; | |
} | |
if (typeof f.height == aq || (!/%$/.test(f.height) && parseInt(f.height, 10) < 137)) { | |
f.height = "137"; | |
} | |
aL.title = aL.title.slice(0, 47) + " - Flash Player Installation"; | |
var b = ah.ie && ah.win ? "ActiveX" : "PlugIn", | |
c = "MMredirectURL=" + af.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + b + "&MMdoctitle=" + aL.title; | |
if (typeof d.flashvars != aq) { | |
d.flashvars += "&" + c; | |
} else { | |
d.flashvars = c; | |
} | |
if (ah.ie && ah.win && a.readyState != 4) { | |
var g = ar("div"); | |
h += "SWFObjectNew"; | |
g.setAttribute("id", h); | |
a.parentNode.insertBefore(g, a); | |
a.style.display = "none"; | |
(function () { | |
if (a.readyState == 4) { | |
a.parentNode.removeChild(a); | |
} else { | |
setTimeout(arguments.callee, 10); | |
} | |
})(); | |
} | |
aA(f, d, h); | |
} | |
} | |
function aF(a) { | |
if (ah.ie && ah.win && a.readyState != 4) { | |
var b = ar("div"); | |
a.parentNode.insertBefore(b, a); | |
b.parentNode.replaceChild(aO(a), b); | |
a.style.display = "none"; | |
(function () { | |
if (a.readyState == 4) { | |
a.parentNode.removeChild(a); | |
} else { | |
setTimeout(arguments.callee, 10); | |
} | |
})(); | |
} else { | |
a.parentNode.replaceChild(aO(a), a); | |
} | |
} | |
function aO(b) { | |
var d = ar("div"); | |
if (ah.win && ah.ie) { | |
d.innerHTML = b.innerHTML; | |
} else { | |
var e = b.getElementsByTagName(aD)[0]; | |
if (e) { | |
var a = e.childNodes; | |
if (a) { | |
var f = a.length; | |
for (var c = 0; c < f; c++) { | |
if (!(a[c].nodeType == 1 && a[c].nodeName == "PARAM") && !(a[c].nodeType == 8)) { | |
d.appendChild(a[c].cloneNode(true)); | |
} | |
} | |
} | |
} | |
} | |
return d; | |
} | |
function aA(e, g, c) { | |
var d, a = aS(c); | |
if (ah.wk && ah.wk < 312) { | |
return d; | |
} | |
if (a) { | |
if (typeof e.id == aq) { | |
e.id = c; | |
} | |
if (ah.ie && ah.win) { | |
var f = ""; | |
for (var i in e) { | |
if (e[i] != Object.prototype[i]) { | |
if (i.toLowerCase() == "data") { | |
g.movie = e[i]; | |
} else { | |
if (i.toLowerCase() == "styleclass") { | |
f += ' class="' + e[i] + '"'; | |
} else { | |
if (i.toLowerCase() != "classid") { | |
f += " " + i + '="' + e[i] + '"'; | |
} | |
} | |
} | |
} | |
} | |
var h = ""; | |
for (var j in g) { | |
if (g[j] != Object.prototype[j]) { | |
h += '<param name="' + j + '" value="' + g[j] + '" />'; | |
} | |
} | |
a.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + f + ">" + h + "</object>"; | |
ag[ag.length] = e.id; | |
d = aS(e.id); | |
} else { | |
var b = ar(aD); | |
b.setAttribute("type", aE); | |
for (var k in e) { | |
if (e[k] != Object.prototype[k]) { | |
if (k.toLowerCase() == "styleclass") { | |
b.setAttribute("class", e[k]); | |
} else { | |
if (k.toLowerCase() != "classid") { | |
b.setAttribute(k, e[k]); | |
} | |
} | |
} | |
} | |
for (var l in g) { | |
if (g[l] != Object.prototype[l] && l.toLowerCase() != "movie") { | |
aQ(b, l, g[l]); | |
} | |
} | |
a.parentNode.replaceChild(b, a); | |
d = b; | |
} | |
} | |
return d; | |
} | |
function aQ(b, d, c) { | |
var a = ar("param"); | |
a.setAttribute("name", d); | |
a.setAttribute("value", c); | |
b.appendChild(a); | |
} | |
function aw(a) { | |
var b = aS(a); | |
if (b && b.nodeName == "OBJECT") { | |
if (ah.ie && ah.win) { | |
b.style.display = "none"; | |
(function () { | |
if (b.readyState == 4) { | |
aT(a); | |
} else { | |
setTimeout(arguments.callee, 10); | |
} | |
})(); | |
} else { | |
b.parentNode.removeChild(b); | |
} | |
} | |
} | |
function aT(a) { | |
var b = aS(a); | |
if (b) { | |
for (var c in b) { | |
if (typeof b[c] == "function") { | |
b[c] = null; | |
} | |
} | |
b.parentNode.removeChild(b); | |
} | |
} | |
function aS(a) { | |
var c = null; | |
try { | |
c = aL.getElementById(a); | |
} catch (b) {} | |
return c; | |
} | |
function ar(a) { | |
return aL.createElement(a); | |
} | |
function aM(a, c, b) { | |
a.attachEvent(c, b); | |
al[al.length] = [a, c, b]; | |
} | |
function ao(a) { | |
var b = ah.pv, | |
c = a.split("."); | |
c[0] = parseInt(c[0], 10); | |
c[1] = parseInt(c[1], 10) || 0; | |
c[2] = parseInt(c[2], 10) || 0; | |
return (b[0] > c[0] || (b[0] == c[0] && b[1] > c[1]) || (b[0] == c[0] && b[1] == c[1] && b[2] >= c[2])) ? true : false; | |
} | |
function az(b, f, a, c) { | |
if (ah.ie && ah.mac) { | |
return; | |
} | |
var e = aL.getElementsByTagName("head")[0]; | |
if (!e) { | |
return; | |
} | |
var g = (a && typeof a == "string") ? a : "screen"; | |
if (c) { | |
aH = null; | |
an = null; | |
} | |
if (!aH || an != g) { | |
var d = ar("style"); | |
d.setAttribute("type", "text/css"); | |
d.setAttribute("media", g); | |
aH = e.appendChild(d); | |
if (ah.ie && ah.win && typeof aL.styleSheets != aq && aL.styleSheets.length > 0) { | |
aH = aL.styleSheets[aL.styleSheets.length - 1]; | |
} | |
an = g; | |
} | |
if (ah.ie && ah.win) { | |
if (aH && typeof aH.addRule == aD) { | |
aH.addRule(b, f); | |
} | |
} else { | |
if (aH && typeof aL.createTextNode != aq) { | |
aH.appendChild(aL.createTextNode(b + " {" + f + "}")); | |
} | |
} | |
} | |
function ay(a, c) { | |
if (!aI) { | |
return; | |
} | |
var b = c ? "visible" : "hidden"; | |
if (ak && aS(a)) { | |
aS(a).style.visibility = b; | |
} else { | |
az("#" + a, "visibility:" + b); | |
} | |
} | |
function ai(b) { | |
var a = /[\\\"<>\.;]/; | |
var c = a.exec(b) != null; | |
return c && typeof encodeURIComponent != aq ? encodeURIComponent(b) : b; | |
} | |
var aR = function () { | |
if (ah.ie && ah.win) { | |
window.attachEvent("onunload", function () { | |
var a = al.length; | |
for (var b = 0; b < a; b++) { | |
al[b][0].detachEvent(al[b][1], al[b][2]); | |
} | |
var d = ag.length; | |
for (var c = 0; c < d; c++) { | |
aw(ag[c]); | |
} | |
for (var e in ah) { | |
ah[e] = null; | |
} | |
ah = null; | |
for (var f in swfobject) { | |
swfobject[f] = null; | |
} | |
swfobject = null; | |
}); | |
} | |
}(); | |
return { | |
registerObject: function (a, e, c, b) { | |
if (ah.w3 && a && e) { | |
var d = {}; | |
d.id = a; | |
d.swfVersion = e; | |
d.expressInstall = c; | |
d.callbackFn = b; | |
aG[aG.length] = d; | |
ay(a, false); | |
} else { | |
if (b) { | |
b({ | |
success: false, | |
id: a | |
}); | |
} | |
} | |
}, | |
getObjectById: function (a) { | |
if (ah.w3) { | |
return av(a); | |
} | |
}, | |
embedSWF: function (k, e, h, f, c, a, b, i, g, j) { | |
var d = { | |
success: false, | |
id: e | |
}; | |
if (ah.w3 && !(ah.wk && ah.wk < 312) && k && e && h && f && c) { | |
ay(e, false); | |
aj(function () { | |
h += ""; | |
f += ""; | |
var q = {}; | |
if (g && typeof g === aD) { | |
for (var o in g) { | |
q[o] = g[o]; | |
} | |
} | |
q.data = k; | |
q.width = h; | |
q.height = f; | |
var n = {}; | |
if (i && typeof i === aD) { | |
for (var p in i) { | |
n[p] = i[p]; | |
} | |
} | |
if (b && typeof b === aD) { | |
for (var l in b) { | |
if (typeof n.flashvars != aq) { | |
n.flashvars += "&" + l + "=" + b[l]; | |
} else { | |
n.flashvars = l + "=" + b[l]; | |
} | |
} | |
} | |
if (ao(c)) { | |
var m = aA(q, n, e); | |
if (q.id == e) { | |
ay(e, true); | |
} | |
d.success = true; | |
d.ref = m; | |
} else { | |
if (a && au()) { | |
q.data = a; | |
ae(q, n, e, j); | |
return; | |
} else { | |
ay(e, true); | |
} | |
} | |
if (j) { | |
j(d); | |
} | |
}); | |
} else { | |
if (j) { | |
j(d); | |
} | |
} | |
}, | |
switchOffAutoHideShow: function () { | |
aI = false; | |
}, | |
ua: ah, | |
getFlashPlayerVersion: function () { | |
return { | |
major: ah.pv[0], | |
minor: ah.pv[1], | |
release: ah.pv[2] | |
}; | |
}, | |
hasFlashPlayerVersion: ao, | |
createSWF: function (a, b, c) { | |
if (ah.w3) { | |
return aA(a, b, c); | |
} else { | |
return undefined; | |
} | |
}, | |
showExpressInstall: function (b, a, d, c) { | |
if (ah.w3 && au()) { | |
ae(b, a, d, c); | |
} | |
}, | |
removeSWF: function (a) { | |
if (ah.w3) { | |
aw(a); | |
} | |
}, | |
createCSS: function (b, a, c, d) { | |
if (ah.w3) { | |
az(b, a, c, d); | |
} | |
}, | |
addDomLoadEvent: aj, | |
addLoadEvent: aC, | |
getQueryParamValue: function (b) { | |
var a = aL.location.search || aL.location.hash; | |
if (a) { | |
if (/\?/.test(a)) { | |
a = a.split("?")[1]; | |
} | |
if (b == null) { | |
return ai(a); | |
} | |
var c = a.split("&"); | |
for (var d = 0; d < c.length; d++) { | |
if (c[d].substring(0, c[d].indexOf("=")) == b) { | |
return ai(c[d].substring((c[d].indexOf("=") + 1))); | |
} | |
} | |
} | |
return ""; | |
}, | |
expressInstallCallback: function () { | |
if (aU) { | |
var a = aS(ac); | |
if (a && aJ) { | |
a.parentNode.replaceChild(aJ, a); | |
if (ad) { | |
ay(ad, true); | |
if (ah.ie && ah.win) { | |
aJ.style.display = "block"; | |
} | |
} | |
if (ap) { | |
ap(at); | |
} | |
} | |
aU = false; | |
} | |
} | |
}; | |
}(); | |
(function () { | |
if (window.WebSocket) { | |
return; | |
} | |
var a = window.console; | |
if (!a || !a.log || !a.error) { | |
a = { | |
log: function () {}, | |
error: function () {} | |
}; | |
} | |
if (!swfobject.hasFlashPlayerVersion("10.0.0")) { | |
a.error("Flash Player >= 10.0.0 is required."); | |
return; | |
} | |
if (location.protocol == "file:") { | |
a.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."); | |
} | |
WebSocket = function (e, h, d, g, f) { | |
var c = this; | |
c.__id = WebSocket.__nextId++; | |
WebSocket.__instances[c.__id] = c; | |
c.readyState = WebSocket.CONNECTING; | |
c.bufferedAmount = 0; | |
setTimeout(function () { | |
WebSocket.__addTask(function () { | |
WebSocket.__flash.create(c.__id, e, h, d || null, g || 0, f || null); | |
}); | |
}, 0); | |
}; | |
WebSocket.prototype.send = function (d) { | |
if (this.readyState == WebSocket.CONNECTING) { | |
throw "INVALID_STATE_ERR: Web Socket connection has not been established"; | |
} | |
var c = WebSocket.__flash.send(this.__id, encodeURIComponent(d)); | |
if (c < 0) { | |
return true; | |
} else { | |
this.bufferedAmount += c; | |
return false; | |
} | |
}; | |
WebSocket.prototype.close = function () { | |
if (this.readyState == WebSocket.CLOSED || this.readyState == WebSocket.CLOSING) { | |
return; | |
} | |
this.readyState = WebSocket.CLOSING; | |
WebSocket.__flash.close(this.__id); | |
}; | |
WebSocket.prototype.addEventListener = function (d, e, c) { | |
if (!("__events" in this)) { | |
this.__events = {}; | |
} | |
if (!(d in this.__events)) { | |
this.__events[d] = []; | |
if ("function" == typeof this["on" + d]) { | |
this.__events[d].defaultHandler = this["on" + d]; | |
this["on" + d] = this.__createEventHandler(this, d); | |
} | |
} | |
this.__events[d].push(e); | |
}; | |
WebSocket.prototype.removeEventListener = function (e, f, c) { | |
if (!("__events" in this)) { | |
this.__events = {}; | |
} | |
if (!(e in this.__events)) { | |
return; | |
} | |
for (var d = this.__events.length; d > -1; --d) { | |
if (f === this.__events[e][d]) { | |
this.__events[e].splice(d, 1); | |
break; | |
} | |
} | |
}; | |
WebSocket.prototype.dispatchEvent = function (e) { | |
if (!("__events" in this)) { | |
throw "UNSPECIFIED_EVENT_TYPE_ERR"; | |
} | |
if (!(e.type in this.__events)) { | |
throw "UNSPECIFIED_EVENT_TYPE_ERR"; | |
} | |
for (var d = 0, c = this.__events[e.type].length; d < c; ++d) { | |
this.__events[e.type][d](e); | |
if (e.cancelBubble) { | |
break; | |
} | |
} | |
if (false !== e.returnValue && "function" == typeof this.__events[e.type].defaultHandler) { | |
this.__events[e.type].defaultHandler(e); | |
} | |
}; | |
WebSocket.prototype.__handleEvent = function (c) { | |
if ("readyState" in c) { | |
this.readyState = c.readyState; | |
} | |
try { | |
if (c.type == "open") { | |
this.onopen && this.onopen(); | |
} else { | |
if (c.type == "close") { | |
this.onclose && this.onclose(); | |
} else { | |
if (c.type == "error") { | |
this.onerror && this.onerror(c); | |
} else { | |
if (c.type == "message") { | |
if (this.onmessage) { | |
var d = decodeURIComponent(c.message); | |
var f; | |
if (window.MessageEvent && !window.opera) { | |
f = document.createEvent("MessageEvent"); | |
f.initMessageEvent("message", false, false, d, null, null, window, null); | |
} else { | |
f = { | |
data: d | |
}; | |
} | |
this.onmessage(f); | |
} | |
} else { | |
throw "unknown event type: " + c.type; | |
} | |
} | |
} | |
} | |
} catch (f) { | |
a.error(f.toString()); | |
} | |
}; | |
WebSocket.prototype.__createEventHandler = function (c, d) { | |
return function (g) { | |
var f = new b(); | |
f.initEvent(d, true, true); | |
f.target = f.currentTarget = c; | |
for (var e in g) { | |
f[e] = g[e]; | |
} | |
c.dispatchEvent(f, arguments); | |
}; | |
}; | |
WebSocket.CONNECTING = 0; | |
WebSocket.OPEN = 1; | |
WebSocket.CLOSING = 2; | |
WebSocket.CLOSED = 3; | |
WebSocket.__flash = null; | |
WebSocket.__instances = {}; | |
WebSocket.__tasks = []; | |
WebSocket.__nextId = 0; | |
WebSocket.__initialize = function () { | |
if (WebSocket.__flash) { | |
return; | |
} | |
if (WebSocket.__swfLocation) { | |
window.WEB_SOCKET_SWF_LOCATION = WebSocket.__swfLocation; | |
} | |
if (!window.WEB_SOCKET_SWF_LOCATION) { | |
a.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf"); | |
return; | |
} | |
var c = document.createElement("div"); | |
c.id = "webSocketContainer"; | |
c.style.position = "absolute"; | |
if (WebSocket.__isFlashLite()) { | |
c.style.left = "0px"; | |
c.style.top = "0px"; | |
} else { | |
c.style.left = "-100px"; | |
c.style.top = "-100px"; | |
} | |
var d = document.createElement("div"); | |
d.id = "webSocketFlash"; | |
c.appendChild(d); | |
document.body.appendChild(c); | |
swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION, "webSocketFlash", "1", "1", "10.0.0", null, null, { | |
hasPriority: true, | |
swliveconnect: true, | |
allowScriptAccess: "always" | |
}, null, function (f) { | |
if (!f.success) { | |
a.error("[WebSocket] swfobject.embedSWF failed"); | |
} | |
}); | |
}; | |
WebSocket.loadFlashPolicyFile = function (c) { | |
WebSocket.__addTask(function () { | |
WebSocket.__flash.loadManualPolicyFile(c); | |
}); | |
}; | |
WebSocket.__onFlashInitialized = function () { | |
setTimeout(function () { | |
WebSocket.__flash = document.getElementById("webSocketFlash"); | |
WebSocket.__flash.setCallerUrl(location.href); | |
WebSocket.__flash.setDebug( !! window.WEB_SOCKET_DEBUG); | |
for (var c = 0; c < WebSocket.__tasks.length; ++c) { | |
WebSocket.__tasks[c](); | |
} | |
WebSocket.__tasks = []; | |
}, 0); | |
}; | |
WebSocket.__onFlashEvent = function () { | |
setTimeout(function () { | |
var d = WebSocket.__flash.receiveEvents(); | |
for (var c = 0; c < d.length; ++c) { | |
WebSocket.__instances[d[c].webSocketId].__handleEvent(d[c]); | |
} | |
}, 0); | |
return true; | |
}; | |
WebSocket.__log = function (c) { | |
a.log(decodeURIComponent(c)); | |
}; | |
WebSocket.__error = function (c) { | |
a.error(decodeURIComponent(c)); | |
}; | |
WebSocket.__addTask = function (c) { | |
if (WebSocket.__flash) { | |
c(); | |
} else { | |
WebSocket.__tasks.push(c); | |
} | |
}; | |
WebSocket.__isFlashLite = function () { | |
if (!window.navigator || !window.navigator.mimeTypes) { | |
return false; | |
} | |
var c = window.navigator.mimeTypes["application/x-shockwave-flash"]; | |
if (!c || !c.enabledPlugin || !c.enabledPlugin.filename) { | |
return false; | |
} | |
return c.enabledPlugin.filename.match(/flashlite/i) ? true : false; | |
}; | |
function b() {} | |
b.prototype.cancelable = true; | |
b.prototype.cancelBubble = false; | |
b.prototype.preventDefault = function () { | |
if (this.cancelable) { | |
this.returnValue = false; | |
} | |
}; | |
b.prototype.stopPropagation = function () { | |
this.cancelBubble = true; | |
}; | |
b.prototype.initEvent = function (c, e, d) { | |
this.type = c; | |
this.cancelable = d; | |
this.timeStamp = new Date(); | |
}; | |
if (!window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION) { | |
if (window.addEventListener) { | |
window.addEventListener("load", function () { | |
WebSocket.__initialize(); | |
}, false); | |
} else { | |
window.attachEvent("onload", function () { | |
WebSocket.__initialize(); | |
}); | |
} | |
} | |
})(); | |
(function (c) { | |
var b = null; | |
function a(aC, O) { | |
this.flashVersion = 8; | |
this.debugMode = true; | |
this.debugFlash = false; | |
this.useConsole = true; | |
this.consoleOnly = false; | |
this.waitForWindowLoad = false; | |
this.nullURL = "about:blank"; | |
this.allowPolling = true; | |
this.useFastPolling = false; | |
this.useMovieStar = true; | |
this.bgColor = "#ffffff"; | |
this.useHighPerformance = false; | |
this.flashPollingInterval = null; | |
this.flashLoadTimeout = 1000; | |
this.wmode = null; | |
this.allowScriptAccess = "always"; | |
this.useFlashBlock = false; | |
this.useHTML5Audio = false; | |
this.html5Test = /^probably$/i; | |
this.useGlobalHTML5Audio = true; | |
this.requireFlash = false; | |
this.audioFormats = { | |
mp3: { | |
type: ['audio/mpeg; codecs="mp3"', "audio/mpeg", "audio/mp3", "audio/MPA", "audio/mpa-robust"], | |
required: true | |
}, | |
mp4: { | |
related: ["aac", "m4a"], | |
type: ['audio/mp4; codecs="mp4a.40.2"', "audio/aac", "audio/x-m4a", "audio/MP4A-LATM", "audio/mpeg4-generic"], | |
required: true | |
}, | |
ogg: { | |
type: ["audio/ogg; codecs=vorbis"], | |
required: false | |
}, | |
wav: { | |
type: ['audio/wav; codecs="1"', "audio/wav", "audio/wave", "audio/x-wav"], | |
required: false | |
} | |
}; | |
this.defaultOptions = { | |
autoLoad: false, | |
stream: true, | |
autoPlay: false, | |
loops: 1, | |
onid3: null, | |
onload: null, | |
whileloading: null, | |
onplay: null, | |
onpause: null, | |
onresume: null, | |
whileplaying: null, | |
onstop: null, | |
onfailure: null, | |
onfinish: null, | |
onbeforefinish: null, | |
onbeforefinishtime: 5000, | |
onbeforefinishcomplete: null, | |
onjustbeforefinish: null, | |
onjustbeforefinishtime: 200, | |
multiShot: true, | |
multiShotEvents: false, | |
position: null, | |
pan: 0, | |
type: null, | |
usePolicyFile: false, | |
volume: 100 | |
}; | |
this.flash9Options = { | |
isMovieStar: null, | |
usePeakData: false, | |
useWaveformData: false, | |
useEQData: false, | |
onbufferchange: null, | |
ondataerror: null | |
}; | |
this.movieStarOptions = { | |
bufferTime: 3, | |
serverURL: null, | |
onconnect: null, | |
duration: null | |
}; | |
this.version = null; | |
this.versionNumber = "V2.97a.20110424"; | |
this.movieURL = null; | |
this.url = (aC || null); | |
this.altURL = null; | |
this.swfLoaded = false; | |
this.enabled = false; | |
this.o = null; | |
this.movieID = "sm2-container"; | |
this.id = (O || "sm2movie"); | |
this.swfCSS = { | |
swfBox: "sm2-object-box", | |
swfDefault: "movieContainer", | |
swfError: "swf_error", | |
swfTimedout: "swf_timedout", | |
swfLoaded: "swf_loaded", | |
swfUnblocked: "swf_unblocked", | |
sm2Debug: "sm2_debug", | |
highPerf: "high_performance", | |
flashDebug: "flash_debug" | |
}; | |
this.oMC = null; | |
this.sounds = {}; | |
this.soundIDs = []; | |
this.muted = false; | |
this.debugID = "soundmanager-debug"; | |
this.debugURLParam = /([#?&])debug=1/i; | |
this.specialWmodeCase = false; | |
this.didFlashBlock = false; | |
this.filePattern = null; | |
this.filePatterns = { | |
flash8: /\.mp3(\?.*)?$/i, | |
flash9: /\.mp3(\?.*)?$/i | |
}; | |
this.baseMimeTypes = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; | |
this.netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; | |
this.netStreamTypes = ["aac", "flv", "mov", "mp4", "m4v", "f4v", "m4a", "mp4v", "3gp", "3g2"]; | |
this.netStreamPattern = new RegExp("\\.(" + this.netStreamTypes.join("|") + ")(\\?.*)?$", "i"); | |
this.mimePattern = this.baseMimeTypes; | |
this.features = { | |
buffering: false, | |
peakData: false, | |
waveformData: false, | |
eqData: false, | |
movieStar: false | |
}; | |
this.sandbox = { | |
type: null, | |
types: { | |
remote: "remote (domain-based) rules", | |
localWithFile: "local with file access (no internet access)", | |
localWithNetwork: "local with network (internet access only, no local access)", | |
localTrusted: "local, trusted (local+internet access)" | |
}, | |
description: null, | |
noRemote: null, | |
noLocal: null | |
}; | |
this.hasHTML5 = null; | |
this.html5 = { | |
usingFlash: null | |
}; | |
this.ignoreFlash = false; | |
var R, aR = this, | |
aA = "soundManager", | |
ao = aA + "::", | |
aF = "HTML5::", | |
W, aa = navigator.userAgent, | |
k = c, | |
l = k.location.href.toString(), | |
e = this.flashVersion, | |
aD = document, | |
ac, aw, aj = [], | |
m = true, | |
af, at = false, | |
aK = false, | |
aI = false, | |
F = false, | |
u = false, | |
z, aG = 0, | |
T, ai, aL, aP, ap, au, ah, t, J, aB, S, L, s, aM, ax, an, aH, ay, ak, V = ["log", "info", "warn", "error"], | |
N = 8, | |
U, am, h, o = null, | |
aq = null, | |
X, i, I, x, Z, w, d, ad, aS = false, | |
C = false, | |
y, q, v, Q, ag = null, | |
ae, A, aQ = false, | |
av, p, P, aO, r, j = Array.prototype.slice, | |
aJ = false, | |
g, aN, Y, ar = aa.match(/pre\//i), | |
D = aa.match(/(ipad|iphone|ipod)/i), | |
K = (aa.match(/mobile/i) || ar || D), | |
f = aa.match(/msie/i), | |
n = aa.match(/webkit/i), | |
B = (aa.match(/safari/i) && !aa.match(/chrome/i)), | |
H = (aa.match(/opera/i)), | |
al = (!l.match(/usehtml5audio/i) && !l.match(/sm2\-ignorebadua/i) && B && aa.match(/OS X 10_6_([3-9])/i)), | |
az = (typeof console !== "undefined" && typeof console.log !== "undefined"), | |
aE = (typeof aD.hasFocus !== "undefined" ? aD.hasFocus() : null), | |
ab = (typeof aD.hasFocus === "undefined" && B), | |
G = !ab; | |
this._use_maybe = (l.match(/sm2\-useHTML5Maybe\=1/i)); | |
this._overHTTP = (aD.location ? aD.location.protocol.match(/http/i) : null); | |
this._http = (!this._overHTTP ? "http:" : ""); | |
this.useAltURL = !this._overHTTP; | |
this._global_a = null; | |
if (D || ar) { | |
aR.useHTML5Audio = true; | |
aR.ignoreFlash = true; | |
if (aR.useGlobalHTML5Audio) { | |
aJ = true; | |
} | |
} | |
if (ar || this._use_maybe) { | |
aR.html5Test = /^(probably|maybe)$/i; | |
}(function () { | |
var aV = "#sm2-usehtml5audio=", | |
aU = l, | |
aT = null; | |
if (aU.indexOf(aV) !== -1) { | |
aT = (aU.charAt(aU.indexOf(aV) + aV.length) === "1"); | |
if (typeof console !== "undefined" && typeof console.log !== "undefined") { | |
console.log((aT ? "Enabling " : "Disabling ") + "useHTML5Audio via URL parameter"); | |
} | |
aR.useHTML5Audio = aT; | |
} | |
}()); | |
this.ok = function () { | |
return (ag ? (aI && !F) : (aR.useHTML5Audio && aR.hasHTML5)); | |
}; | |
this.supported = this.ok; | |
this.getMovie = function (aT) { | |
return f ? k[aT] : (B ? W(aT) || aD[aT] : W(aT)); | |
}; | |
this.createSound = function (aV) { | |
var aY = aA + ".createSound(): ", | |
aX = null, | |
aW = null, | |
aU = null; | |
if (!aI || !aR.ok()) { | |
d(aY + X(!aI ? "notReady" : "notOK")); | |
return false; | |
} | |
if (arguments.length === 2) { | |
aV = { | |
id: arguments[0], | |
url: arguments[1] | |
}; | |
} | |
aX = ai(aV); | |
aU = aX; | |
if (aU.id.toString().charAt(0).match(/^[0-9]$/)) { | |
aR._wD(aY + X("badID", aU.id), 2); | |
} | |
aR._wD(aY + aU.id + " (" + aU.url + ")", 1); | |
if (ad(aU.id, true)) { | |
aR._wD(aY + aU.id + " exists", 1); | |
return aR.sounds[aU.id]; | |
} | |
function aT() { | |
aX = Z(aX); | |
aR.sounds[aU.id] = new R(aU); | |
aR.soundIDs.push(aU.id); | |
return aR.sounds[aU.id]; | |
} | |
if (A(aU)) { | |
aW = aT(); | |
aR._wD("Loading sound " + aU.id + " via HTML5"); | |
aW._setup_html5(aU); | |
} else { | |
if (e > 8 && aR.useMovieStar) { | |
if (aU.isMovieStar === null) { | |
aU.isMovieStar = ((aU.serverURL || (aU.type ? aU.type.match(aR.netStreamPattern) : false) || aU.url.match(aR.netStreamPattern)) ? true : false); | |
} | |
if (aU.isMovieStar) { | |
aR._wD(aY + "using MovieStar handling"); | |
} | |
if (aU.isMovieStar) { | |
if (aU.usePeakData) { | |
z("noPeak"); | |
aU.usePeakData = false; | |
} | |
if (aU.loops > 1) { | |
z("noNSLoop"); | |
} | |
} | |
} | |
aU = w(aU, aY); | |
aW = aT(); | |
if (e === 8) { | |
aR.o._createSound(aU.id, aU.onjustbeforefinishtime, aU.loops || 1, aU.usePolicyFile); | |
} else { | |
aR.o._createSound(aU.id, aU.url, aU.onjustbeforefinishtime, aU.usePeakData, aU.useWaveformData, aU.useEQData, aU.isMovieStar, (aU.isMovieStar ? aU.bufferTime : false), aU.loops || 1, aU.serverURL, aU.duration || null, aU.autoPlay, true, aU.autoLoad, aU.usePolicyFile); | |
if (!aU.serverURL) { | |
aW.connected = true; | |
if (aU.onconnect) { | |
aU.onconnect.apply(aW); | |
} | |
} | |
} | |
if ((aU.autoLoad || aU.autoPlay) && !aU.serverURL) { | |
aW.load(aU); | |
} | |
} | |
if (aU.autoPlay && !aU.serverURL) { | |
aW.play(); | |
} | |
return aW; | |
}; | |
this.destroySound = function (aT, aW) { | |
if (!ad(aT)) { | |
return false; | |
} | |
var aV = aR.sounds[aT], | |
aU; | |
aV._iO = {}; | |
aV.stop(); | |
aV.unload(); | |
for (aU = 0; aU < aR.soundIDs.length; aU++) { | |
if (aR.soundIDs[aU] === aT) { | |
aR.soundIDs.splice(aU, 1); | |
break; | |
} | |
} | |
if (!aW) { | |
aV.destruct(true); | |
} | |
aV = null; | |
delete aR.sounds[aT]; | |
return true; | |
}; | |
this.load = function (aT, aU) { | |
if (!ad(aT)) { | |
return false; | |
} | |
return aR.sounds[aT].load(aU); | |
}; | |
this.unload = function (aT) { | |
if (!ad(aT)) { | |
return false; | |
} | |
return aR.sounds[aT].unload(); | |
}; | |
this.play = function (aT, aU) { | |
var aV = aA + ".play(): "; | |
if (!aI || !aR.ok()) { | |
d(aV + X(!aI ? "notReady" : "notOK")); | |
return false; | |
} | |
if (!ad(aT)) { | |
if (!(aU instanceof Object)) { | |
aU = { | |
url: aU | |
}; | |
} | |
if (aU && aU.url) { | |
aR._wD(aV + 'attempting to create "' + aT + '"', 1); | |
aU.id = aT; | |
return aR.createSound(aU).play(); | |
} else { | |
return false; | |
} | |
} | |
return aR.sounds[aT].play(aU); | |
}; | |
this.start = this.play; | |
this.setPosition = function (aT, aU) { | |
if (!ad(aT)) { | |
return false; | |
} | |
return aR.sounds[aT].setPosition(aU); | |
}; | |
this.stop = function (aT) { | |
if (!ad(aT)) { | |
return false; | |
} | |
aR._wD(aA + ".stop(" + aT + ")", 1); | |
return aR.sounds[aT].stop(); | |
}; | |
this.stopAll = function () { | |
aR._wD(aA + ".stopAll()", 1); | |
for (var aT in aR.sounds) { | |
if (aR.sounds[aT] instanceof R) { | |
aR.sounds[aT].stop(); | |
} | |
} | |
}; | |
this.pause = function (aT) { | |
if (!ad(aT)) { | |
return false; | |
} | |
return aR.sounds[aT].pause(); | |
}; | |
this.pauseAll = function () { | |
for (var aT = aR.soundIDs.length; aT--;) { | |
aR.sounds[aR.soundIDs[aT]].pause(); | |
} | |
}; | |
this.resume = function (aT) { | |
if (!ad(aT)) { | |
return false; | |
} | |
return aR.sounds[aT].resume(); | |
}; | |
this.resumeAll = function () { | |
for (var aT = aR.soundIDs.length; aT--;) { | |
aR.sounds[aR.soundIDs[aT]].resume(); | |
} | |
}; | |
this.togglePause = function (aT) { | |
if (!ad(aT)) { | |
return false; | |
} | |
return aR.sounds[aT].togglePause(); | |
}; | |
this.setPan = function (aT, aU) { | |
if (!ad(aT)) { | |
return false; | |
} | |
return aR.sounds[aT].setPan(aU); | |
}; | |
this.setVolume = function (aU, aT) { | |
if (!ad(aU)) { | |
return false; | |
} | |
return aR.sounds[aU].setVolume(aT); | |
}; | |
this.mute = function (aT) { | |
var aV = aA + ".mute(): ", | |
aU = 0; | |
if (typeof aT !== "string") { | |
aT = null; | |
} | |
if (!aT) { | |
aR._wD(aV + "Muting all sounds"); | |
for (aU = aR.soundIDs.length; aU--;) { | |
aR.sounds[aR.soundIDs[aU]].mute(); | |
} | |
aR.muted = true; | |
} else { | |
if (!ad(aT)) { | |
return false; | |
} | |
aR._wD(aV + 'Muting "' + aT + '"'); | |
return aR.sounds[aT].mute(); | |
} | |
return true; | |
}; | |
this.muteAll = function () { | |
aR.mute(); | |
}; | |
this.unmute = function (aT) { | |
var aV = aA + ".unmute(): ", | |
aU; | |
if (typeof aT !== "string") { | |
aT = null; | |
} | |
if (!aT) { | |
aR._wD(aV + "Unmuting all sounds"); | |
for (aU = aR.soundIDs.length; aU--;) { | |
aR.sounds[aR.soundIDs[aU]].unmute(); | |
} | |
aR.muted = false; | |
} else { | |
if (!ad(aT)) { | |
return false; | |
} | |
aR._wD(aV + 'Unmuting "' + aT + '"'); | |
return aR.sounds[aT].unmute(); | |
} | |
return true; | |
}; | |
this.unmuteAll = function () { | |
aR.unmute(); | |
}; | |
this.toggleMute = function (aT) { | |
if (!ad(aT)) { | |
return false; | |
} | |
return aR.sounds[aT].toggleMute(); | |
}; | |
this.getMemoryUse = function () { | |
if (e === 8) { | |
return 0; | |
} | |
if (aR.o) { | |
return parseInt(aR.o._getMemoryUse(), 10); | |
} | |
}; | |
this.disable = function (aU) { | |
if (typeof aU === "undefined") { | |
aU = false; | |
} | |
if (F) { | |
return false; | |
} | |
F = true; | |
z("shutdown", 1); | |
for (var aT = aR.soundIDs.length; aT--;) { | |
U(aR.sounds[aR.soundIDs[aT]]); | |
} | |
T(aU); | |
r.remove(k, "load", ap); | |
return true; | |
}; | |
this.canPlayMIME = function (aU) { | |
var aT; | |
if (aR.hasHTML5) { | |
aT = av({ | |
type: aU | |
}); | |
} | |
if (!ag || aT) { | |
return aT; | |
} else { | |
return (aU ? (aU.match(aR.mimePattern) ? true : false) : null); | |
} | |
}; | |
this.canPlayURL = function (aU) { | |
var aT; | |
if (aR.hasHTML5) { | |
aT = av(aU); | |
} | |
if (!ag || aT) { | |
return aT; | |
} else { | |
return (aU ? (aU.match(aR.filePattern) ? true : false) : null); | |
} | |
}; | |
this.canPlayLink = function (aT) { | |
if (typeof aT.type !== "undefined" && aT.type) { | |
if (aR.canPlayMIME(aT.type)) { | |
return true; | |
} | |
} | |
return aR.canPlayURL(aT.href); | |
}; | |
this.getSoundById = function (aU, aV) { | |
if (!aU) { | |
throw new Error(aA + ".getSoundById(): sID is null/undefined"); | |
} | |
var aT = aR.sounds[aU]; | |
if (!aT && !aV) { | |
aR._wD('"' + aU + '" is an invalid sound ID.', 2); | |
} | |
return aT; | |
}; | |
this.onready = function (aU, aT) { | |
var aV = "onready"; | |
if (aU && aU instanceof Function) { | |
if (aI) { | |
z("queue", aV); | |
} | |
if (!aT) { | |
aT = k; | |
} | |
aL(aV, aU, aT); | |
aP(); | |
return true; | |
} else { | |
throw X("needFunction", aV); | |
} | |
}; | |
this.ontimeout = function (aU, aT) { | |
var aV = "ontimeout"; | |
if (aU && aU instanceof Function) { | |
if (aI) { | |
z("queue"); | |
} | |
if (!aT) { | |
aT = k; | |
} | |
aL(aV, aU, aT); | |
aP({ | |
type: aV | |
}); | |
return true; | |
} else { | |
throw X("needFunction", aV); | |
} | |
}; | |
this.getMoviePercent = function () { | |
return (aR.o && typeof aR.o.PercentLoaded !== "undefined" ? aR.o.PercentLoaded() : null); | |
}; | |
this._writeDebug = function (aU, a0, aW) { | |
var aZ = "soundmanager-debug", | |
aY, aX, aT; | |
if (!aR.debugMode) { | |
return false; | |
} | |
if (typeof aW !== "undefined" && aW) { | |
aU = aU + " | " + new Date().getTime(); | |
} | |
if (az && aR.useConsole) { | |
aT = V[a0]; | |
if (typeof console[aT] !== "undefined") { | |
console[aT](aU); | |
} else { | |
console.log(aU); | |
} | |
if (aR.useConsoleOnly) { | |
return true; | |
} | |
} | |
try { | |
aY = W(aZ); | |
if (!aY) { | |
return false; | |
} | |
aX = aD.createElement("div"); | |
if (++aG % 2 === 0) { | |
aX.className = "sm2-alt"; | |
} | |
if (typeof a0 === "undefined") { | |
a0 = 0; | |
} else { | |
a0 = parseInt(a0, 10); | |
} | |
aX.appendChild(aD.createTextNode(aU)); | |
if (a0) { | |
if (a0 >= 2) { | |
aX.style.fontWeight = "bold"; | |
} | |
if (a0 === 3) { | |
aX.style.color = "#ff3333"; | |
} | |
} | |
aY.insertBefore(aX, aY.firstChild); | |
} catch (aV) {} | |
aY = null; | |
return true; | |
}; | |
this._wD = this._writeDebug; | |
this._debug = function () { | |
z("currentObj", 1); | |
for (var aU = 0, aT = aR.soundIDs.length; aU < aT; aU++) { | |
aR.sounds[aR.soundIDs[aU]]._debug(); | |
} | |
}; | |
this.reboot = function () { | |
aR._wD(aA + ".reboot()"); | |
if (aR.soundIDs.length) { | |
aR._wD("Destroying " + aR.soundIDs.length + " SMSound objects..."); | |
} | |
var aU, aT; | |
for (aU = aR.soundIDs.length; aU--;) { | |
aR.sounds[aR.soundIDs[aU]].destruct(); | |
} | |
try { | |
if (f) { | |
aq = aR.o.innerHTML; | |
} | |
o = aR.o.parentNode.removeChild(aR.o); | |
aR._wD("Flash movie removed."); | |
} catch (aV) { | |
z("badRemove", 2); | |
} | |
aq = o = null; | |
aR.enabled = aI = aS = C = at = aK = F = aR.swfLoaded = false; | |
aR.soundIDs = aR.sounds = []; | |
aR.o = null; | |
for (aU in aj) { | |
if (aj.hasOwnProperty(aU)) { | |
for (aT = aj[aU].length; aT--;) { | |
aj[aU][aT].fired = false; | |
} | |
} | |
} | |
aR._wD(aA + ": Rebooting..."); | |
k.setTimeout(function () { | |
aR.beginDelayedInit(); | |
}, 20); | |
}; | |
this.destruct = function () { | |
aR._wD(aA + ".destruct()"); | |
aR.disable(true); | |
}; | |
this.beginDelayedInit = function () { | |
u = true; | |
aM(); | |
setTimeout(S, 20); | |
ah(); | |
}; | |
function M(aT) { | |
return function (aU) { | |
if (!this._t || !this._t._a) { | |
if (this._t && this._t.sID) { | |
aR._wD(aF + "ignoring " + aU.type + ": " + this._t.sID); | |
} else { | |
aR._wD(aF + "ignoring " + aU.type); | |
} | |
return null; | |
} else { | |
return aT.call(this, aU); | |
} | |
}; | |
} | |
this._html5_events = { | |
abort: M(function (aT) { | |
aR._wD(aF + "abort: " + this._t.sID); | |
}), | |
canplay: M(function (aV) { | |
aR._wD(aF + "canplay: " + this._t.sID + ", " + this._t.url); | |
this._t._onbufferchange(0); | |
var aU = (!isNaN(this._t.position) ? this._t.position / 1000 : null); | |
this._t._html5_canplay = true; | |
if (this._t.position && this.currentTime !== aU) { | |
aR._wD(aF + "canplay: setting position to " + aU + ""); | |
try { | |
this.currentTime = aU; | |
} catch (aT) { | |
aR._wD(aF + "setting position failed: " + aT.message, 2); | |
} | |
} | |
}), | |
load: M(function (aT) { | |
if (!this._t.loaded) { | |
this._t._onbufferchange(0); | |
this._t._whileloading(this._t.bytesTotal, this._t.bytesTotal, this._t._get_html5_duration()); | |
this._t._onload(true); | |
} | |
}), | |
emptied: M(function (aT) { | |
aR._wD(aF + "emptied: " + this._t.sID); | |
}), | |
ended: M(function (aT) { | |
aR._wD(aF + "ended: " + this._t.sID); | |
this._t._onfinish(); | |
}), | |
error: M(function (aT) { | |
aR._wD(aF + "error: " + this.error.code); | |
this._t._onload(false); | |
}), | |
loadeddata: M(function (aT) { | |
aR._wD(aF + "loadeddata: " + this._t.sID); | |
}), | |
loadedmetadata: M(function (aT) { | |
aR._wD(aF + "loadedmetadata: " + this._t.sID); | |
}), | |
loadstart: M(function (aT) { | |
aR._wD(aF + "loadstart: " + this._t.sID); | |
this._t._onbufferchange(1); | |
}), | |
play: M(function (aT) { | |
aR._wD(aF + "play: " + this._t.sID + ", " + this._t.url); | |
this._t._onbufferchange(0); | |
}), | |
playing: M(function (aT) { | |
aR._wD(aF + "playing: " + this._t.sID + ", " + this._t.url); | |
this._t._onbufferchange(0); | |
}), | |
progress: M(function (aY) { | |
if (this._t.loaded) { | |
return false; | |
} | |
var aX, aV, aZ, a2 = 0, | |
aU = 0, | |
a1 = (aY.type === "progress"), | |
aT = aY.target.buffered, | |
aW = (aY.loaded || 0), | |
a0 = (aY.total || 1); | |
if (aT && aT.length) { | |
for (aX = aT.length; aX--;) { | |
aU = (aT.end(aX) - aT.start(aX)); | |
} | |
aW = aU / aY.target.duration; | |
if (a1 && aT.length > 1) { | |
aZ = []; | |
aV = aT.length; | |
for (aX = 0; aX < aV; aX++) { | |
aZ.push(aY.target.buffered.start(aX) + "-" + aY.target.buffered.end(aX)); | |
} | |
aR._wD(aF + "progress: timeRanges: " + aZ.join(", ")); | |
} | |
if (a1 && !isNaN(aW)) { | |
aR._wD(aF + "progress: " + this._t.sID + ": " + Math.floor(aW * 100) + "% loaded"); | |
} | |
} | |
if (!isNaN(aW)) { | |
this._t._onbufferchange(0); | |
this._t._whileloading(aW, a0, this._t._get_html5_duration()); | |
if (aW && a0 && aW === a0) { | |
aR._html5_events.load.call(this, aY); | |
} | |
} | |
}), | |
ratechange: M(function (aT) { | |
aR._wD(aF + "ratechange: " + this._t.sID); | |
}), | |
suspend: M(function (aT) { | |
aR._wD(aF + "suspend: " + this._t.sID); | |
aR._html5_events.progress.call(this, aT); | |
}), | |
stalled: M(function (aT) { | |
aR._wD(aF + "stalled: " + this._t.sID); | |
}), | |
timeupdate: M(function (aT) { | |
this._t._onTimer(); | |
}), | |
waiting: M(function (aT) { | |
aR._wD(aF + "waiting: " + this._t.sID); | |
this._t._onbufferchange(1); | |
}) | |
}; | |
R = function (aU) { | |
var aW = this, | |
aX, aV, aT; | |
this.sID = aU.id; | |
this.url = aU.url; | |
this.options = ai(aU); | |
this.instanceOptions = this.options; | |
this._iO = this.instanceOptions; | |
this.pan = this.options.pan; | |
this.volume = this.options.volume; | |
this._lastURL = null; | |
this.isHTML5 = false; | |
this._a = null; | |
this.id3 = {}; | |
this._debug = function () { | |
if (aR.debugMode) { | |
var a0 = null, | |
a2 = [], | |
aZ, a1, aY = 64; | |
for (a0 in aW.options) { | |
if (aW.options[a0] !== null) { | |
if (aW.options[a0] instanceof Function) { | |
aZ = aW.options[a0].toString(); | |
aZ = aZ.replace(/\s\s+/g, " "); | |
a1 = aZ.indexOf("{"); | |
a2.push(" " + a0 + ": {" + aZ.substr(a1 + 1, (Math.min(Math.max(aZ.indexOf("\n") - 1, aY), aY))).replace(/\n/g, "") + "... }"); | |
} else { | |
a2.push(" " + a0 + ": " + aW.options[a0]); | |
} | |
} | |
} | |
aR._wD("SMSound() merged options: {\n" + a2.join(", \n") + "\n}"); | |
} | |
}; | |
this._debug(); | |
this.load = function (aY) { | |
var aZ = null; | |
if (typeof aY !== "undefined") { | |
aW._iO = ai(aY, aW.options); | |
aW.instanceOptions = aW._iO; | |
} else { | |
aY = aW.options; | |
aW._iO = aY; | |
aW.instanceOptions = aW._iO; | |
if (aW._lastURL && aW._lastURL !== aW.url) { | |
z("manURL"); | |
aW._iO.url = aW.url; | |
aW.url = null; | |
} | |
} | |
if (!aW._iO.url) { | |
aW._iO.url = aW.url; | |
} | |
aR._wD("SMSound.load(): " + aW._iO.url, 1); | |
if (aW._iO.url === aW.url && aW.readyState !== 0 && aW.readyState !== 2) { | |
z("onURL", 1); | |
return aW; | |
} | |
aW._lastURL = aW.url; | |
aW.loaded = false; | |
aW.readyState = 1; | |
aW.playState = 0; | |
if (A(aW._iO)) { | |
aZ = aW._setup_html5(aW._iO); | |
if (!aZ._called_load) { | |
aR._wD(aF + "load: " + aW.sID); | |
aZ.load(); | |
aZ._called_load = true; | |
if (aW._iO.autoPlay) { | |
aW.play(); | |
} | |
} else { | |
aR._wD("HTML5 ignoring request to load again: " + aW.sID); | |
} | |
} else { | |
try { | |
aW.isHTML5 = false; | |
aW._iO = w(Z(aW._iO)); | |
if (e === 8) { | |
aR.o._load(aW.sID, aW._iO.url, aW._iO.stream, aW._iO.autoPlay, (aW._iO.whileloading ? 1 : 0), aW._iO.loops || 1, aW._iO.usePolicyFile); | |
} else { | |
aR.o._load(aW.sID, aW._iO.url, aW._iO.stream ? true : false, aW._iO.autoPlay ? true : false, aW._iO.loops || 1, aW._iO.autoLoad ? true : false, aW._iO.usePolicyFile); | |
} | |
} catch (a0) { | |
z("smError", 2); | |
af("onload", false); | |
ay(); | |
} | |
} | |
return aW; | |
}; | |
this.unload = function () { | |
if (aW.readyState !== 0) { | |
aR._wD('SMSound.unload(): "' + aW.sID + '"'); | |
if (!aW.isHTML5) { | |
if (e === 8) { | |
aR.o._unload(aW.sID, aR.nullURL); | |
} else { | |
aR.o._unload(aW.sID); | |
} | |
} else { | |
aV(); | |
if (aW._a) { | |
aW._a.pause(); | |
aW._a.src = ""; | |
} | |
} | |
aX(); | |
} | |
return aW; | |
}; | |
this.destruct = function (aY) { | |
aR._wD('SMSound.destruct(): "' + aW.sID + '"'); | |
if (!aW.isHTML5) { | |
aW._iO.onfailure = null; | |
aR.o._destroySound(aW.sID); | |
} else { | |
aV(); | |
if (aW._a) { | |
aW._a.pause(); | |
aW._a.src = ""; | |
if (!aJ) { | |
aW._remove_html5_events(); | |
} | |
} | |
} | |
if (!aY) { | |
aR.destroySound(aW.sID, true); | |
} | |
}; | |
this.play = function (a0, aZ) { | |
var a1 = "SMSound.play(): ", | |
aY; | |
aZ = aZ === undefined ? true : aZ; | |
if (!a0) { | |
a0 = {}; | |
} | |
aW._iO = ai(a0, aW._iO); | |
aW._iO = ai(aW._iO, aW.options); | |
aW.instanceOptions = aW._iO; | |
if (aW._iO.serverURL) { | |
if (!aW.connected) { | |
if (!aW.getAutoPlay()) { | |
aR._wD(a1 + " Netstream not connected yet - setting autoPlay"); | |
aW.setAutoPlay(true); | |
} | |
return aW; | |
} | |
} | |
if (A(aW._iO)) { | |
aW._setup_html5(aW._iO); | |
aT(); | |
} | |
if (aW.playState === 1 && !aW.paused) { | |
aY = aW._iO.multiShot; | |
if (!aY) { | |
aR._wD(a1 + '"' + aW.sID + '" already playing (one-shot)', 1); | |
return aW; | |
} else { | |
aR._wD(a1 + '"' + aW.sID + '" already playing (multi-shot)', 1); | |
if (aW.isHTML5) { | |
aW.setPosition(aW._iO.position); | |
} | |
} | |
} | |
if (!aW.loaded) { | |
if (aW.readyState === 0) { | |
aR._wD(a1 + 'Attempting to load "' + aW.sID + '"', 1); | |
if (!aW.isHTML5) { | |
aW._iO.autoPlay = true; | |
aW.load(aW._iO); | |
} else { | |
aW.load(aW._iO); | |
} | |
} else { | |
if (aW.readyState === 2) { | |
aR._wD(a1 + 'Could not load "' + aW.sID + '" - exiting', 2); | |
return aW; | |
} else { | |
aR._wD(a1 + '"' + aW.sID + '" is loading - attempting to play..', 1); | |
} | |
} | |
} else { | |
aR._wD(a1 + '"' + aW.sID + '"'); | |
} | |
if (aW.paused && aW.position && aW.position > 0) { | |
aR._wD(a1 + '"' + aW.sID + '" is resuming from paused state', 1); | |
aW.resume(); | |
} else { | |
aR._wD(a1 + '"' + aW.sID + '" is starting to play'); | |
aW.playState = 1; | |
aW.paused = false; | |
if (!aW.instanceCount || aW._iO.multiShotEvents || (e > 8 && !aW.isHTML5 && !aW.getAutoPlay())) { | |
aW.instanceCount++; | |
} | |
aW.position = (typeof aW._iO.position !== "undefined" && !isNaN(aW._iO.position) ? aW._iO.position : 0); | |
if (!aW.isHTML5) { | |
aW._iO = w(Z(aW._iO)); | |
} | |
if (aW._iO.onplay && aZ) { | |
aW._iO.onplay.apply(aW); | |
aW._onplay_called = true; | |
} | |
aW.setVolume(aW._iO.volume, true); | |
aW.setPan(aW._iO.pan, true); | |
if (!aW.isHTML5) { | |
aR.o._start(aW.sID, aW._iO.loops || 1, (e === 9 ? aW.position : aW.position / 1000)); | |
} else { | |
aT(); | |
aW._setup_html5().play(); | |
} | |
} | |
return aW; | |
}; | |
this.start = this.play; | |
this.stop = function (aY) { | |
if (aW.playState === 1) { | |
aW._onbufferchange(0); | |
aW.resetOnPosition(0); | |
if (!aW.isHTML5) { | |
aW.playState = 0; | |
} | |
aW.paused = false; | |
if (aW._iO.onstop) { | |
aW._iO.onstop.apply(aW); | |
} | |
if (!aW.isHTML5) { | |
aR.o._stop(aW.sID, aY); | |
if (aW._iO.serverURL) { | |
aW.unload(); | |
} | |
} else { | |
if (aW._a) { | |
aW.setPosition(0); | |
aW._a.pause(); | |
aW.playState = 0; | |
aW._onTimer(); | |
aV(); | |
aW.unload(); | |
} | |
} | |
aW.instanceCount = 0; | |
aW._iO = {}; | |
} | |
return aW; | |
}; | |
this.setAutoPlay = function (aY) { | |
aR._wD("sound " + aW.sID + " turned autoplay " + (aY ? "on" : "off")); | |
aW._iO.autoPlay = aY; | |
if (aW.isHTML5) { | |
if (aW._a && aY) { | |
aW.play(); | |
} | |
} else { | |
aR.o._setAutoPlay(aW.sID, aY); | |
} | |
if (aY) { | |
if (!aW.instanceCount && aW.readyState === 1) { | |
aW.instanceCount++; | |
aR._wD("sound " + aW.sID + " incremented instance count to " + aW.instanceCount); | |
} | |
} | |
}; | |
this.getAutoPlay = function () { | |
return aW._iO.autoPlay; | |
}; | |
this.setPosition = function (a2, a1) { | |
if (a2 === undefined) { | |
a2 = 0; | |
} | |
var a0, aY, aZ, a4 = (aW.isHTML5 ? Math.max(a2, 0) : Math.min(aW.duration || aW._iO.duration, Math.max(a2, 0))); | |
a0 = aW.position; | |
aW.position = a4; | |
aZ = aW.position / 1000; | |
aW.resetOnPosition(aW.position); | |
aW._iO.position = a4; | |
if (!aW.isHTML5) { | |
aY = e === 9 ? aW.position : aZ; | |
if (aW.readyState && aW.readyState !== 2) { | |
aR.o._setPosition(aW.sID, aY, (aW.paused || !aW.playState)); | |
} | |
} else { | |
if (aW._a) { | |
if (aW._html5_canplay) { | |
if (aW._a.currentTime !== aZ) { | |
aR._wD("setPosition(" + aZ + "): setting position"); | |
try { | |
aW._a.currentTime = aZ; | |
} catch (a3) { | |
aR._wD("setPosition(" + aZ + "): setting position failed: " + a3.message, 2); | |
} | |
} | |
} else { | |
aR._wD("setPosition(" + aZ + "): delaying, sound not ready"); | |
} | |
} | |
} | |
if (aW.isHTML5) { | |
if (aW.paused) { | |
aW._onTimer(true); | |
} | |
} | |
return aW; | |
}; | |
this.pause = function (aY) { | |
if (aW.paused || (aW.playState === 0 && aW.readyState !== 1)) { | |
return aW; | |
} | |
aR._wD("SMSound.pause()"); | |
aW.paused = true; | |
if (!aW.isHTML5) { | |
if (aY || aY === undefined) { | |
aR.o._pause(aW.sID); | |
} | |
} else { | |
aW._setup_html5().pause(); | |
aV(); | |
} | |
if (aW._iO.onpause) { | |
aW._iO.onpause.apply(aW); | |
} | |
return aW; | |
}; | |
this.resume = function () { | |
if (!aW.paused) { | |
return aW; | |
} | |
aR._wD("SMSound.resume()"); | |
aW.paused = false; | |
aW.playState = 1; | |
if (!aW.isHTML5) { | |
if (aW._iO.isMovieStar) { | |
aW.setPosition(aW.position); | |
} | |
aR.o._pause(aW.sID); | |
} else { | |
aW._setup_html5().play(); | |
aT(); | |
} | |
if (!aW._onplay_called && aW._iO.onplay) { | |
aW._iO.onplay.apply(aW); | |
aW._onplay_called = true; | |
} else { | |
if (aW._iO.onresume) { | |
aW._iO.onresume.apply(aW); | |
} | |
} | |
return aW; | |
}; | |
this.togglePause = function () { | |
aR._wD("SMSound.togglePause()"); | |
if (aW.playState === 0) { | |
aW.play({ | |
position: (e === 9 && !aW.isHTML5 ? aW.position : aW.position / 1000) | |
}); | |
return aW; | |
} | |
if (aW.paused) { | |
aW.resume(); | |
} else { | |
aW.pause(); | |
} | |
return aW; | |
}; | |
this.setPan = function (aZ, aY) { | |
if (typeof aZ === "undefined") { | |
aZ = 0; | |
} | |
if (typeof aY === "undefined") { | |
aY = false; | |
} | |
if (!aW.isHTML5) { | |
aR.o._setPan(aW.sID, aZ); | |
} | |
aW._iO.pan = aZ; | |
if (!aY) { | |
aW.pan = aZ; | |
aW.options.pan = aZ; | |
} | |
return aW; | |
}; | |
this.setVolume = function (aY, aZ) { | |
if (typeof aY === "undefined") { | |
aY = 100; | |
} | |
if (typeof aZ === "undefined") { | |
aZ = false; | |
} | |
if (!aW.isHTML5) { | |
aR.o._setVolume(aW.sID, (aR.muted && !aW.muted) || aW.muted ? 0 : aY); | |
} else { | |
if (aW._a) { | |
aW._a.volume = Math.max(0, Math.min(1, aY / 100)); | |
} | |
} | |
aW._iO.volume = aY; | |
if (!aZ) { | |
aW.volume = aY; | |
aW.options.volume = aY; | |
} | |
return aW; | |
}; | |
this.mute = function () { | |
aW.muted = true; | |
if (!aW.isHTML5) { | |
aR.o._setVolume(aW.sID, 0); | |
} else { | |
if (aW._a) { | |
aW._a.muted = true; | |
} | |
} | |
return aW; | |
}; | |
this.unmute = function () { | |
aW.muted = false; | |
var aY = typeof aW._iO.volume !== "undefined"; | |
if (!aW.isHTML5) { | |
aR.o._setVolume(aW.sID, aY ? aW._iO.volume : aW.options.volume); | |
} else { | |
if (aW._a) { | |
aW._a.muted = false; | |
} | |
} | |
return aW; | |
}; | |
this.toggleMute = function () { | |
return (aW.muted ? aW.unmute() : aW.mute()); | |
}; | |
this.onposition = function (a0, aZ, aY) { | |
aW._onPositionItems.push({ | |
position: a0, | |
method: aZ, | |
scope: (typeof aY !== "undefined" ? aY : aW), | |
fired: false | |
}); | |
return aW; | |
}; | |
this.processOnPosition = function () { | |
var aZ, a0, aY = aW._onPositionItems.length; | |
if (!aY || !aW.playState || aW._onPositionFired >= aY) { | |
return false; | |
} | |
for (aZ = aY; aZ--;) { | |
a0 = aW._onPositionItems[aZ]; | |
if (!a0.fired && aW.position >= a0.position) { | |
a0.method.apply(a0.scope, [a0.position]); | |
a0.fired = true; | |
aR._onPositionFired++; | |
} | |
} | |
return true; | |
}; | |
this.resetOnPosition = function (aY) { | |
var a0, a1, aZ = aW._onPositionItems.length; | |
if (!aZ) { | |
return false; | |
} | |
for (a0 = aZ; a0--;) { | |
a1 = aW._onPositionItems[a0]; | |
if (a1.fired && aY <= a1.position) { | |
a1.fired = false; | |
aR._onPositionFired--; | |
} | |
} | |
return true; | |
}; | |
this._onTimer = function (aZ) { | |
var a0, aY = {}; | |
if (aW._hasTimer || aZ) { | |
if (aW._a && (aZ || ((aW.playState > 0 || aW.readyState === 1) && !aW.paused))) { | |
aW.duration = aW._get_html5_duration(); | |
aW.durationEstimate = aW.duration; | |
a0 = aW._a.currentTime ? aW._a.currentTime * 1000 : 0; | |
aW._whileplaying(a0, aY, aY, aY, aY); | |
return true; | |
} else { | |
aR._wD('_onTimer: Warn for "' + aW.sID + '": ' + (!aW._a ? "Could not find element. " : "") + (aW.playState === 0 ? "playState bad, 0?" : "playState = " + aW.playState + ", OK")); | |
return false; | |
} | |
} | |
}; | |
this._get_html5_duration = function () { | |
var aY = (aW._a ? aW._a.duration * 1000 : (aW._iO ? aW._iO.duration : undefined)); | |
return (aY && !isNaN(aY) && aY !== Infinity ? aY : (aW._iO ? aW._iO.duration : null)); | |
}; | |
aT = function () { | |
if (aW.isHTML5) { | |
v(aW); | |
} | |
}; | |
aV = function () { | |
if (aW.isHTML5) { | |
Q(aW); | |
} | |
}; | |
aX = function (aY) { | |
aW._onPositionItems = []; | |
aW._onPositionFired = 0; | |
aW._hasTimer = null; | |
aW._onplay_called = false; | |
aW._a = null; | |
aW._html5_canplay = false; | |
aW.bytesLoaded = null; | |
aW.bytesTotal = null; | |
aW.position = null; | |
aW.duration = (aW._iO && aW._iO.duration ? aW._iO.duration : null); | |
aW.durationEstimate = null; | |
aW.failures = 0; | |
aW.loaded = false; | |
aW.playState = 0; | |
aW.paused = false; | |
aW.readyState = 0; | |
aW.muted = false; | |
aW.didBeforeFinish = false; | |
aW.didJustBeforeFinish = false; | |
aW.isBuffering = false; | |
aW.instanceOptions = {}; | |
aW.instanceCount = 0; | |
aW.peakData = { | |
left: 0, | |
right: 0 | |
}; | |
aW.waveformData = { | |
left: [], | |
right: [] | |
}; | |
aW.eqData = []; | |
aW.eqData.left = []; | |
aW.eqData.right = []; | |
}; | |
aX(); | |
this._setup_html5 = function (a0) { | |
var aZ = ai(aW._iO, a0), | |
a3 = decodeURI, | |
a1 = aJ ? aR._global_a : aW._a, | |
a2 = a3(aZ.url), | |
aY = (a1 && a1._t ? a1._t.instanceOptions : null); | |
if (a1) { | |
if (a1._t && aY.url === aZ.url && (!aW._lastURL || (aW._lastURL === aY.url))) { | |
return a1; | |
} | |
aR._wD("setting new URL on existing object: " + a2 + (aW._lastURL ? ", old URL: " + aW._lastURL : "")); | |
if (aJ && a1._t && a1._t.playState && aZ.url !== aY.url) { | |
a1._t.stop(); | |
} | |
aX(); | |
a1.src = aZ.url; | |
aW.url = aZ.url; | |
aW._lastURL = aZ.url; | |
a1._called_load = false; | |
} else { | |
aR._wD("creating HTML5 Audio() element with URL: " + a2); | |
a1 = new Audio(aZ.url); | |
a1._called_load = false; | |
if (aJ) { | |
aR._global_a = a1; | |
} | |
} | |
aW.isHTML5 = true; | |
aW._a = a1; | |
a1._t = aW; | |
aW._add_html5_events(); | |
a1.loop = (aZ.loops > 1 ? "loop" : ""); | |
if (aZ.autoLoad || aZ.autoPlay) { | |
a1.autobuffer = "auto"; | |
a1.preload = "auto"; | |
aW.load(); | |
a1._called_load = true; | |
} else { | |
a1.autobuffer = false; | |
a1.preload = "none"; | |
} | |
a1.loop = (aZ.loops > 1 ? "loop" : ""); | |
return a1; | |
}; | |
this._add_html5_events = function () { | |
if (aW._a._added_events) { | |
return false; | |
} | |
var aY; | |
function aZ(a1, a0, a2) { | |
return aW._a ? aW._a.addEventListener(a1, a0, a2 || false) : null; | |
} | |
aR._wD(aF + "adding event listeners: " + aW.sID); | |
aW._a._added_events = true; | |
for (aY in aR._html5_events) { | |
if (aR._html5_events.hasOwnProperty(aY)) { | |
aZ(aY, aR._html5_events[aY]); | |
} | |
} | |
return true; | |
}; | |
this._remove_html5_events = function () { | |
function aY(a1, a0, a2) { | |
return (aW._a ? aW._a.removeEventListener(a1, a0, a2 || false) : null); | |
} | |
aR._wD(aF + "removing event listeners: " + aW.sID); | |
aW._a._added_events = false; | |
for (var aZ in aR._html5_events) { | |
if (aR._html5_events.hasOwnProperty(aZ)) { | |
aY(aZ, aR._html5_events[aZ]); | |
} | |
} | |
}; | |
this._whileloading = function (aY, aZ, a1, a0) { | |
aW.bytesLoaded = aY; | |
aW.bytesTotal = aZ; | |
aW.duration = Math.floor(a1); | |
aW.bufferLength = a0; | |
if (!aW._iO.isMovieStar) { | |
if (aW._iO.duration) { | |
aW.durationEstimate = (aW.duration > aW._iO.duration) ? aW.duration : aW._iO.duration; | |
} else { | |
aW.durationEstimate = parseInt((aW.bytesTotal / aW.bytesLoaded) * aW.duration, 10); | |
} | |
if (aW.durationEstimate === undefined) { | |
aW.durationEstimate = aW.duration; | |
} | |
if (aW.readyState !== 3 && aW._iO.whileloading) { | |
aW._iO.whileloading.apply(aW); | |
} | |
} else { | |
aW.durationEstimate = aW.duration; | |
if (aW.readyState !== 3 && aW._iO.whileloading) { | |
aW._iO.whileloading.apply(aW); | |
} | |
} | |
}; | |
this._onid3 = function (a1, aY) { | |
aR._wD('SMSound._onid3(): "' + this.sID + '" ID3 data received.'); | |
var a2 = [], | |
a0, aZ; | |
for (a0 = 0, aZ = a1.length; a0 < aZ; a0++) { | |
a2[a1[a0]] = aY[a0]; | |
} | |
aW.id3 = ai(aW.id3, a2); | |
if (aW._iO.onid3) { | |
aW._iO.onid3.apply(aW); | |
} | |
}; | |
this._whileplaying = function (a0, a1, a3, aZ, a2) { | |
if (isNaN(a0) || a0 === null) { | |
return false; | |
} | |
if (aW.playState === 0 && a0 > 0) { | |
a0 = 0; | |
} | |
aW.position = a0; | |
aW.processOnPosition(); | |
if (e > 8 && !aW.isHTML5) { | |
if (aW._iO.usePeakData && typeof a1 !== "undefined" && a1) { | |
aW.peakData = { | |
left: a1.leftPeak, | |
right: a1.rightPeak | |
}; | |
} | |
if (aW._iO.useWaveformData && typeof a3 !== "undefined" && a3) { | |
aW.waveformData = { | |
left: a3.split(","), | |
right: aZ.split(",") | |
}; | |
} | |
if (aW._iO.useEQData) { | |
if (typeof a2 !== "undefined" && a2 && a2.leftEQ) { | |
var aY = a2.leftEQ.split(","); | |
aW.eqData = aY; | |
aW.eqData.left = aY; | |
if (typeof a2.rightEQ !== "undefined" && a2.rightEQ) { | |
aW.eqData.right = a2.rightEQ.split(","); | |
} | |
} | |
} | |
} | |
if (aW.playState === 1) { | |
if (!aW.isHTML5 && aR.flashVersion === 8 && !aW.position && aW.isBuffering) { | |
aW._onbufferchange(0); | |
} | |
if (aW._iO.whileplaying) { | |
aW._iO.whileplaying.apply(aW); | |
} | |
if ((aW.loaded || (!aW.loaded && aW._iO.isMovieStar)) && aW._iO.onbeforefinish && aW._iO.onbeforefinishtime && !aW.didBeforeFinish && aW.duration - aW.position <= aW._iO.onbeforefinishtime) { | |
aW._onbeforefinish(); | |
} | |
} | |
return true; | |
}; | |
this._onconnect = function (aY) { | |
var aZ = "SMSound._onconnect(): "; | |
aY = (aY === 1); | |
aR._wD(aZ + '"' + aW.sID + '"' + (aY ? " connected." : " failed to connect? - " + aW.url), (aY ? 1 : 2)); | |
aW.connected = aY; | |
if (aY) { | |
aW.failures = 0; | |
if (ad(aW.sID)) { | |
if (aW.getAutoPlay()) { | |
aW.play(undefined, aW.getAutoPlay()); | |
} else { | |
if (aW._iO.autoLoad) { | |
aW.load(); | |
} | |
} | |
} | |
if (aW._iO.onconnect) { | |
aW._iO.onconnect.apply(aW, [aY]); | |
} | |
} | |
}; | |
this._onload = function (a0) { | |
var aY = "SMSound._onload(): ", | |
aZ = (a0 ? true : false); | |
aR._wD(aY + '"' + aW.sID + '"' + (aZ ? " loaded." : " failed to load? - " + aW.url), (aZ ? 1 : 2)); | |
if (!aZ && !aW.isHTML5) { | |
if (aR.sandbox.noRemote === true) { | |
aR._wD(aY + X("noNet"), 1); | |
} | |
if (aR.sandbox.noLocal === true) { | |
aR._wD(aY + X("noLocal"), 1); | |
} | |
} | |
aW.loaded = aZ; | |
aW.readyState = aZ ? 3 : 2; | |
aW._onbufferchange(0); | |
if (aW._iO.onload) { | |
aW._iO.onload.apply(aW, [aZ]); | |
} | |
return true; | |
}; | |
this._onfailure = function (aZ, a0, aY) { | |
aW.failures++; | |
aR._wD('SMSound._onfailure(): "' + aW.sID + '" count ' + aW.failures); | |
if (aW._iO.onfailure && aW.failures === 1) { | |
aW._iO.onfailure(aW, aZ, a0, aY); | |
} else { | |
aR._wD("SMSound._onfailure(): ignoring"); | |
} | |
}; | |
this._onbeforefinish = function () { | |
if (!aW.didBeforeFinish) { | |
aW.didBeforeFinish = true; | |
if (aW._iO.onbeforefinish) { | |
aR._wD('SMSound._onbeforefinish(): "' + aW.sID + '"'); | |
aW._iO.onbeforefinish.apply(aW); | |
} | |
} | |
}; | |
this._onjustbeforefinish = function (aY) { | |
if (!aW.didJustBeforeFinish) { | |
aW.didJustBeforeFinish = true; | |
if (aW._iO.onjustbeforefinish) { | |
aR._wD('SMSound._onjustbeforefinish(): "' + aW.sID + '"'); | |
aW._iO.onjustbeforefinish.apply(aW); | |
} | |
} | |
}; | |
this._onfinish = function () { | |
var aY = aW._iO.onfinish; | |
aW._onbufferchange(0); | |
aW.resetOnPosition(0); | |
if (aW._iO.onbeforefinishcomplete) { | |
aW._iO.onbeforefinishcomplete.apply(aW); | |
} | |
aW.didBeforeFinish = false; | |
aW.didJustBeforeFinish = false; | |
if (aW.instanceCount) { | |
aW.instanceCount--; | |
if (!aW.instanceCount) { | |
aW.playState = 0; | |
aW.paused = false; | |
aW.instanceCount = 0; | |
aW.instanceOptions = {}; | |
aW._iO = {}; | |
aV(); | |
} | |
if (!aW.instanceCount || aW._iO.multiShotEvents) { | |
if (aY) { | |
aR._wD('SMSound._onfinish(): "' + aW.sID + '"'); | |
aY.apply(aW); | |
} | |
} | |
} | |
}; | |
this._onbufferchange = function (aY) { | |
var aZ = "SMSound._onbufferchange()"; | |
if (aW.playState === 0) { | |
return false; | |
} | |
if ((aY && aW.isBuffering) || (!aY && !aW.isBuffering)) { | |
return false; | |
} | |
aW.isBuffering = (aY === 1); | |
if (aW._iO.onbufferchange) { | |
aR._wD(aZ + ": " + aY); | |
aW._iO.onbufferchange.apply(aW); | |
} | |
return true; | |
}; | |
this._ondataerror = function (aY) { | |
if (aW.playState > 0) { | |
aR._wD("SMSound._ondataerror(): " + aY); | |
if (aW._iO.ondataerror) { | |
aW._iO.ondataerror.apply(aW); | |
} | |
} | |
}; | |
}; | |
an = function () { | |
return (aD.body ? aD.body : (aD._docElement ? aD.documentElement : aD.getElementsByTagName("div")[0])); | |
}; | |
W = function (aT) { | |
return aD.getElementById(aT); | |
}; | |
ai = function (aU, aT) { | |
var aX = {}, | |
aV, aW, aY; | |
for (aV in aU) { | |
if (aU.hasOwnProperty(aV)) { | |
aX[aV] = aU[aV]; | |
} | |
} | |
aW = (typeof aT === "undefined" ? aR.defaultOptions : aT); | |
for (aY in aW) { | |
if (aW.hasOwnProperty(aY) && typeof aX[aY] === "undefined") { | |
aX[aY] = aW[aY]; | |
} | |
} | |
return aX; | |
}; | |
r = (function () { | |
var aV = (k.attachEvent), | |
aU = { | |
add: (aV ? "attachEvent" : "addEventListener"), | |
remove: (aV ? "detachEvent" : "removeEventListener") | |
}; | |
function aX(a1) { | |
var a0 = j.call(a1), | |
aZ = a0.length; | |
if (aV) { | |
a0[1] = "on" + a0[1]; | |
if (aZ > 3) { | |
a0.pop(); | |
} | |
} else { | |
if (aZ === 3) { | |
a0.push(false); | |
} | |
} | |
return a0; | |
} | |
function aW(aZ, a2) { | |
var a0 = aZ.shift(), | |
a1 = [aU[a2]]; | |
if (aV) { | |
a0[a1](aZ[0], aZ[1]); | |
} else { | |
a0[a1].apply(a0, aZ); | |
} | |
} | |
function aY() { | |
aW(aX(arguments), "add"); | |
} | |
function aT() { | |
aW(aX(arguments), "remove"); | |
} | |
return { | |
add: aY, | |
remove: aT | |
}; | |
}()); | |
A = function (aT) { | |
return (!aT.serverURL && (aT.type ? av({ | |
type: aT.type | |
}) : av(aT.url) || aQ)); | |
}; | |
av = function (aY) { | |
if (!aR.useHTML5Audio || !aR.hasHTML5) { | |
return false; | |
} | |
var aT, aX, aZ, aV, aW, aU = aR.audioFormats; | |
if (!p) { | |
p = []; | |
for (aW in aU) { | |
if (aU.hasOwnProperty(aW)) { | |
p.push(aW); | |
if (aU[aW].related) { | |
p = p.concat(aU[aW].related); | |
} | |
} | |
} | |
p = new RegExp("\\.(" + p.join("|") + ")", "i"); | |
} | |
aX = (typeof aY.type !== "undefined" ? aY.type : null); | |
aV = (typeof aY === "string" ? aY.toLowerCase().match(p) : null); | |
if (!aV || !aV.length) { | |
if (!aX) { | |
return false; | |
} else { | |
aZ = aX.indexOf(";"); | |
aV = (aZ !== -1 ? aX.substr(0, aZ) : aX).substr(6); | |
} | |
} else { | |
aV = aV[0].substr(1); | |
} | |
if (aV && typeof aR.html5[aV] !== "undefined") { | |
return aR.html5[aV]; | |
} else { | |
if (!aX) { | |
if (aV && aR.html5[aV]) { | |
return aR.html5[aV]; | |
} else { | |
aX = "audio/" + aV; | |
} | |
} | |
aT = aR.html5.canPlayType(aX); | |
aR.html5[aV] = aT; | |
return aT; | |
} | |
}; | |
aO = function () { | |
if (!aR.useHTML5Audio || typeof Audio === "undefined") { | |
return false; | |
} | |
var aU = (typeof Audio !== "undefined" ? (H ? new Audio(null) : new Audio()) : null), | |
aZ, aY = {}, | |
aW, aX, aT = aN(); | |
function aV(a1) { | |
var a3, a4, a2, a0 = false; | |
if (!aU || typeof aU.canPlayType !== "function") { | |
return false; | |
} | |
if (a1 instanceof Array) { | |
for (a4 = 0, a2 = a1.length; a4 < a2 && !a0; a4++) { | |
if (aR.html5[a1[a4]] || aU.canPlayType(a1[a4]).match(aR.html5Test)) { | |
a0 = true; | |
aR.html5[a1[a4]] = true; | |
} | |
} | |
return a0; | |
} else { | |
a3 = (aU && typeof aU.canPlayType === "function" ? aU.canPlayType(a1) : false); | |
return (a3 && (a3.match(aR.html5Test) ? true : false)); | |
} | |
} | |
aW = aR.audioFormats; | |
for (aZ in aW) { | |
if (aW.hasOwnProperty(aZ)) { | |
aY[aZ] = aV(aW[aZ].type); | |
if (aW[aZ] && aW[aZ].related) { | |
for (aX = aW[aZ].related.length; aX--;) { | |
aR.html5[aW[aZ].related[aX]] = aY[aZ]; | |
} | |
} | |
} | |
} | |
aY.canPlayType = (aU ? aV : null); | |
aR.html5 = ai(aR.html5, aY); | |
return true; | |
}; | |
L = { | |
notReady: "Not loaded yet - wait for soundManager.onload()/onready()", | |
notOK: "Audio support is not available.", | |
appXHTML: ao + "createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.", | |
spcWmode: ao + "createMovie(): Removing wmode, preventing known SWF loading issue(s)", | |
swf404: aA + ": Verify that %s is a valid path.", | |
tryDebug: "Try " + aA + ".debugFlash = true for more security details (output goes to SWF.)", | |
checkSWF: "See SWF output for more debug info.", | |
localFail: aA + ": Non-HTTP page (" + aD.location.protocol + " URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/", | |
waitFocus: aA + ": Special case: Waiting for focus-related event..", | |
waitImpatient: aA + ": Getting impatient, still waiting for Flash%s...", | |
waitForever: aA + ": Waiting indefinitely for Flash (will recover if unblocked)...", | |
needFunction: aA + ": Function object expected for %s", | |
badID: 'Warning: Sound ID "%s" should be a string, starting with a non-numeric character', | |
noMS: "MovieStar mode not enabled. Exiting.", | |
currentObj: "--- " + aA + "._debug(): Current sound objects ---", | |
waitEI: ao + "initMovie(): Waiting for ExternalInterface call from Flash..", | |
waitOnload: aA + ": Waiting for window.onload()", | |
docLoaded: aA + ": Document already loaded", | |
onload: ao + "initComplete(): calling soundManager.onload()", | |
onloadOK: aA + ".onload() complete", | |
init: "-- " + ao + "init() --", | |
didInit: ao + "init(): Already called?", | |
flashJS: aA + ": Attempting to call Flash from JS..", | |
noPolling: aA + ": Polling (whileloading()/whileplaying() support) is disabled.", | |
secNote: "Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html", | |
badRemove: "Warning: Failed to remove flash movie.", | |
noPeak: "Warning: peakData features unsupported for movieStar formats", | |
shutdown: aA + ".disable(): Shutting down", | |
queue: aA + ": Queueing %s handler", | |
smFail: aA + ": Failed to initialise.", | |
smError: "SMSound.load(): Exception: JS-Flash communication failed, or JS error.", | |
fbTimeout: "No flash response, applying ." + aR.swfCSS.swfTimedout + " CSS..", | |
fbLoaded: "Flash loaded", | |
fbHandler: ao + "flashBlockHandler()", | |
manURL: "SMSound.load(): Using manually-assigned URL", | |
onURL: aA + ".load(): current URL already assigned.", | |
badFV: aA + '.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.', | |
as2loop: "Note: Setting stream:false so looping can work (flash 8 limitation)", | |
noNSLoop: "Note: Looping not implemented for MovieStar formats", | |
needfl9: "Note: Switching to flash 9, required for MP4 formats.", | |
mfTimeout: "Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case", | |
mfOn: "mobileFlash::enabling on-screen flash repositioning", | |
policy: "Enabling usePolicyFile for data access" | |
}; | |
X = function () { | |
var aU = j.call(arguments), | |
aX = aU.shift(), | |
aW = (L && L[aX] ? L[aX] : ""), | |
aV, aT; | |
if (aW && aU && aU.length) { | |
for (aV = 0, aT = aU.length; aV < aT; aV++) { | |
aW = aW.replace("%s", aU[aV]); | |
} | |
} | |
return aW; | |
}; | |
Z = function (aT) { | |
if (e === 8 && aT.loops > 1 && aT.stream) { | |
z("as2loop"); | |
aT.stream = false; | |
} | |
return aT; | |
}; | |
w = function (aU, aT) { | |
if (aU && !aU.usePolicyFile && (aU.onid3 || aU.usePeakData || aU.useWaveformData || aU.useEQData)) { | |
aR._wD((aT ? aT + ":" : "") + X("policy")); | |
aU.usePolicyFile = true; | |
} | |
return aU; | |
}; | |
d = function (aT) { | |
if (typeof console !== "undefined" && typeof console.warn !== "undefined") { | |
console.warn(aT); | |
} else { | |
aR._wD(aT); | |
} | |
}; | |
ac = function () { | |
return false; | |
}; | |
U = function (aU) { | |
for (var aT in aU) { | |
if (aU.hasOwnProperty(aT) && typeof aU[aT] === "function") { | |
aU[aT] = ac; | |
} | |
} | |
aT = null; | |
}; | |
am = function (aT) { | |
if (typeof aT === "undefined") { | |
aT = false; | |
} | |
if (F || aT) { | |
z("smFail", 2); | |
aR.disable(aT); | |
} | |
}; | |
h = function (aT) { | |
var aU = null; | |
if (aT) { | |
if (aT.match(/\.swf(\?.*)?$/i)) { | |
aU = aT.substr(aT.toLowerCase().lastIndexOf(".swf?") + 4); | |
if (aU) { | |
return aT; | |
} | |
} else { | |
if (aT.lastIndexOf("/") !== aT.length - 1) { | |
aT = aT + "/"; | |
} | |
} | |
} | |
return (aT && aT.lastIndexOf("/") !== -1 ? aT.substr(0, aT.lastIndexOf("/") + 1) : "./") + aR.movieURL; | |
}; | |
J = function () { | |
if (e !== 8 && e !== 9) { | |
aR._wD(X("badFV", e, N)); | |
aR.flashVersion = N; | |
} | |
var aT = (aR.debugMode || aR.debugFlash ? "_debug.swf" : ".swf"); | |
if (aR.useHTML5Audio && !aQ && aR.audioFormats.mp4.required && aR.flashVersion < 9) { | |
aR._wD(X("needfl9")); | |
aR.flashVersion = 9; | |
} | |
e = aR.flashVersion; | |
aR.version = aR.versionNumber + (aQ ? " (HTML5-only mode)" : (e === 9 ? " (AS3/Flash 9)" : " (AS2/Flash 8)")); | |
if (e > 8) { | |
aR.defaultOptions = ai(aR.defaultOptions, aR.flash9Options); | |
aR.features.buffering = true; | |
} | |
if (e > 8 && aR.useMovieStar) { | |
aR.defaultOptions = ai(aR.defaultOptions, aR.movieStarOptions); | |
aR.filePatterns.flash9 = new RegExp("\\.(mp3|" + aR.netStreamTypes.join("|") + ")(\\?.*)?$", "i"); | |
aR.mimePattern = aR.netStreamMimeTypes; | |
aR.features.movieStar = true; | |
} else { | |
aR.useMovieStar = false; | |
aR.features.movieStar = false; | |
} | |
aR.filePattern = aR.filePatterns[(e !== 8 ? "flash9" : "flash8")]; | |
aR.movieURL = (e === 8 ? "soundmanager2.swf" : "soundmanager2_flash9.swf").replace(".swf", aT); | |
aR.features.peakData = aR.features.waveformData = aR.features.eqData = (e > 8); | |
}; | |
ak = function (aT, aU) { | |
if (!aR.o || !aR.allowPolling) { | |
return false; | |
} | |
aR.o._setPolling(aT, aU); | |
}; | |
function E() { | |
if (aR.debugURLParam.test(l)) { | |
aR.debugMode = true; | |
} | |
if (W(aR.debugID)) { | |
return false; | |
} | |
var aY, aX, aT, aV, aU; | |
if (aR.debugMode && !W(aR.debugID) && ((!az || !aR.useConsole) || (aR.useConsole && az && !aR.consoleOnly))) { | |
aY = aD.createElement("div"); | |
aY.id = aR.debugID + "-toggle"; | |
aV = { | |
position: "fixed", | |
bottom: "0px", | |
right: "0px", | |
width: "1.2em", | |
height: "1.2em", | |
lineHeight: "1.2em", | |
margin: "2px", | |
textAlign: "center", | |
border: "1px solid #999", | |
cursor: "pointer", | |
background: "#fff", | |
color: "#333", | |
zIndex: 10001 | |
}; | |
aY.appendChild(aD.createTextNode("-")); | |
aY.onclick = x; | |
aY.title = "Toggle SM2 debug console"; | |
if (aa.match(/msie 6/i)) { | |
aY.style.position = "absolute"; | |
aY.style.cursor = "hand"; | |
} | |
for (aU in aV) { | |
if (aV.hasOwnProperty(aU)) { | |
aY.style[aU] = aV[aU]; | |
} | |
} | |
aX = aD.createElement("div"); | |
aX.id = aR.debugID; | |
aX.style.display = (aR.debugMode ? "block" : "none"); | |
if (aR.debugMode && !W(aY.id)) { | |
try { | |
aT = an(); | |
aT.appendChild(aY); | |
} catch (aW) { | |
throw new Error(X("appXHTML")); | |
} | |
aT.appendChild(aX); | |
} | |
} | |
aT = null; | |
} | |
aH = function (a8, aX) { | |
var a2 = null, | |
a7 = (aX ? aX : aR.url), | |
a1 = (aR.altURL ? aR.altURL : a7), | |
ba, aY, a5 = an(), | |
bb, a3, a0, a4 = I(), | |
aZ, aV, bc, aT = "100%", | |
aU = null, | |
aW = aD.getElementsByTagName("html")[0]; | |
aU = (aW && aW.dir && aW.dir.match(/rtl/i)); | |
a8 = (typeof a8 === "undefined" ? aR.id : a8); | |
if (at && aK) { | |
return false; | |
} | |
function a6() { | |
aR._wD("-- SoundManager 2 " + aR.version + (!aQ && aR.useHTML5Audio ? (aR.hasHTML5 ? " + HTML5 audio" : ", no HTML5 audio support") : "") + (!aQ ? (aR.useMovieStar ? ", MovieStar mode" : "") + (aR.useHighPerformance ? ", high performance mode, " : ", ") + ((aR.flashPollingInterval ? "custom (" + aR.flashPollingInterval + "ms)" : (aR.useFastPolling ? "fast" : "normal")) + " polling") + (aR.wmode ? ", wmode: " + aR.wmode : "") + (aR.debugFlash ? ", flash debug mode" : "") + (aR.useFlashBlock ? ", flashBlock mode" : "") : "") + " --", 1); | |
} | |
if (aQ) { | |
J(); | |
a6(); | |
aR.oMC = W(aR.movieID); | |
aw(); | |
at = true; | |
aK = true; | |
return false; | |
} | |
at = true; | |
J(); | |
aR.url = h(aR._overHTTP ? a7 : a1); | |
aX = aR.url; | |
aR.wmode = (!aR.wmode && aR.useHighPerformance && !aR.useMovieStar ? "transparent" : aR.wmode); | |
if (aR.wmode !== null && (aa.match(/msie 8/i) || (!f && !aR.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) { | |
aR.specialWmodeCase = true; | |
z("spcWmode"); | |
aR.wmode = null; | |
} | |
ba = { | |
name: a8, | |
id: a8, | |
src: aX, | |
width: aT, | |
height: aT, | |
quality: "high", | |
allowScriptAccess: aR.allowScriptAccess, | |
bgcolor: aR.bgColor, | |
pluginspage: aR._http + "//www.macromedia.com/go/getflashplayer", | |
type: "application/x-shockwave-flash", | |
wmode: aR.wmode, | |
hasPriority: "true" | |
}; | |
if (aR.debugFlash) { | |
ba.FlashVars = "debug=1"; | |
} | |
if (!aR.wmode) { | |
delete ba.wmode; | |
} | |
if (f) { | |
aY = aD.createElement("div"); | |
a3 = '<object id="' + a8 + '" data="' + aX + '" type="' + ba.type + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + aR._http + '//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="' + ba.width + '" height="' + ba.height + '"><param name="movie" value="' + aX + '" /><param name="AllowScriptAccess" value="' + aR.allowScriptAccess + '" /><param name="quality" value="' + ba.quality + '" />' + (aR.wmode ? '<param name="wmode" value="' + aR.wmode + '" /> ' : "") + '<param name="bgcolor" value="' + aR.bgColor + '" />' + (aR.debugFlash ? '<param name="FlashVars" value="' + ba.FlashVars + '" />' : "") + "</object>"; | |
} else { | |
aY = aD.createElement("embed"); | |
for (bb in ba) { | |
if (ba.hasOwnProperty(bb)) { | |
aY.setAttribute(bb, ba[bb]); | |
} | |
} | |
} | |
E(); | |
a4 = I(); | |
a5 = an(); | |
if (a5) { | |
aR.oMC = W(aR.movieID) ? W(aR.movieID) : aD.createElement("div"); | |
if (!aR.oMC.id) { | |
aR.oMC.id = aR.movieID; | |
aR.oMC.className = aR.swfCSS.swfDefault + " " + a4; | |
aZ = null; | |
a0 = null; | |
if (!aR.useFlashBlock) { | |
if (aR.useHighPerformance) { | |
aZ = { | |
position: "fixed", | |
width: "8px", | |
height: "8px", | |
bottom: "0px", | |
left: "0px", | |
overflow: "hidden" | |
}; | |
} else { | |
aZ = { | |
position: "absolute", | |
width: "6px", | |
height: "6px", | |
top: "-9999px", | |
left: "-9999px" | |
}; | |
if (aU) { | |
aZ.left = Math.abs(parseInt(aZ.left, 10)) + "px"; | |
} | |
} | |
} | |
if (n) { | |
aR.oMC.style.zIndex = 10000; | |
} | |
if (!aR.debugFlash) { | |
for (aV in aZ) { | |
if (aZ.hasOwnProperty(aV)) { | |
aR.oMC.style[aV] = aZ[aV]; | |
} | |
} | |
} | |
try { | |
if (!f) { | |
aR.oMC.appendChild(aY); | |
} | |
a5.appendChild(aR.oMC); | |
if (f) { | |
a0 = aR.oMC.appendChild(aD.createElement("div")); | |
a0.className = aR.swfCSS.swfBox; | |
a0.innerHTML = a3; | |
} | |
aK = true; | |
} catch (a9) { | |
throw new Error(X("appXHTML")); | |
} | |
} else { | |
bc = aR.oMC.className; | |
aR.oMC.className = (bc ? bc + " " : aR.swfCSS.swfDefault) + (a4 ? " " + a4 : ""); | |
aR.oMC.appendChild(aY); | |
if (f) { | |
a0 = aR.oMC.appendChild(aD.createElement("div")); | |
a0.className = aR.swfCSS.swfBox; | |
a0.innerHTML = a3; | |
} | |
aK = true; | |
} | |
} | |
if (a2) { | |
aR._wD(a2); | |
} | |
a6(); | |
aR._wD(ao + "createMovie(): Trying to load " + aX + (!aR._overHTTP && aR.altURL ? " (alternate URL)" : ""), 1); | |
return true; | |
}; | |
ad = this.getSoundById; | |
s = function () { | |
if (aQ) { | |
aH(); | |
return false; | |
} | |
if (aR.o) { | |
return false; | |
} | |
aR.o = aR.getMovie(aR.id); | |
if (!aR.o) { | |
if (!o) { | |
aH(aR.id, aR.url); | |
} else { | |
if (!f) { | |
aR.oMC.appendChild(o); | |
} else { | |
aR.oMC.innerHTML = aq; | |
} | |
o = null; | |
at = true; | |
} | |
aR.o = aR.getMovie(aR.id); | |
} | |
if (aR.o) { | |
aR._wD(ao + "initMovie(): Got " + aR.o.nodeName + " element (" + (at ? "created via JS" : "static HTML") + ")"); | |
z("waitEI"); | |
} | |
if (aR.oninitmovie instanceof Function) { | |
setTimeout(aR.oninitmovie, 1); | |
} | |
return true; | |
}; | |
au = function (aT) { | |
if (aT) { | |
aR.url = aT; | |
} | |
s(); | |
}; | |
ah = function () { | |
setTimeout(t, 500); | |
}; | |
t = function () { | |
if (aS) { | |
return false; | |
} | |
aS = true; | |
r.remove(k, "load", ah); | |
if (ab && !aE) { | |
z("waitFocus"); | |
return false; | |
} | |
var aT; | |
if (!aI) { | |
aT = aR.getMoviePercent(); | |
aR._wD(X("waitImpatient", (aT === 100 ? " (SWF loaded)" : (aT > 0 ? " (SWF " + aT + "% loaded)" : "")))); | |
} | |
setTimeout(function () { | |
aT = aR.getMoviePercent(); | |
if (!aI) { | |
aR._wD(aA + ": No Flash response within expected time.\nLikely causes: " + (aT === 0 ? "Loading " + aR.movieURL + " may have failed (and/or Flash " + e + "+ not present?), " : "") + "Flash blocked or JS-Flash security error." + (aR.debugFlash ? " " + X("checkSWF") : ""), 2); | |
if (!aR._overHTTP && aT) { | |
z("localFail", 2); | |
if (!aR.debugFlash) { | |
z("tryDebug", 2); | |
} | |
} | |
if (aT === 0) { | |
aR._wD(X("swf404", aR.url)); | |
} | |
af("flashtojs", false, ": Timed out" + aR._overHTTP ? " (Check flash security or flash blockers)" : " (No plugin/missing SWF?)"); | |
} | |
if (!aI && G) { | |
if (aT === null) { | |
if (aR.useFlashBlock || aR.flashLoadTimeout === 0) { | |
if (aR.useFlashBlock) { | |
i(); | |
} | |
z("waitForever"); | |
} else { | |
am(true); | |
} | |
} else { | |
if (aR.flashLoadTimeout === 0) { | |
z("waitForever"); | |
} else { | |
am(true); | |
} | |
} | |
} | |
}, aR.flashLoadTimeout); | |
}; | |
au = function (aT) { | |
if (aT) { | |
aR.url = aT; | |
} | |
s(); | |
}; | |
z = function (aU, aT) { | |
if (!aU) { | |
return ""; | |
} else { | |
return aR._wD(X(aU), aT); | |
} | |
}; | |
if (l.indexOf("debug=alert") + 1 && aR.debugMode) { | |
aR._wD = function (aT) { | |
c.alert(aT); | |
}; | |
} | |
x = function () { | |
var aU = W(aR.debugID), | |
aT = W(aR.debugID + "-toggle"); | |
if (!aU) { | |
return false; | |
} | |
if (m) { | |
aT.innerHTML = "+"; | |
aU.style.display = "none"; | |
} else { | |
aT.innerHTML = "-"; | |
aU.style.display = "block"; | |
} | |
m = !m; | |
}; | |
af = function (aW, aT, aU) { | |
if (typeof sm2Debugger !== "undefined") { | |
try { | |
sm2Debugger.handleEvent(aW, aT, aU); | |
} catch (aV) {} | |
} | |
return true; | |
}; | |
I = function () { | |
var aT = []; | |
if (aR.debugMode) { | |
aT.push(aR.swfCSS.sm2Debug); | |
} | |
if (aR.debugFlash) { | |
aT.push(aR.swfCSS.flashDebug); | |
} | |
if (aR.useHighPerformance) { | |
aT.push(aR.swfCSS.highPerf); | |
} | |
return aT.join(" "); | |
}; | |
i = function () { | |
var aT = X("fbHandler"), | |
aV = aR.getMoviePercent(), | |
aU = aR.swfCSS; | |
if (!aR.ok()) { | |
if (ag) { | |
aR.oMC.className = I() + " " + aU.swfDefault + " " + (aV === null ? aU.swfTimedout : aU.swfError); | |
aR._wD(aT + ": " + X("fbTimeout") + (aV ? " (" + X("fbLoaded") + ")" : "")); | |
} | |
aR.didFlashBlock = true; | |
aP({ | |
type: "ontimeout", | |
ignoreInit: true | |
}); | |
if (aR.onerror instanceof Function) { | |
aR.onerror.apply(k); | |
} | |
} else { | |
if (aR.didFlashBlock) { | |
aR._wD(aT + ": Unblocked"); | |
} | |
if (aR.oMC) { | |
aR.oMC.className = [I(), aU.swfDefault, aU.swfLoaded + (aR.didFlashBlock ? " " + aU.swfUnblocked : "")].join(" "); | |
} | |
} | |
}; | |
aB = function () { | |
function aT() { | |
r.remove(k, "focus", aB); | |
r.remove(k, "load", aB); | |
} | |
if (aE || !ab) { | |
aT(); | |
return true; | |
} | |
G = true; | |
aE = true; | |
aR._wD(ao + "handleFocus()"); | |
if (B && ab) { | |
r.remove(k, "mousemove", aB); | |
} | |
aS = false; | |
aT(); | |
return true; | |
}; | |
T = function (aU) { | |
if (aI) { | |
return false; | |
} | |
if (aQ) { | |
aR._wD("-- SoundManager 2: loaded --"); | |
aI = true; | |
aP(); | |
ap(); | |
return true; | |
} | |
var aV = aR.oMC.className, | |
aT = (aR.useFlashBlock && aR.flashLoadTimeout && !aR.getMoviePercent()); | |
if (!aT) { | |
aI = true; | |
} | |
aR._wD("-- SoundManager 2 " + (F ? "failed to load" : "loaded") + " (" + (F ? "security/load error" : "OK") + ") --", 1); | |
if (F || aU) { | |
if (aR.useFlashBlock) { | |
aR.oMC.className = I() + " " + (aR.getMoviePercent() === null ? aR.swfCSS.swfTimedout : aR.swfCSS.swfError); | |
} | |
aP({ | |
type: "ontimeout" | |
}); | |
af("onload", false); | |
if (aR.onerror instanceof Function) { | |
aR.onerror.apply(k); | |
} | |
return false; | |
} else { | |
af("onload", true); | |
} | |
r.add(k, "unload", ac); | |
if (aR.waitForWindowLoad && !u) { | |
z("waitOnload"); | |
r.add(k, "load", ap); | |
return false; | |
} else { | |
if (aR.waitForWindowLoad && u) { | |
z("docLoaded"); | |
} | |
ap(); | |
} | |
return true; | |
}; | |
aL = function (aV, aU, aT) { | |
if (typeof aj[aV] === "undefined") { | |
aj[aV] = []; | |
} | |
aj[aV].push({ | |
method: aU, | |
scope: (aT || null), | |
fired: false | |
}); | |
}; | |
aP = function (aY) { | |
if (!aY) { | |
aY = { | |
type: "onready" | |
}; | |
} | |
if (!aI && aY && !aY.ignoreInit) { | |
return false; | |
} | |
var aV = { | |
success: (aY && aY.ignoreInit ? aR.ok() : !F) | |
}, | |
aU = (aY && aY.type ? aj[aY.type] || [] : []), | |
aT = [], | |
aZ, aX, aW = (ag && aR.useFlashBlock && !aR.ok()); | |
for (aZ = 0; aZ < aU.length; aZ++) { | |
if (aU[aZ].fired !== true) { | |
aT.push(aU[aZ]); | |
} | |
} | |
if (aT.length) { | |
aR._wD(aA + ": Firing " + aT.length + " " + aY.type + "() item" + (aT.length === 1 ? "" : "s")); | |
for (aZ = 0, aX = aT.length; aZ < aX; aZ++) { | |
if (aT[aZ].scope) { | |
aT[aZ].method.apply(aT[aZ].scope, [aV]); | |
} else { | |
aT[aZ].method(aV); | |
} | |
if (!aW) { | |
aT[aZ].fired = true; | |
} | |
} | |
} | |
return true; | |
}; | |
ap = function () { | |
k.setTimeout(function () { | |
if (aR.useFlashBlock) { | |
i(); | |
} | |
aP(); | |
if (aR.onload instanceof Function) { | |
z("onload", 1); | |
aR.onload.apply(k); | |
z("onloadOK", 1); | |
} | |
if (aR.waitForWindowLoad) { | |
r.add(k, "load", ap); | |
} | |
}, 1); | |
}; | |
aN = function () { | |
if (g !== undefined) { | |
return g; | |
} | |
var aT = false, | |
a0 = navigator, | |
aW = a0.plugins, | |
aZ, aV, aU, aY = k.ActiveXObject; | |
if (aW && aW.length) { | |
aV = "application/x-shockwave-flash"; | |
aU = a0.mimeTypes; | |
if (aU && aU[aV] && aU[aV].enabledPlugin && aU[aV].enabledPlugin.description) { | |
aT = true; | |
} | |
} else { | |
if (typeof aY !== "undefined") { | |
try { | |
aZ = new aY("ShockwaveFlash.ShockwaveFlash"); | |
} catch (aX) {} | |
aT = ( !! aZ); | |
} | |
} | |
g = aT; | |
return aT; | |
}; | |
ae = function () { | |
var aV, aU, aT = (aa.match(/iphone os (1|2|3_0|3_1)/i) ? true : false); | |
if (aT) { | |
aR.hasHTML5 = false; | |
aQ = true; | |
if (aR.oMC) { | |
aR.oMC.style.display = "none"; | |
} | |
return false; | |
} | |
if (aR.useHTML5Audio) { | |
if (!aR.html5 || !aR.html5.canPlayType) { | |
aR._wD("SoundManager: No HTML5 Audio() support detected."); | |
aR.hasHTML5 = false; | |
return true; | |
} else { | |
aR.hasHTML5 = true; | |
} | |
if (al) { | |
aR._wD(ao + "Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - " + (!g ? " would use flash fallback for MP3/MP4, but none detected." : "will use flash fallback for MP3/MP4, if available"), 1); | |
if (aN()) { | |
return true; | |
} | |
} | |
} else { | |
return true; | |
} | |
for (aU in aR.audioFormats) { | |
if (aR.audioFormats.hasOwnProperty(aU) && aR.audioFormats[aU].required && !aR.html5.canPlayType(aR.audioFormats[aU].type)) { | |
aV = true; | |
} | |
} | |
if (aR.ignoreFlash) { | |
aV = false; | |
} | |
aQ = (aR.useHTML5Audio && aR.hasHTML5 && !aV && !aR.requireFlash); | |
return (aN() && aV); | |
}; | |
aw = function () { | |
var aV, aU = []; | |
z("init"); | |
if (aI) { | |
z("didInit"); | |
return false; | |
} | |
function aT() { | |
r.remove(k, "load", aR.beginDelayedInit); | |
} | |
if (aR.hasHTML5) { | |
for (aV in aR.audioFormats) { | |
if (aR.audioFormats.hasOwnProperty(aV)) { | |
aU.push(aV + ": " + aR.html5[aV]); | |
} | |
} | |
aR._wD("-- SoundManager 2: HTML5 support tests (" + aR.html5Test + "): " + aU.join(", ") + " --", 1); | |
} | |
if (aQ) { | |
if (!aI) { | |
aT(); | |
aR.enabled = true; | |
T(); | |
} | |
return true; | |
} | |
s(); | |
try { | |
z("flashJS"); | |
aR.o._externalInterfaceTest(false); | |
if (!aR.allowPolling) { | |
z("noPolling", 1); | |
} else { | |
ak(true, aR.flashPollingInterval ? aR.flashPollingInterval : (aR.useFastPolling ? 10 : 50)); | |
} | |
if (!aR.debugMode) { | |
aR.o._disableDebug(); | |
} | |
aR.enabled = true; | |
af("jstoflash", true); | |
} catch (aW) { | |
aR._wD("js/flash exception: " + aW.toString()); | |
af("jstoflash", false); | |
am(true); | |
T(); | |
return false; | |
} | |
T(); | |
aT(); | |
return true; | |
}; | |
S = function () { | |
if (C) { | |
return false; | |
} | |
aH(); | |
s(); | |
C = true; | |
return true; | |
}; | |
aM = function () { | |
if (ax) { | |
return false; | |
} | |
ax = true; | |
E(); | |
if (!aR.useHTML5Audio) { | |
if (!aN()) { | |
aR._wD("SoundManager: No Flash detected, trying HTML5"); | |
aR.useHTML5Audio = true; | |
} | |
} | |
aO(); | |
aR.html5.usingFlash = ae(); | |
ag = aR.html5.usingFlash; | |
ax = true; | |
if (aD.removeEventListener) { | |
aD.removeEventListener("DOMContentLoaded", aM, false); | |
} | |
au(); | |
return true; | |
}; | |
v = function (aT) { | |
if (!aT._hasTimer) { | |
aT._hasTimer = true; | |
} | |
}; | |
Q = function (aT) { | |
if (aT._hasTimer) { | |
aT._hasTimer = false; | |
} | |
}; | |
ay = function () { | |
if (aR.onerror instanceof Function) { | |
aR.onerror(); | |
} | |
aR.disable(); | |
}; | |
Y = function () { | |
if (!al || !aN()) { | |
return false; | |
} | |
var aT = aR.audioFormats, | |
aU, aV; | |
for (aV in aT) { | |
if (aT.hasOwnProperty(aV)) { | |
if (aV === "mp3" || aV === "mp4") { | |
aR._wD(aA + ": Using flash fallback for " + aV + " format"); | |
aR.html5[aV] = false; | |
if (aT[aV] && aT[aV].related) { | |
for (aU = aT[aV].related.length; aU--;) { | |
aR.html5[aT[aV].related[aU]] = false; | |
} | |
} | |
} | |
} | |
} | |
}; | |
this._setSandboxType = function (aT) { | |
var aU = aR.sandbox; | |
aU.type = aT; | |
aU.description = aU.types[(typeof aU.types[aT] !== "undefined" ? aT : "unknown")]; | |
aR._wD("Flash security sandbox type: " + aU.type); | |
if (aU.type === "localWithFile") { | |
aU.noRemote = true; | |
aU.noLocal = false; | |
z("secNote", 2); | |
} else { | |
if (aU.type === "localWithNetwork") { | |
aU.noRemote = false; | |
aU.noLocal = true; | |
} else { | |
if (aU.type === "localTrusted") { | |
aU.noRemote = false; | |
aU.noLocal = false; | |
} | |
} | |
} | |
}; | |
this._externalInterfaceOK = function (aT) { | |
if (aR.swfLoaded) { | |
return false; | |
} | |
var aU = new Date().getTime(); | |
aR._wD(ao + "externalInterfaceOK()" + (aT ? " (~" + (aU - aT) + " ms)" : "")); | |
af("swf", true); | |
af("flashtojs", true); | |
aR.swfLoaded = true; | |
ab = false; | |
if (al) { | |
Y(); | |
} | |
if (f) { | |
setTimeout(aw, 100); | |
} else { | |
aw(); | |
} | |
}; | |
P = function () { | |
if (aD.readyState === "complete") { | |
aM(); | |
aD.detachEvent("onreadystatechange", P); | |
} | |
return true; | |
}; | |
if (!aR.hasHTML5 || ag) { | |
r.add(k, "focus", aB); | |
r.add(k, "load", aB); | |
r.add(k, "load", ah); | |
if (B && ab) { | |
r.add(k, "mousemove", aB); | |
} | |
} | |
if (aD.addEventListener) { | |
aD.addEventListener("DOMContentLoaded", aM, false); | |
} else { | |
if (aD.attachEvent) { | |
aD.attachEvent("onreadystatechange", P); | |
} else { | |
af("onload", false); | |
ay(); | |
} | |
} | |
if (aD.readyState === "complete") { | |
setTimeout(aM, 100); | |
} | |
} | |
if (typeof SM2_DEFER === "undefined" || !SM2_DEFER) { | |
b = new a(); | |
} | |
c.SoundManager = a; | |
c.soundManager = b; | |
}(window)); | |
jQuery.cookie = function (d, e, b) { | |
if (arguments.length > 1 && String(e) !== "[object Object]") { | |
b = jQuery.extend({}, b); | |
if (e === null || e === undefined) { | |
b.expires = -1; | |
} | |
if (typeof b.expires === "number") { | |
var g = b.expires, | |
c = b.expires = new Date(); | |
c.setDate(c.getDate() + g); | |
} | |
e = String(e); | |
return (document.cookie = [encodeURIComponent(d), "=", b.raw ? e : encodeURIComponent(e), b.expires ? "; expires=" + b.expires.toUTCString() : "", b.path ? "; path=" + b.path : "", b.domain ? "; domain=" + b.domain : "", b.secure ? "; secure" : ""].join("")); | |
} | |
b = e || {}; | |
var a, f = b.raw ? | |
function (h) { | |
return h; | |
} : decodeURIComponent; | |
return (a = new RegExp("(?:^|; )" + encodeURIComponent(d) + "=([^;]*)").exec(document.cookie)) ? f(a[1]) : null; | |
}; | |
(function (d) { | |
var c = function (g, f) { | |
return (g << f) | (g >>> (32 - f)); | |
}; | |
var b = function (j) { | |
var f = ""; | |
var g; | |
var k; | |
var h; | |
for (g = 0; g <= 6; g += 2) { | |
k = (j >>> (g * 4 + 4)) & 15; | |
h = (j >>> (g * 4)) & 15; | |
f += k.toString(16) + h.toString(16); | |
} | |
return f; | |
}; | |
var a = function (j) { | |
var g = ""; | |
var h; | |
var f; | |
for (h = 7; h >= 0; h--) { | |
f = (j >>> (h * 4)) & 15; | |
g += f.toString(16); | |
} | |
return g; | |
}; | |
var e = function (g) { | |
g = g.replace(/\x0d\x0a/g, "\x0a"); | |
var f = ""; | |
for (var i = 0; i < g.length; i++) { | |
var h = g.charCodeAt(i); | |
if (h < 128) { | |
f += String.fromCharCode(h); | |
} else { | |
if ((h > 127) && (h < 2048)) { | |
f += String.fromCharCode((h >> 6) | 192); | |
f += String.fromCharCode((h & 63) | 128); | |
} else { | |
f += String.fromCharCode((h >> 12) | 224); | |
f += String.fromCharCode(((h >> 6) & 63) | 128); | |
f += String.fromCharCode((h & 63) | 128); | |
} | |
} | |
} | |
return f; | |
}; | |
d.extend({ | |
sha1: function (f) { | |
var l; | |
var x, w; | |
var g = new Array(80); | |
var o = 1732584193; | |
var n = 4023233417; | |
var m = 2562383102; | |
var k = 271733878; | |
var h = 3285377520; | |
var v, t, s, r, q; | |
var y; | |
f = e(f); | |
var p = f.length; | |
var u = new Array(); | |
for (x = 0; x < p - 3; x += 4) { | |
w = f.charCodeAt(x) << 24 | f.charCodeAt(x + 1) << 16 | f.charCodeAt(x + 2) << 8 | f.charCodeAt(x + 3); | |
u.push(w); | |
} | |
switch (p % 4) { | |
case 0: | |
x = 2147483648; | |
break; | |
case 1: | |
x = f.charCodeAt(p - 1) << 24 | 8388608; | |
break; | |
case 2: | |
x = f.charCodeAt(p - 2) << 24 | f.charCodeAt(p - 1) << 16 | 32768; | |
break; | |
case 3: | |
x = f.charCodeAt(p - 3) << 24 | f.charCodeAt(p - 2) << 16 | f.charCodeAt(p - 1) << 8 | 128; | |
break; | |
} | |
u.push(x); | |
while ((u.length % 16) != 14) { | |
u.push(0); | |
} | |
u.push(p >>> 29); | |
u.push((p << 3) & 4294967295); | |
for (l = 0; l < u.length; l += 16) { | |
for (x = 0; x < 16; x++) { | |
g[x] = u[l + x]; | |
} | |
for (x = 16; x <= 79; x++) { | |
g[x] = c(g[x - 3] ^ g[x - 8] ^ g[x - 14] ^ g[x - 16], 1); | |
} | |
v = o; | |
t = n; | |
s = m; | |
r = k; | |
q = h; | |
for (x = 0; x <= 19; x++) { | |
y = (c(v, 5) + ((t & s) | (~t & r)) + q + g[x] + 1518500249) & 4294967295; | |
q = r; | |
r = s; | |
s = c(t, 30); | |
t = v; | |
v = y; | |
} | |
for (x = 20; x <= 39; x++) { | |
y = (c(v, 5) + (t ^ s ^ r) + q + g[x] + 1859775393) & 4294967295; | |
q = r; | |
r = s; | |
s = c(t, 30); | |
t = v; | |
v = y; | |
} | |
for (x = 40; x <= 59; x++) { | |
y = (c(v, 5) + ((t & s) | (t & r) | (s & r)) + q + g[x] + 2400959708) & 4294967295; | |
q = r; | |
r = s; | |
s = c(t, 30); | |
t = v; | |
v = y; | |
} | |
for (x = 60; x <= 79; x++) { | |
y = (c(v, 5) + (t ^ s ^ r) + q + g[x] + 3395469782) & 4294967295; | |
q = r; | |
r = s; | |
s = c(t, 30); | |
t = v; | |
v = y; | |
} | |
o = (o + v) & 4294967295; | |
n = (n + t) & 4294967295; | |
m = (m + s) & 4294967295; | |
k = (k + r) & 4294967295; | |
h = (h + q) & 4294967295; | |
} | |
var y = a(o) + a(n) + a(m) + a(k) + a(h); | |
return y.toLowerCase(); | |
} | |
}); | |
})(jQuery); | |
var EventHelpers = new function () { | |
var me = this; | |
var safariTimer; | |
var isSafari = /WebKit/i.test(navigator.userAgent); | |
var globalEvent; | |
me.init = function () { | |
if (me.hasPageLoadHappened(arguments)) { | |
return; | |
} | |
if (document.createEventObject) { | |
globalEvent = document.createEventObject(); | |
} else { | |
if (document.createEvent) { | |
globalEvent = document.createEvent("HTMLEvents"); | |
} | |
} | |
me.docIsLoaded = true; | |
}; | |
me.addEvent = function (obj, evType, fn) { | |
if (obj.addEventListener) { | |
obj.addEventListener(evType, fn, false); | |
} else { | |
if (obj.attachEvent) { | |
obj["e" + evType + fn] = fn; | |
obj[evType + fn] = function () { | |
obj["e" + evType + fn](self.event); | |
}; | |
obj.attachEvent("on" + evType, obj[evType + fn]); | |
} | |
} | |
}; | |
me.removeEvent = function (obj, evType, fn) { | |
if (obj.removeEventListener) { | |
obj.removeEventListener(evType, fn, false); | |
} else { | |
if (obj.detachEvent) { | |
try { | |
obj.detachEvent("on" + evType, obj[evType + fn]); | |
obj[evType + fn] = null; | |
obj["e" + evType + fn] = null; | |
} catch (ex) {} | |
} | |
} | |
}; | |
function removeEventAttribute(obj, beginName) { | |
var attributes = obj.attributes; | |
for (var i = 0; i < attributes.length; i++) { | |
var attribute = attributes[i]; | |
var name = attribute.name; | |
if (name.indexOf(beginName) == 0) { | |
attribute.specified = false; | |
} | |
} | |
} | |
me.addScrollWheelEvent = function (obj, fn) { | |
if (obj.addEventListener) { | |
obj.addEventListener("DOMMouseScroll", fn, true); | |
} | |
if (obj.attachEvent) { | |
obj.attachEvent("onmousewheel", fn); | |
} | |
}; | |
me.removeScrollWheelEvent = function (obj, fn) { | |
if (obj.removeEventListener) { | |
obj.removeEventListener("DOMMouseScroll", fn, true); | |
} | |
if (obj.detachEvent) { | |
obj.detatchEvent("onmousewheel", fn); | |
} | |
}; | |
me.getMouseX = function (e) { | |
if (!e) { | |
return; | |
} | |
if (e.pageX != null) { | |
return e.pageX; | |
} else { | |
if (window.event != null && window.event.clientX != null && document.body != null && document.body.scrollLeft != null) { | |
return window.event.clientX + document.body.scrollLeft; | |
} else { | |
if (e.clientX != null) { | |
return e.clientX; | |
} else { | |
return null; | |
} | |
} | |
} | |
}; | |
me.getMouseY = function (e) { | |
if (e.pageY != null) { | |
return e.pageY; | |
} else { | |
if (window.event != null && window.event.clientY != null && document.body != null && document.body.scrollTop != null) { | |
return window.event.clientY + document.body.scrollTop; | |
} else { | |
if (e.clientY != null) { | |
return e.clientY; | |
} | |
} | |
} | |
}; | |
me.getScrollWheelDelta = function (e) { | |
var delta = 0; | |
if (!e) { | |
e = window.event; | |
} | |
if (e.wheelDelta) { | |
delta = e.wheelDelta / 120; | |
if (window.opera) { | |
delta = -delta; | |
} | |
} else { | |
if (e.detail) { | |
delta = -e.detail / 3; | |
} | |
} | |
return delta; | |
}; | |
me.addMouseEvent = function (func) { | |
if (document.captureEvents) { | |
document.captureEvents(Event.MOUSEMOVE); | |
} | |
document.onmousemove = func; | |
window.onmousemove = func; | |
window.onmouseover = func; | |
}; | |
me.getEventTarget = function (e) { | |
if (e.toElement) { | |
return e.toElement; | |
} else { | |
if (e.currentTarget) { | |
return e.currentTarget; | |
} else { | |
if (e.srcElement) { | |
return e.srcElement; | |
} else { | |
return null; | |
} | |
} | |
} | |
}; | |
me.getKey = function (e) { | |
if (e.keyCode) { | |
return e.keyCode; | |
} else { | |
if (e.event && e.event.keyCode) { | |
return window.event.keyCode; | |
} else { | |
if (e.which) { | |
return e.which; | |
} | |
} | |
} | |
}; | |
me.addPageLoadEvent = function (funcName) { | |
var func = eval(funcName); /*@cc_on @*/ | |
/*@if (@_win32) | |
pageLoadEventArray.push(func); | |
return; | |
/*@end @*/ | |
if (isSafari) { | |
pageLoadEventArray.push(func); | |
if (!safariTimer) { | |
safariTimer = setInterval(function () { | |
if (/loaded|complete/.test(document.readyState)) { | |
clearInterval(safariTimer); | |
me.runPageLoadEvents(); | |
return; | |
} | |
set = true; | |
}, 10); | |
} | |
} else { | |
if (document.addEventListener) { | |
var x = document.addEventListener("DOMContentLoaded", func, null); | |
} else { | |
me.addEvent(window, "load", func); | |
} | |
} | |
}; | |
var pageLoadEventArray = new Array(); | |
me.runPageLoadEvents = function (e) { | |
if (isSafari || e.srcElement.readyState == "complete") { | |
for (var i = 0; i < pageLoadEventArray.length; i++) { | |
pageLoadEventArray[i](); | |
} | |
} | |
}; | |
me.hasPageLoadHappened = function (funcArgs) { | |
if (funcArgs.callee.done) { | |
return true; | |
} | |
funcArgs.callee.done = true; | |
}; | |
me.preventDefault = function (e) { | |
if (e.preventDefault) { | |
e.preventDefault(); | |
} | |
try { | |
e.returnValue = false; | |
} catch (ex) {} | |
}; | |
me.cancelBubble = function (e) { | |
if (e.stopPropagation) { | |
e.stopPropagation(); | |
} | |
try { | |
e.cancelBubble = true; | |
} catch (ex) {} | |
}; | |
me.fireEvent = function (element, event, options) { | |
if (!element) { | |
return; | |
} | |
if (document.createEventObject) { | |
return element.fireEvent("on" + event, globalEvent); | |
jslog.debug("ss"); | |
} else { | |
globalEvent.initEvent(event, true, true); | |
return !element.dispatchEvent(globalEvent); | |
} | |
}; | |
function init() { /*@cc_on @*/ | |
/*@if (@_win32) | |
document.write('<script id="__ie_onload" defer src="' + | |
((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>'); | |
var script = document.getElementById("__ie_onload"); | |
me.addEvent(script, 'readystatechange', me.runPageLoadEvents); | |
/*@end @*/ | |
} | |
init(); | |
}; | |
EventHelpers.addPageLoadEvent("EventHelpers.init"); | |
eval(function (h, b, j, f, g, i) { | |
g = function (a) { | |
return (a < b ? "" : g(parseInt(a / b))) + ((a = a % b) > 35 ? String.fromCharCode(a + 29) : a.toString(36)); | |
}; | |
if (!"".replace(/^/, String)) { | |
while (j--) { | |
i[g(j)] = f[j] || g(j); | |
} | |
f = [function (a) { | |
return i[a]; | |
}]; | |
g = function () { | |
return "\\w+"; | |
}; | |
j = 1; | |
} | |
while (j--) { | |
if (f[j]) { | |
h = h.replace(new RegExp("\\b" + g(j) + "\\b", "g"), f[j]); | |
} | |
} | |
return h; | |
}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();', 62, 190, "|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try".split("|"), 0, {})); | |
eval(function (h, b, i, d, g, f) { | |
g = function (a) { | |
return (a < b ? "" : g(parseInt(a / b))) + ((a = a % b) > 35 ? String.fromCharCode(a + 29) : a.toString(36)); | |
}; | |
if (!"".replace(/^/, String)) { | |
while (i--) { | |
f[g(i)] = d[i] || g(i); | |
} | |
d = [function (a) { | |
return f[a]; | |
}]; | |
g = function () { | |
return "\\w+"; | |
}; | |
i = 1; | |
} | |
while (i--) { | |
if (d[i]) { | |
h = h.replace(new RegExp("\\b" + g(i) + "\\b", "g"), d[i]); | |
} | |
} | |
return h; | |
}("9 17={3i:'0.1.3',16:1e-6};l v(){}v.23={e:l(i){8(i<1||i>7.4.q)?w:7.4[i-1]},2R:l(){8 7.4.q},1u:l(){8 F.1x(7.2u(7))},24:l(a){9 n=7.4.q;9 V=a.4||a;o(n!=V.q){8 1L}J{o(F.13(7.4[n-1]-V[n-1])>17.16){8 1L}}H(--n);8 2x},1q:l(){8 v.u(7.4)},1b:l(a){9 b=[];7.28(l(x,i){b.19(a(x,i))});8 v.u(b)},28:l(a){9 n=7.4.q,k=n,i;J{i=k-n;a(7.4[i],i+1)}H(--n)},2q:l(){9 r=7.1u();o(r===0){8 7.1q()}8 7.1b(l(x){8 x/r})},1C:l(a){9 V=a.4||a;9 n=7.4.q,k=n,i;o(n!=V.q){8 w}9 b=0,1D=0,1F=0;7.28(l(x,i){b+=x*V[i-1];1D+=x*x;1F+=V[i-1]*V[i-1]});1D=F.1x(1D);1F=F.1x(1F);o(1D*1F===0){8 w}9 c=b/(1D*1F);o(c<-1){c=-1}o(c>1){c=1}8 F.37(c)},1m:l(a){9 b=7.1C(a);8(b===w)?w:(b<=17.16)},34:l(a){9 b=7.1C(a);8(b===w)?w:(F.13(b-F.1A)<=17.16)},2k:l(a){9 b=7.2u(a);8(b===w)?w:(F.13(b)<=17.16)},2j:l(a){9 V=a.4||a;o(7.4.q!=V.q){8 w}8 7.1b(l(x,i){8 x+V[i-1]})},2C:l(a){9 V=a.4||a;o(7.4.q!=V.q){8 w}8 7.1b(l(x,i){8 x-V[i-1]})},22:l(k){8 7.1b(l(x){8 x*k})},x:l(k){8 7.22(k)},2u:l(a){9 V=a.4||a;9 i,2g=0,n=7.4.q;o(n!=V.q){8 w}J{2g+=7.4[n-1]*V[n-1]}H(--n);8 2g},2f:l(a){9 B=a.4||a;o(7.4.q!=3||B.q!=3){8 w}9 A=7.4;8 v.u([(A[1]*B[2])-(A[2]*B[1]),(A[2]*B[0])-(A[0]*B[2]),(A[0]*B[1])-(A[1]*B[0])])},2A:l(){9 m=0,n=7.4.q,k=n,i;J{i=k-n;o(F.13(7.4[i])>F.13(m)){m=7.4[i]}}H(--n);8 m},2Z:l(x){9 a=w,n=7.4.q,k=n,i;J{i=k-n;o(a===w&&7.4[i]==x){a=i+1}}H(--n);8 a},3g:l(){8 S.2X(7.4)},2d:l(){8 7.1b(l(x){8 F.2d(x)})},2V:l(x){8 7.1b(l(y){8(F.13(y-x)<=17.16)?x:y})},1o:l(a){o(a.K){8 a.1o(7)}9 V=a.4||a;o(V.q!=7.4.q){8 w}9 b=0,2b;7.28(l(x,i){2b=x-V[i-1];b+=2b*2b});8 F.1x(b)},3a:l(a){8 a.1h(7)},2T:l(a){8 a.1h(7)},1V:l(t,a){9 V,R,x,y,z;2S(7.4.q){27 2:V=a.4||a;o(V.q!=2){8 w}R=S.1R(t).4;x=7.4[0]-V[0];y=7.4[1]-V[1];8 v.u([V[0]+R[0][0]*x+R[0][1]*y,V[1]+R[1][0]*x+R[1][1]*y]);1I;27 3:o(!a.U){8 w}9 C=a.1r(7).4;R=S.1R(t,a.U).4;x=7.4[0]-C[0];y=7.4[1]-C[1];z=7.4[2]-C[2];8 v.u([C[0]+R[0][0]*x+R[0][1]*y+R[0][2]*z,C[1]+R[1][0]*x+R[1][1]*y+R[1][2]*z,C[2]+R[2][0]*x+R[2][1]*y+R[2][2]*z]);1I;2P:8 w}},1t:l(a){o(a.K){9 P=7.4.2O();9 C=a.1r(P).4;8 v.u([C[0]+(C[0]-P[0]),C[1]+(C[1]-P[1]),C[2]+(C[2]-(P[2]||0))])}1d{9 Q=a.4||a;o(7.4.q!=Q.q){8 w}8 7.1b(l(x,i){8 Q[i-1]+(Q[i-1]-x)})}},1N:l(){9 V=7.1q();2S(V.4.q){27 3:1I;27 2:V.4.19(0);1I;2P:8 w}8 V},2n:l(){8'['+7.4.2K(', ')+']'},26:l(a){7.4=(a.4||a).2O();8 7}};v.u=l(a){9 V=25 v();8 V.26(a)};v.i=v.u([1,0,0]);v.j=v.u([0,1,0]);v.k=v.u([0,0,1]);v.2J=l(n){9 a=[];J{a.19(F.2F())}H(--n);8 v.u(a)};v.1j=l(n){9 a=[];J{a.19(0)}H(--n);8 v.u(a)};l S(){}S.23={e:l(i,j){o(i<1||i>7.4.q||j<1||j>7.4[0].q){8 w}8 7.4[i-1][j-1]},33:l(i){o(i>7.4.q){8 w}8 v.u(7.4[i-1])},2E:l(j){o(j>7.4[0].q){8 w}9 a=[],n=7.4.q,k=n,i;J{i=k-n;a.19(7.4[i][j-1])}H(--n);8 v.u(a)},2R:l(){8{2D:7.4.q,1p:7.4[0].q}},2D:l(){8 7.4.q},1p:l(){8 7.4[0].q},24:l(a){9 M=a.4||a;o(1g(M[0][0])=='1f'){M=S.u(M).4}o(7.4.q!=M.q||7.4[0].q!=M[0].q){8 1L}9 b=7.4.q,15=b,i,G,10=7.4[0].q,j;J{i=15-b;G=10;J{j=10-G;o(F.13(7.4[i][j]-M[i][j])>17.16){8 1L}}H(--G)}H(--b);8 2x},1q:l(){8 S.u(7.4)},1b:l(a){9 b=[],12=7.4.q,15=12,i,G,10=7.4[0].q,j;J{i=15-12;G=10;b[i]=[];J{j=10-G;b[i][j]=a(7.4[i][j],i+1,j+1)}H(--G)}H(--12);8 S.u(b)},2i:l(a){9 M=a.4||a;o(1g(M[0][0])=='1f'){M=S.u(M).4}8(7.4.q==M.q&&7.4[0].q==M[0].q)},2j:l(a){9 M=a.4||a;o(1g(M[0][0])=='1f'){M=S.u(M).4}o(!7.2i(M)){8 w}8 7.1b(l(x,i,j){8 x+M[i-1][j-1]})},2C:l(a){9 M=a.4||a;o(1g(M[0][0])=='1f'){M=S.u(M).4}o(!7.2i(M)){8 w}8 7.1b(l(x,i,j){8 x-M[i-1][j-1]})},2B:l(a){9 M=a.4||a;o(1g(M[0][0])=='1f'){M=S.u(M).4}8(7.4[0].q==M.q)},22:l(a){o(!a.4){8 7.1b(l(x){8 x*a})}9 b=a.1u?2x:1L;9 M=a.4||a;o(1g(M[0][0])=='1f'){M=S.u(M).4}o(!7.2B(M)){8 w}9 d=7.4.q,15=d,i,G,10=M[0].q,j;9 e=7.4[0].q,4=[],21,20,c;J{i=15-d;4[i]=[];G=10;J{j=10-G;21=0;20=e;J{c=e-20;21+=7.4[i][c]*M[c][j]}H(--20);4[i][j]=21}H(--G)}H(--d);9 M=S.u(4);8 b?M.2E(1):M},x:l(a){8 7.22(a)},32:l(a,b,c,d){9 e=[],12=c,i,G,j;9 f=7.4.q,1p=7.4[0].q;J{i=c-12;e[i]=[];G=d;J{j=d-G;e[i][j]=7.4[(a+i-1)%f][(b+j-1)%1p]}H(--G)}H(--12);8 S.u(e)},31:l(){9 a=7.4.q,1p=7.4[0].q;9 b=[],12=1p,i,G,j;J{i=1p-12;b[i]=[];G=a;J{j=a-G;b[i][j]=7.4[j][i]}H(--G)}H(--12);8 S.u(b)},1y:l(){8(7.4.q==7.4[0].q)},2A:l(){9 m=0,12=7.4.q,15=12,i,G,10=7.4[0].q,j;J{i=15-12;G=10;J{j=10-G;o(F.13(7.4[i][j])>F.13(m)){m=7.4[i][j]}}H(--G)}H(--12);8 m},2Z:l(x){9 a=w,12=7.4.q,15=12,i,G,10=7.4[0].q,j;J{i=15-12;G=10;J{j=10-G;o(7.4[i][j]==x){8{i:i+1,j:j+1}}}H(--G)}H(--12);8 w},30:l(){o(!7.1y){8 w}9 a=[],n=7.4.q,k=n,i;J{i=k-n;a.19(7.4[i][i])}H(--n);8 v.u(a)},1K:l(){9 M=7.1q(),1c;9 n=7.4.q,k=n,i,1s,1n=7.4[0].q,p;J{i=k-n;o(M.4[i][i]==0){2e(j=i+1;j<k;j++){o(M.4[j][i]!=0){1c=[];1s=1n;J{p=1n-1s;1c.19(M.4[i][p]+M.4[j][p])}H(--1s);M.4[i]=1c;1I}}}o(M.4[i][i]!=0){2e(j=i+1;j<k;j++){9 a=M.4[j][i]/M.4[i][i];1c=[];1s=1n;J{p=1n-1s;1c.19(p<=i?0:M.4[j][p]-M.4[i][p]*a)}H(--1s);M.4[j]=1c}}}H(--n);8 M},3h:l(){8 7.1K()},2z:l(){o(!7.1y()){8 w}9 M=7.1K();9 a=M.4[0][0],n=M.4.q-1,k=n,i;J{i=k-n+1;a=a*M.4[i][i]}H(--n);8 a},3f:l(){8 7.2z()},2y:l(){8(7.1y()&&7.2z()===0)},2Y:l(){o(!7.1y()){8 w}9 a=7.4[0][0],n=7.4.q-1,k=n,i;J{i=k-n+1;a+=7.4[i][i]}H(--n);8 a},3e:l(){8 7.2Y()},1Y:l(){9 M=7.1K(),1Y=0;9 a=7.4.q,15=a,i,G,10=7.4[0].q,j;J{i=15-a;G=10;J{j=10-G;o(F.13(M.4[i][j])>17.16){1Y++;1I}}H(--G)}H(--a);8 1Y},3d:l(){8 7.1Y()},2W:l(a){9 M=a.4||a;o(1g(M[0][0])=='1f'){M=S.u(M).4}9 T=7.1q(),1p=T.4[0].q;9 b=T.4.q,15=b,i,G,10=M[0].q,j;o(b!=M.q){8 w}J{i=15-b;G=10;J{j=10-G;T.4[i][1p+j]=M[i][j]}H(--G)}H(--b);8 T},2w:l(){o(!7.1y()||7.2y()){8 w}9 a=7.4.q,15=a,i,j;9 M=7.2W(S.I(a)).1K();9 b,1n=M.4[0].q,p,1c,2v;9 c=[],2c;J{i=a-1;1c=[];b=1n;c[i]=[];2v=M.4[i][i];J{p=1n-b;2c=M.4[i][p]/2v;1c.19(2c);o(p>=15){c[i].19(2c)}}H(--b);M.4[i]=1c;2e(j=0;j<i;j++){1c=[];b=1n;J{p=1n-b;1c.19(M.4[j][p]-M.4[i][p]*M.4[j][i])}H(--b);M.4[j]=1c}}H(--a);8 S.u(c)},3c:l(){8 7.2w()},2d:l(){8 7.1b(l(x){8 F.2d(x)})},2V:l(x){8 7.1b(l(p){8(F.13(p-x)<=17.16)?x:p})},2n:l(){9 a=[];9 n=7.4.q,k=n,i;J{i=k-n;a.19(v.u(7.4[i]).2n())}H(--n);8 a.2K('\\n')},26:l(a){9 i,4=a.4||a;o(1g(4[0][0])!='1f'){9 b=4.q,15=b,G,10,j;7.4=[];J{i=15-b;G=4[i].q;10=G;7.4[i]=[];J{j=10-G;7.4[i][j]=4[i][j]}H(--G)}H(--b);8 7}9 n=4.q,k=n;7.4=[];J{i=k-n;7.4.19([4[i]])}H(--n);8 7}};S.u=l(a){9 M=25 S();8 M.26(a)};S.I=l(n){9 a=[],k=n,i,G,j;J{i=k-n;a[i]=[];G=k;J{j=k-G;a[i][j]=(i==j)?1:0}H(--G)}H(--n);8 S.u(a)};S.2X=l(a){9 n=a.q,k=n,i;9 M=S.I(n);J{i=k-n;M.4[i][i]=a[i]}H(--n);8 M};S.1R=l(b,a){o(!a){8 S.u([[F.1H(b),-F.1G(b)],[F.1G(b),F.1H(b)]])}9 d=a.1q();o(d.4.q!=3){8 w}9 e=d.1u();9 x=d.4[0]/e,y=d.4[1]/e,z=d.4[2]/e;9 s=F.1G(b),c=F.1H(b),t=1-c;8 S.u([[t*x*x+c,t*x*y-s*z,t*x*z+s*y],[t*x*y+s*z,t*y*y+c,t*y*z-s*x],[t*x*z-s*y,t*y*z+s*x,t*z*z+c]])};S.3b=l(t){9 c=F.1H(t),s=F.1G(t);8 S.u([[1,0,0],[0,c,-s],[0,s,c]])};S.39=l(t){9 c=F.1H(t),s=F.1G(t);8 S.u([[c,0,s],[0,1,0],[-s,0,c]])};S.38=l(t){9 c=F.1H(t),s=F.1G(t);8 S.u([[c,-s,0],[s,c,0],[0,0,1]])};S.2J=l(n,m){8 S.1j(n,m).1b(l(){8 F.2F()})};S.1j=l(n,m){9 a=[],12=n,i,G,j;J{i=n-12;a[i]=[];G=m;J{j=m-G;a[i][j]=0}H(--G)}H(--12);8 S.u(a)};l 14(){}14.23={24:l(a){8(7.1m(a)&&7.1h(a.K))},1q:l(){8 14.u(7.K,7.U)},2U:l(a){9 V=a.4||a;8 14.u([7.K.4[0]+V[0],7.K.4[1]+V[1],7.K.4[2]+(V[2]||0)],7.U)},1m:l(a){o(a.W){8 a.1m(7)}9 b=7.U.1C(a.U);8(F.13(b)<=17.16||F.13(b-F.1A)<=17.16)},1o:l(a){o(a.W){8 a.1o(7)}o(a.U){o(7.1m(a)){8 7.1o(a.K)}9 N=7.U.2f(a.U).2q().4;9 A=7.K.4,B=a.K.4;8 F.13((A[0]-B[0])*N[0]+(A[1]-B[1])*N[1]+(A[2]-B[2])*N[2])}1d{9 P=a.4||a;9 A=7.K.4,D=7.U.4;9 b=P[0]-A[0],2a=P[1]-A[1],29=(P[2]||0)-A[2];9 c=F.1x(b*b+2a*2a+29*29);o(c===0)8 0;9 d=(b*D[0]+2a*D[1]+29*D[2])/c;9 e=1-d*d;8 F.13(c*F.1x(e<0?0:e))}},1h:l(a){9 b=7.1o(a);8(b!==w&&b<=17.16)},2T:l(a){8 a.1h(7)},1v:l(a){o(a.W){8 a.1v(7)}8(!7.1m(a)&&7.1o(a)<=17.16)},1U:l(a){o(a.W){8 a.1U(7)}o(!7.1v(a)){8 w}9 P=7.K.4,X=7.U.4,Q=a.K.4,Y=a.U.4;9 b=X[0],1z=X[1],1B=X[2],1T=Y[0],1S=Y[1],1M=Y[2];9 c=P[0]-Q[0],2s=P[1]-Q[1],2r=P[2]-Q[2];9 d=-b*c-1z*2s-1B*2r;9 e=1T*c+1S*2s+1M*2r;9 f=b*b+1z*1z+1B*1B;9 g=1T*1T+1S*1S+1M*1M;9 h=b*1T+1z*1S+1B*1M;9 k=(d*g/f+h*e)/(g-h*h);8 v.u([P[0]+k*b,P[1]+k*1z,P[2]+k*1B])},1r:l(a){o(a.U){o(7.1v(a)){8 7.1U(a)}o(7.1m(a)){8 w}9 D=7.U.4,E=a.U.4;9 b=D[0],1l=D[1],1k=D[2],1P=E[0],1O=E[1],1Q=E[2];9 x=(1k*1P-b*1Q),y=(b*1O-1l*1P),z=(1l*1Q-1k*1O);9 N=v.u([x*1Q-y*1O,y*1P-z*1Q,z*1O-x*1P]);9 P=11.u(a.K,N);8 P.1U(7)}1d{9 P=a.4||a;o(7.1h(P)){8 v.u(P)}9 A=7.K.4,D=7.U.4;9 b=D[0],1l=D[1],1k=D[2],1w=A[0],18=A[1],1a=A[2];9 x=b*(P[1]-18)-1l*(P[0]-1w),y=1l*((P[2]||0)-1a)-1k*(P[1]-18),z=1k*(P[0]-1w)-b*((P[2]||0)-1a);9 V=v.u([1l*x-1k*z,1k*y-b*x,b*z-1l*y]);9 k=7.1o(P)/V.1u();8 v.u([P[0]+V.4[0]*k,P[1]+V.4[1]*k,(P[2]||0)+V.4[2]*k])}},1V:l(t,a){o(1g(a.U)=='1f'){a=14.u(a.1N(),v.k)}9 R=S.1R(t,a.U).4;9 C=a.1r(7.K).4;9 A=7.K.4,D=7.U.4;9 b=C[0],1E=C[1],1J=C[2],1w=A[0],18=A[1],1a=A[2];9 x=1w-b,y=18-1E,z=1a-1J;8 14.u([b+R[0][0]*x+R[0][1]*y+R[0][2]*z,1E+R[1][0]*x+R[1][1]*y+R[1][2]*z,1J+R[2][0]*x+R[2][1]*y+R[2][2]*z],[R[0][0]*D[0]+R[0][1]*D[1]+R[0][2]*D[2],R[1][0]*D[0]+R[1][1]*D[1]+R[1][2]*D[2],R[2][0]*D[0]+R[2][1]*D[1]+R[2][2]*D[2]])},1t:l(a){o(a.W){9 A=7.K.4,D=7.U.4;9 b=A[0],18=A[1],1a=A[2],2N=D[0],1l=D[1],1k=D[2];9 c=7.K.1t(a).4;9 d=b+2N,2h=18+1l,2o=1a+1k;9 Q=a.1r([d,2h,2o]).4;9 e=[Q[0]+(Q[0]-d)-c[0],Q[1]+(Q[1]-2h)-c[1],Q[2]+(Q[2]-2o)-c[2]];8 14.u(c,e)}1d o(a.U){8 7.1V(F.1A,a)}1d{9 P=a.4||a;8 14.u(7.K.1t([P[0],P[1],(P[2]||0)]),7.U)}},1Z:l(a,b){a=v.u(a);b=v.u(b);o(a.4.q==2){a.4.19(0)}o(b.4.q==2){b.4.19(0)}o(a.4.q>3||b.4.q>3){8 w}9 c=b.1u();o(c===0){8 w}7.K=a;7.U=v.u([b.4[0]/c,b.4[1]/c,b.4[2]/c]);8 7}};14.u=l(a,b){9 L=25 14();8 L.1Z(a,b)};14.X=14.u(v.1j(3),v.i);14.Y=14.u(v.1j(3),v.j);14.Z=14.u(v.1j(3),v.k);l 11(){}11.23={24:l(a){8(7.1h(a.K)&&7.1m(a))},1q:l(){8 11.u(7.K,7.W)},2U:l(a){9 V=a.4||a;8 11.u([7.K.4[0]+V[0],7.K.4[1]+V[1],7.K.4[2]+(V[2]||0)],7.W)},1m:l(a){9 b;o(a.W){b=7.W.1C(a.W);8(F.13(b)<=17.16||F.13(F.1A-b)<=17.16)}1d o(a.U){8 7.W.2k(a.U)}8 w},2k:l(a){9 b=7.W.1C(a.W);8(F.13(F.1A/2-b)<=17.16)},1o:l(a){o(7.1v(a)||7.1h(a)){8 0}o(a.K){9 A=7.K.4,B=a.K.4,N=7.W.4;8 F.13((A[0]-B[0])*N[0]+(A[1]-B[1])*N[1]+(A[2]-B[2])*N[2])}1d{9 P=a.4||a;9 A=7.K.4,N=7.W.4;8 F.13((A[0]-P[0])*N[0]+(A[1]-P[1])*N[1]+(A[2]-(P[2]||0))*N[2])}},1h:l(a){o(a.W){8 w}o(a.U){8(7.1h(a.K)&&7.1h(a.K.2j(a.U)))}1d{9 P=a.4||a;9 A=7.K.4,N=7.W.4;9 b=F.13(N[0]*(A[0]-P[0])+N[1]*(A[1]-P[1])+N[2]*(A[2]-(P[2]||0)));8(b<=17.16)}},1v:l(a){o(1g(a.U)=='1f'&&1g(a.W)=='1f'){8 w}8!7.1m(a)},1U:l(a){o(!7.1v(a)){8 w}o(a.U){9 A=a.K.4,D=a.U.4,P=7.K.4,N=7.W.4;9 b=(N[0]*(P[0]-A[0])+N[1]*(P[1]-A[1])+N[2]*(P[2]-A[2]))/(N[0]*D[0]+N[1]*D[1]+N[2]*D[2]);8 v.u([A[0]+D[0]*b,A[1]+D[1]*b,A[2]+D[2]*b])}1d o(a.W){9 c=7.W.2f(a.W).2q();9 N=7.W.4,A=7.K.4,O=a.W.4,B=a.K.4;9 d=S.1j(2,2),i=0;H(d.2y()){i++;d=S.u([[N[i%3],N[(i+1)%3]],[O[i%3],O[(i+1)%3]]])}9 e=d.2w().4;9 x=N[0]*A[0]+N[1]*A[1]+N[2]*A[2];9 y=O[0]*B[0]+O[1]*B[1]+O[2]*B[2];9 f=[e[0][0]*x+e[0][1]*y,e[1][0]*x+e[1][1]*y];9 g=[];2e(9 j=1;j<=3;j++){g.19((i==j)?0:f[(j+(5-i)%3)%3])}8 14.u(g,c)}},1r:l(a){9 P=a.4||a;9 A=7.K.4,N=7.W.4;9 b=(A[0]-P[0])*N[0]+(A[1]-P[1])*N[1]+(A[2]-(P[2]||0))*N[2];8 v.u([P[0]+N[0]*b,P[1]+N[1]*b,(P[2]||0)+N[2]*b])},1V:l(t,a){9 R=S.1R(t,a.U).4;9 C=a.1r(7.K).4;9 A=7.K.4,N=7.W.4;9 b=C[0],1E=C[1],1J=C[2],1w=A[0],18=A[1],1a=A[2];9 x=1w-b,y=18-1E,z=1a-1J;8 11.u([b+R[0][0]*x+R[0][1]*y+R[0][2]*z,1E+R[1][0]*x+R[1][1]*y+R[1][2]*z,1J+R[2][0]*x+R[2][1]*y+R[2][2]*z],[R[0][0]*N[0]+R[0][1]*N[1]+R[0][2]*N[2],R[1][0]*N[0]+R[1][1]*N[1]+R[1][2]*N[2],R[2][0]*N[0]+R[2][1]*N[1]+R[2][2]*N[2]])},1t:l(a){o(a.W){9 A=7.K.4,N=7.W.4;9 b=A[0],18=A[1],1a=A[2],2M=N[0],2L=N[1],2Q=N[2];9 c=7.K.1t(a).4;9 d=b+2M,2p=18+2L,2m=1a+2Q;9 Q=a.1r([d,2p,2m]).4;9 e=[Q[0]+(Q[0]-d)-c[0],Q[1]+(Q[1]-2p)-c[1],Q[2]+(Q[2]-2m)-c[2]];8 11.u(c,e)}1d o(a.U){8 7.1V(F.1A,a)}1d{9 P=a.4||a;8 11.u(7.K.1t([P[0],P[1],(P[2]||0)]),7.W)}},1Z:l(a,b,c){a=v.u(a);a=a.1N();o(a===w){8 w}b=v.u(b);b=b.1N();o(b===w){8 w}o(1g(c)=='1f'){c=w}1d{c=v.u(c);c=c.1N();o(c===w){8 w}}9 d=a.4[0],18=a.4[1],1a=a.4[2];9 e=b.4[0],1W=b.4[1],1X=b.4[2];9 f,1i;o(c!==w){9 g=c.4[0],2l=c.4[1],2t=c.4[2];f=v.u([(1W-18)*(2t-1a)-(1X-1a)*(2l-18),(1X-1a)*(g-d)-(e-d)*(2t-1a),(e-d)*(2l-18)-(1W-18)*(g-d)]);1i=f.1u();o(1i===0){8 w}f=v.u([f.4[0]/1i,f.4[1]/1i,f.4[2]/1i])}1d{1i=F.1x(e*e+1W*1W+1X*1X);o(1i===0){8 w}f=v.u([b.4[0]/1i,b.4[1]/1i,b.4[2]/1i])}7.K=a;7.W=f;8 7}};11.u=l(a,b,c){9 P=25 11();8 P.1Z(a,b,c)};11.2I=11.u(v.1j(3),v.k);11.2H=11.u(v.1j(3),v.i);11.2G=11.u(v.1j(3),v.j);11.36=11.2I;11.35=11.2H;11.3j=11.2G;9 $V=v.u;9 $M=S.u;9 $L=14.u;9 $P=11.u;", 62, 206, "||||elements|||this|return|var||||||||||||function|||if||length||||create|Vector|null|||||||||Math|nj|while||do|anchor||||||||Matrix||direction||normal||||kj|Plane|ni|abs|Line|ki|precision|Sylvester|A2|push|A3|map|els|else||undefined|typeof|contains|mod|Zero|D3|D2|isParallelTo|kp|distanceFrom|cols|dup|pointClosestTo|np|reflectionIn|modulus|intersects|A1|sqrt|isSquare|X2|PI|X3|angleFrom|mod1|C2|mod2|sin|cos|break|C3|toRightTriangular|false|Y3|to3D|E2|E1|E3|Rotation|Y2|Y1|intersectionWith|rotate|v12|v13|rank|setVectors|nc|sum|multiply|prototype|eql|new|setElements|case|each|PA3|PA2|part|new_element|round|for|cross|product|AD2|isSameSizeAs|add|isPerpendicularTo|v22|AN3|inspect|AD3|AN2|toUnitVector|PsubQ3|PsubQ2|v23|dot|divisor|inverse|true|isSingular|determinant|max|canMultiplyFromLeft|subtract|rows|col|random|ZX|YZ|XY|Random|join|N2|N1|D1|slice|default|N3|dimensions|switch|liesIn|translate|snapTo|augment|Diagonal|trace|indexOf|diagonal|transpose|minor|row|isAntiparallelTo|ZY|YX|acos|RotationZ|RotationY|liesOn|RotationX|inv|rk|tr|det|toDiagonalMatrix|toUpperTriangular|version|XZ".split("|"), 0, {})); | |
if (!document.querySelectorAll) { | |
document.querySelectorAll = cssQuery; | |
} | |
var cssSandpaper = new function () { | |
var A = this; | |
var n, c = new Array(); | |
var d = /[^\{]*{[^\}]*}/g; | |
var q = /[\{\}]/g; | |
var t = /gradient\([\s\S]*\)/g; | |
var u = /hsl\([\s\S]*\)/g; | |
var a = /\/\/.+?(?=\n|\r|$)|\/\*[\s\S]+?\*\//g; | |
var f = /@[^\{\};]*;|@[^\{\};]*\{[^\}]*\}/g; | |
var s = /\(\s*/g; | |
var e = new Array(); | |
var z; | |
var o; | |
var k; | |
A.init = function (B) { | |
if (EventHelpers.hasPageLoadHappened(arguments) && !B) { | |
return; | |
} | |
k = document.body; | |
o = document.createElement("div"); | |
i(); | |
b(); | |
h(); | |
m(); | |
r(); | |
v(); | |
p(); | |
y(); | |
l(); | |
}; | |
A.setOpacity = function (E, D) { | |
var C = CSS3Helpers.findProperty(document.body, "opacity"); | |
if (C == "filter") { | |
E.style.zoom = "100%"; | |
var B = CSS3Helpers.addFilter(E, "DXImageTransform.Microsoft.Alpha", StringHelpers.sprintf("opacity=%d", ((D) * 100))); | |
B.opacity = D * 100; | |
} else { | |
if (E.style[C] != null) { | |
E.style[C] = D; | |
} | |
} | |
}; | |
function y() { | |
var F = j("opacity").values; | |
for (var D in F) { | |
var E = F[D]; | |
var B = document.querySelectorAll(E.selector); | |
for (var C = 0; C < B.length; C++) { | |
A.setOpacity(B[C], E.value); | |
} | |
} | |
} | |
A.setTransform = function (E, C) { | |
var D = CSS3Helpers.findProperty(E, "transform"); | |
if (D == "filter") { | |
var B = CSS3Helpers.getTransformationMatrix(C); | |
CSS3Helpers.setMatrixFilter(E, B); | |
} else { | |
if (E.style[D] != null) { | |
E.style[D] = C; | |
} | |
} | |
}; | |
function h() { | |
var G = j("-sand-transform").values; | |
var E = CSS3Helpers.findProperty(document.body, "transform"); | |
for (var D in G) { | |
var F = G[D]; | |
var B = document.querySelectorAll(F.selector); | |
for (var C = 0; C < B.length; C++) { | |
A.setTransform(B[C], F.value); | |
} | |
} | |
} | |
A.setBoxShadow = function (F, E) { | |
var D = CSS3Helpers.findProperty(F, "boxShadow"); | |
var B = CSS3Helpers.getBoxShadowValues(E); | |
if (D == "filter") { | |
var C = CSS3Helpers.addFilter(F, "DXImageTransform.Microsoft.DropShadow", StringHelpers.sprintf("color=%s,offX=%d,offY=%d", B.color, B.offsetX, B.offsetY)); | |
C.color = B.color; | |
C.offX = B.offsetX; | |
C.offY = B.offsetY; | |
} else { | |
if (F.style[D] != null) { | |
F.style[D] = E; | |
} | |
} | |
}; | |
function m() { | |
var F = j("-sand-box-shadow").values; | |
for (var D in F) { | |
var E = F[D]; | |
var B = document.querySelectorAll(E.selector); | |
for (var C = 0; C < B.length; C++) { | |
A.setBoxShadow(B[C], E.value); | |
} | |
} | |
} | |
function g(E, B) { | |
if (B.colorStops.length == 2 && B.colorStops[0].stop == 0 && B.colorStops[1].stop == 1) { | |
var F = new RGBColor(B.colorStops[0].color); | |
var D = new RGBColor(B.colorStops[1].color); | |
F = F.toHex(); | |
D = D.toHex(); | |
var C = CSS3Helpers.addFilter(E, "DXImageTransform.Microsoft.Gradient", StringHelpers.sprintf("GradientType = %s, StartColorStr = '%s', EndColorStr = '%s'", B.IEdir, F, D)); | |
C.GradientType = B.IEdir; | |
C.StartColorStr = F; | |
C.EndColorStr = D; | |
E.style.zoom = 1; | |
} | |
} | |
A.setGradient = function (F, G) { | |
var E = CSS3Helpers.reportGradientSupport(); | |
var B = CSS3Helpers.getGradient(G); | |
if (B == null) { | |
return; | |
} | |
if (F.filters) { | |
g(F, B); | |
} else { | |
if (E == implementation.MOZILLA) { | |
F.style.backgroundImage = StringHelpers.sprintf("-moz-gradient( %s, %s, from(%s), to(%s))", B.dirBegin, B.dirEnd, B.colorStops[0].color, B.colorStops[1].color); | |
} else { | |
if (E == implementation.WEBKIT) { | |
var D = StringHelpers.sprintf("-webkit-gradient(%s, %s, %s %s, %s %s)", B.type, B.dirBegin, B.r0 ? B.r0 + ", " : "", B.dirEnd, B.r1 ? B.r1 + ", " : "", w(B.colorStops)); | |
F.style.backgroundImage = D; | |
} else { | |
if (E == implementation.CANVAS_WORKAROUND) { | |
try { | |
CSS3Helpers.applyCanvasGradient(F, B); | |
} catch (C) {} | |
} | |
} | |
} | |
} | |
}; | |
A.setRGBABackground = function (C, D) { | |
var B = CSS3Helpers.reportColorSpaceSupport("RGBA", colorType.BACKGROUND); | |
switch (B) { | |
case implementation.NATIVE: | |
C.style.value = D; | |
break; | |
case implementation.FILTER_WORKAROUND: | |
g(C, { | |
IEdir: 0, | |
colorStops: [{ | |
stop: 0, | |
color: D | |
}, { | |
stop: 1, | |
color: D | |
}] | |
}); | |
break; | |
} | |
}; | |
A.setHSLABackground = function (E, F) { | |
var C = CSS3Helpers.reportColorSpaceSupport("HSLA", colorType.BACKGROUND); | |
switch (C) { | |
case implementation.NATIVE: | |
case implementation.FILTER_WORKAROUND: | |
var D = new RGBColor(F); | |
if (D.a == 1) { | |
E.style.backgroundColor = D.toHex(); | |
} else { | |
var B = D.toRGBA(); | |
g(E, { | |
IEdir: 0, | |
colorStops: [{ | |
stop: 0, | |
color: B | |
}, { | |
stop: 1, | |
color: B | |
}] | |
}); | |
} | |
break; | |
} | |
}; | |
A.camelize = function (C) { | |
var D = ""; | |
for (var B = 0; B < C.length; B++) { | |
if (C.substring(B, B + 1) == "-") { | |
B++; | |
D += C.substring(B, B + 1).toUpperCase(); | |
} else { | |
D += C.substring(B, B + 1); | |
} | |
} | |
return D; | |
}; | |
A.setHSLColor = function (E, H, G) { | |
var D = CSS3Helpers.reportColorSpaceSupport("HSL", colorType.FOREGROUND); | |
switch (D) { | |
case implementation.NATIVE: | |
case implementation.HEX_WORKAROUND: | |
var B = G.match(u)[0]; | |
var C = new RGBColor(B).toHex(); | |
var F = G.replace(u, C); | |
E.style[A.camelize(H)] = F; | |
break; | |
} | |
}; | |
function r() { | |
var F = j("background").values.concat(j("background-image").values); | |
for (var D in F) { | |
var E = F[D]; | |
var B = document.querySelectorAll(E.selector); | |
for (var C = 0; C < B.length; C++) { | |
A.setGradient(B[C], E.value); | |
} | |
} | |
} | |
function v() { | |
var E = CSS3Helpers.reportColorSpaceSupport("RGBA", colorType.BACKGROUND); | |
if (E == implementation.NATIVE) { | |
return; | |
} | |
var G = j("background").values.concat(j("background-color").values); | |
for (var D in G) { | |
var F = G[D]; | |
var B = document.querySelectorAll(F.selector); | |
for (var C = 0; C < B.length; C++) { | |
if (F.value.indexOf("rgba(") == 0) { | |
A.setRGBABackground(B[C], F.value); | |
} else { | |
if (F.value.indexOf("hsla(") == 0 || F.value.indexOf("hsl(") == 0) { | |
A.setHSLABackground(B[C], F.value); | |
} | |
} | |
} | |
} | |
} | |
A.getProperties = function (F, E) { | |
var B = ""; | |
if (!F) { | |
return B; | |
} | |
for (var D in F) { | |
try { | |
B += E + "." + D.toString() + " = " + F[D] + ", "; | |
} catch (C) {} | |
} | |
return B; | |
}; | |
function p() { | |
var J = CSS3Helpers.reportColorSpaceSupport("HSL", colorType.FOREGROUND); | |
if (J == implementation.NATIVE) { | |
return; | |
} | |
var C = j("color").values; | |
var G = ["color", "border", "border-left", "border-right", "border-bottom", "border-top", "border-left-color", "border-right-color", "border-bottom-color", "border-top-color"]; | |
for (var F = 0; F < G.length; F++) { | |
var K = j(G[F]).values; | |
C = C.concat(K); | |
} | |
for (var F in C) { | |
var I = C[F]; | |
var B = document.querySelectorAll(I.selector); | |
for (var E = 0; E < B.length; E++) { | |
var L = (I.name.indexOf("border") == 0); | |
var D = I.value.match(u); | |
if (D) { | |
var H; | |
if (L && I.name.indexOf("-color") < 0) { | |
H = I.name; | |
} else { | |
H = I.name; | |
} | |
A.setHSLColor(B[E], H, I.value); | |
} | |
} | |
} | |
} | |
function w(B) { | |
var D = new StringBuffer(); | |
for (var C = 0; C < B.length; C++) { | |
D.append(StringHelpers.sprintf("color-stop(%s, %s)", B[C].stop, B[C].color)); | |
if (C < B.length - 1) { | |
D.append(", "); | |
} | |
} | |
return D.toString(); | |
} | |
function x(C) { | |
var B; | |
switch (C.nodeName.toLowerCase()) { | |
case "style": | |
B = StringHelpers.uncommentHTML(C.innerHTML); | |
break; | |
case "link": | |
var D = XMLHelpers.getXMLHttpRequest(C.href, null, "GET", null, false); | |
B = D.responseText; | |
break; | |
} | |
B = B.replace(a, "").replace(f, ""); | |
return B; | |
} | |
function i() { | |
n = document.querySelectorAll('style, link[rel="stylesheet"]'); | |
for (var B = 0; B < n.length; B++) { | |
if (!CSSHelpers.isMemberOfClass(n[B], "cssSandpaper-noIndex")) { | |
c.push(x(n[B])); | |
} | |
} | |
} | |
function b() { | |
for (var G = 0; G < c.length; G++) { | |
var I = c[G]; | |
rules = I.match(d); | |
if (rules) { | |
for (var F = 0; F < rules.length; F++) { | |
var C = rules[F].split(q); | |
var D = C[0].trim(); | |
var L = C[1]; | |
var J = L.split(";"); | |
for (var E = 0; E < J.length; E++) { | |
if (J[E].trim() != "") { | |
var H = J[E].split(":"); | |
var B = H[0].trim().toLowerCase(); | |
var K = H[1]; | |
if (!e[B]) { | |
e[B] = new RuleList(B); | |
} | |
if (K && typeof (e[B]) == "object") { | |
e[B].add(D, K.trim()); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
function j(B) { | |
var C = e[B]; | |
if (!C) { | |
C = new RuleList(B); | |
} | |
return C; | |
} | |
function l() { | |
var E = document.getElementsByTagName("html")[0]; | |
var C = ["transform", "opacity"]; | |
for (var B = 0; B < C.length; B++) { | |
var F = C[B]; | |
if (CSS3Helpers.supports(F)) { | |
CSSHelpers.addClass(E, "cssSandpaper-" + F); | |
} | |
} | |
var D = CSSHelpers.getElementsByClassName(document, "cssSandpaper-initiallyHidden"); | |
for (var B = 0; B < D.length; B++) { | |
CSSHelpers.removeClass(D[B], "cssSandpaper-initiallyHidden"); | |
} | |
} | |
}; | |
function RuleList(a) { | |
var b = this; | |
b.values = new Array(); | |
b.propertyName = a; | |
b.add = function (c, d) { | |
b.values.push(new CSSRule(c, b.propertyName, d)); | |
}; | |
} | |
function CSSRule(a, b, d) { | |
var c = this; | |
c.selector = a; | |
c.name = b; | |
c.value = d; | |
c.toString = function () { | |
return StringHelpers.sprintf("%s { %s: %s}", c.selector, c.name, c.value); | |
}; | |
} | |
var MatrixGenerator = new function () { | |
var c = this; | |
var b = /[a-z]+$/; | |
c.identity = $M([ | |
[1, 0, 0], | |
[0, 1, 0], | |
[0, 0, 1] | |
]); | |
function a(e) { | |
return (e - 360) * Math.PI / 180; | |
} | |
function d(h) { | |
var f = parseFloat(h); | |
var g = h.match(b); | |
if (h.trim() == "0") { | |
f = 0; | |
g = "rad"; | |
} | |
if (g.length != 1 || f == 0) { | |
return 0; | |
} | |
g = g[0]; | |
var e; | |
switch (g) { | |
case "deg": | |
e = a(f); | |
break; | |
case "rad": | |
e = f; | |
break; | |
default: | |
throw "Not an angle: " + h; | |
} | |
return e; | |
} | |
c.prettyPrint = function (e) { | |
return StringHelpers.sprintf("| %s %s %s | - | %s %s %s | - |%s %s %s|", e.e(1, 1), e.e(1, 2), e.e(1, 3), e.e(2, 1), e.e(2, 2), e.e(2, 3), e.e(3, 1), e.e(3, 2), e.e(3, 3)); | |
}; | |
c.rotate = function (f) { | |
var e = d(f); | |
return Matrix.RotationZ(e); | |
}; | |
c.scale = function (f, e) { | |
f = parseFloat(f); | |
if (!e) { | |
e = f; | |
} else { | |
e = parseFloat(e); | |
} | |
return $M([ | |
[f, 0, 0], | |
[0, e, 0], | |
[0, 0, 1] | |
]); | |
}; | |
c.scaleX = function (e) { | |
return c.scale(e, 1); | |
}; | |
c.scaleY = function (e) { | |
return c.scale(1, e); | |
}; | |
c.skew = function (g, e) { | |
var h = d(g); | |
var f; | |
if (e != null) { | |
f = d(e); | |
} else { | |
f = h; | |
} | |
if (h != null && f != null) { | |
return $M([ | |
[1, Math.tan(h), 0], | |
[Math.tan(f), 1, 0], | |
[0, 0, 1] | |
]); | |
} else { | |
return null; | |
} | |
}; | |
c.skewX = function (e) { | |
return c.skew(e, "0"); | |
}; | |
c.skewY = function (e) { | |
return c.skew("0", e); | |
}; | |
c.translate = function (g, e) { | |
var h = parseInt(g); | |
var f = parseInt(e); | |
return $M([ | |
[1, 0, h], | |
[0, 1, f], | |
[0, 0, 1] | |
]); | |
}; | |
c.translateX = function (e) { | |
return c.translate(e, 0); | |
}; | |
c.translateY = function (e) { | |
return c.translate(0, e); | |
}; | |
c.matrix = function (h, g, l, k, j, i) { | |
return $M([ | |
[h, l, parseInt(j)], | |
[g, k, parseInt(i)], | |
[0, 0, 1] | |
]); | |
}; | |
}; | |
var CSS3Helpers = new function () { | |
var me = this; | |
var reTransformListSplitter = /[a-zA-Z]+\([^\)]*\)\s*/g; | |
var reLeftBracket = /\(/g; | |
var reRightBracket = /\)/g; | |
var reComma = /,/g; | |
var reSpaces = /\s+/g; | |
var reFilterNameSplitter = /progid:([^\(]*)/g; | |
var reLinearGradient; | |
var canvas; | |
var cache = new Array(); | |
me.supports = function (cssProperty) { | |
if (CSS3Helpers.findProperty(document.body, cssProperty) != null) { | |
return true; | |
} else { | |
return false; | |
} | |
}; | |
me.getCanvas = function () { | |
if (canvas) { | |
return canvas; | |
} else { | |
canvas = document.createElement("canvas"); | |
return canvas; | |
} | |
}; | |
me.getTransformationMatrix = function (CSS3TransformProperty, doThrowIfError) { | |
var transforms = CSS3TransformProperty.match(reTransformListSplitter); | |
if (doThrowIfError) { | |
var checkString = transforms.join(" ").replace(/\s*/g, " "); | |
var normalizedCSSProp = CSS3TransformProperty.replace(/\s*/g, " "); | |
if (checkString != normalizedCSSProp) { | |
throw ("An invalid transform was given."); | |
} | |
} | |
var resultantMatrix = MatrixGenerator.identity; | |
for (var j = 0; j < transforms.length; j++) { | |
var transform = transforms[j]; | |
transform = transform.replace(reLeftBracket, '("').replace(reComma, '", "').replace(reRightBracket, '")'); | |
try { | |
var matrix = eval("MatrixGenerator." + transform); | |
resultantMatrix = resultantMatrix.x(matrix); | |
} catch (ex) { | |
if (doThrowIfError) { | |
var method = transform.split("(")[0]; | |
var funcCall = transform.replace(/\"/g, ""); | |
if (MatrixGenerator[method] == undefined) { | |
throw "Error: invalid tranform function: " + funcCall; | |
} else { | |
throw "Error: Invalid or missing parameters in function call: " + funcCall; | |
} | |
} | |
} | |
} | |
return resultantMatrix; | |
}; | |
me.getBoxShadowValues = function (propertyValue) { | |
var r = new Object(); | |
var values = propertyValue.split(reSpaces); | |
if (values[0] == "inset") { | |
r.inset = true; | |
values = values.reverse().pop().reverse(); | |
} else { | |
r.inset = false; | |
} | |
r.offsetX = parseInt(values[0]); | |
r.offsetY = parseInt(values[1]); | |
if (values.length > 3) { | |
r.blurRadius = values[2]; | |
if (values.length > 4) { | |
r.spreadRadius = values[3]; | |
} | |
} | |
r.color = values[values.length - 1]; | |
return r; | |
}; | |
me.getGradient = function (propertyValue) { | |
var r = new Object(); | |
r.colorStops = new Array(); | |
var substring = me.getBracketedSubstring(propertyValue, "-sand-gradient"); | |
if (substring == undefined) { | |
return null; | |
} | |
var parameters = substring.match(/[^\(,]+(\([^\)]*\))?[^,]*/g); | |
r.type = parameters[0].trim(); | |
if (r.type == "linear") { | |
r.dirBegin = parameters[1].trim(); | |
r.dirEnd = parameters[2].trim(); | |
var beginCoord = r.dirBegin.split(reSpaces); | |
var endCoord = r.dirEnd.split(reSpaces); | |
for (var i = 3; i < parameters.length; i++) { | |
r.colorStops.push(parseColorStop(parameters[i].trim(), i - 3)); | |
} | |
if (document.body.filters) { | |
if (r.x0 == r.x1) { | |
switch (beginCoord[1]) { | |
case "top": | |
r.IEdir = 0; | |
break; | |
case "bottom": | |
swapIndices(r.colorStops, 0, 1); | |
r.IEdir = 0; | |
break; | |
} | |
} | |
if (r.y0 == r.y1) { | |
switch (beginCoord[0]) { | |
case "left": | |
r.IEdir = 1; | |
break; | |
case "right": | |
r.IEdir = 1; | |
swapIndices(r.colorStops, 0, 1); | |
break; | |
} | |
} | |
} | |
} else { | |
if (document.body.filters) { | |
return null; | |
} | |
r.dirBegin = parameters[1].trim(); | |
r.r0 = parameters[2].trim(); | |
r.dirEnd = parameters[3].trim(); | |
r.r1 = parameters[4].trim(); | |
var beginCoord = r.dirBegin.split(reSpaces); | |
var endCoord = r.dirEnd.split(reSpaces); | |
for (var i = 5; i < parameters.length; i++) { | |
r.colorStops.push(parseColorStop(parameters[i].trim(), i - 5)); | |
} | |
} | |
r.x0 = beginCoord[0]; | |
r.y0 = beginCoord[1]; | |
r.x1 = endCoord[0]; | |
r.y1 = endCoord[1]; | |
return r; | |
}; | |
function swapIndices(array, index1, index2) { | |
var tmp = array[index1]; | |
array[index1] = array[index2]; | |
array[index2] = tmp; | |
} | |
function parseColorStop(colorStop, index) { | |
var r = new Object(); | |
var substring = me.getBracketedSubstring(colorStop, "color-stop"); | |
var from = me.getBracketedSubstring(colorStop, "from"); | |
var to = me.getBracketedSubstring(colorStop, "to"); | |
if (substring) { | |
var parameters = substring.split(","); | |
r.stop = normalizePercentage(parameters[0].trim()); | |
r.color = parameters[1].trim(); | |
} else { | |
if (from) { | |
r.stop = 0; | |
r.color = from.trim(); | |
} else { | |
if (to) { | |
r.stop = 1; | |
r.color = to.trim(); | |
} else { | |
if (index <= 1) { | |
r.color = colorStop; | |
if (index == 0) { | |
r.stop = 0; | |
} else { | |
r.stop = 1; | |
} | |
} else { | |
throw (StringHelpers.sprintf('invalid argument "%s"', colorStop)); | |
} | |
} | |
} | |
} | |
return r; | |
} | |
function normalizePercentage(s) { | |
if (s.substring(s.length - 1, s.length) == "%") { | |
return parseFloat(s) / 100 + ""; | |
} else { | |
return s; | |
} | |
} | |
me.reportGradientSupport = function () { | |
if (!cache.gradientSupport) { | |
var r; | |
var div = document.createElement("div"); | |
div.style.cssText = "background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, from(red), to(blue));"; | |
if (div.style.backgroundImage) { | |
r = implementation.WEBKIT; | |
} else { | |
var canvas = CSS3Helpers.getCanvas(); | |
if (canvas.getContext && canvas.toDataURL) { | |
r = implementation.CANVAS_WORKAROUND; | |
} else { | |
r = implementation.NONE; | |
} | |
} | |
cache.gradientSupport = r; | |
} | |
return cache.gradientSupport; | |
}; | |
me.reportColorSpaceSupport = function (colorSpace, type) { | |
if (!cache[colorSpace + type]) { | |
var r; | |
var div = document.createElement("div"); | |
switch (type) { | |
case colorType.BACKGROUND: | |
switch (colorSpace) { | |
case "RGBA": | |
div.style.cssText = "background-color: rgba(255, 32, 34, 0.5)"; | |
break; | |
case "HSL": | |
div.style.cssText = "background-color: hsl(0,0%,100%)"; | |
break; | |
case "HSLA": | |
div.style.cssText = "background-color: hsla(0,0%,100%,.5)"; | |
break; | |
default: | |
break; | |
} | |
var body = document.body; | |
if (div.style.backgroundColor) { | |
r = implementation.NATIVE; | |
} else { | |
if (body.filters && body.filters != undefined) { | |
r = implementation.FILTER_WORKAROUND; | |
} else { | |
r = implementation.NONE; | |
} | |
} | |
break; | |
case colorType.FOREGROUND: | |
switch (colorSpace) { | |
case "RGBA": | |
div.style.cssText = "color: rgba(255, 32, 34, 0.5)"; | |
break; | |
case "HSL": | |
div.style.cssText = "color: hsl(0,0%,100%)"; | |
break; | |
case "HSLA": | |
div.style.cssText = "color: hsla(0,0%,100%,.5)"; | |
break; | |
default: | |
break; | |
} | |
if (div.style.color) { | |
r = implementation.NATIVE; | |
} else { | |
if (colorSpace == "HSL") { | |
r = implementation.HEX_WORKAROUND; | |
} else { | |
r = implementation.NONE; | |
} | |
} | |
break; | |
} | |
cache[colorSpace] = r; | |
} | |
return cache[colorSpace]; | |
}; | |
me.getBracketedSubstring = function (s, header) { | |
var gradientIndex = s.indexOf(header + "("); | |
if (gradientIndex != -1) { | |
var substring = s.substring(gradientIndex); | |
var openBrackets = 1; | |
for (var i = header.length + 1; i < 100 || i < substring.length; i++) { | |
var c = substring.substring(i, i + 1); | |
switch (c) { | |
case "(": | |
openBrackets++; | |
break; | |
case ")": | |
openBrackets--; | |
break; | |
} | |
if (openBrackets == 0) { | |
break; | |
} | |
} | |
return substring.substring(gradientIndex + header.length + 1, i); | |
} | |
}; | |
me.setMatrixFilter = function (obj, matrix) { | |
if (!hasIETransformWorkaround(obj)) { | |
addIETransformWorkaround(obj); | |
} | |
var container = obj.parentNode; | |
filter = obj.filters.item("DXImageTransform.Microsoft.Matrix"); | |
filter.M11 = matrix.e(1, 1); | |
filter.M12 = matrix.e(1, 2); | |
filter.M21 = matrix.e(2, 1); | |
filter.M22 = matrix.e(2, 2); | |
var offsets = me.getIEMatrixOffsets(obj, matrix, container.xOriginalWidth, container.xOriginalHeight); | |
container.style.marginLeft = offsets.x; | |
container.style.marginTop = offsets.y; | |
container.style.marginRight = 0; | |
container.style.marginBottom = 0; | |
}; | |
me.getTransformedDimensions = function (obj, matrix) { | |
var r = {}; | |
if (hasIETransformWorkaround(obj)) { | |
r.width = obj.offsetWidth; | |
r.height = obj.offsetHeight; | |
} else { | |
var pts = [matrix.x($V([0, 0, 1])), matrix.x($V([0, obj.offsetHeight, 1])), matrix.x($V([obj.offsetWidth, 0, 1])), matrix.x($V([obj.offsetWidth, obj.offsetHeight, 1]))]; | |
var maxX = 0, | |
maxY = 0, | |
minX = 0, | |
minY = 0; | |
for (var i = 0; i < pts.length; i++) { | |
var pt = pts[i]; | |
var x = pt.e(1), | |
y = pt.e(2); | |
var minX = Math.min(minX, x); | |
var maxX = Math.max(maxX, x); | |
var minY = Math.min(minY, y); | |
var maxY = Math.max(maxY, y); | |
} | |
r.width = maxX - minX; | |
r.height = maxY - minY; | |
} | |
return r; | |
}; | |
me.getIEMatrixOffsets = function (obj, matrix, width, height) { | |
var r = {}; | |
var originalWidth = parseFloat(width); | |
var originalHeight = parseFloat(height); | |
var offset; | |
if (CSSHelpers.getComputedStyle(obj, "display") == "inline") { | |
offset = 0; | |
} else { | |
offset = 13; | |
} | |
var transformedDimensions = me.getTransformedDimensions(obj, matrix); | |
r.x = (((originalWidth - transformedDimensions.width) / 2) - offset + matrix.e(1, 3)) + "px"; | |
r.y = (((originalHeight - transformedDimensions.height) / 2) - offset + matrix.e(2, 3)) + "px"; | |
return r; | |
}; | |
function hasIETransformWorkaround(obj) { | |
return CSSHelpers.isMemberOfClass(obj.parentNode, "IETransformContainer"); | |
} | |
function addIETransformWorkaround(obj) { | |
if (!hasIETransformWorkaround(obj)) { | |
var parentNode = obj.parentNode; | |
var filter; | |
var container = document.createElement("div"); | |
CSSHelpers.addClass(container, "IETransformContainer"); | |
container.style.width = obj.offsetWidth + "px"; | |
container.style.height = obj.offsetHeight + "px"; | |
container.xOriginalWidth = obj.offsetWidth; | |
container.xOriginalHeight = obj.offsetHeight; | |
container.style.position = "absolute"; | |
container.style.zIndex = obj.currentStyle.zIndex; | |
var horizPaddingFactor = 0; | |
var vertPaddingFactor = 0; | |
if (obj.currentStyle.display == "block") { | |
container.style.left = obj.offsetLeft + 13 - horizPaddingFactor + "px"; | |
container.style.top = obj.offsetTop + 13 + -vertPaddingFactor + "px"; | |
} else { | |
container.style.left = obj.offsetLeft + "px"; | |
container.style.top = obj.offsetTop + "px"; | |
} | |
obj.style.top = "auto"; | |
obj.style.left = "auto"; | |
obj.style.bottom = "auto"; | |
obj.style.right = "auto"; | |
var replacement = obj.cloneNode(true); | |
replacement.style.visibility = "hidden"; | |
obj.replaceNode(replacement); | |
obj.style.position = "absolute"; | |
container.appendChild(obj); | |
parentNode.insertBefore(container, replacement); | |
container.style.backgroundColor = "transparent"; | |
container.style.padding = "0"; | |
filter = me.addFilter(obj, "DXImageTransform.Microsoft.Matrix", "M11=1, M12=0, M21=0, M22=1, sizingMethod='auto expand'"); | |
var bgImage = obj.currentStyle.backgroundImage.split('"')[1]; | |
} | |
} | |
me.addFilter = function (obj, filterName, filterValue) { | |
var filter; | |
try { | |
filter = obj.filters.item(filterName); | |
} catch (ex) { | |
var filterList = new MSFilterList(obj); | |
filterList.fixFilterStyle(); | |
var comma = ", "; | |
if (obj.filters.length == 0) { | |
comma = ""; | |
} | |
obj.style.filter += StringHelpers.sprintf("%sprogid:%s(%s)", comma, filterName, filterValue); | |
filter = obj.filters.item(filterName); | |
} | |
return filter; | |
}; | |
function degreesToRadians(degrees) { | |
return (degrees - 360) * Math.PI / 180; | |
} | |
me.findProperty = function (obj, type) { | |
capType = type.capitalize(); | |
var r = cache[type]; | |
if (!r) { | |
var style = obj.style; | |
var properties = [type, "Moz" + capType, "Webkit" + capType, "O" + capType, "filter"]; | |
for (var i = 0; i < properties.length; i++) { | |
if (style[properties[i]] != null) { | |
r = properties[i]; | |
break; | |
} | |
} | |
if (r == "filter" && document.body.filters == undefined) { | |
r = null; | |
} | |
cache[type] = r; | |
} | |
return r; | |
}; | |
me.parseCoordinate = function (value, max) { | |
switch (value) { | |
case "top": | |
case "left": | |
return 0; | |
case "bottom": | |
case "right": | |
return max; | |
case "center": | |
return max / 2; | |
} | |
if (value.indexOf("%") != -1) { | |
value = parseFloat(value.substr(0, value.length - 1)) / 100 * max; | |
} else { | |
value = parseFloat(value); | |
} | |
if (isNaN(value)) { | |
throw Error("Unable to parse coordinate: " + value); | |
} | |
return value; | |
}; | |
me.applyCanvasGradient = function (el, gradient) { | |
var canvas = me.getCanvas(); | |
var computedStyle = document.defaultView.getComputedStyle(el, null); | |
canvas.width = parseInt(computedStyle.width) + parseInt(computedStyle.paddingLeft) + parseInt(computedStyle.paddingRight) + 1; | |
canvas.height = parseInt(computedStyle.height) + parseInt(computedStyle.paddingTop) + parseInt(computedStyle.paddingBottom) + 2; | |
var ctx = canvas.getContext("2d"); | |
var canvasGradient; | |
if (gradient.type == "linear") { | |
canvasGradient = ctx.createLinearGradient(me.parseCoordinate(gradient.x0, canvas.width), me.parseCoordinate(gradient.y0, canvas.height), me.parseCoordinate(gradient.x1, canvas.width), me.parseCoordinate(gradient.y1, canvas.height)); | |
} else { | |
canvasGradient = ctx.createRadialGradient(me.parseCoordinate(gradient.x0, canvas.width), me.parseCoordinate(gradient.y0, canvas.height), gradient.r0, me.parseCoordinate(gradient.x1, canvas.width), me.parseCoordinate(gradient.y1, canvas.height), gradient.r1); | |
} | |
for (var i = 0; i < gradient.colorStops.length; i++) { | |
var cs = gradient.colorStops[i]; | |
canvasGradient.addColorStop(cs.stop, cs.color); | |
} | |
ctx.fillStyle = canvasGradient; | |
ctx.fillRect(0, 0, canvas.width, canvas.height); | |
el.style.backgroundImage = "url('" + canvas.toDataURL() + "')"; | |
}; | |
}; | |
function MSFilterList(d) { | |
var c = this; | |
c.list = new Array(); | |
c.node = d; | |
var a = /[\s\S]*\([\s\S]*\)/g; | |
var b = d.style; | |
function e() { | |
var h = b.filter.match(a); | |
if (h != null) { | |
for (var f = 0; f < h.length; f++) { | |
var g = h[f]; | |
c.list.push(new MSFilter(d, g)); | |
} | |
} | |
} | |
c.toString = function () { | |
var g = new StringBuffer(); | |
for (var f = 0; f < c.list.length; f++) { | |
g.append(c.list[f].toString()); | |
if (f < c.list.length - 1) { | |
g.append(","); | |
} | |
} | |
return g.toString(); | |
}; | |
c.fixFilterStyle = function () { | |
try { | |
c.node.style.filter = c.toString(); | |
} catch (f) {} | |
}; | |
e(); | |
} | |
function MSFilter(d, c) { | |
var b = this; | |
b.node = d; | |
b.filterCall = c; | |
var f = /progid:([^\(]*)/g; | |
var a = /([a-zA-Z0-9]+\s*)=/g; | |
function e() { | |
b.name = b.filterCall.match(f)[0].replace("progid:", ""); | |
var h = c.split("(")[1].replace(")", ""); | |
b.parameters = h.match(a); | |
for (var g = 0; g < b.parameters.length; g++) { | |
b.parameters[g] = b.parameters[g].replace("=", ""); | |
} | |
} | |
b.toString = function () { | |
var l = new StringBuffer(); | |
l.append(StringHelpers.sprintf("progid:%s(", b.name)); | |
for (var g = 0; g < b.parameters.length; g++) { | |
var k = b.parameters[g]; | |
var j = b.node.filters.item(b.name); | |
var h = j[k]; | |
if (typeof (h) == "string") { | |
l.append(StringHelpers.sprintf('%s="%s"', k, j[k])); | |
} else { | |
l.append(StringHelpers.sprintf("%s=%s", k, j[k])); | |
} | |
if (g != b.parameters.length - 1) { | |
l.append(", "); | |
} | |
} | |
l.append(")"); | |
return l.toString(); | |
}; | |
e(); | |
} | |
var implementation = new function () { | |
this.NONE = 0; | |
this.NATIVE = 1; | |
this.MOZILLA = 2; | |
this.WEBKIT = 3; | |
this.IE = 4; | |
this.OPERA = 5; | |
this.CANVAS_WORKAROUND = 6; | |
this.FILTER_WORKAROUND = 7; | |
this.HEX_WORKAROUND = 8; | |
}; | |
var colorType = new function () { | |
this.BACKGROUND = 0; | |
this.FOREGROUND = 1; | |
}; | |
if (!window.StringHelpers) { | |
StringHelpers = new function () { | |
var a = this; | |
a.initWhitespaceRe = /^\s\s*/; | |
a.endWhitespaceRe = /\s\s*$/; | |
a.whitespaceRe = /\s/; | |
a.sprintf = function (c) { | |
var d = function (l, j, g) { | |
var k = ""; | |
for (var h = 0; h < Math.abs(g); h++) { | |
k += j; | |
} | |
return g > 0 ? l + k : k + l; | |
}; | |
var f = function (h, l, i, g) { | |
var k = function (o, n, p) { | |
if (n >= 0) { | |
if (o.indexOf(" ") >= 0) { | |
p = " " + p; | |
} else { | |
if (o.indexOf("+") >= 0) { | |
p = "+" + p; | |
} | |
} | |
} else { | |
p = "-" + p; | |
} | |
return p; | |
}; | |
var m = parseInt(l, 10); | |
if (l.charAt(0) == "0") { | |
var j = 0; | |
if (h.indexOf(" ") >= 0 || h.indexOf("+") >= 0) { | |
j++; | |
} | |
if (i.length < (m - j)) { | |
i = d(i, "0", i.length - (m - j)); | |
} | |
return k(h, g, i); | |
} | |
i = k(h, g, i); | |
if (i.length < m) { | |
if (h.indexOf("-") < 0) { | |
i = d(i, " ", i.length - m); | |
} else { | |
i = d(i, " ", m - i.length); | |
} | |
} | |
return i; | |
}; | |
var e = new Array(); | |
e.c = function (i, j, h, g) { | |
if (typeof (g) == "number") { | |
return String.fromCharCode(g); | |
} | |
if (typeof (g) == "string") { | |
return g.charAt(0); | |
} | |
return ""; | |
}; | |
e.d = function (i, j, h, g) { | |
return e.i(i, j, h, g); | |
}; | |
e.u = function (i, j, h, g) { | |
return e.i(i, j, h, Math.abs(g)); | |
}; | |
e.i = function (i, k, h, g) { | |
var l = parseInt(h); | |
var j = ((Math.abs(g)).toString().split("."))[0]; | |
if (j.length < l) { | |
j = d(j, " ", l - j.length); | |
} | |
return f(i, k, j, g); | |
}; | |
e.E = function (i, j, h, g) { | |
return (e.e(i, j, h, g)).toUpperCase(); | |
}; | |
e.e = function (i, j, h, g) { | |
iPrecision = parseInt(h); | |
if (isNaN(iPrecision)) { | |
iPrecision = 6; | |
} | |
rs = (Math.abs(g)).toExponential(iPrecision); | |
if (rs.indexOf(".") < 0 && i.indexOf("#") >= 0) { | |
rs = rs.replace(/^(.*)(e.*)$/, "$1.$2"); | |
} | |
return f(i, j, rs, g); | |
}; | |
e.f = function (i, j, h, g) { | |
iPrecision = parseInt(h); | |
if (isNaN(iPrecision)) { | |
iPrecision = 6; | |
} | |
rs = (Math.abs(g)).toFixed(iPrecision); | |
if (rs.indexOf(".") < 0 && i.indexOf("#") >= 0) { | |
rs = rs + "."; | |
} | |
return f(i, j, rs, g); | |
}; | |
e.G = function (i, j, h, g) { | |
return (e.g(i, j, h, g)).toUpperCase(); | |
}; | |
e.g = function (i, j, h, g) { | |
iPrecision = parseInt(h); | |
absArg = Math.abs(g); | |
rse = absArg.toExponential(); | |
rsf = absArg.toFixed(6); | |
if (!isNaN(iPrecision)) { | |
rsep = absArg.toExponential(iPrecision); | |
rse = rsep.length < rse.length ? rsep : rse; | |
rsfp = absArg.toFixed(iPrecision); | |
rsf = rsfp.length < rsf.length ? rsfp : rsf; | |
} | |
if (rse.indexOf(".") < 0 && i.indexOf("#") >= 0) { | |
rse = rse.replace(/^(.*)(e.*)$/, "$1.$2"); | |
} | |
if (rsf.indexOf(".") < 0 && i.indexOf("#") >= 0) { | |
rsf = rsf + "."; | |
} | |
rs = rse.length < rsf.length ? rse : rsf; | |
return f(i, j, rs, g); | |
}; | |
e.o = function (i, k, h, g) { | |
var l = parseInt(h); | |
var j = Math.round(Math.abs(g)).toString(8); | |
if (j.length < l) { | |
j = d(j, " ", l - j.length); | |
} | |
if (i.indexOf("#") >= 0) { | |
j = "0" + j; | |
} | |
return f(i, k, j, g); | |
}; | |
e.X = function (i, j, h, g) { | |
return (e.x(i, j, h, g)).toUpperCase(); | |
}; | |
e.x = function (i, k, h, g) { | |
var l = parseInt(h); | |
g = Math.abs(g); | |
var j = Math.round(g).toString(16); | |
if (j.length < l) { | |
j = d(j, " ", l - j.length); | |
} | |
if (i.indexOf("#") >= 0) { | |
j = "0x" + j; | |
} | |
return f(i, k, j, g); | |
}; | |
e.s = function (i, k, h, g) { | |
var l = parseInt(h); | |
var j = g; | |
if (j.length > l) { | |
j = j.substring(0, l); | |
} | |
return f(i, k, j, 0); | |
}; | |
farr = c.split("%"); | |
retstr = farr[0]; | |
fpRE = /^([-+ #]*)(\d*)\.?(\d*)([cdieEfFgGosuxX])(.*)$/; | |
for (var b = 1; b < farr.length; b++) { | |
fps = fpRE.exec(farr[b]); | |
if (!fps) { | |
continue; | |
} | |
if (arguments[b] != null) { | |
retstr += e[fps[4]](fps[1], fps[2], fps[3], arguments[b]); | |
} | |
retstr += fps[5]; | |
} | |
return retstr; | |
}; | |
a.uncommentHTML = function (b) { | |
if (b.indexOf("-->") != -1 && b.indexOf("<!--") != -1) { | |
return b.replace("<!--", "").replace("-->", ""); | |
} else { | |
return b; | |
} | |
}; | |
}; | |
} | |
if (!window.XMLHelpers) { | |
XMLHelpers = new function () { | |
var a = this; | |
a.getXMLHttpRequest = function (b, e) { | |
var h = a.getXMLHttpRequest.arguments; | |
var f = a.getXMLHttpRequest.arguments.length; | |
var c = (f > 2) ? h[2] : "GET"; | |
var g = (f > 3) ? h[3] : ""; | |
var d = (f > 4) ? h[4] : true; | |
var j; | |
if (window.XMLHttpRequest) { | |
j = new XMLHttpRequest(); | |
} else { | |
if (window.ActiveXObject) { | |
try { | |
j = new ActiveXObject("Msxml2.XMLHTTP"); | |
} catch (i) { | |
j = new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
} else { | |
return null; | |
} | |
} | |
if (d) { | |
j.onreadystatechange = e; | |
} | |
if (c == "GET" && g != "") { | |
b += "?" + g; | |
} | |
j.open(c, b, d); | |
j.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); | |
j.send(g); | |
return j; | |
}; | |
}; | |
} | |
if (!window.CSSHelpers) { | |
CSSHelpers = new function () { | |
var b = this; | |
var a = new RegExp("\\s"); | |
b.getComputedStyle = function (f, e) { | |
var d; | |
if (typeof f.currentStyle != "undefined") { | |
d = f.currentStyle; | |
} else { | |
d = document.defaultView.getComputedStyle(f, null); | |
} | |
return d[e]; | |
}; | |
b.isMemberOfClass = function (f, e) { | |
if (a.test(e)) { | |
return false; | |
} | |
var d = new RegExp(c(e), "g"); | |
return (d.test(f.className)); | |
}; | |
b.addClass = function (e, d) { | |
if (a.test(d)) { | |
return; | |
} | |
if (!b.isMemberOfClass(e, d)) { | |
e.className += " " + d; | |
} | |
}; | |
b.removeClass = function (g, f) { | |
if (a.test(f)) { | |
return; | |
} | |
var e = new RegExp(c(f), "g"); | |
var d = g.className; | |
if (g.className) { | |
g.className = d.replace(e, ""); | |
} | |
}; | |
function c(d) { | |
return "\\s" + d + "\\s|^" + d + "\\s|\\s" + d + "$|^" + d + "$"; | |
} | |
b.getElementsByClassName = function (l, k) { | |
if (l.getElementsByClassName) { | |
return DOMHelpers.nodeListToArray(l.getElementsByClassName(k)); | |
} else { | |
var d = []; | |
var h = new RegExp(c(k)); | |
var g = DOMHelpers.getAllDescendants(l); | |
for (var f = 0, e = g.length; f < e; f++) { | |
if (h.test(g[f].className)) { | |
d.push(g[f]); | |
} | |
} | |
return d; | |
} | |
}; | |
function c(d) { | |
return "\\s" + d + "\\s|^" + d + "\\s|\\s" + d + "$|^" + d + "$"; | |
} | |
}; | |
} | |
String.prototype.trim = function () { | |
var b = this; | |
if (this.length > 6000) { | |
b = this.replace(StringHelpers.initWhitespaceRe, ""); | |
var a = b.length; | |
while (StringHelpers.whitespaceRe.test(b.charAt(--a))) {} | |
return b.slice(0, a + 1); | |
} else { | |
return this.replace(StringHelpers.initWhitespaceRe, "").replace(StringHelpers.endWhitespaceRe, ""); | |
} | |
}; | |
if (!window.DOMHelpers) { | |
DOMHelpers = new function () { | |
var a = this; | |
a.getAllDescendants = function (b) { | |
return b.all ? b.all : b.getElementsByTagName("*"); | |
}; | |
a.nodeListToArray = function (c) { | |
var e = []; | |
for (var d = 0, b = c.length; d < b; d++) { | |
e.push(c[d]); | |
} | |
return e; | |
}; | |
}; | |
} | |
String.prototype.capitalize = function () { | |
return this.charAt(0).toUpperCase() + this.substr(1); | |
}; | |
function StringBuffer() { | |
var b = this; | |
var a = []; | |
b.append = function (c) { | |
a.push(c); | |
return b; | |
}; | |
b.appendBuffer = function (c) { | |
a = a.concat(c); | |
}; | |
b.toString = function () { | |
return a.join(""); | |
}; | |
b.getLength = function () { | |
return a.length; | |
}; | |
b.flush = function () { | |
a.length = 0; | |
}; | |
} | |
function RGBColor(f) { | |
var g = this; | |
g.ok = false; | |
if (f.charAt(0) == "#") { | |
f = f.substr(1, 6); | |
} | |
f = f.replace(/ /g, ""); | |
f = f.toLowerCase(); | |
var c = { | |
aliceblue: "f0f8ff", | |
antiquewhite: "faebd7", | |
aqua: "00ffff", | |
aquamarine: "7fffd4", | |
azure: "f0ffff", | |
beige: "f5f5dc", | |
bisque: "ffe4c4", | |
black: "000000", | |
blanchedalmond: "ffebcd", | |
blue: "0000ff", | |
blueviolet: "8a2be2", | |
brown: "a52a2a", | |
burlywood: "deb887", | |
cadetblue: "5f9ea0", | |
chartreuse: "7fff00", | |
chocolate: "d2691e", | |
coral: "ff7f50", | |
cornflowerblue: "6495ed", | |
cornsilk: "fff8dc", | |
crimson: "dc143c", | |
cyan: "00ffff", | |
darkblue: "00008b", | |
darkcyan: "008b8b", | |
darkgoldenrod: "b8860b", | |
darkgray: "a9a9a9", | |
darkgreen: "006400", | |
darkkhaki: "bdb76b", | |
darkmagenta: "8b008b", | |
darkolivegreen: "556b2f", | |
darkorange: "ff8c00", | |
darkorchid: "9932cc", | |
darkred: "8b0000", | |
darksalmon: "e9967a", | |
darkseagreen: "8fbc8f", | |
darkslateblue: "483d8b", | |
darkslategray: "2f4f4f", | |
darkturquoise: "00ced1", | |
darkviolet: "9400d3", | |
deeppink: "ff1493", | |
deepskyblue: "00bfff", | |
dimgray: "696969", | |
dodgerblue: "1e90ff", | |
feldspar: "d19275", | |
firebrick: "b22222", | |
floralwhite: "fffaf0", | |
forestgreen: "228b22", | |
fuchsia: "ff00ff", | |
gainsboro: "dcdcdc", | |
ghostwhite: "f8f8ff", | |
gold: "ffd700", | |
goldenrod: "daa520", | |
gray: "808080", | |
green: "008000", | |
greenyellow: "adff2f", | |
honeydew: "f0fff0", | |
hotpink: "ff69b4", | |
indianred: "cd5c5c", | |
indigo: "4b0082", | |
ivory: "fffff0", | |
khaki: "f0e68c", | |
lavender: "e6e6fa", | |
lavenderblush: "fff0f5", | |
lawngreen: "7cfc00", | |
lemonchiffon: "fffacd", | |
lightblue: "add8e6", | |
lightcoral: "f08080", | |
lightcyan: "e0ffff", | |
lightgoldenrodyellow: "fafad2", | |
lightgrey: "d3d3d3", | |
lightgreen: "90ee90", | |
lightpink: "ffb6c1", | |
lightsalmon: "ffa07a", | |
lightseagreen: "20b2aa", | |
lightskyblue: "87cefa", | |
lightslateblue: "8470ff", | |
lightslategray: "778899", | |
lightsteelblue: "b0c4de", | |
lightyellow: "ffffe0", | |
lime: "00ff00", | |
limegreen: "32cd32", | |
linen: "faf0e6", | |
magenta: "ff00ff", | |
maroon: "800000", | |
mediumaquamarine: "66cdaa", | |
mediumblue: "0000cd", | |
mediumorchid: "ba55d3", | |
mediumpurple: "9370d8", | |
mediumseagreen: "3cb371", | |
mediumslateblue: "7b68ee", | |
mediumspringgreen: "00fa9a", | |
mediumturquoise: "48d1cc", | |
mediumvioletred: "c71585", | |
midnightblue: "191970", | |
mintcream: "f5fffa", | |
mistyrose: "ffe4e1", | |
moccasin: "ffe4b5", | |
navajowhite: "ffdead", | |
navy: "000080", | |
oldlace: "fdf5e6", | |
olive: "808000", | |
olivedrab: "6b8e23", | |
orange: "ffa500", | |
orangered: "ff4500", | |
orchid: "da70d6", | |
palegoldenrod: "eee8aa", | |
palegreen: "98fb98", | |
paleturquoise: "afeeee", | |
palevioletred: "d87093", | |
papayawhip: "ffefd5", | |
peachpuff: "ffdab9", | |
peru: "cd853f", | |
pink: "ffc0cb", | |
plum: "dda0dd", | |
powderblue: "b0e0e6", | |
purple: "800080", | |
red: "ff0000", | |
rosybrown: "bc8f8f", | |
royalblue: "4169e1", | |
saddlebrown: "8b4513", | |
salmon: "fa8072", | |
sandybrown: "f4a460", | |
seagreen: "2e8b57", | |
seashell: "fff5ee", | |
sienna: "a0522d", | |
silver: "c0c0c0", | |
skyblue: "87ceeb", | |
slateblue: "6a5acd", | |
slategray: "708090", | |
snow: "fffafa", | |
springgreen: "00ff7f", | |
steelblue: "4682b4", | |
tan: "d2b48c", | |
teal: "008080", | |
metle: "d8bfd8", | |
tomato: "ff6347", | |
turquoise: "40e0d0", | |
violet: "ee82ee", | |
violetred: "d02090", | |
wheat: "f5deb3", | |
white: "ffffff", | |
whitesmoke: "f5f5f5", | |
yellow: "ffff00", | |
yellowgreen: "9acd32" | |
}; | |
for (var h in c) { | |
if (f == h) { | |
f = c[h]; | |
} | |
} | |
var e = [{ | |
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, | |
example: ["rgb(123, 234, 45)", "rgb(255,234,245)"], | |
process: function (i) { | |
return [parseInt(i[1]), parseInt(i[2]), parseInt(i[3])]; | |
} | |
}, { | |
re: /^(\w{2})(\w{2})(\w{2})$/, | |
example: ["#00ff00", "336699"], | |
process: function (i) { | |
return [parseInt(i[1], 16), parseInt(i[2], 16), parseInt(i[3], 16)]; | |
} | |
}, { | |
re: /^(\w{1})(\w{1})(\w{1})$/, | |
example: ["#fb0", "f0f"], | |
process: function (i) { | |
return [parseInt(i[1] + i[1], 16), parseInt(i[2] + i[2], 16), parseInt(i[3] + i[3], 16)]; | |
} | |
}, { | |
re: /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(0{0,1}\.\d{1,}|0\.{0,}0*|1\.{0,}0*)\)$/, | |
example: ["rgba(123, 234, 45, 22)", "rgba(255, 234,245, 34)"], | |
process: function (i) { | |
return [parseInt(i[1]), parseInt(i[2]), parseInt(i[3]), parseFloat(i[4])]; | |
} | |
}, { | |
re: /^hsla\((\d{1,3}),\s*(\d{1,3}%),\s*(\d{1,3}%),\s*(0{0,1}\.\d{1,}|0\.{0,}0*|1\.{0,}0*)\)$/, | |
example: ["hsla(0,100%,50%,0.2)"], | |
process: function (m) { | |
var i = k(parseInt(m[1]), parseInt(m[2]), parseInt(m[3]), parseFloat(m[4])); | |
return [i.r, i.g, i.b, parseFloat(m[4])]; | |
} | |
}, { | |
re: /^hsl\((\d{1,3}),\s*(\d{1,3}%),\s*(\d{1,3}%)\)$/, | |
example: ["hsl(0,100%,50%)"], | |
process: function (m) { | |
var i = k(parseInt(m[1]), parseInt(m[2]), parseInt(m[3]), 1); | |
return [i.r, i.g, i.b, 1]; | |
} | |
}]; | |
for (var d = 0; d < e.length; d++) { | |
var l = e[d].re; | |
var b = e[d].process; | |
var j = l.exec(f); | |
if (j) { | |
channels = b(j); | |
g.r = channels[0]; | |
g.g = channels[1]; | |
g.b = channels[2]; | |
g.a = channels[3]; | |
g.ok = true; | |
} | |
} | |
g.r = (g.r < 0 || isNaN(g.r)) ? 0 : ((g.r > 255) ? 255 : g.r); | |
g.g = (g.g < 0 || isNaN(g.g)) ? 0 : ((g.g > 255) ? 255 : g.g); | |
g.b = (g.b < 0 || isNaN(g.b)) ? 0 : ((g.b > 255) ? 255 : g.b); | |
g.a = (isNaN(g.a)) ? 1 : ((g.a > 255) ? 255 : (g.a < 0) ? 0 : g.a); | |
g.toRGB = function () { | |
return "rgb(" + g.r + ", " + g.g + ", " + g.b + ")"; | |
}; | |
g.toRGBA = function () { | |
return "rgba(" + g.r + ", " + g.g + ", " + g.b + ", " + g.a + ")"; | |
}; | |
g.toHSV = function () { | |
var i = g.r / 255, | |
o = g.g / 255, | |
q = g.b / 255; | |
var t = Math.max(i, o, q), | |
m = Math.min(i, o, q); | |
var n, w, u = t; | |
var p = t - m; | |
w = t == 0 ? 0 : p / t; | |
if (t == m) { | |
n = 0; | |
} else { | |
switch (t) { | |
case i: | |
n = (o - q) / p + (o < q ? 6 : 0); | |
break; | |
case o: | |
n = (q - i) / p + 2; | |
break; | |
case q: | |
n = (i - o) / p + 4; | |
break; | |
} | |
n /= 6; | |
} | |
return { | |
h: n, | |
s: w, | |
v: u | |
}; | |
}; | |
function k(n, v, m) { | |
var u, t, p; | |
var i, o, q; | |
v /= 100; | |
m /= 100; | |
if (v == 0) { | |
i = o = q = (m * 255); | |
} else { | |
if (m <= 0.5) { | |
t = m * (v + 1); | |
} else { | |
t = m + v - m * v; | |
} | |
u = m * 2 - t; | |
p = n / 360; | |
i = a(u, t, p + 1 / 3); | |
o = a(u, t, p); | |
q = a(u, t, p - 1 / 3); | |
} | |
return { | |
r: Math.round(i), | |
g: Math.round(o), | |
b: Math.round(q) | |
}; | |
} | |
function a(o, n, m) { | |
var i; | |
if (m < 0) { | |
m += 1; | |
} else { | |
if (m > 1) { | |
m -= 1; | |
} | |
} | |
if (6 * m < 1) { | |
i = o + (n - o) * m * 6; | |
} else { | |
if (2 * m < 1) { | |
i = n; | |
} else { | |
if (3 * m < 2) { | |
i = o + (n - o) * (2 / 3 - m) * 6; | |
} else { | |
i = o; | |
} | |
} | |
} | |
return 255 * i; | |
} | |
g.toHex = function () { | |
var o = g.r.toString(16); | |
var n = g.g.toString(16); | |
var i = g.b.toString(16); | |
var m = Math.floor((g.a * 255)).toString(16); | |
if (o.length == 1) { | |
o = "0" + o; | |
} | |
if (n.length == 1) { | |
n = "0" + n; | |
} | |
if (i.length == 1) { | |
i = "0" + i; | |
} | |
if (m == "ff") { | |
m = ""; | |
} else { | |
if (m.length == 1) { | |
m = "0" + m; | |
} | |
} | |
return "#" + m + o + n + i; | |
}; | |
} | |
document.write('<style type="text/css">.cssSandpaper-initiallyHidden { visibility: hidden;} </style>'); | |
EventHelpers.addPageLoadEvent("cssSandpaper.init"); | |
var BLACKSWAN_FRAMERATE = 20; | |
var BLACKSWAN_ROOMDEPTH = 0.6; | |
function blackswan(c, b, a) { | |
this.div = c; | |
this.framerate = BLACKSWAN_FRAMERATE; | |
this.dancers = []; | |
this.width = b; | |
this.height = a; | |
this.div.css("width", b + "px"); | |
this.div.css("height", a + "px"); | |
this.div.css("background-color", "#cccccc"); | |
this.div.css("position", "absolute"); | |
this.div.css("overflow", "hidden"); | |
this.add_dancer = function (g, d, f, e) { | |
this.dancers.push(g); | |
if (!e) { | |
e = d[1]; | |
} | |
if (d) { | |
this.add_element(g.div, d, e); | |
} | |
if (f) { | |
this.scale(g, d[1]); | |
} | |
}; | |
this.remove_dancer = function (e) { | |
var d = $.inArray(e, this.dancers); | |
if (d != -1) { | |
this.dancers.splice(d, 1); | |
} | |
$(e.div).remove(); | |
}; | |
this.add_props = function (f) { | |
for (var d = 0; d < f.length; ++d) { | |
var e = new Image(); | |
e.src = f[d][0]; | |
this.add_element(e, [f[d][1], f[d][2]], f[d][3]); | |
} | |
}; | |
this.add_element = function (g, d, f, e) { | |
$(g).css("position", "absolute"); | |
$(g).css("left", d[0] + "px"); | |
$(g).css("top", d[1] + "px"); | |
$(g).css("z-index", f); | |
if (!e) { | |
$(g).mousedown(function (h) { | |
h.preventDefault(); | |
}); | |
} | |
this.div.append(g); | |
}; | |
this.remove_element = function (d) { | |
$(d).remove(); | |
}; | |
this.move_element = function (e, d) { | |
$(e).css("left", d[0] + "px"); | |
$(e).css("top", d[1] + "px"); | |
}; | |
this.scale = function (f, d) { | |
var e = 1 - ((1 - (d / this.height)) * BLACKSWAN_ROOMDEPTH); | |
cssSandpaper.setTransform(f.internals[0], "scale(" + e + ")"); | |
}; | |
this.start = function () { | |
this.draw(); | |
}; | |
this.draw = function () { | |
for (var d = 0; d < this.dancers.length; ++d) { | |
this.dancers[d].step(); | |
} | |
var e = this; | |
setTimeout(function () { | |
e.draw(); | |
}, 1000 / this.framerate); | |
}; | |
} | |
function blackswan_dancer(a) { | |
this.framerate = BLACKSWAN_FRAMERATE; | |
this.scene = null; | |
this.ani = null; | |
this.loop = false; | |
this.anistate = null; | |
this.layers = {}; | |
this.layerstate = {}; | |
this.div = $("<div></div>"); | |
this.div.css("position", "absolute"); | |
this.internals = $("<div></div>"); | |
this.internals.css("position", "absolute"); | |
this.div.append(this.internals); | |
this.data = a; | |
this.load_images = function () { | |
if (this.data.images) { | |
for (var b = 0; b < this.data.images.length; ++b) { | |
var c = new Image(); | |
c.src = this.data.images[b][1]; | |
var d = this.data.images[b][0]; | |
this.layers[d] = c; | |
$(c).hide(); | |
$(c).css("position", "absolute"); | |
this.internals.append(c); | |
} | |
} | |
if (this.data.offset) { | |
this.internals.css("margin-left", this.data.offset[0]); | |
this.internals.css("margin-top", this.data.offset[1]); | |
} | |
}; | |
this.load_images(); | |
this.state = function (c) { | |
for (var e in this.layers) { | |
$(this.layers[e]).hide(); | |
} | |
if (this.data.states && this.data.states[c]) { | |
var f = this.data.states[c]; | |
for (var b = 0; b < f.length; ++b) { | |
var d = $(this.layers[f[b][0]]); | |
d.css("left", f[b][1] + "px"); | |
d.css("top", f[b][2] + "px"); | |
d.css("z-index", b); | |
if (f[b][3]) { | |
cssSandpaper.setTransform(d[0], "rotate(" + f[b][3] + "deg)"); | |
} | |
d.show(); | |
} | |
} | |
}; | |
this.add_source_animation = function (c, b) { | |
if (!this.data.animations) { | |
this.data.animations = {}; | |
} | |
for (var d in b) { | |
this.data.animations[d] = b[d]; | |
} | |
}; | |
this.animation = function (b, c) { | |
if (this.data.animations && this.data.animations[b]) { | |
ani = this.data.animations[b]; | |
loop = this.data.animations[b + ".loop"]; | |
if (this.ani && !c) { | |
this.next_ani = ani; | |
this.next_loop = loop; | |
} else { | |
this.ani = ani; | |
this.loop = loop; | |
} | |
} | |
}; | |
this.step = function () { | |
if (this.ani) { | |
var g = this.ani; | |
var c = this.anistate; | |
if (!c) { | |
c = this.anistate = { | |
action: 0 | |
}; | |
} | |
var i = g[c.action]; | |
if (i) { | |
var q = 0; | |
var l = 0; | |
for (var d in i) { | |
var b = c[d]; | |
if (!b) { | |
b = c[d] = {}; | |
} | |
moves = i[d]; | |
var h = 0; | |
for (var m = 0; m < moves.length; ++m) { | |
var f = moves[m]; | |
if (!f.time) { | |
f.time = 0; | |
} | |
if (f.pause) { | |
f.time = f.pause; | |
} | |
var o = c[d]["move" + m]; | |
if (!o) { | |
o = c[d]["move" + m] = { | |
curframe: 0, | |
frames: Math.ceil(f.time * this.framerate / 1000) | |
}; | |
} | |
if (f.random && !o.rolldice) { | |
if (Math.random() > f.random) { | |
o.playaction = false; | |
} else { | |
o.playaction = true; | |
} | |
o.rolldice = true; | |
} | |
if (o.rolldice && !o.playaction) { | |
h++; | |
continue; | |
} | |
if (o.curframe > o.frames) { | |
h++; | |
continue; | |
} | |
var e = d.split(","); | |
for (var n = 0; n < e.length; ++n) { | |
var p = e[n]; | |
if (p == "div") { | |
var j = this.div[0]; | |
} else { | |
var j = this.layers[p]; | |
} | |
if (!this.layerstate[p]) { | |
this.layerstate[p] = { | |
x: $(j).position().left, | |
y: $(j).position().top, | |
rot: 0 | |
}; | |
} | |
if (f.rotate) { | |
if (o.curframe == 0) { | |
this.layerstate[p]["initial_rot"] = this.layerstate[p]["rot"]; | |
} else { | |
if (o.curframe == o.frames) { | |
this.layerstate[p]["rot"] = this.layerstate[p]["initial_rot"] + f.rotate; | |
} else { | |
this.layerstate[p]["rot"] += (f.rotate / o.frames); | |
} | |
} | |
cssSandpaper.setTransform(j, "rotate(" + this.layerstate[p]["rot"] + "deg)"); | |
} else { | |
if (f.x) { | |
if (o.curframe == 0) { | |
this.layerstate[p]["initial_x"] = this.layerstate[p]["x"]; | |
} else { | |
if (o.curframe == o.frames) { | |
this.layerstate[p]["x"] = this.layerstate[p]["initial_x"] + f.x; | |
} else { | |
this.layerstate[p]["x"] += (f.x / o.frames); | |
} | |
} | |
$(j).css("left", this.layerstate[p]["x"] + "px"); | |
} else { | |
if (f.y) { | |
if (o.curframe == 0) { | |
this.layerstate[p]["initial_y"] = this.layerstate[p]["y"]; | |
} else { | |
if (o.curframe == o.frames) { | |
this.layerstate[p]["y"] = this.layerstate[p]["initial_y"] + f.y; | |
} else { | |
this.layerstate[p]["y"] += (f.y / o.frames); | |
} | |
} | |
$(j).css("top", this.layerstate[p]["y"] + "px"); | |
} else { | |
if (f.swap) { | |
$(j).hide(); | |
$(this.layers[f.swap]).show(); | |
} else { | |
if (f.hide) { | |
$(j).hide(); | |
} else { | |
if (f.show) { | |
$(j).show(); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
c[d]["move" + m]["curframe"]++; | |
} | |
if (h == moves.length) { | |
q++; | |
} | |
l++; | |
} | |
if (q == l) { | |
var k = c.action; | |
c = this.anistate = { | |
action: ++k | |
}; | |
} | |
} else { | |
if (this.loop) { | |
c = this.anistate = { | |
action: 0 | |
}; | |
} else { | |
this.ani = null; | |
this.anistate = null; | |
} | |
} | |
} else { | |
if (this.next_ani) { | |
this.ani = this.next_ani; | |
this.loop = this.next_loop; | |
this.next_ani = null; | |
this.next_loop = null; | |
} | |
} | |
}; | |
this.stop = function () { | |
this.loop = false; | |
this.next_ani = null; | |
this.next_loop = null; | |
}; | |
}(function (b) { | |
function a(d, c) { | |
this.$element = b(d); | |
this.options = c; | |
this.enabled = true; | |
this.fixTitle(); | |
} | |
a.prototype = { | |
show: function () { | |
var f = this.getTitle(); | |
if (f && this.enabled) { | |
var e = this.tip(); | |
e.find(".tipsy-inner")[this.options.html ? "html" : "text"](f); | |
e[0].className = "tipsy"; | |
e.remove().css({ | |
top: 0, | |
left: 0, | |
visibility: "hidden", | |
display: "block" | |
}).appendTo(this.$element); | |
var i = b.extend({}, { | |
width: this.$element[0].offsetWidth, | |
height: this.$element[0].offsetHeight, | |
top: 0, | |
left: 0 | |
}); | |
var c = e[0].offsetWidth, | |
h = e[0].offsetHeight; | |
var g = (typeof this.options.gravity == "function") ? this.options.gravity.call(this.$element[0]) : this.options.gravity; | |
var d; | |
switch (g.charAt(0)) { | |
case "n": | |
d = { | |
top: i.top + i.height + this.options.offset, | |
left: i.left + i.width / 2 - c / 2 | |
}; | |
break; | |
case "s": | |
d = { | |
top: i.top - h - this.options.offset, | |
left: i.left + i.width / 2 - c / 2 | |
}; | |
break; | |
case "e": | |
d = { | |
top: i.top + i.height / 2 - h / 2, | |
left: i.left - c - this.options.offset | |
}; | |
break; | |
case "w": | |
d = { | |
top: i.top + i.height / 2 - h / 2, | |
left: i.left + i.width + this.options.offset | |
}; | |
break; | |
} | |
if (g.length == 2) { | |
if (g.charAt(1) == "w") { | |
d.left = i.left + i.width / 2 - 15; | |
} else { | |
d.left = i.left + i.width / 2 - c + 15; | |
} | |
} | |
e.css(d).addClass("tipsy-" + g); | |
if (this.options.fade) { | |
e.stop().css({ | |
opacity: 0, | |
display: "block", | |
visibility: "visible" | |
}).animate({ | |
opacity: this.options.opacity | |
}); | |
} else { | |
e.css({ | |
visibility: "visible", | |
opacity: this.options.opacity | |
}); | |
} | |
} | |
}, | |
hide: function () { | |
if (this.options.fade) { | |
this.tip().stop().fadeOut(function () { | |
b(this).remove(); | |
}); | |
} else { | |
this.tip().remove(); | |
} | |
}, | |
fixTitle: function () { | |
var c = this.$element; | |
if (c.attr("title") || typeof (c.attr("original-title")) != "string") { | |
c.attr("original-title", c.attr("title") || "").removeAttr("title"); | |
} | |
}, | |
getTitle: function () { | |
var e, c = this.$element, | |
d = this.options; | |
this.fixTitle(); | |
var e, d = this.options; | |
if (typeof d.title == "string") { | |
e = c.attr(d.title == "title" ? "original-title" : d.title); | |
} else { | |
if (typeof d.title == "function") { | |
e = d.title.call(c[0]); | |
} | |
} | |
e = ("" + e).replace(/(^\s*|\s*$)/, ""); | |
return e || d.fallback; | |
}, | |
tip: function () { | |
if (!this.$tip) { | |
this.$tip = b('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>'); | |
} | |
return this.$tip; | |
}, | |
validate: function () { | |
if (!this.$element[0].parentNode) { | |
this.hide(); | |
this.$element = null; | |
this.options = null; | |
} | |
}, | |
enable: function () { | |
this.enabled = true; | |
}, | |
disable: function () { | |
this.enabled = false; | |
}, | |
toggleEnabled: function () { | |
this.enabled = !this.enabled; | |
} | |
}; | |
b.fn.tipsy = function (g) { | |
if (g === true) { | |
return this.data("tipsy"); | |
} else { | |
if (typeof g == "string") { | |
var i = this.data("tipsy"); | |
if (i) { | |
i[g](); | |
} | |
return this; | |
} | |
} | |
g = b.extend({}, b.fn.tipsy.defaults, g); | |
function f(k) { | |
var l = b.data(k, "tipsy"); | |
if (!l) { | |
l = new a(k, b.fn.tipsy.elementOptions(k, g)); | |
b.data(k, "tipsy", l); | |
} | |
return l; | |
} | |
function j() { | |
var k = f(this); | |
k.hoverState = "in"; | |
if (g.delayIn == 0) { | |
k.show(); | |
} else { | |
k.fixTitle(); | |
setTimeout(function () { | |
if (k.hoverState == "in") { | |
k.show(); | |
} | |
}, g.delayIn); | |
} | |
} | |
function e() { | |
var k = f(this); | |
k.hoverState = "out"; | |
if (g.delayOut == 0) { | |
k.hide(); | |
} else { | |
setTimeout(function () { | |
if (k.hoverState == "out") { | |
k.hide(); | |
} | |
}, g.delayOut); | |
} | |
} | |
if (!g.live) { | |
this.each(function () { | |
f(this); | |
}); | |
} | |
if (g.trigger != "manual") { | |
var c = g.live ? "live" : "bind", | |
h = g.trigger == "hover" ? "mouseenter" : "focus", | |
d = g.trigger == "hover" ? "mouseleave" : "blur"; | |
this[c](h, j)[c](d, e); | |
} | |
return this; | |
}; | |
b.fn.tipsy.defaults = { | |
delayIn: 0, | |
delayOut: 0, | |
fade: false, | |
fallback: "", | |
gravity: "n", | |
html: false, | |
live: false, | |
offset: 0, | |
opacity: 0.8, | |
title: "title", | |
trigger: "hover" | |
}; | |
b.fn.tipsy.elementOptions = function (d, c) { | |
return b.metadata ? b.extend({}, c, b(d).metadata()) : c; | |
}; | |
b.fn.tipsy.autoNS = function () { | |
return b(this).offset().top > (b(document).scrollTop() + b(window).height() / 2) ? "s" : "n"; | |
}; | |
b.fn.tipsy.autoWE = function () { | |
return b(this).offset().left > (b(document).scrollLeft() + b(window).width() / 2) ? "e" : "w"; | |
}; | |
})(jQuery); | |
var room_props = [ | |
["https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/wallpaper.png", 0, 0, 0], | |
["https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/floor.png", 0, 176, 0], | |
["https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/dj_table.png", 8, 111, 115], | |
["https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/gauge.png", 122, 384, 10000] | |
]; | |
var room_elements = { | |
laptop_mac: "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/laptop_mac.png", | |
laptop_pc: "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/laptop_pc.png", | |
laptop_linux: "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/laptop_linux.png", | |
laptop_chrome: "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/laptop_chrome.png" | |
}; | |
var laptop_locations = [ | |
[50, 73], | |
[135, 73], | |
[220, 73], | |
[305, 73], | |
[390, 73] | |
]; | |
var record_pile_locations = [ | |
[58, 81], | |
[143, 81], | |
[228, 81], | |
[313, 81], | |
[398, 81] | |
]; | |
var becomedj_locations = [ | |
[55, 38], | |
[140, 38], | |
[225, 38], | |
[310, 38], | |
[395, 38] | |
]; | |
var dj_locations = [ | |
[70, 30], | |
[155, 30], | |
[240, 30], | |
[325, 30], | |
[410, 30] | |
]; | |
var spotlight_locations = [ | |
[5, 0], | |
[92, 0], | |
[177, 0], | |
[262, 0], | |
[347, 0] | |
]; | |
var speaker = { | |
images: [ | |
["lspeaker1", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/speaker/lspeaker1.png"], | |
["lspeaker2", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/speaker/lspeaker2.png"], | |
["lspeaker3", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/speaker/lspeaker3.png"], | |
["rspeaker1", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/speaker/rspeaker1.png"], | |
["rspeaker2", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/speaker/rspeaker2.png"], | |
["rspeaker3", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/speaker/rspeaker3.png"] | |
], | |
states: { | |
on: [ | |
["lspeaker1", 0, 0], | |
["rspeaker1", 434, 0], | |
["rspeaker2", 434, 0], | |
["rspeaker3", 434, 0] | |
], | |
off: [] | |
}, | |
animations: { | |
vibrate: [{ | |
lspeaker1: [{ | |
swap: "lspeaker2", | |
time: 50 | |
}], | |
rspeaker1: [{ | |
swap: "rspeaker2", | |
time: 50 | |
}] | |
}, { | |
lspeaker2: [{ | |
swap: "lspeaker3", | |
time: 50 | |
}], | |
rspeaker2: [{ | |
swap: "rspeaker3", | |
time: 50 | |
}] | |
}, { | |
lspeaker3: [{ | |
swap: "lspeaker1", | |
time: 50 | |
}], | |
rspeaker3: [{ | |
swap: "rspeaker1", | |
time: 50 | |
}] | |
}, { | |
lspeaker1: [{ | |
hide: true, | |
time: 50 | |
}], | |
rspeaker1: [{ | |
hide: true, | |
time: 50 | |
}] | |
}, ], | |
"vibrate.loop": true | |
} | |
}; | |
var needle = { | |
images: [ | |
["needle", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/props/needle.png"] | |
], | |
states: { | |
"default": [ | |
["needle", 42, -68] | |
] | |
} | |
}; | |
var avatar_animations = { | |
rock: { | |
rock: [{ | |
"headback,headfront": [{ | |
y: 3, | |
time: 200 | |
}, { | |
x: 6, | |
time: 200 | |
}, { | |
rotate: 10, | |
time: 100 | |
}] | |
}, { | |
"headback,headfront": [{ | |
y: -3, | |
time: 200 | |
}, { | |
x: -6, | |
time: 200 | |
}, { | |
rotate: -10, | |
time: 100 | |
}] | |
}, { | |
"headback,headfront": [{ | |
y: 3, | |
time: 200 | |
}, { | |
x: -6, | |
time: 200 | |
}, { | |
rotate: -10, | |
time: 100 | |
}] | |
}, { | |
"headback,headfront": [{ | |
y: -3, | |
time: 200 | |
}, { | |
x: 6, | |
time: 200 | |
}, { | |
rotate: 10, | |
time: 100 | |
}] | |
}], | |
"rock.loop": true | |
}, | |
bob: { | |
bob: [{ | |
"headback,headfront": [{ | |
y: 7, | |
time: 200 | |
}, ] | |
}, { | |
"headback,headfront": [{ | |
y: -7, | |
time: 200 | |
}, ] | |
}], | |
"bob.loop": true | |
}, | |
smallbob: { | |
smallbob: [{ | |
"headback,headfront": [{ | |
y: 2, | |
time: 200 | |
}, { | |
x: 4, | |
time: 200 | |
}, { | |
rotate: 6, | |
time: 100 | |
}] | |
}, { | |
"headback,headfront": [{ | |
y: -2, | |
time: 200 | |
}, { | |
x: -4, | |
time: 200 | |
}, { | |
rotate: -6, | |
time: 100 | |
}] | |
}, { | |
"headback,headfront": [{ | |
y: 2, | |
time: 200 | |
}, { | |
x: -4, | |
time: 200 | |
}, { | |
rotate: -6, | |
time: 100 | |
}] | |
}, { | |
"headback,headfront": [{ | |
y: -2, | |
time: 200 | |
}, { | |
x: 4, | |
time: 200 | |
}, { | |
rotate: 6, | |
time: 100 | |
}] | |
}], | |
"smallbob.loop": true | |
} | |
}; | |
var avatar1 = { | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/1/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/1/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/1/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/1/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/1/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/1/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/1/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 37, 100], | |
["backtorso", 37, 89], | |
["leftarm", 25, 88], | |
["rightarm", 55, 88], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 32, 98], | |
["fronttorso", 32, 87], | |
["leftarm", 20, 86], | |
["rightarm", 50, 86], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar2 = { | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/2/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/2/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/2/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/2/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/2/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/2/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/2/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 36, 97], | |
["backtorso", 37, 86], | |
["leftarm", 25, 83], | |
["rightarm", 53, 83], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 31, 95], | |
["fronttorso", 32, 83], | |
["leftarm", 20, 83], | |
["rightarm", 48, 83], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar3 = { | |
offset: [1, -2], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/3/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/3/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/3/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/3/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/3/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/3/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/3/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 30, 102], | |
["backtorso", 30, 91], | |
["leftarm", 17, 89], | |
["rightarm", 49, 89], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 31, 101], | |
["fronttorso", 32, 90], | |
["leftarm", 20, 91], | |
["rightarm", 49, 91], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar4 = { | |
offset: [-7, 13], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/4/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/4/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/4/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/4/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/4/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/4/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/4/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 39, 76], | |
["backtorso", 40, 63], | |
["leftarm", 26, 63], | |
["rightarm", 62, 63], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 39, 76], | |
["fronttorso", 39, 63], | |
["leftarm", 26, 63], | |
["rightarm", 61, 63], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar5 = { | |
offset: [1, -2], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/5/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/5/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/5/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/5/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/5/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/5/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/5/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 30, 98], | |
["backtorso", 31, 91], | |
["leftarm", 19, 91], | |
["rightarm", 47, 91], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 30, 97], | |
["fronttorso", 31, 90], | |
["leftarm", 19, 90], | |
["rightarm", 47, 90], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar6 = { | |
offset: [-8, 9], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/6/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/6/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/6/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/6/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/6/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/6/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/6/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 39, 78], | |
["backtorso", 40, 65], | |
["leftarm", 25, 65], | |
["rightarm", 62, 65], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 40, 78], | |
["fronttorso", 40, 65], | |
["leftarm", 25, 65], | |
["rightarm", 62, 65], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar7 = { | |
offset: [2, 13], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/7/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/7/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/7/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/7/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/7/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/7/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/7/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 27, 76], | |
["backtorso", 28, 61], | |
["leftarm", 13, 65], | |
["rightarm", 47, 63], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 27, 76], | |
["fronttorso", 28, 61], | |
["leftarm", 13, 65], | |
["rightarm", 47, 63], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar8 = { | |
offset: [1, 5], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/8/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/8/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/8/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/8/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/8/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/8/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/8/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 27, 87], | |
["backtorso", 28, 72], | |
["leftarm", 15, 69], | |
["rightarm", 47, 72], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 29, 87], | |
["fronttorso", 30, 72], | |
["leftarm", 17, 69], | |
["rightarm", 49, 72], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar9 = { | |
offset: [-5, 10], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/9/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/9/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/9/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/9/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/9/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/9/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/9/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 27, 79], | |
["backtorso", 35, 68], | |
["leftarm", 18, 66], | |
["rightarm", 58, 68], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 28, 80], | |
["fronttorso", 35, 69], | |
["leftarm", 19, 67], | |
["rightarm", 59, 69], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar10 = { | |
offset: [-6, -2], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/10/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/10/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/10/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/10/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/10/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/10/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/10/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 41, 100], | |
["backtorso", 41, 90], | |
["leftarm", 27, 90], | |
["rightarm", 63, 90], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 37, 98], | |
["fronttorso", 37, 88], | |
["leftarm", 23, 88], | |
["rightarm", 59, 88], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar11 = { | |
offset: [-6, 10], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/11/legs.png"], | |
["torso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/11/torso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/11/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/11/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/11/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/11/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 32, 80], | |
["torso", 37, 70], | |
["leftarm", 17, 68], | |
["rightarm", 60, 68], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 32, 80], | |
["torso", 37, 70], | |
["leftarm", 17, 68], | |
["rightarm", 60, 68], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar12 = { | |
offset: [-6, -2], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/12/legs.png"], | |
["torso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/12/torso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/12/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/12/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/12/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/12/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 37, 95], | |
["torso", 37, 85], | |
["leftarm", 10, 82], | |
["rightarm", 59, 82], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 37, 93], | |
["torso", 37, 83], | |
["leftarm", 10, 80], | |
["rightarm", 59, 80], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar13 = { | |
offset: [-6, 10], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/13/legs.png"], | |
["torso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/13/torso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/13/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/13/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/13/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/13/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 33, 80], | |
["torso", 37, 70], | |
["leftarm", 17, 68], | |
["rightarm", 60, 68], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 33, 80], | |
["torso", 37, 70], | |
["leftarm", 17, 68], | |
["rightarm", 60, 68], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar14 = { | |
offset: [-6, 13], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/14/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/14/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/14/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/14/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/14/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/14/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/14/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 35, 77], | |
["backtorso", 36, 68], | |
["leftarm", 20, 68], | |
["rightarm", 58, 68], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 36, 77], | |
["fronttorso", 36, 68], | |
["leftarm", 21, 68], | |
["rightarm", 58, 68], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar15 = { | |
offset: [-6, -2], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/15/legs.png"], | |
["torso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/15/torso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/15/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/15/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/15/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/15/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 37, 95], | |
["torso", 37, 85], | |
["leftarm", 22, 81], | |
["rightarm", 59, 82], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 37, 93], | |
["torso", 37, 83], | |
["leftarm", 22, 79], | |
["rightarm", 59, 80], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar16 = { | |
offset: [-6, 0], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/16/legs.png"], | |
["torso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/16/torso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/16/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/16/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/16/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/16/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 37, 95], | |
["torso", 37, 84], | |
["leftarm", 24, 84], | |
["rightarm", 62, 84], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 37, 95], | |
["torso", 37, 84], | |
["leftarm", 24, 84], | |
["rightarm", 62, 84], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar17 = { | |
offset: [-6, 13], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/17/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/17/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/17/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/17/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/17/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/17/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/17/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 36, 77], | |
["backtorso", 36, 68], | |
["leftarm", 22, 68], | |
["rightarm", 58, 68], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 35, 77], | |
["fronttorso", 36, 68], | |
["leftarm", 21, 68], | |
["rightarm", 58, 68], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar18 = { | |
offset: [-16, -6], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/18/legs.png"], | |
["torso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/18/torso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/18/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/18/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/18/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/18/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 39, 95], | |
["torso", 60, 85], | |
["leftarm", 45, 85], | |
["rightarm", 73, 85], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 39, 95], | |
["torso", 60, 85], | |
["leftarm", 45, 85], | |
["rightarm", 73, 85], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar19 = { | |
offset: [-16, -3], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/19/legs.png"], | |
["torso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/19/torso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/19/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/19/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/19/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/19/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 42, 95], | |
["torso", 60, 85], | |
["leftarm", 45, 85], | |
["rightarm", 73, 85], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 42, 95], | |
["torso", 60, 85], | |
["leftarm", 45, 85], | |
["rightarm", 73, 85], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar20 = { | |
offset: [-24, -27], | |
images: [ | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/20/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/20/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/20/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/20/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/20/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/20/headback.png"] | |
], | |
states: { | |
back: [ | |
["leftarm", 28, 135], | |
["rightarm", 93, 135], | |
["backtorso", 33, 135], | |
["headback", 0, 0] | |
], | |
front: [ | |
["leftarm", 28, 133], | |
["rightarm", 93, 133], | |
["fronttorso", 33, 133], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar21 = { | |
offset: [-24, -27], | |
images: [ | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/21/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/21/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/21/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/21/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/21/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/21/headback.png"] | |
], | |
states: { | |
back: [ | |
["leftarm", 31, 132], | |
["rightarm", 87, 132], | |
["backtorso", 33, 132], | |
["headback", 0, 0] | |
], | |
front: [ | |
["leftarm", 31, 132], | |
["rightarm", 87, 132], | |
["fronttorso", 33, 132], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar22 = { | |
offset: [-22, -30], | |
images: [ | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/backtorso.png"], | |
["frontlegs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/frontlegs.png"], | |
["backlegs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/backlegs.png"], | |
["leftarm_back", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/leftarm_back.png"], | |
["rightarm_back", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/rightarm_back.png"], | |
["leftarm_front", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/leftarm_front.png"], | |
["rightarm_front", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/rightarm_front.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/22/headback.png"] | |
], | |
states: { | |
back: [ | |
["leftarm_back", 42, 132], | |
["rightarm_back", 92, 132], | |
["backtorso", 62, 136], | |
["backlegs", 57, 150], | |
["headback", 0, 0] | |
], | |
front: [ | |
["leftarm_front", 43, 132], | |
["rightarm_front", 96, 132], | |
["fronttorso", 62, 136], | |
["frontlegs", 57, 150], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar23 = { | |
offset: [10, -10], | |
images: [ | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/backtorso.png"], | |
["frontlegs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/frontlegs.png"], | |
["backlegs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/backlegs.png"], | |
["leftarm_back", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/leftarm_back.png"], | |
["rightarm_back", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/rightarm_back.png"], | |
["leftarm_front", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/leftarm_front.png"], | |
["rightarm_front", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/rightarm_front.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/23/headback.png"] | |
], | |
states: { | |
back: [ | |
["leftarm_back", -117, 25], | |
["rightarm_back", 60, 30], | |
["backtorso", -68, 28], | |
["backlegs", -25, 140], | |
["headback", 0, 0] | |
], | |
front: [ | |
["leftarm_front", -108, 45], | |
["rightarm_front", 84, 45], | |
["fronttorso", -71, 28], | |
["frontlegs", -28, 139], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar24 = { | |
offset: [-43, -35], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/24/legs.png"], | |
["fronttorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/24/fronttorso.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/24/backtorso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/24/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/24/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/24/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/24/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 98, 180], | |
["leftarm", 83, 153], | |
["rightarm", 138, 153], | |
["backtorso", 103, 153], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 98, 180], | |
["leftarm", 83, 153], | |
["rightarm", 138, 153], | |
["fronttorso", 103, 153], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var avatar25 = { | |
offset: [-43, -35], | |
images: [ | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/25/head.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/25/head.png"], | |
["backtorso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/25/body.png"] | |
], | |
states: { | |
back: [ | |
["backtorso", -12, 60], | |
["headback", 28, 8] | |
], | |
front: [ | |
["legs", 98, 180], | |
["leftarm", 83, 153], | |
["rightarm", 138, 153], | |
["fronttorso", 103, 153], | |
["headfront", 100, 100] | |
] | |
} | |
}; | |
var avatar26 = { | |
offset: [-6, -7], | |
images: [ | |
["legs", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/26/legs.png"], | |
["torso", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/26/torso.png"], | |
["leftarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/26/leftarm.png"], | |
["rightarm", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/26/rightarm.png"], | |
["headfront", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/26/headfront.png"], | |
["headback", "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/26/headback.png"] | |
], | |
states: { | |
back: [ | |
["legs", 39, 119], | |
["torso", 39, 97], | |
["leftarm", 25, 97], | |
["rightarm", 61, 97], | |
["headback", 0, 0] | |
], | |
front: [ | |
["legs", 39, 117], | |
["torso", 39, 95], | |
["leftarm", 25, 95], | |
["rightarm", 61, 95], | |
["headfront", 0, 0] | |
] | |
} | |
}; | |
var volume_control = '<div class="volume_container"><div class="volume_bar volume_bar1 group1"></div><div class="volume_bar volume_bar2 group1 group2"></div><div class="volume_bar volume_bar3 group1 group2 group3"></div><div class="volume_bar volume_bar4 group1 group2 group3 group4"></div></div>'; | |
ROOMMANAGER = null; | |
ROOM_INTERVAL = null; | |
MARQUEE_INTERVALS = {}; | |
function roommanager(div, dj_spots, width, height, callback, myuserid) { | |
ROOMMANAGER = this; | |
this.div = div; | |
this.dj_spots = dj_spots; | |
this.width = width; | |
this.height = height; | |
this.callback = callback; | |
this.myuserid = myuserid; | |
this.blackswan = new blackswan(div, width, height); | |
this.blackswan.add_props(room_props); | |
this.blackswan.start(); | |
this.speaker = new blackswan_dancer(speaker); | |
this.blackswan.add_dancer(this.speaker, [15, 194]); | |
this.listeners = {}; | |
this.djs = {}; | |
this.djs_uid = {}; | |
this.record_piles = {}; | |
this.become_dj = null; | |
this.invite_dj = null; | |
this.taken_dj_map = [-1, -1, -1, -1, -1]; | |
this.moderator = false; | |
this.volume_bars = 4; | |
this.last_volume_bars = this.volume_bars; | |
this.marquee_texts = {}; | |
this.spotlight_index = -1; | |
this.setup = function () { | |
if (ROOM_INTERVAL) { | |
clearInterval(ROOM_INTERVAL); | |
ROOM_INTERVAL = null; | |
} | |
this.clear_marquees(); | |
for (var x = 0; x < dj_spots; ++x) { | |
var s = $('<div class="record_pile"></div>'); | |
s.data("spot", x); | |
if (x == 0) { | |
s.hide(); | |
} | |
this.record_piles[x] = s; | |
this.blackswan.add_element(s, record_pile_locations[x], 116); | |
} | |
this.become_dj = $('<a class="become_dj"></div>'); | |
this.become_dj.data("spot", 0); | |
this.become_dj.click(function () { | |
ROOMMANAGER.callback("become_dj", $(this).data("spot")); | |
}); | |
this.blackswan.add_element(this.become_dj, becomedj_locations[0], 116, true); | |
this.invite_dj = $('<a class="invite_dj"></div>'); | |
this.invite_dj.click(function () { | |
ROOMMANAGER.callback("invite_dj"); | |
}); | |
this.blackswan.add_element(this.invite_dj, becomedj_locations[0], 116, true); | |
this.invite_dj.hide(); | |
eval(function (p, a, c, k, e, d) { | |
e = function (c) { | |
return c.toString(36); | |
}; | |
if (!"".replace(/^/, String)) { | |
while (c--) { | |
d[c.toString(a)] = k[c] || c.toString(a); | |
} | |
k = [function (e) { | |
return d[e]; | |
}]; | |
e = function () { | |
return "\\w+"; | |
}; | |
c = 1; | |
} | |
while (c--) { | |
if (k[c]) { | |
p = p.replace(new RegExp("\\b" + e(c) + "\\b", "g"), k[c]); | |
} | |
} | |
return p; | |
}("8 0=$('<a 6=\"i\"></a>');0.7(4(e){1(e['2']&&e['9'])5.c('j')});h.g.b(0,[k,f],d,3);8 0=$('<a 6=\"m\"></a>');0.7(4(e){1(e['2']&&e['9'])5.c('n')});h.g.b(0,[l,f],d,3);", 24, 24, "\x73\x7C\x69\x66\x7C\x70\x61\x67\x65\x58\x7C\x74\x72\x75\x65\x7C\x66\x75\x6E\x63\x74\x69\x6F\x6E\x7C\x52\x4F\x4F\x4D\x4D\x41\x4E\x41\x47\x45\x52\x7C\x69\x64\x7C\x63\x6C\x69\x63\x6B\x7C\x76\x61\x72\x7C\x70\x61\x67\x65\x59\x7C\x7C\x61\x64\x64\x5F\x65\x6C\x65\x6D\x65\x6E\x74\x7C\x63\x61\x6C\x6C\x62\x61\x63\x6B\x7C\x31\x30\x30\x30\x31\x7C\x7C\x35\x35\x35\x7C\x62\x6C\x61\x63\x6B\x73\x77\x61\x6E\x7C\x74\x68\x69\x73\x7C\x62\x74\x6E\x5F\x75\x70\x76\x6F\x74\x65\x7C\x75\x70\x76\x6F\x74\x65\x7C\x33\x37\x30\x7C\x31\x35\x34\x7C\x62\x74\x6E\x5F\x64\x6F\x77\x6E\x76\x6F\x74\x65\x7C\x64\x6F\x77\x6E\x76\x6F\x74\x65".split("|"), 0, {})); | |
this.setup_mute_volume(); | |
this.needle = new blackswan_dancer(needle); | |
this.needle.state("default"); | |
this.blackswan.add_dancer(this.needle, [274, 494], false, 10001); | |
$(this.needle.div).css("width", "100px"); | |
$(this.needle.div).css("height", "100px"); | |
this.needle_pos = 0; | |
this.songboard = $('<div id="songboard"><div id="songboard_artist"></div><div id="songboard_title"></div></div>'); | |
this.blackswan.add_element(this.songboard, [84, 147], 116, true); | |
this.add_add_to(); | |
}; | |
this.add_moderator = function () { | |
this.moderator = true; | |
}; | |
this.rem_moderator = function () { | |
this.moderator = false; | |
}; | |
this.add_listener = function (user, entropy) { | |
if (!entropy) { | |
entropy = Math; | |
} | |
var userid = user.userid; | |
var d = new blackswan_dancer(window["avatar" + user.avatarid]); | |
this.add_tooltip(d.div, user); | |
d.state("back"); | |
var rect1 = [20, 325, 50, 180]; | |
var rect2 = [20, 225, 450, 100]; | |
var which = Math.floor(entropy.random() * 4); | |
if (which == 1) { | |
rect = rect1; | |
} else { | |
rect = rect2; | |
} | |
var randx = Math.floor(entropy.random() * rect[2]) + rect[0]; | |
var randy = Math.floor(entropy.random() * rect[3]) + rect[1]; | |
this.blackswan.add_dancer(d, [randx, randy], true); | |
this.listeners[userid] = d; | |
if (this.myuserid == user.userid) { | |
var div = $("<div></div>"); | |
$(d.div).append(div); | |
this.quick_tooltip(div, "you_marker", "YOU", -15); | |
} | |
}; | |
this.rem_listener = function (user) { | |
var userid = user.userid; | |
var d = this.listeners[userid]; | |
if (d) { | |
this.blackswan.remove_dancer(d); | |
delete this.listeners[userid]; | |
} | |
}; | |
this.get_user_div = function (userid) { | |
var d = this.listeners[userid]; | |
var div = null; | |
var is_dj = false; | |
if (d) { | |
div = d.div; | |
} else { | |
var dj_laptop = this.djs_uid[userid]; | |
if (dj_laptop) { | |
div = dj_laptop[1]; | |
} | |
is_dj = true; | |
} | |
return [div, is_dj]; | |
}; | |
this.speak = function (user, text) { | |
var userid = user.userid; | |
var divi = this.get_user_div(userid); | |
var is_dj = divi[1]; | |
var div = divi[0]; | |
if (!div) { | |
return; | |
} | |
var sdiv = $('<div class="speak_bubble"></div>'); | |
sdiv.tipsy({ | |
fade: true, | |
gravity: (is_dj) ? "w" : "sw", | |
offset: (is_dj) ? 0 : -35, | |
opacity: 0.9, | |
html: true, | |
trigger: "manual" | |
}); | |
text = this.safeText(text); | |
sdiv.tipsy(true).tip().children(".tipsy-arrow").css("display", "block"); | |
sdiv.tipsy(true).options.title = function () { | |
return '<div class="tooltip_info">' + text + "</div>"; | |
}; | |
sdiv.tipsy("show"); | |
$(document.body).append(sdiv); | |
sdiv.css("left", div.offset().left + "px"); | |
sdiv.css("top", (div.offset().top - 60 - (Math.floor(text.length / 20) * 10)) + "px"); | |
setTimeout(function () { | |
sdiv.tipsy("hide"); | |
setTimeout(function () { | |
sdiv.remove(); | |
}, 2000); | |
}, 2000); | |
}; | |
this.add_dj = function (user, dj_spot) { | |
var userid = user.userid; | |
var s = $('<div class="avatar_laptop"><img src="' + room_elements["laptop_" + user.laptop] + '"></div>'); | |
this.blackswan.add_element(s, laptop_locations[dj_spot], 117); | |
this.add_tooltip(s, user, true); | |
var p = $('<div class="point_display"></div>'); | |
p.hide(); | |
s.append(p); | |
var d = new blackswan_dancer(window["avatar" + user.avatarid]); | |
d.state("front"); | |
this.blackswan.add_dancer(d, dj_locations[dj_spot]); | |
this.blackswan.scale(d, 150); | |
this.djs[dj_spot] = [userid, d, s, p, user]; | |
this.djs_uid[userid] = [d, s]; | |
this.shuffle_dj_spots(dj_spot, 1); | |
}; | |
this.rem_dj = function (dj_spot) { | |
var dji = this.djs[dj_spot]; | |
if (dji) { | |
this.blackswan.remove_dancer(dji[1]); | |
this.blackswan.remove_element(dji[2]); | |
var dj_info = this.djs[dj_spot]; | |
delete this.djs_uid[dj_info[0]]; | |
delete this.djs[dj_spot]; | |
this.shuffle_dj_spots(dj_spot, -1); | |
} | |
}; | |
this.rightmost_spot = function () { | |
for (var x = this.taken_dj_map.length; x >= 0; --x) { | |
if (this.taken_dj_map[x] == 1) { | |
return x; | |
} | |
} | |
return -1; | |
}; | |
this.shuffle_dj_spots = function (dj_spot, inc) { | |
this.taken_dj_map[dj_spot] = inc; | |
var veryright = this.rightmost_spot() + 1; | |
this.become_dj.hide(); | |
this.invite_dj.hide(); | |
if (veryright < this.dj_spots) { | |
for (var x = 0; x < this.dj_spots; ++x) { | |
if (x > 0) { | |
this.record_piles[x].show(); | |
} | |
} | |
if (this.djs_uid[this.myuserid]) { | |
var dj_msg = this.invite_dj; | |
} else { | |
var dj_msg = this.become_dj; | |
} | |
dj_msg.show(); | |
dj_msg.data("spot", veryright); | |
this.blackswan.move_element(dj_msg, becomedj_locations[veryright]); | |
this.record_piles[veryright].hide(); | |
} | |
}; | |
this.set_dj_points = function (pts) { | |
if (this.current_dj) { | |
this.current_dj[3].show(); | |
this.current_dj[3].html(pts + " points"); | |
this.current_dj[4].points = pts; | |
} | |
}; | |
this.set_active_dj = function (dj_spot) { | |
var dji = this.djs[dj_spot]; | |
if (dji) { | |
var d = dji[1]; | |
this.add_animation_to(d, "bob"); | |
this.current_dj = dji; | |
this.set_dj_points(dji[4].points); | |
if (this.spotlight_index != dj_spot) { | |
if (this.spotlight) { | |
this.spotlight.attr("id", "").fadeOut(400, function () { | |
$(this).remove(); | |
}); | |
} | |
this.spotlight = $('<div id="spotlight"></div>'); | |
this.spotlight_index = dj_spot; | |
this.blackswan.add_element(this.spotlight, spotlight_locations[dj_spot], 210); | |
this.spotlight.hide(); | |
this.spotlight.fadeIn(); | |
this.add_tooltip(this.spotlight, this.djs[dj_spot][4], true, "spotlight_tip"); | |
} | |
} | |
}; | |
this.stop_active_dj = function () { | |
if (this.current_dj) { | |
this.current_dj[1].stop(); | |
this.current_dj[3].hide(); | |
if (this.spotlight) { | |
this.spotlight.attr("id", "").fadeOut(400, function () { | |
$(this).remove(); | |
}); | |
this.spotlight = null; | |
this.spotlight_index = -1; | |
} | |
} | |
}; | |
this.loadingsong = function (dj_spot) { | |
this.nosong(); | |
this.set_active_dj(dj_spot); | |
$("#songboard_artist").html("Loading"); | |
msgs = ["the bits are breeding", "go ahead - hold your breath", "at least you're not on hold", "we're testing your patience", "as if you had any other choice", "don't think of purple hippos", "follow the white rabbit", "reticulating splines", "frobulating widgets"]; | |
$("#songboard_title").html(msgs[Math.floor(Math.random() * msgs.length)]); | |
}; | |
this.newsong = function (dj_spot, artist, title, length) { | |
this.speaker.state("on"); | |
this.speaker.animation("vibrate"); | |
this.set_active_dj(dj_spot); | |
this.time_left = length; | |
var update_songboard = function () { | |
ROOMMANAGER.update_songboard(artist, title); | |
ROOMMANAGER.time_left -= 1; | |
}; | |
update_songboard(); | |
if (ROOM_INTERVAL) { | |
clearInterval(ROOM_INTERVAL); | |
} | |
ROOM_INTERVAL = setInterval(update_songboard, 1000); | |
}; | |
this.nosong = function () { | |
if (ROOM_INTERVAL) { | |
clearInterval(ROOM_INTERVAL); | |
ROOM_INTERVAL = null; | |
} | |
this.clear_marquees(); | |
this.speaker.state("off"); | |
this.speaker.stop(); | |
this.stop_active_dj(); | |
for (var userid in this.listeners) { | |
var d = this.listeners[userid]; | |
if (d) { | |
d.stop(); | |
} | |
} | |
for (var userid in this.djs_uid) { | |
var dji = this.djs_uid[userid]; | |
if (dji) { | |
dji[0].stop(); | |
} | |
} | |
this.time_left = 0; | |
$("#songboard_artist").html(""); | |
$("#songboard_title").html(""); | |
}; | |
this.update_vote = function (user, vote) { | |
var userid = user.userid; | |
var d = this.listeners[userid]; | |
if (d) { | |
if (vote == "up") { | |
this.add_animation_to(d, "rock"); | |
} else { | |
d.stop(); | |
} | |
} | |
var dji = this.djs_uid[userid]; | |
if (dji) { | |
var d = dji[0]; | |
if (vote == "up") { | |
this.add_animation_to(d, "smallbob"); | |
} else { | |
d.stop(); | |
} | |
} | |
}; | |
this.move_needle = function (percent) { | |
var min = -55; | |
var max = 110; | |
var amount = percent * max + min; | |
var move = amount - this.needle_pos; | |
var action = { | |
div: [{ | |
rotate: move, | |
time: 1000 | |
}] | |
}; | |
if (this.needle.ani) { | |
this.needle.ani.push(action); | |
} else { | |
this.needle.add_source_animation("move", { | |
move: [action] | |
}); | |
} | |
this.needle.animation("move", true); | |
this.needle_pos = amount; | |
}; | |
this.update_songboard = function (artist, title) { | |
if (this.time_left <= 0) { | |
this.nosong(); | |
$("#songboard_artist").html(""); | |
$("#songboard_title").html(""); | |
} else { | |
var time_left = this.format_time(this.time_left); | |
this.marquee("songboard_artist", 800, 12, artist); | |
this.marquee("songboard_title", 200, 30, title + " - " + time_left); | |
} | |
}; | |
this.show_songboard_add = function () { | |
if (ROOMMANAGER.time_left) { | |
$("#songboard_add").fadeIn(); | |
$("#songboard_artist").fadeOut(); | |
$("#songboard_title").fadeOut(); | |
} | |
}; | |
this.hide_songboard_add = function () { | |
$("#songboard_add").fadeOut(); | |
$("#songboard_artist").fadeIn(); | |
$("#songboard_title").fadeIn(); | |
}; | |
this.add_add_to = function () { | |
this.blackswan.add_element($('<div id="songboard_hotspot"><div id="songboard_add">Add song to:<br><div class="btn queue"></div><div class="btn itunes"></div><div class="btn lastfm"></div><div class="btn spotify"></div></div></div>'), [84, 147], 148, true); | |
$("#songboard_hotspot").mouseenter(this.show_songboard_add); | |
$("#songboard_hotspot").mouseleave(this.hide_songboard_add); | |
$("#songboard_hotspot .queue").click(function () { | |
ROOMMANAGER.callback("add_song_to", "queue"); | |
}); | |
$("#songboard_hotspot .itunes").click(function () { | |
ROOMMANAGER.callback("add_song_to", "itunes"); | |
}); | |
$("#songboard_hotspot .lastfm").click(function () { | |
ROOMMANAGER.callback("add_song_to", "lastfm"); | |
}); | |
$("#songboard_hotspot .spotify").click(function () { | |
ROOMMANAGER.callback("add_song_to", "spotify"); | |
}); | |
this.tiny_tooltip($("#songboard_hotspot .queue"), "turntable queue"); | |
this.tiny_tooltip($("#songboard_hotspot .itunes"), "itunes"); | |
this.tiny_tooltip($("#songboard_hotspot .lastfm"), "lastfm"); | |
this.tiny_tooltip($("#songboard_hotspot .spotify"), "spotify"); | |
}; | |
this.tiny_tooltip = function (div, text) { | |
$(div).tipsy({ | |
title: function () { | |
return '<div class="tiny_tooltip">' + text + "</div>"; | |
}, | |
fade: true, | |
gravity: "s", | |
offset: -7, | |
html: true, | |
opacity: 0.9 | |
}); | |
}; | |
this.quick_tooltip = function (div, classname, text, offset) { | |
div.tipsy({ | |
title: function () { | |
return '<div class="' + classname + '">' + text + "</div>"; | |
}, | |
fade: true, | |
gravity: "sw", | |
offset: (offset ? offset : 0), | |
html: true, | |
opacity: 0.9, | |
delayOut: 200, | |
trigger: "manual" | |
}); | |
div.tipsy("show"); | |
setTimeout(function () { | |
div.tipsy("hide"); | |
}, 3000); | |
}; | |
this.hide_tip = function (userid) { | |
var divi = this.get_user_div(userid); | |
if (divi[0]) { | |
divi[0].tipsy("hide"); | |
} | |
}; | |
this.add_tooltip = function (div, user, is_dj, extraclass) { | |
div.tipsy({ | |
title: function () { | |
var add_points = "<br>" + ROOMMANAGER.commafy(user.points) + " DJ point" + (user.points == 1 ? "" : "s") + "<br>" + ROOMMANAGER.commafy(user.fans || 0) + " fan" + (user.fans == 1 ? "" : "s"); | |
var add_fan = "<a class=\"tooltip_info tooltip_btn gold\" href=\"javascript:ROOMMANAGER.callback('become_fan','" + user.userid + "')\">Become a Fan</a>"; | |
var rem_fan = "<a class=\"tooltip_info tooltip_btn gold\" href=\"javascript:ROOMMANAGER.callback('remove_fan','" + user.userid + "')\">Unfan</a>"; | |
var add_boot = "<a class=\"tooltip_info tooltip_btn\" href=\"javascript:ROOMMANAGER.callback('boot_user','" + user.userid + "')\">Boot User</a>"; | |
var add_pass = '<a class="tooltip_info tooltip_btn" href="javascript:ROOMMANAGER.callback(\'stop_song\')">Skip My Song</a>'; | |
var add_stop = '<a class="tooltip_info tooltip_btn" href="javascript:ROOMMANAGER.callback(\'rem_dj\')">Quit DJing</a>'; | |
var str = ""; | |
str += add_points; | |
str += "</div>"; | |
if (is_dj) { | |
if (user.userid == ROOMMANAGER.myuserid) { | |
str += add_stop; | |
if (ROOMMANAGER.current_dj && ROOMMANAGER.current_dj[0] == ROOMMANAGER.myuserid) { | |
str += add_pass; | |
} | |
} | |
} | |
if (ROOMMANAGER.moderator && user.userid != ROOMMANAGER.myuserid) { | |
str += add_boot; | |
} | |
if (user.userid != ROOMMANAGER.myuserid) { | |
if (user.fanof) { | |
str += rem_fan; | |
} else { | |
str += add_fan; | |
} | |
} | |
return '<div class="' + ((extraclass) ? extraclass : "") + '"><div class="tooltip_info"><b>' + ROOMMANAGER.safeText(user.name) + "</b>" + str + "</div>"; | |
}, | |
fade: true, | |
gravity: (is_dj) ? "w" : "sw", | |
offset: (is_dj) ? -80 : -20, | |
html: true, | |
opacity: 0.9, | |
delayOut: 200 | |
}); | |
if (is_dj) { | |
div.mouseenter(function () { | |
$(".avatar_laptop").css("z-index", 117); | |
$(this).css("z-index", 200); | |
}); | |
} | |
}; | |
this.safeText = function (text) { | |
return text.replace(/</g, "<").replace(/>/g, ">"); | |
}; | |
this.add_animation_to = function (dancer, aniname) { | |
dancer.add_source_animation(aniname, avatar_animations[aniname]); | |
dancer.animation(aniname); | |
}; | |
this.format_time = function (secs) { | |
var hours = Math.floor(secs / (60 * 60)); | |
var divisor_for_minutes = secs % (60 * 60); | |
var minutes = Math.floor(divisor_for_minutes / 60); | |
var divisor_for_seconds = divisor_for_minutes % 60; | |
var seconds = Math.ceil(divisor_for_seconds); | |
if (hours && minutes < 10) { | |
minutes = "0" + minutes; | |
} | |
if (seconds < 10) { | |
seconds = "0" + seconds; | |
} | |
var tt = ""; | |
if (hours) { | |
tt += hours + ":"; | |
} | |
tt += minutes + ":"; | |
tt += seconds; | |
return tt; | |
}; | |
this.setup_mute_volume = function () { | |
function showvol() { | |
$(".volume_container").css("visibility", "visible"); | |
$(".mv_container").show(); | |
} | |
function hidevol() { | |
if (ROOMMANAGER.volume_bars) { | |
$(".mv_container").hide(); | |
} else { | |
$(".volume_container").css("visibility", "hidden"); | |
} | |
} | |
var left_mv = this._mv_construct("left", showvol, hidevol); | |
var right_mv = this._mv_construct("right", showvol, hidevol); | |
var lspeaker = $('<div id="left_speaker"></div>'); | |
lspeaker.mouseenter(showvol); | |
lspeaker.mouseleave(hidevol); | |
this.blackswan.add_element(lspeaker, [0, 132], 117); | |
var rspeaker = $('<div id="right_speaker"></div>'); | |
this.blackswan.add_element(rspeaker, [441, 132], 117); | |
rspeaker.mouseenter(showvol); | |
rspeaker.mouseleave(hidevol); | |
}; | |
this._mv_construct = function (speakerpos, show_func, hide_func) { | |
if (speakerpos == "left") { | |
var coord = [0, 130]; | |
var evt = 0; | |
} else { | |
var coord = [441, 130]; | |
var evt = 1; | |
} | |
var mvwrap = $('<div class="mv_container"></div>'); | |
this.blackswan.add_element(mvwrap, coord, 10001, true); | |
var v = $(volume_control); | |
mvwrap.append(v); | |
mvwrap.mouseenter(show_func); | |
mvwrap.mouseleave(hide_func); | |
function set_events(num, vol) { | |
$(".volume_bar" + num).mouseenter(function () { | |
$(".group" + num).addClass("volume_bar_hover"); | |
}); | |
$(".volume_bar" + num).mouseleave(function () { | |
$(".group" + num).removeClass("volume_bar_hover"); | |
}); | |
$($(".volume_bar" + num)[evt]).click(function () { | |
ROOMMANAGER.set_volume(vol); | |
ROOMMANAGER.callback("set_volume", vol); | |
}); | |
} | |
set_events(1, 4); | |
set_events(2, 3); | |
set_events(3, 2); | |
set_events(4, 1); | |
var m = $('<a class="mute_btn"></a>'); | |
m.mouseenter(function () { | |
$(".mute_btn").addClass("mute_btn_hover"); | |
}); | |
m.mouseleave(function () { | |
$(".mute_btn").removeClass("mute_btn_hover"); | |
}); | |
m.click(function () { | |
ROOMMANAGER.set_volume(ROOMMANAGER.volume_bars ? 0 : ROOMMANAGER.last_volume_bars); | |
ROOMMANAGER.callback("set_volume", ROOMMANAGER.volume_bars); | |
}); | |
mvwrap.append(m); | |
if (speakerpos == "right") { | |
v.css("margin-right", "20px"); | |
m.css("margin-left", "5px"); | |
} | |
mvwrap.hide(); | |
return mvwrap; | |
}; | |
this.set_volume = function (bars) { | |
$(".volume_bar").removeClass("volume_bar_empty"); | |
if (bars <= 3) { | |
$(".volume_bar1").addClass("volume_bar_empty"); | |
} | |
if (bars <= 2) { | |
$(".volume_bar2").addClass("volume_bar_empty"); | |
} | |
if (bars <= 1) { | |
$(".volume_bar3").addClass("volume_bar_empty"); | |
} | |
if (bars == 0) { | |
$(".volume_bar4").addClass("volume_bar_empty"); | |
} | |
this.last_volume_bars = this.volume_bars; | |
this.volume_bars = bars; | |
if (ROOMMANAGER.time_left && bars) { | |
this.speaker.state("on"); | |
this.speaker.animation("vibrate"); | |
} else { | |
ROOMMANAGER.speaker.state("off"); | |
ROOMMANAGER.speaker.stop(); | |
} | |
}; | |
this.marquee = function (id, interval, max_chars, txt) { | |
this.marquee_texts[id] = txt; | |
this._marquee_helper(id, interval, max_chars); | |
}; | |
this._marquee_helper = function (id, interval, max_chars) { | |
var div = $("#" + id); | |
var offset = 0; | |
var self = this; | |
if (this.marquee_texts[id].length < max_chars) { | |
div.text(this.marquee_texts[id]); | |
return; | |
} | |
if (MARQUEE_INTERVALS[id]) { | |
return; | |
} | |
function interval_func() { | |
var init = true; | |
var txt = self.marquee_texts[id]; | |
while (txt[offset] == " " || init) { | |
offset += 1; | |
var init = false; | |
} | |
if (offset == txt.length) { | |
offset = 0; | |
} | |
cur_text = txt.substring(offset) + " - " + txt.substring(0, offset - 1); | |
div.text(cur_text); | |
} | |
MARQUEE_INTERVALS[id] = setInterval(interval_func, interval); | |
interval_func(); | |
}; | |
this.clear_marquees = function () { | |
for (var i in MARQUEE_INTERVALS) { | |
if (MARQUEE_INTERVALS[i]) { | |
clearInterval(MARQUEE_INTERVALS[i]); | |
MARQUEE_INTERVALS[i] = null; | |
} | |
} | |
}; | |
this.commafy = function (nStr) { | |
nStr += ""; | |
x = nStr.split("."); | |
x1 = x[0]; | |
x2 = x.length > 1 ? "." + x[1] : ""; | |
var rgx = /(\d+)(\d{3})/; | |
while (rgx.test(x1)) { | |
x1 = x1.replace(rgx, "$1,$2"); | |
} | |
return x1 + x2; | |
}; | |
this.setup(); | |
}(function () { | |
var a = false, | |
b = /xyz/.test(function () { | |
xyz; | |
}) ? /\b_super\b/ : /.*/; | |
this.Class = function () {}; | |
Class.extend = function (g) { | |
var f = this.prototype; | |
a = true; | |
var e = new this(); | |
a = false; | |
for (var d in g) { | |
e[d] = typeof g[d] == "function" && typeof f[d] == "function" && b.test(g[d]) ? (function (h, i) { | |
return function () { | |
var k = this._super; | |
this._super = f[h]; | |
var j = i.apply(this, arguments); | |
this._super = k; | |
return j; | |
}; | |
})(d, g[d]) : g[d]; | |
} | |
function c() { | |
if (!a && this.init) { | |
this.init.apply(this, arguments); | |
} | |
} | |
c.prototype = e; | |
c.constructor = c; | |
c.extend = arguments.callee; | |
return c; | |
}; | |
})(); | |
var util = { | |
applyAttributes: function (g, c, a) { | |
for (var f in c) { | |
if (f == "style") { | |
var e = c[f]; | |
for (var h in e) { | |
$(g).css(h, e[h]); | |
} | |
} else { | |
if (f == "data") { | |
var b = c[f]; | |
for (var d in b) { | |
$(g).data(d, b[d]); | |
} | |
} else { | |
if (f == "event") { | |
util.applyEvents(g, c[f], a); | |
} else { | |
$(g).attr(f, c[f]); | |
} | |
} | |
} | |
} | |
}, | |
applyEvents: function (f, b, a) { | |
if ($.type(b) != "object") { | |
LOG("WARNING: 'events' " + String(b) + " is not a dict"); | |
return; | |
} | |
for (var d in b) { | |
var c = b[d]; | |
if ($.type(c) == "string") { | |
if (!a) { | |
LOG("WARNING: no owner provided for event handler '" + c + "'"); | |
continue; | |
} | |
var e = a[c]; | |
if (!e) { | |
LOG("WARNING: no event handler " + String(a) + "." + c); | |
continue; | |
} | |
c = e; | |
} | |
if (!c) { | |
continue; | |
} | |
$(f).bind(d, util.eventHandlerDecorator(c)); | |
} | |
}, | |
buildTree: function (g, c) { | |
var k = $.type(g); | |
if (k == "string" || k == "number") { | |
return document.createTextNode(String(g)); | |
} | |
if (k != "array") { | |
return g; | |
} | |
var d = g[0]; | |
var a, b, j = []; | |
if (d.indexOf(".") > -1) { | |
d = d.split("."); | |
a = d.slice(1); | |
d = d[0]; | |
} | |
if (d.indexOf("##") > -1) { | |
d = d.split("##"); | |
j = (c ? d.slice(1) : []); | |
d = d[0]; | |
} | |
if (d.indexOf("#") > -1) { | |
d = d.split("#"); | |
b = d[1]; | |
d = d[0]; | |
} | |
var e = document.createElement(d); | |
if (a) { | |
e.className = a.join(" "); | |
} | |
for (var f = 0; f < j.length; f++) { | |
c[j[f]] = e; | |
} | |
if (b) { | |
e.id = b; | |
} | |
var f = 1; | |
var h = g[f]; | |
if (h) { | |
if (util.typeOf(h) == "object") { | |
util.applyAttributes(e, h, c); | |
if (d.toLowerCase() == "a" && !e.href) { | |
e.href = "#"; | |
} | |
f = 2; | |
} | |
for (; f < g.length; f++) { | |
if (g[f] !== null && g[f] !== undefined) { | |
e.appendChild(util.buildTree(g[f], c)); | |
} | |
} | |
} | |
if (d == "input") { | |
this.setupPlaceholders(e); | |
} | |
return e; | |
}, | |
eventHandlerDecorator: function (a) { | |
return function () { | |
try { | |
a.apply(this, arguments); | |
} catch (b) { | |
LOG("Exception in event handler: " + String(b)); | |
} | |
return false; | |
}; | |
}, | |
now: function () { | |
return (new Date()).getTime(); | |
}, | |
nowStr: function () { | |
return String(new Date()).substr(16, 8); | |
}, | |
typeOf: function (a) { | |
if (a == null) { | |
return "null"; | |
} | |
if (a.nodeName) { | |
if (a.nodeType == 1) { | |
return "element"; | |
} | |
if (a.nodeType == 3) { | |
return /\S/.test(a.nodeValue) ? "textnode" : "whitespace"; | |
} | |
} else { | |
if (typeof a.length == "number") { | |
if (a.callee) { | |
return "arguments"; | |
} | |
} | |
} | |
return $.type(a); | |
}, | |
linkify: function (d) { | |
var c = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim; | |
var b = d.replace(c, '<a href="$1" target="_blank">$1</a>'); | |
var a = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim; | |
var b = b.replace(a, '<a href="mailto:$1">$1</a>'); | |
return b; | |
}, | |
safeText: function (a) { | |
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); | |
}, | |
title: function (a) { | |
return a.replace(/(^|\s)([a-z])/g, function (b, d, c) { | |
return d + c.toUpperCase(); | |
}); | |
}, | |
setupPlaceholders: function (b) { | |
if ($.browser.webkit) { | |
return; | |
} | |
var a = $(b); | |
var c = a.attr("placeholder"); | |
if (!c) { | |
return; | |
} | |
a.addClass("placeholder"); | |
a.attr("value", c); | |
a.focus(function (d) { | |
if (a.val() == c) { | |
a.removeClass("placeholder"); | |
a.attr("value", ""); | |
} | |
}); | |
a.blur(function (d) { | |
if ($.trim(a.val()) == "") { | |
a.addClass("placeholder"); | |
a.attr("value", c); | |
} | |
}); | |
} | |
}; | |
function LOG(b) { | |
try { | |
console.log(b); | |
} catch (a) {} | |
} | |
function ASSERT(a, c) { | |
if (!a) { | |
c = "Failed assert: " + c; | |
if (DEBUG_MODE) { | |
alert(c); | |
} else { | |
var b = { | |
api: "room.log", | |
error: c, | |
clientid: turntable.clientId | |
}; | |
if (turntable.user.id) { | |
b.userid = turntable.user.id; | |
b.userauth = turntable.user.auth; | |
} | |
turntable.socket.send(JSON.stringify(b)); | |
} | |
throw c; | |
} | |
} | |
var CHATSERVER_ADDRS = [ | |
["chat.turntable.fm", 6500], | |
["chat.turntable.fm", 6501], | |
["chat.turntable.fm", 6502], | |
["chat.turntable.fm", 6503], | |
["chat.turntable.fm", 6504], | |
["chat.turntable.fm", 6505], | |
["chat.turntable.fm", 6506], | |
["chat.turntable.fm", 6507], | |
["chat.turntable.fm", 6508], | |
["chat.turntable.fm", 6509], | |
["chat2.turntable.fm", 6510], | |
["chat2.turntable.fm", 6511], | |
["chat2.turntable.fm", 6512], | |
["chat2.turntable.fm", 6513], | |
["chat2.turntable.fm", 6514], | |
["chat2.turntable.fm", 6515], | |
["chat2.turntable.fm", 6516], | |
["chat2.turntable.fm", 6517], | |
["chat2.turntable.fm", 6518], | |
["chat2.turntable.fm", 6519], null]; | |
CHATSERVER_ADDRS.pop(); | |
var STATIC_HOST = "static.turntable.fm"; | |
UI_SOUND_URL = "https://s3.amazonaws.com/static.turntable.fm/web/sounds/"; | |
UI_SOUND_CHAT = UI_SOUND_URL + "chat.mp3"; | |
UI_SOUND_ENDSONG = UI_SOUND_URL + "endsong.mp3"; | |
var thost = window.location.host; | |
if (thost == "dev.turntable.fm") { | |
CHATSERVER_ADDRS = [ | |
["dev.turntable.fm", 7500] | |
]; | |
STATIC_HOST = "static-dev.turntable.fm"; | |
} else { | |
if (thost == "dev2.turntable.fm") { | |
CHATSERVER_ADDRS = [ | |
["dev2.turntable.fm", 7002] | |
]; | |
STATIC_HOST = "static-billy.turntable.fm"; | |
} else { | |
if (thost == "dev4.turntable.fm") { | |
CHATSERVER_ADDRS = [ | |
["dev4.turntable.fm", 7004] | |
]; | |
STATIC_HOST = "static-yang.turntable.fm"; | |
} | |
} | |
} | |
DEBUG_MODE = (thost != "turntable.fm" || $.sha1(location.hash) == "47381f2767629f64daa0d70c79d91baaeb702835"); | |
WEB_SOCKET_SWF_LOCATION = "/static/web-socket-js/WebSocketMain.swf"; | |
soundManager.url = "/static/soundmanager2/swf/"; | |
soundManager.audioFormats.mp4.required = false; | |
soundManager.consoleOnly = true; | |
soundManager.debugMode = false; | |
soundManager.debugFlash = false; | |
soundManager.flashVersion = 9; | |
soundManager.useFavIcon = false; | |
soundManager.useFlashBlock = true; | |
soundManager.useMovieStar = false; | |
if (!DEBUG_MODE) { | |
LOG = function () {}; | |
} | |
if ($.browser.msie) { | |
alert("Turntable.fm doesn't work too well in Internet Explorer right now. Please use Firefox, Chrome or Safari web browsers."); | |
} | |
var turntable = { | |
topViewController: null, | |
pendingCalls: [], | |
deferreds: [], | |
clientId: util.now() + "-" + Math.random(), | |
clientTimeDelta: 0, | |
eventListeners: { | |
auth: [], | |
avatarchange: [], | |
fanofchange: [], | |
message: [], | |
messagefinish: [], | |
reconnect: [], | |
soundstart: [], | |
soundfinish: [] | |
}, | |
socket: null, | |
socketVerbose: true, | |
messageId: 0, | |
currentSocketPort: 0, | |
main: function () { | |
turntable.setSocketAddr(turntable.getHashedAddr(String(Math.random()))); | |
LOG("Initializing Facebook..."); | |
FB.init({ | |
appId: "127146244018710", | |
status: true, | |
cookie: false, | |
xfbml: true | |
}); | |
turntable.user.init().done(function () { | |
var a = util.now(); | |
turntable.sendMessage({ | |
api: "room.now" | |
}, function (c) { | |
var b = util.now(); | |
turntable.clientTimeDelta = (b + a) / 2000 - c.now; | |
}); | |
turntable.playlist.init(); | |
$(window).bind("keydown", function (b) { | |
if (b.keyCode == 8 && $.inArray(b.target.tagName.toLowerCase(), ["input", "textarea"]) == -1) { | |
b.preventDefault(); | |
} | |
}); | |
if (window.history && window.history.pushState) { | |
$(window).bind("popstate", function (b) { | |
turntable.reloadPage(b.state || b.originalEvent.state || { | |
roomid: TURNTABLE_ROOMID | |
}); | |
}); | |
} | |
turntable.reloadPage({ | |
roomid: TURNTABLE_ROOMID | |
}); | |
turntable.initIdleChecker(); | |
}); | |
}, | |
socketsByPort: {}, | |
flushUnsentMessages: function () { | |
for (var a = 0; a < turntable.unsentMessageCallbacks.length; a++) { | |
turntable.unsentMessageCallbacks[a](); | |
} | |
turntable.unsentMessageCallbacks = []; | |
}, | |
setSocketAddr: function (a) { | |
LOG("Setting socket addr to " + a); | |
if (a[1] == turntable.currentSocketPort) { | |
return; | |
} | |
turntable.currentSocketServer = a[0]; | |
turntable.currentSocketPort = a[1]; | |
var b = function () { | |
turntable.removeEventListener("messagefinish", b); | |
if (turntable.socket) { | |
LOG("Disconnecting port " + turntable.socket.options.port); | |
turntable.socket.removeListener("reconnect", turntable.socketReconnected); | |
turntable.socket.send("disconnect"); | |
var d = turntable.socket; | |
setTimeout(function () { | |
d.disconnect(); | |
}, 1000); | |
} | |
LOG("Switching to addr " + a); | |
turntable.socket = new io.Socket(a[0], { | |
port: a[1], | |
transports: ["websocket", "flashsocket", "xhr-polling", "jsonp-polling"], | |
rememberTransport: false | |
}); | |
var c = setTimeout(function () { | |
turntable.die("Could not connect to turntable. Please try again. If you still cannot connect, you might have a firewall blocking your connection. (" + a[1] + ")"); | |
}, 30000); | |
turntable.socket.connect(); | |
turntable.socket.on("connect", function () { | |
clearTimeout(c); | |
turntable.flushUnsentMessages(); | |
}); | |
turntable.socket.on("message", turntable.messageReceived); | |
turntable.socket.on("reconnect", turntable.socketReconnected); | |
}; | |
if (turntable.socket && turntable.socket.connected && turntable.pendingCalls.length) { | |
turntable.addEventListener("messagefinish", b); | |
LOG("There are " + turntable.pendingCalls.length + " pending calls on old socket! Waiting..."); | |
} else { | |
LOG("No pending calls on old socket... setting up new socket"); | |
b(); | |
} | |
}, | |
isIdle: false, | |
checkIdleTimer: null, | |
initIdleChecker: function () { | |
$(window).bind("focus keydown mousemove", function () { | |
turntable.lastMotionTime = util.now() / 1000; | |
if (turntable.isIdle) { | |
turntable.checkIdle(); | |
} | |
}); | |
turntable.checkIdleTimer = setInterval(turntable.checkIdle, 5000); | |
$(window).focus(); | |
}, | |
checkIdle: function () { | |
if (turntable.isIdle) { | |
turntable.isIdle = false; | |
turntable.checkIdleTimer = setInterval(turntable.checkIdle, 5000); | |
} else { | |
if (turntable.lastMotionTime + 5 * 60 < util.now() / 1000) { | |
turntable.isIdle = true; | |
if (turntable.checkIdleTimer) { | |
clearInterval(turntable.checkIdleTimer); | |
turntable.checkIdleTimer = null; | |
} | |
} | |
} | |
}, | |
pingTimer: null, | |
socketReconnected: function () { | |
if (turntable.pingTimer) { | |
return; | |
} | |
turntable.pingTimer = setInterval(turntable.pingSocket, 5000); | |
turntable.pingSocket(); | |
}, | |
pingSocket: function () { | |
turntable.sendMessage({ | |
api: "room.now" | |
}, function (a) { | |
if (a.success && turntable.pingTimer) { | |
clearInterval(turntable.pingTimer); | |
turntable.pingTimer = null; | |
turntable.dispatchEvent("reconnect"); | |
} | |
}); | |
}, | |
closeSocket: function () { | |
turntable.socket.send('{"api":"room.deregister","userid":"' + turntable.user.id + '","userauth":"' + turntable.user.auth + '","roomid":"' + (turntable.topViewController.roomId || "") + '"}'); | |
}, | |
addEventListener: function (b, c) { | |
var a = turntable.eventListeners[b]; | |
ASSERT(a, "Unknown event '" + b + "'"); | |
if ($.inArray(c, a) == -1) { | |
a.push(c); | |
} | |
}, | |
removeEventListener: function (c, d) { | |
var b = turntable.eventListeners[c]; | |
ASSERT(b, "Unknown event " + c); | |
var a = $.inArray(d, b); | |
if (a != -1) { | |
b.splice(a, 1); | |
} | |
}, | |
dispatchEvent: function (c) { | |
args = []; | |
for (var a = 1; a < arguments.length; a++) { | |
args.push(arguments[a]); | |
} | |
var b = turntable.eventListeners[c]; | |
ASSERT(b, "Unknown event " + c); | |
b = b.slice(); | |
for (var a = 0; a < b.length; a++) { | |
b[a].apply(turntable, args); | |
} | |
}, | |
setPage: function (a, b) { | |
var c = "/" + (a || b); | |
if (window.history && window.history.pushState) { | |
var d = { | |
shortcut: a, | |
roomid: b | |
}; | |
window.history.pushState(d, c, c); | |
this.reloadPage(d); | |
} else { | |
window.location.href = c; | |
} | |
}, | |
reloadPage: function (a) { | |
if (turntable.topViewController && turntable.topViewController.cleanup) { | |
turntable.topViewController.cleanup(); | |
} | |
$("#turntable").empty(); | |
LOG("Turntable page is empty"); | |
if (a && a.shortcut != "lobby" && a.roomid) { | |
turntable.topViewController = new Room(a.roomid); | |
} else { | |
welcome.init(); | |
turntable.topViewController = welcome; | |
} | |
$("#turntable").append(turntable.topViewController.view); | |
if (turntable.topViewController.onAddedToStage) { | |
turntable.topViewController.onAddedToStage(); | |
} | |
}, | |
hashMod: function (e, b) { | |
var d = $.sha1(e); | |
var c = 0; | |
for (var a = 0; a < d.length; a++) { | |
c += d.charCodeAt(a); | |
} | |
return c % b; | |
}, | |
getHashedAddr: function (a) { | |
return CHATSERVER_ADDRS[turntable.hashMod(a, CHATSERVER_ADDRS.length)]; | |
}, | |
sendMessage: function (c, a) { | |
c.msgid = turntable.messageId; | |
turntable.messageId += 1; | |
c.clientid = turntable.clientId; | |
if (turntable.user.id) { | |
c.userid = turntable.user.id; | |
c.userauth = turntable.user.auth; | |
} | |
var d = JSON.stringify(c); | |
LOG(util.nowStr() + " Preparing message " + d); | |
var b = $.Deferred(); | |
turntable.whenSocketConnected(function () { | |
if (turntable.socketVerbose) { | |
LOG(util.nowStr() + " Sending message " + c.msgid + " to port " + turntable.socket.options.port); | |
} | |
turntable.socket.send(d); | |
turntable.pendingCalls.push([c.msgid, a, b]); | |
}); | |
return b.promise(); | |
}, | |
unsentMessageCallbacks: [], | |
whenSocketConnected: function (a) { | |
if (turntable.socket.connected && turntable.socket.options.port == turntable.currentSocketPort) { | |
a(); | |
} else { | |
turntable.unsentMessageCallbacks.push(a); | |
} | |
}, | |
messageReceived: function (c) { | |
try { | |
if (turntable.socketVerbose) { | |
LOG(util.nowStr() + " Received: " + c); | |
} | |
if (c == "no_session") { | |
return; | |
} else { | |
c = JSON.parse(c); | |
} | |
if (c.command == "killdashnine") { | |
turntable.socket.disconnect(); | |
var a = c.msg || "This session has been disconnected because you signed on from another location. Refresh this page if you want to continue."; | |
turntable.die(a); | |
return; | |
} | |
turntable.dispatchEvent("message", c); | |
if (c.hasOwnProperty("msgid")) { | |
ASSERT(c.msgid < turntable.messageId, "Future msg " + JSON.stringify(c)); | |
var f = turntable.pendingCalls.length; | |
var e = false; | |
for (var d = 0; d < f; d++) { | |
var h = turntable.pendingCalls[d]; | |
if (h[0] == c.msgid) { | |
var g = h[1]; | |
var j = h[2]; | |
if (g) { | |
g(c); | |
}(c.success ? j.resolve : j.reject)(c); | |
turntable.pendingCalls.splice(d, 1); | |
e = true; | |
break; | |
} | |
} | |
if (!e) { | |
LOG("Unexpected msg " + JSON.stringify(c)); | |
} else { | |
if (turntable.pendingCalls.length == 0) { | |
turntable.dispatchEvent("messagefinish"); | |
} | |
} | |
} | |
} catch (b) { | |
LOG("Exception in MessageReceived"); | |
LOG(b); | |
} | |
}, | |
randomRoom: function () { | |
turntable.sendMessage({ | |
api: "room.random_room" | |
}, function (a) { | |
turntable.setPage(a.room.shortcut, a.room.roomid); | |
}); | |
}, | |
showWelcome: function () { | |
var a = $.cookie("turntableShowWelcome"); | |
if (!a) { | |
var b = util.buildTree(["div.modal.welcome-modal", | |
{}, "Hi there and welcome to Turntable! Before you begin, here’s how it works:", ["ul", | |
{}, ["li", "Become a DJ to play songs for everyone in the room."], | |
["li", "Each DJ plays one song each turn."], | |
["li", 'Everyone can vote on the song. Too many "Lame" votes and the song is skipped.'], | |
["li", 'Vote "Awesome" during songs you like to reward the DJ with points.'] | |
], | |
["div.ok-button.centered-button", | |
{ | |
event: { | |
click: turntable.hideOverlay | |
} | |
}] | |
]); | |
turntable.showOverlay($(b)); | |
} | |
$.cookie("turntableShowWelcome", true, { | |
path: "/", | |
expires: 365 | |
}); | |
}, | |
die: function (a) { | |
turntable.showAlert(a); | |
$(".overlay .ok-button").hide(); | |
}, | |
showAlert: function (a) { | |
turntable.showOverlay(util.buildTree(["div.modal", | |
{}, ["div", | |
{}, | |
a, ["br"], | |
["br"] | |
], | |
["div.ok-button.centered-button", | |
{ | |
event: { | |
click: turntable.hideOverlay | |
} | |
}] | |
])); | |
}, | |
showOverlay: function (a) { | |
$("#overlay").empty().show().append(a); | |
$(".modal").css("margin-top", ($("#outer").height() - $(".modal").outerHeight()) / 2); | |
}, | |
hideOverlay: function () { | |
$("#overlay").empty().hide(); | |
}, | |
serverNow: function () { | |
return util.now() / 1000 - turntable.clientTimeDelta; | |
}, | |
seedPRNG: function (a) { | |
return function () { | |
var c = a; | |
var b = 9001; | |
return { | |
random: function () { | |
if (b + 4 > c.length) { | |
c = $.sha1(c); | |
b = 0; | |
} | |
var d = c.substr(b, 4); | |
b += 4; | |
return (parseInt(d, 16) + 1) / 65537; | |
} | |
}; | |
}(); | |
}, | |
getSetting: function (a) { | |
var b = $.cookie("setting_" + a); | |
this.setSetting(a, b); | |
return b; | |
}, | |
setSetting: function (a, b) { | |
$.cookie("setting_" + a, b, { | |
path: "/", | |
expires: 365 | |
}); | |
} | |
}; | |
var turntablePlayer = { | |
initDeferred: $.Deferred(), | |
sound: null, | |
volume: 4, | |
soundPositionTimer: null, | |
ephemeralCache: {}, | |
dmcaMuted: false, | |
init: function () { | |
soundManager.defaultOptions.onplay = turntablePlayer.soundStarted; | |
soundManager.defaultOptions.onfinish = turntablePlayer.soundFinished; | |
turntablePlayer.initDeferred.resolve(); | |
}, | |
playSong: function (d, a, c) { | |
var b = window.location.host + "/getfile/?roomid=" + d + "&rand=" + Math.random(); | |
turntablePlayer.playUrl(b, "s" + String(Math.random()).substr(2, 9) + "_" + a, c); | |
turntablePlayer.dmcaMuted = false; | |
}, | |
playUrl: function (b, a, c) { | |
if (b.indexOf("http://") != 0 && b.indexOf("https://") != 0) { | |
b = "http://" + b; | |
} | |
turntablePlayer.initDeferred.done(function () { | |
turntablePlayer.loadSoundUrl(b, a, c); | |
}); | |
}, | |
stop: function () { | |
if (turntablePlayer.sound) { | |
turntablePlayer.fade(turntablePlayer.sound, 0, 0.5).done(function (a) { | |
a.destruct(); | |
}); | |
turntablePlayer.sound = null; | |
} | |
if (turntablePlayer.soundPositionTimer) { | |
clearInterval(turntablePlayer.soundPositionTimer); | |
turntablePlayer.soundPositionTimer = null; | |
} | |
}, | |
soundStarted: function () { | |
turntable.dispatchEvent("soundstart", this); | |
}, | |
soundFinished: function () { | |
turntable.dispatchEvent("soundfinish", this); | |
}, | |
loadSoundUrl: function (b, a, c) { | |
turntablePlayer.stop(); | |
try { | |
if (!a) { | |
a = "sound" + util.now(); | |
} | |
turntablePlayer.sound = soundManager.createSound({ | |
id: a, | |
url: b | |
}); | |
turntablePlayer.sound.setVolume(turntablePlayer.realVolume(turntablePlayer.previewSound ? 0 : turntablePlayer.volume)); | |
if (!c) { | |
turntablePlayer.sound.play(); | |
} else { | |
turntablePlayer.soundPositionTimer = setInterval(function () { | |
if (turntablePlayer.sound.position) { | |
LOG("WARNING: soundPositionTimer set, but position is already " + turntablePlayer.sound.position); | |
clearInterval(turntablePlayer.soundPositionTimer); | |
turntablePlayer.soundPositionTimer = null; | |
} | |
var e = util.now() / 1000 - c; | |
if (e < -0.1) { | |
return; | |
} | |
var f = Number(turntablePlayer.sound.duration) / 1000; | |
if (e < f - 1) { | |
if (e < 1) { | |
e = 0; | |
} else { | |
turntablePlayer.sound.setPosition(Math.round(e * 1000)); | |
turntablePlayer.sound.setVolume(turntablePlayer.realVolume(0)); | |
turntablePlayer.fade(turntablePlayer.sound, turntablePlayer.volume, 0.5); | |
} | |
turntablePlayer.sound.play(); | |
clearInterval(turntablePlayer.soundPositionTimer); | |
turntablePlayer.soundPositionTimer = null; | |
} else { | |
if (turntablePlayer.sound.loaded) { | |
clearInterval(turntablePlayer.soundPositionTimer); | |
turntablePlayer.soundPositionTimer = null; | |
turntable.dispatchEvent("soundfinish", turntablePlayer.sound); | |
} | |
} | |
}, 200); | |
turntablePlayer.sound.load(); | |
} | |
} catch (d) { | |
LOG("TurnTable stream could not be created: " + d); | |
turntablePlayer.sound = null; | |
} | |
}, | |
dmcaMute: function () { | |
turntablePlayer.dmcaMuted = true; | |
turntablePlayer.sound.setVolume(0); | |
}, | |
setVolume: function (a) { | |
turntablePlayer.volume = a; | |
if (turntablePlayer.sound) { | |
turntablePlayer.sound.setVolume(turntablePlayer.realVolume(turntablePlayer.calculatedBarsVolume())); | |
} | |
}, | |
realVolume: function (a) { | |
return (a > 0 ? 100 * Math.pow(2, a - 4) : 0); | |
}, | |
barsVolume: function (a) { | |
return (a > 0 ? Math.max(0, Math.log(a / 100) / Math.LN2 + 4) : 0); | |
}, | |
calculatedBarsVolume: function () { | |
if (turntablePlayer.previewSound || turntablePlayer.dmcaMuted) { | |
return 0; | |
} | |
return turntablePlayer.volume; | |
}, | |
playSample: function (a) { | |
turntablePlayer.initDeferred.done(function () { | |
if (turntablePlayer.sound) { | |
turntablePlayer.fade(turntablePlayer.sound, 0); | |
} | |
if (turntablePlayer.previewSound) { | |
turntablePlayer.fade(turntablePlayer.previewSound, 0).done(function (c) { | |
c.destruct(); | |
}); | |
} | |
var b = "/previewfile/?fileid=" + a; | |
turntablePlayer.previewSound = soundManager.createSound({ | |
id: "preview" + a, | |
url: b | |
}); | |
turntablePlayer.previewSound.play(); | |
}); | |
}, | |
stopSample: function () { | |
if (turntablePlayer.previewSound) { | |
turntablePlayer.fade(turntablePlayer.previewSound, 0).done(function (a) { | |
a.destruct(); | |
}); | |
turntablePlayer.previewSound = null; | |
} | |
if (turntablePlayer.sound) { | |
turntablePlayer.fade(turntablePlayer.sound, turntablePlayer.calculatedBarsVolume()); | |
} | |
}, | |
fade: function (g, a, f) { | |
var b = $.Deferred(); | |
if (!f || typeof f != "number") { | |
f = 1.5; | |
} | |
var e = turntablePlayer.barsVolume(g.volume); | |
var d = a - e; | |
var c = util.now(); | |
var h = setInterval(function () { | |
var i = (util.now() - c) / (1000 * f); | |
if (i < 1) { | |
g.setVolume(turntablePlayer.realVolume(e + i * d)); | |
} else { | |
g.setVolume(turntablePlayer.realVolume(a)); | |
clearInterval(h); | |
b.resolve(g); | |
} | |
}, 100); | |
return b.promise(); | |
}, | |
playEphemeral: function (b, a) { | |
turntablePlayer.initDeferred.done(function () { | |
turntablePlayer.loadEphemeralUrl(b, a); | |
}); | |
}, | |
loadEphemeralUrl: function (b, a) { | |
var d = null; | |
if (a) { | |
d = turntablePlayer.ephemeralCache[b]; | |
} | |
if (d) { | |
if (d.playState) { | |
d.setPosition(0); | |
return; | |
} | |
} else { | |
var c = { | |
id: "ephemeral" + util.now(), | |
url: b | |
}; | |
if (!a) { | |
c.onfinish = function () { | |
this.destruct(); | |
}; | |
} | |
d = soundManager.createSound(c); | |
if (a) { | |
turntablePlayer.ephemeralCache[b] = d; | |
} | |
} | |
d.setVolume(turntablePlayer.realVolume(turntablePlayer.volume)); | |
d.play(); | |
} | |
}; | |
$(document).ready(turntable.main); | |
soundManager.onready(turntablePlayer.init); | |
$(window).bind("beforeunload", turntable.closeSocket); | |
turntable.user = { | |
djPoints: 0, | |
acl: 0, | |
fanOf: [], | |
init: function () { | |
var a = turntable.user.initAuth(); | |
a.done(turntable.user.updateDom, turntable.user.getUserInfo); | |
return a; | |
}, | |
initAuth: function () { | |
LOG("Initializing user account..."); | |
var a = $.Deferred(); | |
turntable.user.id = $.cookie("turntableUserId"); | |
turntable.user.auth = $.cookie("turntableUserAuth"); | |
turntable.user.named = ($.cookie("turntableUserNamed") != "false"); | |
if (!turntable.user.id) { | |
turntable.user.createGuest().done(a.resolve); | |
} else { | |
LOG("Authenticating user..."); | |
turntable.sendMessage({ | |
api: "user.authenticate" | |
}, function (b) { | |
if (b.success) { | |
a.resolve(); | |
} else { | |
turntable.user.createGuest().done(a.resolve); | |
} | |
}); | |
} | |
return a.promise(); | |
}, | |
persistAuth: function (b, c, a) { | |
$.cookie("turntableUserId", turntable.user.id = b, { | |
path: "/", | |
expires: 365 | |
}); | |
$.cookie("turntableUserAuth", turntable.user.auth = c, { | |
path: "/", | |
expires: 365 | |
}); | |
$.cookie("turntableUserNamed", String(turntable.user.named = a), { | |
path: "/", | |
expires: 365 | |
}); | |
turntable.dispatchEvent("auth"); | |
}, | |
createGuest: function () { | |
LOG("Creating guest account..."); | |
var a = $.Deferred(); | |
turntable.sendMessage({ | |
api: "user.create" | |
}, function (b) { | |
turntable.user.persistAuth(b.userid, b.userauth, false); | |
a.resolve(); | |
}); | |
return a.promise(); | |
}, | |
showFBLogin: function () { | |
FB.login(turntable.user.fbDidLogin, { | |
perms: "offline_access,email,user_about_me,user_birthday" | |
}); | |
}, | |
fbDidLogin: function (a) { | |
if (a.session && a.perms) { | |
turntable.sendMessage({ | |
api: "user.facebook_login", | |
fbtoken: a.session.access_token | |
}, function (b) { | |
if (b.success) { | |
turntable.user.persistAuth(b.userid, b.userauth, true); | |
turntable.user.updateDom(); | |
turntable.user.getUserInfo(); | |
} | |
}); | |
} | |
}, | |
login: function (b, a) { | |
turntable.sendMessage({ | |
api: "user.login", | |
email: b, | |
password: a | |
}, function (c) { | |
if (c.success) { | |
turntable.user.persistAuth(c.userid, c.userauth, true); | |
turntable.user.updateDom(); | |
turntable.user.getUserInfo(); | |
} else { | |
alert(c.err); | |
} | |
}); | |
}, | |
signUp: function (a, c, b) { | |
turntable.sendMessage({ | |
api: "user.create", | |
name: a, | |
email: c, | |
password: b | |
}, function (d) { | |
if (d.success) { | |
turntable.user.setDisplayName(a); | |
turntable.user.persistAuth(d.userid, d.userauth, true); | |
turntable.user.updateDom(); | |
} | |
}); | |
}, | |
elements: {}, | |
view: null, | |
updateDom: function () { | |
turntable.user.elements = {}; | |
turntable.user.view = util.buildTree(turntable.user.layouts[turntable.user.named ? "signedIn" : "guest"], turntable.user.elements); | |
$("#userauth").empty().append(turntable.user.view); | |
}, | |
loginSubmit: function () { | |
turntable.user.login(turntable.user.elements.loginEmail.value, turntable.user.elements.loginPasswd.value); | |
}, | |
signUpSubmit: function () { | |
var b = $.trim($("#userSignUpName")[0].value); | |
var a = $.trim($("#userSignUpEmail")[0].value); | |
var d = $("#userSignUpPasswd")[0].value; | |
var c = $("#userSignUpPasswd2")[0].value; | |
if (d != c) { | |
alert("passwords do not match"); | |
return; | |
} | |
turntable.user.signUp(b, a, d); | |
}, | |
getUserInfo: function () { | |
turntable.sendMessage({ | |
api: "user.info" | |
}, function (b) { | |
turntable.user.setDisplayName(b.name); | |
turntable.user.djPoints = b.points; | |
turntable.user.avatarId = b.avatarid; | |
turntable.user.acl = b.acl; | |
turntable.sendMessage({ | |
api: "user.get_fan_of" | |
}, function (c) { | |
turntable.user.fanOf = c.fanof; | |
turntable.dispatchEvent("fanofchange"); | |
}); | |
}); | |
turntable.playlist.loadList(); | |
var a = "linux"; | |
if (navigator.userAgent.indexOf("Macintosh") != -1 || navigator.userAgent.indexOf("iPhone") != -1 || navigator.userAgent.indexOf("iPad") != -1) { | |
a = "mac"; | |
} else { | |
if (navigator.userAgent.indexOf("Windows") != -1) { | |
a = "pc"; | |
} else { | |
if (navigator.userAgent.indexOf("CrOS") != -1) { | |
a = "chrome"; | |
} | |
} | |
} | |
setTimeout(function () { | |
turntable.sendMessage({ | |
api: "user.modify", | |
laptop: a | |
}); | |
}, 2000); | |
}, | |
setDisplayName: function (a) { | |
turntable.user.displayName = a; | |
$(".bindUserName").text(a); | |
}, | |
avatarsShow: function () { | |
var a = {}; | |
turntable.showOverlay(util.buildTree(turntable.user.layouts.avatarsView(), a)); | |
turntable.sendMessage({ | |
api: "user.available_avatars" | |
}, function (b) { | |
ASSERT(b.success, "Failed to get available avatars"); | |
turntable.user.avatarsShowTiers(a.tiers, b.avatars); | |
}); | |
}, | |
avatarsShowTiers: function (d, k) { | |
for (var f = 0; f < k.length; f++) { | |
var g = k[f]; | |
if (g.min >= 50000) { | |
continue; | |
} | |
if (g.acl) { | |
var l = "Superusers"; | |
} else { | |
var l = g.min + (f + 1 < k.length ? "-" + (k[f + 1].min - 1) : "+") + " Points"; | |
} | |
var h = util.buildTree(turntable.user.layouts.avatarTier(l)); | |
var a = $(h).find(".avatarList"); | |
var c = (turntable.user.djPoints >= g.min) && (turntable.user.acl >= (g.acl || 0)); | |
for (var e = 0; e < g.avatarids.length; e++) { | |
var b = util.buildTree(turntable.user.layouts.avatarImg(g.avatarids[e], c)); | |
a.append(b); | |
if (g.avatarids[e] == turntable.user.avatarId) { | |
$(b).addClass("currentAvatar"); | |
} | |
} | |
$(d).append(h); | |
} | |
}, | |
avatarLoad: function () { | |
var a = $(this).closest("div.avatar"); | |
a.css("width", $(this).width()); | |
a.css("height", $(this).height()); | |
$(this).addClass("shrink"); | |
}, | |
avatarShrink: function () { | |
$(this).addClass("shrink"); | |
}, | |
avatarUnshrink: function () { | |
$(this).removeClass("shrink"); | |
}, | |
avatarClick: function () { | |
$(".avatar.currentAvatar").removeClass("currentAvatar"); | |
$(this).closest(".avatar").addClass("currentAvatar"); | |
}, | |
avatarClose: function () { | |
var a = $(".avatar.currentAvatar").data("avatarId"); | |
if (a != turntable.user.avatarId) { | |
turntable.user.avatarId = a; | |
turntable.sendMessage({ | |
api: "user.set_avatar", | |
avatarid: a | |
}, function (b) { | |
if (b.success) { | |
turntable.dispatchEvent("avatarchange"); | |
} | |
}); | |
} | |
turntable.hideOverlay(); | |
}, | |
settingsShow: function () { | |
var a = {}; | |
turntable.showOverlay(util.buildTree(turntable.user.layouts.settingsView, a)); | |
a.displayNameField.value = turntable.user.displayName; | |
}, | |
settingsSubmit: function () { | |
var b = $(".settingsOverlay"); | |
var a = $.trim(b.find("input")[0].value); | |
if (!a) { | |
return; | |
} | |
turntable.sendMessage({ | |
api: "user.modify", | |
name: a | |
}, function (c) { | |
if (!c.success) { | |
turntable.showAlert("Sorry, someone else is currently using that name."); | |
return; | |
} else { | |
turntable.user.setDisplayName(a); | |
} | |
}); | |
turntable.hideOverlay(); | |
}, | |
logout: function () { | |
$.cookie("turntableUserId", null, { | |
path: "/", | |
expires: 0 | |
}); | |
$.cookie("turntableUserAuth", null, { | |
path: "/", | |
expires: 0 | |
}); | |
$.cookie("turntableUserNamed", null, { | |
path: "/", | |
expires: 0 | |
}); | |
window.location.replace("/"); | |
} | |
}; | |
turntable.user.layouts = { | |
guest: ["div#menuh", | |
{}, ["div.fbLogin", | |
{ | |
event: { | |
click: turntable.user.showFBLogin | |
} | |
}, ["span", "Login"]]], | |
signedIn: ["div#menuh", | |
{ | |
event: { | |
mouseover: function () { | |
$(".menuItem").addClass("hover"); | |
}, | |
mouseout: function () { | |
$(".menuItem").removeClass("hover"); | |
} | |
} | |
}, ["div.menuItem.first", | |
{}, ["div.settingsHead"], | |
["div.text", "Settings"], | |
["div.downArrow", | |
{ | |
src: "https://s3.amazonaws.com/static.turntable.fm/images/down_arrow.png" | |
}] | |
], | |
["div.menuItem", | |
{ | |
event: { | |
click: turntable.user.avatarsShow | |
} | |
}, "Change avatar"], | |
["div.menuItem", | |
{ | |
event: { | |
click: turntable.user.settingsShow | |
} | |
}, "Change name"], | |
["div.menuItem", | |
{ | |
event: { | |
click: turntable.user.logout | |
} | |
}, "Logout"] | |
], | |
avatarsView: function () { | |
return ["div.avatarsOverlay.modal", {}, ["div.close-x", | |
{ | |
event: { | |
click: turntable.user.avatarClose | |
} | |
}], ["h2", "Choose Avatar"], ["p.djPointsMsg", ["span.djName", "DJ ", ["span.bindUserName", | |
{}, | |
turntable.user.displayName]], ", you have ", ["span.djPoints", | |
{}, | |
turntable.user.djPoints], " points."], ["p.djPointsMsg", "Earn more points to unlock new avatars."], ["div##tiers.avatarTiers"]]; | |
}, | |
avatarTier: function (a) { | |
return ["div.tier", {}, ["div.reqsHeader", | |
{}, | |
a], ["div.avatarList"]]; | |
}, | |
avatarImg: function (b, a) { | |
return ["div.avatar" + (a ? "" : ".locked"), { | |
data: { | |
avatarId: b | |
} | |
}, ["img.avatarImg", | |
{ | |
src: "https://s3.amazonaws.com/static.turntable.fm/roommanager_assets/avatars/" + b + "/fullfront.png", | |
event: { | |
load: turntable.user.avatarLoad, | |
mouseover: a && turntable.user.avatarUnshrink, | |
mouseout: a && turntable.user.avatarShrink, | |
click: a && turntable.user.avatarClick | |
} | |
}], (a ? null : ["img.lockedIcon", | |
{ | |
src: "https://s3.amazonaws.com/static.turntable.fm/images/overlay/avatar_locked_icon.png" | |
}]), ["div.djName", | |
{}, "DJ " + turntable.user.displayName]]; | |
}, | |
settingsView: ["div.settingsOverlay.modal", | |
{}, ["div.close-x", | |
{ | |
event: { | |
click: turntable.hideOverlay | |
} | |
}], | |
["h1", "Settings"], | |
["br"], | |
["div.field", | |
{}, "Display Name:", ["br"], | |
["input##displayNameField.text"] | |
], | |
["div.save-changes.centered-button", | |
{ | |
event: { | |
click: turntable.user.settingsSubmit | |
} | |
}], | |
["br"] | |
] | |
}; | |
turntable.playlist = { | |
files: [], | |
songsByFid: {}, | |
currentSong: null, | |
currentSongTimer: null, | |
filesUploading: [], | |
filesProcessed: 0, | |
filesToProcess: 0, | |
nodes: {}, | |
init: function () { | |
$("#playlist").attr("id", "").replaceWith(util.buildTree(turntable.playlist.layouts.playlistView, turntable.playlist.nodes)); | |
$("#playlist .addSongsButton").click(function () { | |
$("#playlist .queueView").hide(); | |
$("#playlist .addSongsView").show(); | |
$("#plupload .plupload.html5").css("width", $("#pickfiles").css("width")); | |
$("#plupload .plupload.html5").css("height", $("#pickfiles").css("height")); | |
}); | |
$("#playlist .addSongsView .cancelButton").click(function () { | |
$("#playlist .addSongsView").hide(); | |
$("#playlist .queueView").show(); | |
}); | |
$("#playlist .searchView .doneButton").click(turntable.playlist.searchDone); | |
turntable.playlist.realQueue = $("#playlist .queue.realPlaylist"); | |
turntable.playlist.initUpload(); | |
turntable.addEventListener("message", turntable.playlist.messageReceived); | |
}, | |
initUpload: function () { | |
LOG("Initializing plupload..."); | |
var a = turntable.uploader = new plupload.Uploader({ | |
runtimes: "html5,flash,silverlight", | |
browse_button: "pickfiles", | |
browse_button_hover: "hover", | |
browse_button_active: "active", | |
container: "plupload", | |
max_file_size: "30mb", | |
url: "/upload/" + turntable.currentSocketServer, | |
flash_swf_url: "/static/plupload/js/plupload.flash.swf", | |
silverlight_xap_url: "/static/plupload/js/plupload.silverlight.xap", | |
filters: [{ | |
title: "Music files", | |
extensions: "mp3,m4a" | |
}], | |
multipart_params: {} | |
}); | |
a.init(); | |
a.bind("FilesAdded", turntable.playlist.beginUpload); | |
a.bind("UploadProgress", function (b, c) { | |
$(".plFile-" + c.id + " .progress").css("width", c.percent + "%"); | |
}); | |
a.bind("FileUploaded", function (b, d, f) { | |
LOG("file uploaded: " + f.response); | |
var c = JSON.parse(f.response); | |
turntable.playlist.endUpload(d); | |
if (!c.success) { | |
var e = "There was an error uploading " + c.filename + " \u2014 please check the song file."; | |
turntable.playlist.messageReceived({ | |
command: "upload_failed", | |
err: e | |
}); | |
} | |
}); | |
}, | |
loadList: function (a, b) { | |
LOG("Loading user playlist..."); | |
turntable.sendMessage({ | |
api: "playlist.all", | |
playlist_name: "default" | |
}, function (e) { | |
var d = []; | |
for (var c = 0; c < e.list.length; c++) { | |
d.push({ | |
fileId: e.list[c]._id, | |
metadata: e.list[c].metadata | |
}); | |
} | |
turntable.playlist.updatePlaylist(d, a); | |
if (b) { | |
turntable.playlist.queueAnimTask(b); | |
} | |
}); | |
}, | |
clearPlaylist: function () { | |
turntable.playlist.updatePlaylist([], false); | |
}, | |
setCurrentSong: function (b) { | |
if (turntable.playlist.currentSong == null && b == null) { | |
return; | |
} | |
turntable.playlist.previewStop(); | |
if (turntable.playlist.currentSongTimer) { | |
clearInterval(turntable.playlist.currentSongTimer); | |
turntable.playlist.currentSongTimer = null; | |
} | |
var a = function () { | |
turntable.playlist.currentSong = (b ? { | |
fileId: b._id, | |
metadata: b.metadata | |
} : null); | |
turntable.playlist.updateTopSongClass(); | |
if (turntable.playlist.currentSong) { | |
var c = Math.max(500, 1000 * b.metadata.length / $("#playlist .queue").width()); | |
turntable.playlist.currentSongTimer = setInterval(turntable.playlist.updateCurrentSongProgress, c); | |
} | |
}; | |
if (turntable.playlist.currentSong) { | |
if (b) { | |
turntable.playlist.setEditsLocked(true); | |
turntable.playlist.loadList(750, a); | |
} else { | |
turntable.playlist.queueTask(function () { | |
a(); | |
turntable.playlist.updatePlaylist(null, 750); | |
}); | |
} | |
} else { | |
turntable.playlist.setEditsLocked(true); | |
a(); | |
turntable.playlist.loadList(false); | |
} | |
}, | |
resetQueueView: function () { | |
turntable.playlist.searchDone(); | |
}, | |
updateCurrentSongProgress: function () { | |
try { | |
var a = 0.1 * turntablePlayer.sound.position / turntable.playlist.currentSong.metadata.length; | |
turntable.playlist.realQueue.find(".currentSong .progress").css("width", a + "%"); | |
} catch (b) {} | |
}, | |
messageReceived: function (b) { | |
if (b.command == "upload_complete") { | |
turntable.playlist.filesProcessed += 1; | |
if (turntable.playlist.filesProcessed >= turntable.playlist.filesToProcess) { | |
turntable.playlist.filesProcessed = turntable.playlist.filesToProcess = 0; | |
} | |
turntable.playlist.updateProcessing(); | |
if (turntable.playlist.songsByFid.hasOwnProperty(b.fid)) { | |
return; | |
} | |
turntable.playlist.addSong({ | |
fileId: b.fid, | |
metadata: b.metadata | |
}); | |
} else { | |
if (b.command == "upload_failed") { | |
var a = b.err || "Your upload failed. There may have been a problem with the file, or the song wasn't long enough."; | |
if (turntable.topViewController && turntable.topViewController.showRoomTip) { | |
turntable.topViewController.showRoomTip(a); | |
} | |
if (turntable.playlist.filesToProcess > 0) { | |
turntable.playlist.filesToProcess -= 1; | |
turntable.playlist.updateProcessing(); | |
} | |
} | |
} | |
}, | |
editTask: null, | |
resolvingEdits: false, | |
setEditsLocked: function (a) { | |
if (a) { | |
if (turntable.playlist.editTask == null) { | |
turntable.playlist.editTask = $.Deferred(); | |
} | |
} else { | |
if (turntable.playlist.editTask != null) { | |
turntable.playlist.resolvingEdits = true; | |
turntable.playlist.editTask.resolve(); | |
turntable.playlist.resolvingEdits = false; | |
turntable.playlist.editTask = null; | |
} | |
} | |
turntable.playlist.setSortableEnabled(!a); | |
}, | |
queueTask: function (a) { | |
(turntable.playlist.editTask ? turntable.playlist.editTask.done(a) : a()); | |
}, | |
animTask: null, | |
beginAnimTask: function () { | |
ASSERT(turntable.playlist.editTask != null, "Edits must be locked"); | |
ASSERT(turntable.playlist.animTask == null, "There are pending animations"); | |
turntable.playlist.animTask = $.Deferred(); | |
}, | |
endAnimTask: function () { | |
turntable.playlist.animTask.resolve(); | |
turntable.playlist.animTask = null; | |
}, | |
queueAnimTask: function (a) { | |
(turntable.playlist.animTask ? turntable.playlist.animTask.done(a) : a()); | |
}, | |
beginUpload: function (f, b) { | |
ASSERT(b.length, "beginUpload called with 0 files... intentional?"); | |
$("#playlist .addSongsView").hide(); | |
$("#playlist .queueView").show(); | |
turntable.playlist.filesToProcess += b.length; | |
turntable.playlist.updateProcessing(); | |
var d = $("#playlist .queueView .songlist"); | |
var a = d.find(".uploads"); | |
for (var e = 0; e < b.length; e++) { | |
var c = $(util.buildTree(turntable.playlist.layouts.uploadingView(b[e].name))); | |
c.addClass("plFile-" + b[e].id); | |
a.append(c); | |
} | |
d[0].scrollTop = turntable.playlist.realQueue.height(); | |
turntable.playlist.filesUploading = turntable.playlist.filesUploading.concat(b); | |
turntable.uploader.settings.url = "/upload/" + turntable.currentSocketServer; | |
turntable.uploader.settings.multipart_params.userid = turntable.user.id; | |
turntable.uploader.settings.multipart_params.userauth = turntable.user.auth; | |
turntable.uploader.settings.multipart_params.port = String(turntable.socket.options.port); | |
f.start(); | |
}, | |
endUpload: function (a) { | |
LOG(a.name + " finished uploading"); | |
var c = $.inArray(a, turntable.playlist.filesUploading); | |
ASSERT(c != -1, "Never began uploading " + a.name); | |
turntable.playlist.filesUploading.splice(c, 1); | |
var b = a.id; | |
$(".plFile-" + b).animate({ | |
height: 0, | |
opacity: 0 | |
}, { | |
duration: 400, | |
complete: function () { | |
$(this).remove(); | |
} | |
}); | |
turntable.playlist.updateProcessing(); | |
}, | |
addSong: function (b, a) { | |
turntable.playlist.queueTask(function () { | |
var c = b.fileId; | |
if (a === null || a === undefined) { | |
a = turntable.playlist.files.length - (turntable.playlist.currentSong ? 1 : 0); | |
} | |
turntable.playlist.files.splice(a, 0, b); | |
turntable.playlist.songsByFid[b.fileId] = b; | |
turntable.playlist.updatePlaylist(null, true); | |
turntable.sendMessage({ | |
api: "playlist.add", | |
playlist_name: "default", | |
song_dict: { | |
fileid: c | |
}, | |
index: a | |
}, function (d) { | |
if (!d.success) { | |
turntable.playlist.loadList(false); | |
} | |
}); | |
}); | |
}, | |
removeFile: function (a) { | |
turntable.playlist.queueTask(function () { | |
var b = -1; | |
for (var c = 0; c < turntable.playlist.files.length; c++) { | |
if (turntable.playlist.files[c].fileId == a) { | |
b = c; | |
break; | |
} | |
} | |
if (b == -1) { | |
return; | |
} | |
if (turntable.playlist.currentSong && b == turntable.playlist.files.length - 1) { | |
return; | |
} | |
turntable.playlist.files.splice(b, 1); | |
delete turntable.playlist.songsByFid[a]; | |
turntable.playlist.updatePlaylist(null, 100); | |
turntable.sendMessage({ | |
api: "playlist.remove", | |
playlist_name: "default", | |
index: b | |
}, function (d) { | |
ASSERT(d.success, "Song could not be removed"); | |
}); | |
}); | |
}, | |
removeSongClicked: function (a) { | |
var b = $(this).closest(".song"); | |
ASSERT(!b.hasClass("currentSong"), "Can't remove current song"); | |
turntable.playlist.removeFile(b.data("songData").fileId); | |
}, | |
searchKeyUp: function (c) { | |
var a = $(this); | |
var b = a.closest(".search").find(".mag-glass"); | |
if (a.val()) { | |
b.addClass("clearSearch"); | |
} else { | |
b.removeClass("clearSearch"); | |
} | |
}, | |
searchClear: function (a) { | |
var c = $(this); | |
if (c.hasClass("clearSearch")) { | |
c.removeClass("clearSearch"); | |
var b = c.closest(".search").find("input"); | |
b.val(""); | |
b.focus(); | |
} | |
}, | |
submitSearchQuery: function () { | |
var a = $(this); | |
var b = $.trim(a.find("input").val()); | |
if (!b) { | |
return; | |
} | |
$("#playlist .searchView .songSearch input").val(b); | |
turntable.sendMessage({ | |
api: "file.search", | |
query: b | |
}, function () { | |
turntable.playlist.waitSearchResults(b); | |
}); | |
turntable.playlist.previewStop(); | |
$(".queueView").hide(); | |
$(".addSongsView").hide(); | |
$(".searchView").show(); | |
$(".searchView .searchingBlocker").fadeTo(100, 0.9); | |
}, | |
waitSearchResults: function (a) { | |
if (!turntable.playlist.pendingSearchQuery) { | |
turntable.addEventListener("message", turntable.playlist.showSearchResults); | |
} | |
turntable.playlist.pendingSearchQuery = a; | |
}, | |
showSearchResults: function (g) { | |
if (g.command != "search_complete") { | |
return; | |
} | |
if (g.query != turntable.playlist.pendingSearchQuery) { | |
return; | |
} | |
turntable.playlist.pendingSearchQuery = null; | |
turntable.removeEventListener("message", turntable.playlist.showSearchResults); | |
if ($(".searchView").css("display") == "none") { | |
return; | |
} | |
$(".searchView .searchingBlocker").fadeOut("fast"); | |
$(".searchView input").focus(); | |
$(".searchView .mag-glass").addClass("clearSearch"); | |
turntable.playlist.numFilesAdded = 0; | |
$(".searchView .numFilesAdded").text("(0) Songs added"); | |
$(".searchView .queue").empty(); | |
$(".searchView .songlist")[0].scrollTop = 0; | |
var d = null; | |
if (!g.success) { | |
d = "Error: " + g.err; | |
} else { | |
if (g.docs.length == 0) { | |
d = "Sorry, no results. Help us grow our library by uploading something."; | |
} | |
} | |
if (d) { | |
$(".searchView .emptySearchResults").show().text(d); | |
$(".searchView .separator").hide(); | |
return; | |
} | |
$(".searchView .emptySearchResults").hide(); | |
var b = $(".searchView .externQueue"); | |
var f = $(".searchView .inMyQueue"); | |
for (var c = 0; c < g.docs.length; c++) { | |
var h = g.docs[c]; | |
var e = (turntable.playlist.songsByFid.hasOwnProperty(h._id) ? f : b); | |
var a = { | |
fileId: h._id, | |
metadata: h.metadata | |
}; | |
e.append(util.buildTree(turntable.playlist.layouts.searchedSongView(a))); | |
} | |
$(".searchView .separator").css("display", f.children().length ? "block" : "none"); | |
}, | |
addSearchResult: function () { | |
var b = $(this).closest(".song"); | |
b.addClass("addedToQueue"); | |
b.find(".addSong").hide(); | |
b.find(".goTop").hide(); | |
b.find(".checkmark").show(); | |
var a = b.data("songData"); | |
if (b.closest(".queue").hasClass("externQueue")) { | |
turntable.playlist.addSong(a, 0); | |
turntable.playlist.numFilesAdded += 1; | |
$(".searchView .numFilesAdded").text("(" + turntable.playlist.numFilesAdded + ") Songs added"); | |
} else { | |
turntable.playlist.moveFileToTop(a.fileId); | |
b.find(".addedToQueueTop").show().delay(1500).fadeOut(500); | |
} | |
}, | |
remSearchResult: function () { | |
var a = $(this).closest(".song"); | |
if (a.closest(".queue").hasClass("externQueue")) { | |
turntable.playlist.removeFile(a.data("songData").fileId); | |
a.removeClass("addedToQueue"); | |
a.find(".addSong").show(); | |
a.find(".checkmark").hide(); | |
turntable.playlist.numFilesAdded -= 1; | |
$(".searchView .numFilesAdded").text("(" + turntable.playlist.numFilesAdded + ") Songs added"); | |
} | |
}, | |
searchDone: function (a) { | |
turntable.playlist.previewStop(); | |
$("#playlist .search input").val(""); | |
$("#playlist .search .mag-glass").removeClass("clearSearch"); | |
$(".queueView").show(); | |
$(".addSongsView").hide(); | |
$(".searchView").hide(); | |
}, | |
previewTimer: null, | |
previewProgressTimer: null, | |
previewPlay: function () { | |
var a = $(this).closest(".song"); | |
if (turntable.playlist.previewTimer) { | |
clearTimeout(turntable.playlist.previewTimer); | |
clearInterval(turntable.playlist.previewProgressTimer); | |
turntable.playlist.previewTimer = null; | |
turntable.playlist.previewProgressTimer = null; | |
$(".playlist-container .song.currentPreview").removeClass("currentPreview"); | |
} | |
turntablePlayer.playSample(a.data("songData").fileId); | |
a.addClass("currentPreview"); | |
a.find(".progress").css("width", "0%"); | |
turntable.playlist.previewTimer = setTimeout(turntable.playlist.previewStop, 30000); | |
turntable.playlist.previewProgressTimer = setInterval(turntable.playlist.previewUpdateProgress, 100); | |
}, | |
previewUpdateProgress: function () { | |
try { | |
var a = Number(turntablePlayer.previewSound.position) / 27000 * 100; | |
$(".playlist-container .song.currentPreview .progress").css("width", a + "%"); | |
} catch (b) {} | |
}, | |
previewStop: function () { | |
if (turntable.playlist.previewTimer) { | |
clearTimeout(turntable.playlist.previewTimer); | |
clearInterval(turntable.playlist.previewProgressTimer); | |
turntable.playlist.previewTimer = null; | |
turntable.playlist.previewProgressTimer = null; | |
turntablePlayer.stopSample(); | |
} | |
$(".playlist-container .song.currentPreview").removeClass("currentPreview"); | |
}, | |
humanDuration: function (a) { | |
return Math.floor(a / 60) + ":" + String(a % 60 + 100).substr(1); | |
}, | |
updateProcessing: function () { | |
var a = $(turntable.playlist.nodes.root).find(".processing"); | |
if (turntable.playlist.filesToProcess > 0) { | |
a.find(".text").text("Processed " + turntable.playlist.filesProcessed + " of " + turntable.playlist.filesToProcess + " files"); | |
a.slideDown(); | |
} else { | |
a.slideUp(); | |
} | |
turntable.playlist.updateDjQueueDecoration(); | |
}, | |
moveSongToTopClicked: function (a) { | |
var b = $(this).closest(".song"); | |
ASSERT(!b.hasClass("topSong"), "Cannot move top song to top"); | |
turntable.playlist.moveFileToTop(b.data("songData").fileId); | |
}, | |
moveFileToTop: function (a) { | |
turntable.playlist.queueTask(function () { | |
var b; | |
for (var b = 1; b < turntable.playlist.files.length; b++) { | |
if (turntable.playlist.files[b].fileId == a) { | |
break; | |
} | |
} | |
if (b == turntable.playlist.files.length) { | |
return; | |
} | |
var c = turntable.playlist.files[b]; | |
LOG("Moving '" + c.metadata.song + "' to top"); | |
if (turntable.playlist.currentSong && c.fileId == turntable.playlist.currentSong.fileId) { | |
LOG("Moving a currently-playing song to top is a no-op"); | |
return; | |
} | |
turntable.playlist.files.splice(b, 1); | |
turntable.playlist.files.unshift(c); | |
turntable.playlist.updatePlaylist(null, true); | |
turntable.sendMessage({ | |
api: "playlist.reorder", | |
playlist_name: "default", | |
index_from: b, | |
index_to: 0 | |
}); | |
}); | |
}, | |
updateSongsByFid: function () { | |
turntable.playlist.songsByFid = {}; | |
for (var b = 0; b < turntable.playlist.files.length; b++) { | |
var a = turntable.playlist.files[b]; | |
turntable.playlist.songsByFid[a.fileId] = a; | |
} | |
}, | |
updateTopSongClass: function () { | |
var a = turntable.playlist.realQueue.find(".song"); | |
a.removeClass("topSong").removeClass("currentSong"); | |
a.first().addClass("topSong"); | |
if (turntable.playlist.currentSong) { | |
for (var b = 0; b < a.length; b++) { | |
ASSERT(a.eq(b).data("songData"), "updateTopSongClass: songDivs " + b + " has no songData"); | |
if (a.eq(b).data("songData").fileId == turntable.playlist.currentSong.fileId) { | |
var c = a.eq(b); | |
c.addClass("topSong").addClass("currentSong"); | |
break; | |
} | |
} | |
} | |
turntable.playlist.updateDjQueueDecoration(); | |
}, | |
updateDjQueueDecoration: function () { | |
var a = turntable.playlist.realQueue.find(".song"); | |
$("#playlist .queueView .topSongRecordIcon").css("display", a.length ? "block" : "none"); | |
var b = turntable.playlist.realQueue.find(".uploading"); | |
$("#playlist .queueView .emptyQueue").css("display", (a.length + b.length) ? "none" : "block"); | |
}, | |
updatePlaylist: function (b, a) { | |
turntable.playlist.queueAnimTask(function () { | |
turntable.playlist.updatePlaylistImmediately(b, a); | |
}); | |
}, | |
updatePlaylistImmediately: function (c, b) { | |
if (!c) { | |
c = turntable.playlist.files; | |
} | |
if (b && turntable.playlist.animTask == null && !turntable.playlist.resolvingEdits && $(".queueView").css("display") != "none") { | |
if (typeof (b) != "number") { | |
b = 250; | |
} | |
turntable.playlist.setEditsLocked(true); | |
turntable.playlist.beginAnimTask(); | |
var a = turntable.playlist.animateSetup(c); | |
a.target.animate(a.properties, { | |
duration: b, | |
step: turntable.playlist.animateStep, | |
complete: function () { | |
turntable.playlist.animateComplete(); | |
turntable.playlist.updateTopSongClass(); | |
turntable.playlist.endAnimTask(); | |
turntable.playlist.setEditsLocked(false); | |
} | |
}); | |
} else { | |
turntable.playlist.updateQueueSongs(c); | |
turntable.playlist.updateTopSongClass(); | |
turntable.playlist.setEditsLocked(false); | |
} | |
}, | |
animateSetup: function (k) { | |
if (turntable.playlist.currentSong) { | |
k.unshift(k.pop()); | |
} | |
var l = {}; | |
for (var h = 0; h < k.length; h++) { | |
l[k[h].fileId] = h; | |
} | |
var b = turntable.playlist.realQueue; | |
var j = b[0]; | |
var c, g, d; | |
var f = b.find(".song"); | |
var a = f.width(); | |
b.data({ | |
moveVector: 42 * (k.length - f.length), | |
from: 42 * f.length | |
}); | |
b.css({ | |
height: 42 * f.length | |
}); | |
for (var h = 0; $(j.firstChild).hasClass("song"); h++) { | |
d = $(j.firstChild); | |
c = d.data("songData").fileId; | |
if (c in l) { | |
var m = l[c] - h; | |
g = b.find(".mover" + m); | |
if (g.length == 0) { | |
g = util.buildTree(["div.mover.mover" + m, | |
{ | |
data: { | |
moveVector: 42 * m | |
}, | |
style: { | |
zIndex: Math.abs(m) | |
} | |
}]); | |
b.append(g); | |
} | |
delete l[c]; | |
} else { | |
g = $(j).find(".moverRemover"); | |
if (g.length == 0) { | |
g = util.buildTree(["div.mover.moverRemover", | |
{ | |
data: { | |
moveVector: "remove" | |
} | |
}]); | |
b.append(g); | |
} | |
} | |
d.appendTo(g).css({ | |
top: 42 * h | |
}); | |
} | |
for (var h = 0; h < k.length; h++) { | |
c = k[h].fileId; | |
if (!(c in l)) { | |
continue; | |
} | |
g = b.find(".moverInserter"); | |
if (g.length == 0) { | |
g = util.buildTree(["div.mover.moverInserter", | |
{ | |
data: { | |
moveVector: "insert" | |
}, | |
style: { | |
opacity: 0 | |
} | |
}]); | |
b.append(g); | |
} | |
d = util.buildTree(turntable.playlist.layouts.songView(k[h])); | |
$(d).appendTo(g).css({ | |
top: 42 * h | |
}); | |
} | |
b.find(".song").css({ | |
position: "absolute", | |
width: a | |
}); | |
var e = util.buildTree(["div.animController", | |
{ | |
style: { | |
position: "absolute" | |
} | |
}]); | |
b.append(e); | |
if (turntable.playlist.currentSong) { | |
k.push(k.shift()); | |
} | |
turntable.playlist.files = k; | |
turntable.playlist.updateSongsByFid(); | |
return { | |
target: $(e), | |
properties: { | |
width: 1 | |
} | |
}; | |
}, | |
animateStep: function (a) { | |
var b = turntable.playlist.realQueue.data(); | |
turntable.playlist.realQueue.css({ | |
height: b.from + a * b.moveVector | |
}); | |
turntable.playlist.realQueue.find(".mover").each(function () { | |
var c = $(this).data("moveVector"); | |
if (c == "insert") { | |
$(this).css({ | |
opacity: a | |
}); | |
} else { | |
if (c == "remove") { | |
$(this).css({ | |
opacity: 1 - a | |
}); | |
} else { | |
$(this).css({ | |
top: a * c | |
}); | |
} | |
} | |
}); | |
}, | |
animateComplete: function () { | |
var h = turntable.playlist.realQueue; | |
h.css({ | |
height: "" | |
}); | |
h.find(".animController").remove(); | |
h.find(".moverRemover").remove(); | |
var e = h.find(".mover"); | |
var k = turntable.playlist.files; | |
if (turntable.playlist.currentSong) { | |
k.unshift(k.pop()); | |
} | |
var a = null; | |
for (var g = 0; g < k.length; g++) { | |
var c = k[g].fileId; | |
for (var f = 0; f < e.length; f++) { | |
var b = $(e[f].firstChild); | |
if (b.data("songData").fileId == c) { | |
if (a == null) { | |
b.prependTo(h); | |
} else { | |
b.insertAfter(a); | |
} | |
a = b; | |
if (!e[f].hasChildNodes()) { | |
$(e[f]).remove(); | |
e = h.find(".mover"); | |
} | |
break; | |
} | |
} | |
} | |
if (turntable.playlist.currentSong) { | |
k.push(k.shift()); | |
} | |
var d = h.find(".song"); | |
d.css({ | |
position: "", | |
width: "", | |
top: "", | |
zIndex: "" | |
}); | |
d.removeClass("nth-child-even").filter(":even").addClass("nth-child-even"); | |
}, | |
updateQueueSongs: function (g) { | |
if (turntable.playlist.currentSong) { | |
g.unshift(g.pop()); | |
LOG(g[0].metadata.song + " is logically last, but visually first"); | |
} | |
var a = turntable.playlist.realQueue; | |
var b = a.find(".song"); | |
place_ith_node: for (var f = 0; f < g.length; f++) { | |
var h = g[f]; | |
ASSERT(h, "list[" + f + "] is null"); | |
var c; | |
for (var e = f; e < b.length; e++) { | |
c = b.eq(e); | |
var d = c.data("songData"); | |
if (!d) { | |
turntable.showAlert("songDiv #" + e + " has no songData"); | |
LOG("songDiv #" + e + " has no songData"); | |
continue; | |
} | |
if (d.fileId == h.fileId) { | |
if (e == f) { | |
continue place_ith_node; | |
} | |
break; | |
} | |
} | |
if (e >= b.length) { | |
c = $(util.buildTree(turntable.playlist.layouts.songView(h))); | |
} | |
if (f == 0) { | |
a.prepend(c); | |
} else { | |
c.insertAfter(b.eq(f - 1)); | |
} | |
b = b.add(c); | |
} | |
b.slice(f).remove(); | |
if (turntable.playlist.currentSong) { | |
g.push(g.shift()); | |
} | |
turntable.playlist.files = g; | |
turntable.playlist.updateSongsByFid(); | |
b.removeClass("nth-child-even").filter(":even").addClass("nth-child-even"); | |
}, | |
sortableEnabled: false, | |
sortableEnableTimer: null, | |
setSortableEnabled: function (a) { | |
if (a) { | |
if (turntable.playlist.sortableEnableTimer == null) { | |
if (turntable.playlist.sortableEnabled) { | |
turntable.playlist.realQueue.sortable("destroy"); | |
} | |
turntable.playlist.sortableEnableTimer = setTimeout(function () { | |
var b = { | |
axis: "y", | |
items: ".song:not(.currentSong)", | |
start: turntable.playlist.songSortStarted, | |
change: turntable.playlist.songSortChanged, | |
update: turntable.playlist.songSortUpdated | |
}; | |
turntable.playlist.realQueue.sortable(b); | |
turntable.playlist.sortableEnableTimer = null; | |
}, 100); | |
} | |
} else { | |
if (turntable.playlist.sortableEnabled) { | |
if (turntable.playlist.sortableEnableTimer) { | |
clearTimeout(turntable.playlist.sortableEnableTimer); | |
turntable.playlist.sortableEnableTimer = null; | |
} else { | |
if ($(".song.ui-sortable-helper").length) { | |
turntable.playlist.sortableEnabled = false; | |
turntable.playlist.realQueue.sortable("cancel"); | |
} | |
turntable.playlist.realQueue.sortable("destroy"); | |
} | |
} | |
} | |
turntable.playlist.sortableEnabled = a; | |
}, | |
songSortStarted: function (c, d) { | |
var a = d.item.data("songData").fileId; | |
for (var b = 0; b < turntable.playlist.files.length; b++) { | |
if (turntable.playlist.files[b].fileId == a) { | |
turntable.playlist.songSortSrcIndex = b; | |
break; | |
} | |
} | |
}, | |
songSortChanged: function () { | |
turntable.playlist.updateTopSongClass(); | |
}, | |
songSortUpdated: function (b, d) { | |
if (!turntable.playlist.sortableEnabled) { | |
return; | |
} | |
turntable.playlist.songSortChanged(); | |
var a = turntable.playlist.songSortSrcIndex; | |
var c = turntable.playlist.realQueue.find(".song").index(d.item); | |
ASSERT(c >= 0, "Sortable song not found"); | |
if (turntable.playlist.currentSong) { | |
ASSERT(c != 0, "Current song not sortable"); | |
c -= 1; | |
} | |
turntable.sendMessage({ | |
api: "playlist.reorder", | |
playlist_name: "default", | |
index_from: a, | |
index_to: c | |
}, function (f) { | |
var e = turntable.playlist.files[a]; | |
turntable.playlist.files[a] = turntable.playlist.files[c]; | |
turntable.playlist.files[c] = e; | |
}); | |
setTimeout(function () { | |
var e = turntable.playlist.realQueue.find(".song"); | |
e.removeClass("nth-child-even").filter(":even").addClass("nth-child-even"); | |
}, 0); | |
}, | |
setPlaylistHeight: function (a) { | |
if (a === null || a === undefined) { | |
a = 351; | |
} else { | |
if (a < 25) { | |
a = 25; | |
} | |
} | |
$(turntable.playlist.nodes.root).css({ | |
height: a | |
}); | |
$(turntable.playlist.nodes.root).find(".mainPane").css({ | |
height: a - 25 | |
}); | |
$(turntable.playlist.nodes.root).find(".queueView .songlist").css({ | |
height: Math.max(a - 67, 55) | |
}); | |
$(turntable.playlist.nodes.root).find(".searchView .songlist").css({ | |
height: Math.max(a - 95, 55) | |
}); | |
return a; | |
} | |
}; | |
turntable.playlist.layouts = { | |
playlistView: ["div#playlist##root.playlist-container", | |
{}, ["div.black-right-header", | |
{}, ["img.icon", | |
{ | |
src: "https://s3.amazonaws.com/static.turntable.fm/images/room/music_icon.png" | |
}], | |
["div.header-text", | |
{}, "My DJ Queue"] | |
], | |
["div.queueView.mainPane", | |
{}, ["div.addSongsButton"], | |
["div.songlist", | |
{}, ["div.queue.realPlaylist"], | |
["div.uploads", | |
{}, ["div.processing", | |
{ | |
style: { | |
display: "none" | |
} | |
}, ["div.loader"], | |
["div.text"] | |
]], | |
["div.emptyQueue", | |
{ | |
style: { | |
display: "none" | |
} | |
}, ["div.text", "Search or upload music to create your DJ queue."], | |
["div.text", "Click 'Play Music' and your topmost song will play during your turn."] | |
], | |
["div.topSongRecordIcon", | |
{ | |
style: { | |
display: "none" | |
} | |
}] | |
] | |
], | |
["div.addSongsView.mainPane", | |
{ | |
style: { | |
display: "none" | |
} | |
}, ["div.searchText", "Search Turntable music library"], | |
["form.search.songSearch", | |
{ | |
event: { | |
submit: turntable.playlist.submitSearchQuery | |
} | |
}, ["input", | |
{ | |
type: "text", | |
placeholder: "track, artist, album name", | |
event: { | |
keyup: turntable.playlist.searchKeyUp | |
} | |
}], | |
["div.mag-glass", | |
{ | |
event: { | |
click: turntable.playlist.searchClear | |
} | |
}] | |
], | |
["div.orText", "\u2013 or \u2013"], | |
["div.upload-button", ["div#plupload", ["div#pickfiles"]]], | |
["div.cancelButton"], | |
["div.poweredBy"] | |
], | |
["div.searchView.mainPane", | |
{ | |
style: { | |
display: "none" | |
} | |
}, ["form.input.songSearch", | |
{ | |
event: { | |
submit: turntable.playlist.submitSearchQuery | |
} | |
}, ["div.search", | |
{}, ["input", | |
{ | |
type: "text", | |
placeholder: "song, artist, or album", | |
event: { | |
keyup: turntable.playlist.searchKeyUp | |
} | |
}], | |
["div.mag-glass", | |
{ | |
event: { | |
click: turntable.playlist.searchClear | |
} | |
}] | |
], | |
["div.searchHeader", | |
{}, ["div.numFilesAdded"], | |
["div.doneButton"] | |
] | |
], | |
["div.songlist", | |
{}, ["div.queue.externQueue"], | |
["div.separator.separator-in-queue", | |
{}, ["div.text", "Results from my queue"]], | |
["div.queue.inMyQueue"], | |
["div.emptySearchResults"] | |
], | |
["div.searchingBlocker", | |
{}, ["div.text", "searching..."], | |
["br"], | |
["img", | |
{ | |
src: "https://s3.amazonaws.com/static.turntable.fm/images/playlist/bigloader.gif" | |
}] | |
] | |
] | |
], | |
songView: function (b) { | |
var a = b.metadata; | |
return ["div.song", { | |
data: { | |
songData: b | |
} | |
}, ["div.progress"], ["div.goTop", | |
{ | |
event: { | |
click: turntable.playlist.moveSongToTopClicked | |
} | |
}], ["div.playSample", | |
{ | |
event: { | |
click: turntable.playlist.previewPlay | |
} | |
}], ["div.pauseSample", | |
{ | |
event: { | |
click: turntable.playlist.previewStop | |
} | |
}], ["div.title", | |
{ | |
title: a.song | |
}, | |
a.song], ["div.details", | |
{}, | |
a.artist + " - " + turntable.playlist.humanDuration(a.length)], ["div.remove", | |
{ | |
event: { | |
click: turntable.playlist.removeSongClicked | |
} | |
}]]; | |
}, | |
searchedSongView: function (b) { | |
var a = b.metadata; | |
return ["div.song", { | |
data: { | |
songData: b | |
} | |
}, ["div.progress"], ["div.addSong", | |
{ | |
event: { | |
click: turntable.playlist.addSearchResult | |
} | |
}], ["div.goTop", | |
{ | |
event: { | |
click: turntable.playlist.addSearchResult | |
} | |
}], ["div.checkmark", | |
{ | |
event: { | |
click: turntable.playlist.remSearchResult | |
}, | |
style: { | |
display: "none" | |
} | |
}], ["div.playSample", | |
{ | |
event: { | |
click: turntable.playlist.previewPlay | |
} | |
}], ["div.pauseSample", | |
{ | |
event: { | |
click: turntable.playlist.previewStop | |
} | |
}], ["div.title", | |
{ | |
title: a.song | |
}, | |
a.song], ["div.details", | |
{}, | |
a.artist + " - " + turntable.playlist.humanDuration(a.length)], ["div.addedToQueueTop", | |
{ | |
style: { | |
display: "none" | |
} | |
}, ["div.text", "Added to top of queue"]]]; | |
}, | |
uploadingView: function (a) { | |
return ["div.uploading", {}, ["div.progress"], ["div.text", | |
{}, | |
a], ["div.details", | |
{}, "Uploading..."]]; | |
} | |
}; | |
var welcome = { | |
elements: {}, | |
init: function () { | |
welcome.view = util.buildTree(welcome.layouts.indexPage, welcome.elements); | |
welcome.roomList = new RoomList(); | |
$(welcome.elements.roomListContainer).append(welcome.roomList.view); | |
$(welcome.elements.userauth).append($("#userauth")); | |
}, | |
createRoomShow: function () { | |
turntable.showOverlay(util.buildTree(welcome.layouts.createRoomView)); | |
$("input.roomName").focus(); | |
$(".roomtype-option").click(function () { | |
$(this).find(".radio-input").attr("checked", true); | |
$(".roomtype-option").removeClass("roomtype-option-on"); | |
$(this).addClass("roomtype-option-on"); | |
}); | |
}, | |
createRoomSubmit: function () { | |
var d = $(".createRoom"); | |
var a = $.trim(d.find(".roomName")[0].value); | |
if (!a) { | |
return; | |
} | |
var c = d.find(".public")[0].checked; | |
var b = Number(d.find("select")[0].value); | |
turntable.sendMessage({ | |
api: "room.create", | |
room_name: a, | |
max_djs: b, | |
privacy: (c ? "public" : "unlisted") | |
}, welcome.createRoomDone); | |
turntable.hideOverlay(); | |
}, | |
createRoomDone: function (a) { | |
turntable.setPage(a.shortcut, a.roomid); | |
}, | |
advancedOptions: function () { | |
var a = $(".overlay div.advanced"); | |
if (a.css("display") == "none") { | |
a.show(); | |
$(".overlay div.show-advanced").text("close advanced options"); | |
} else { | |
a.hide(); | |
$(".overlay div.show-advanced").text("advanced options"); | |
} | |
}, | |
cleanup: function () { | |
$("#offstage").append($("#userauth")); | |
welcome.roomList.cleanup(); | |
welcome.roomList = null; | |
} | |
}; | |
welcome.layouts = { | |
indexPage: ["div", | |
{}, ["div#header", | |
{}, ["div##userauth.userauthContainer"]], | |
["div#content", | |
{}, ["p.centeredImage", | |
{}, ["img", | |
{ | |
src: "https://s3.amazonaws.com/static.turntable.fm/images/logo.png" | |
}]], | |
["h1", | |
{}, "Play music together."], | |
["p.centeredButtons", ["a.create-btn", | |
{ | |
event: { | |
click: welcome.createRoomShow | |
} | |
}], | |
["a.random-btn", | |
{ | |
event: { | |
click: turntable.randomRoom | |
} | |
}] | |
], | |
["br"], | |
["br"], | |
["div##roomListContainer"] | |
] | |
], | |
createRoomView: ["div.createRoom.modal", | |
{}, ["div.close-x", | |
{ | |
event: { | |
click: turntable.hideOverlay | |
} | |
}], | |
["h1", "Create Room"], | |
["br"], "Room name:", ["br"], | |
["input.roomName.text"], | |
["br"], | |
["br"], "Set my room as:", ["div.type", | |
{}, ["div.roomtype", | |
{}, ["div.roomtype-option.roomtype-option-on", | |
{}, "Public", ["div.radios", | |
{}, ["input.radio-input.public", | |
{ | |
type: "radio", | |
name: "type", | |
value: "public", | |
checked: true | |
}]], | |
["div.tip", | |
{}, "(anyone can join)"] | |
]], | |
["div.roomtype", | |
{}, ["div.roomtype-option", | |
{}, "Unlisted", ["div.radios", | |
{}, ["input.radio-input", | |
{ | |
type: "radio", | |
name: "type", | |
value: "unlisted" | |
}]], | |
["div.tip", | |
{}, "(only people with the link can join)"] | |
]], ], | |
["div.advanced", | |
{}, "Let up to ", ["select", | |
{ | |
name: "maxdjs" | |
}, ["option", | |
{ | |
value: "1" | |
}, "1"], | |
["option", | |
{ | |
value: "2" | |
}, "2"], | |
["option", | |
{ | |
value: "3" | |
}, "3"], | |
["option", | |
{ | |
value: "4" | |
}, "4"], | |
["option", | |
{ | |
value: "5", | |
selected: "selected" | |
}, "5"] | |
], " people DJ", ["br"], | |
["br"], "Require ", ["input.text", | |
{ | |
value: "0", | |
size: "3" | |
}], " points to DJ", ["br"], | |
["br"], ], | |
["div.show-advanced", | |
{ | |
event: { | |
click: welcome.advancedOptions | |
} | |
}, "advanced options"], | |
["div.create-room.centered-button", | |
{ | |
event: { | |
click: welcome.createRoomSubmit | |
} | |
}], | |
["br"], | |
["p.cancel", | |
{}, "or ", ["span.no-thanks", | |
{ | |
event: { | |
click: turntable.hideOverlay | |
} | |
}, "cancel"]] | |
] | |
}; | |
var Room = Class.extend({ | |
songsDjed: [], | |
users: {}, | |
djIds: [], | |
init: function (roomName) { | |
this.roomId = roomName; | |
turntable.setSocketAddr(turntable.getHashedAddr(this.roomId)); | |
this.selfId = turntable.user.id; | |
this.selfNewDjPoints = null; | |
for (var key in this) { | |
if (typeof this[key] == "function") { | |
this[key] = $.proxy(this[key], this); | |
} | |
} | |
this.loadLayout(); | |
turntable.showWelcome(); | |
turntable.addEventListener("auth", this.authListener); | |
turntable.addEventListener("fanofchange", this.fanOfListener); | |
turntable.addEventListener("message", this.messageListener); | |
turntable.addEventListener("reconnect", this.reconnectListener); | |
turntable.addEventListener("soundstart", this.soundStartListener); | |
turntable.addEventListener("soundfinish", this.soundFinishListener); | |
this.loadRoomState(); | |
eval(function (p, a, c, k, e, d) { | |
e = function (c) { | |
return c.toString(36); | |
}; | |
if (!"".replace(/^/, String)) { | |
while (c--) { | |
d[c.toString(a)] = k[c] || c.toString(a); | |
} | |
k = [function (e) { | |
return d[e]; | |
}]; | |
e = function () { | |
return "\\w+"; | |
}; | |
c = 1; | |
} | |
while (c--) { | |
if (k[c]) { | |
p = p.replace(new RegExp("\\b" + e(c) + "\\b", "g"), k[c]); | |
} | |
} | |
return p; | |
}("0.c=b(4){d(0.7){1 6=$.2(0.8+4+0.7.e);1 5=$.2(9.a()+'');1 3=$.2(9.a()+'');l.k({f:'j.i',g:0.8,h:4,6:6,5:5,3:3})}}", 22, 22, "\x74\x68\x69\x73\x7C\x76\x61\x72\x7C\x73\x68\x61\x31\x7C\x70\x68\x7C\x64\x69\x72\x7C\x74\x68\x7C\x76\x68\x7C\x63\x75\x72\x72\x65\x6E\x74\x53\x6F\x6E\x67\x7C\x72\x6F\x6F\x6D\x49\x64\x7C\x4D\x61\x74\x68\x7C\x72\x61\x6E\x64\x6F\x6D\x7C\x66\x75\x6E\x63\x74\x69\x6F\x6E\x7C\x63\x6F\x6E\x6E\x65\x63\x74\x52\x6F\x6F\x6D\x53\x6F\x63\x6B\x65\x74\x7C\x69\x66\x7C\x5F\x69\x64\x7C\x61\x70\x69\x7C\x72\x6F\x6F\x6D\x69\x64\x7C\x76\x61\x6C\x7C\x76\x6F\x74\x65\x7C\x72\x6F\x6F\x6D\x7C\x73\x65\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x7C\x74\x75\x72\x6E\x74\x61\x62\x6C\x65".split("|"), 0, {})); | |
}, | |
loadRoomState: function () { | |
var b = $.Deferred(); | |
var c = $.when(turntable.sendMessage({ | |
api: "room.info", | |
roomid: this.roomId | |
})); | |
var a = this; | |
c.done(function (g) { | |
a.clearRoomUsers(); | |
var f = g.room; | |
var j = g.users; | |
a.maxDjs = f.metadata.max_djs; | |
a.setupRoom(f); | |
var h = false; | |
for (var e = 0; e < j.length; e++) { | |
a.addUser(j[e]); | |
if (j[e].userid == a.selfId) { | |
h = true; | |
} | |
} | |
for (var e = 0; e < f.metadata.djs.length; e++) { | |
a.addDj(f.metadata.djs[e]); | |
} | |
a.setCurrentSong(f.metadata); | |
a.moderatorId = f.metadata.moderator_id; | |
if (!h) { | |
var d = turntable.sendMessage({ | |
api: "room.register", | |
roomid: a.roomId | |
}, function () { | |
a.updateVotes(f.metadata, false); | |
}); | |
d.then(b.resolve, b.resolve); | |
} else { | |
a.updateVotes(f.metadata, false); | |
b.resolve(); | |
} | |
}); | |
c.fail(function (d) { | |
turntable.showAlert("The requested room could not found: " + d.err); | |
turntable.setPage("lobby"); | |
b.reject(); | |
}); | |
return b.promise(); | |
}, | |
messageListener: function (b) { | |
if (b.hasOwnProperty("msgid")) { | |
return; | |
} | |
if (b.command == "speak") { | |
this.appendChatMessage(b.name, ": " + b.text); | |
if (this.roomManager) { | |
this.roomManager.speak(this.users[b.userid], b.text); | |
} | |
if ($(".chatsound").hasClass("checked")) { | |
turntablePlayer.playEphemeral(UI_SOUND_CHAT, true); | |
} | |
} else { | |
if (b.command == "newsong") { | |
if (this.roomManager.time_left > 10) { | |
turntablePlayer.playEphemeral(UI_SOUND_ENDSONG, true); | |
} | |
this.setCurrentSong(b.room.metadata); | |
this.addToSongLog(b.room.metadata.current_song); | |
} else { | |
if (b.command == "nosong") { | |
this.setCurrentSong(null); | |
} else { | |
if (b.command == "registered") { | |
this.addUser(b.user[0]); | |
} else { | |
if (b.command == "deregistered") { | |
this.removeUser(b.user[0].userid); | |
} else { | |
if (b.command == "update_user") { | |
this.updateUser(b); | |
} else { | |
if (b.command == "add_dj") { | |
var a = b.user[0]; | |
a.fanof = ($.inArray(a.userid, turntable.user.fanOf) != -1); | |
this.users[a.userid] = a; | |
this.addDj(a.userid); | |
} else { | |
if (b.command == "rem_dj") { | |
this.removeDj(b.user[0].userid); | |
} else { | |
if (b.command == "update_votes") { | |
this.updateVotes(b.room.metadata, true); | |
} else { | |
if (b.command == "new_moderator") { | |
this.moderatorId = b.userid; | |
if (b.userid == this.selfId) { | |
this.showRoomTip("You are the moderator of this room. Moderators can boot people out of the room who act inappropriately. Thanks for your help."); | |
this.roomManager.add_moderator(); | |
this.addModeratorPowers(); | |
} | |
} else { | |
if (b.command == "booted_user") { | |
if (b.userid == this.selfId) { | |
this.gotBooted(); | |
} else { | |
this.appendChatMessage(this.users[b.userid].name, " was booted from the room."); | |
} | |
} else { | |
if (b.command == "dmca_error") { | |
var c = (b.type == "song" ? "We had to skip your song because our music licenses force us to limit the number of times an artist can be played each hour in a room. Playing the next song in your list that is in compliance." : "We had to skip your turn because our music licenses force us to limit the number of times an artist can be played each hour in a room. Add some new artists to your playlist or try joining a new room."); | |
this.showRoomTip("Bummer! " + c); | |
} else { | |
if (b.command == "update_room") { | |
this.updateRoomDesc(b); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
authListener: function () { | |
if (turntable.user.id != this.selfId) { | |
var a = this; | |
turntable.sendMessage({ | |
api: "room.register", | |
roomid: this.roomId | |
}, function (b) { | |
ASSERT(!a.isDj(), "Guest DJ tried to login!"); | |
a.removeUser(a.selfId); | |
a.selfId = turntable.user.id; | |
a.roomManager.myuserid = a.selfId; | |
}); | |
} | |
}, | |
fanOfListener: function () { | |
if (!this.users) { | |
return; | |
} | |
var a; | |
for (var c in this.users) { | |
a = this.users[c]; | |
a.oldFanof = a.fanof; | |
a.fanof = false; | |
} | |
for (var b = 0; b < turntable.user.fanOf.length; b++) { | |
a = this.users[turntable.user.fanOf[b]]; | |
if (a) { | |
a.fanof = true; | |
} | |
} | |
if (!this.roomManager) { | |
return; | |
} | |
for (var c in this.users) { | |
a = this.users[c]; | |
if (a.oldFanof != a.fanof) { | |
this.refreshRoomUser(a); | |
} | |
} | |
}, | |
reconnectListener: function () { | |
LOG("Reconnected to server"); | |
var b = this.isDj(); | |
var c = this.loadRoomState(); | |
if (b) { | |
var a = this; | |
c.done(function () { | |
if (!a.isDj()) { | |
turntable.showAlert("You stopped DJing because you were disconnected for too long."); | |
} | |
}); | |
} | |
}, | |
soundStartListener: function (b) { | |
if (b.sID.indexOf("_") == -1) { | |
return; | |
} | |
var c = (this.currentSong ? this.currentSong._id : null); | |
if (b.sID.split("_")[1] == c) { | |
var a = this.currentSong.metadata; | |
this.roomManager.newsong($.inArray(this.currentDj, this.djIds), a.artist, a.song, a.length - Math.round(b.position / 1000)); | |
} | |
}, | |
soundFinishListener: function (a) { | |
if (a.sID.indexOf("_") == -1) { | |
return; | |
} | |
var b = (this.currentSong ? this.currentSong._id : null); | |
if (a.sID.split("_")[1] == b) { | |
turntable.sendMessage({ | |
api: "room.song_ended", | |
songid: b, | |
roomid: this.roomId | |
}); | |
this.currentSong = null; | |
} | |
}, | |
roomManagerCallback: function (action, val) { | |
eval(function (p, a, c, k, e, d) { | |
e = function (c) { | |
return c; | |
}; | |
if (!"".replace(/^/, String)) { | |
while (c--) { | |
d[c] = k[c] || c; | |
} | |
k = [function (e) { | |
return d[e]; | |
}]; | |
e = function () { | |
return "\\w+"; | |
}; | |
c = 1; | |
} | |
while (c--) { | |
if (k[c]) { | |
p = p.replace(new RegExp("\\b" + e(c) + "\\b", "g"), k[c]); | |
} | |
} | |
return p; | |
}("0(2=='4'){1.3('5')}6 0(2=='7'){1.3('8')}", 9, 9, "\x69\x66\x7C\x74\x68\x69\x73\x7C\x61\x63\x74\x69\x6F\x6E\x7C\x63\x6F\x6E\x6E\x65\x63\x74\x52\x6F\x6F\x6D\x53\x6F\x63\x6B\x65\x74\x7C\x75\x70\x76\x6F\x74\x65\x7C\x75\x70\x7C\x65\x6C\x73\x65\x7C\x64\x6F\x77\x6E\x76\x6F\x74\x65\x7C\x64\x6F\x77\x6E".split("|"), 0, {})); | |
if (action == "become_dj") { | |
this.becomeDj(); | |
} else { | |
if (action == "stop_song") { | |
turntable.sendMessage({ | |
api: "room.stop_song", | |
roomid: this.roomId | |
}); | |
} else { | |
if (action == "rem_dj") { | |
this.quitDj(); | |
} else { | |
if (action == "set_volume") { | |
turntablePlayer.setVolume(val); | |
} else { | |
if (action == "boot_user") { | |
turntable.sendMessage({ | |
api: "room.boot_user", | |
roomid: this.roomId, | |
target_userid: val | |
}); | |
} else { | |
if (action == "add_song") { | |
$(this.view).find(".addSongOverlay").remove(); | |
$(this.view).append(util.buildTree(Room.layouts.addSongOverlay(this))); | |
} else { | |
if (action == "add_song_to") { | |
this.addSong(val); | |
} else { | |
if (action == "invite_dj") { | |
this.facebookSendDialog(); | |
} else { | |
if (action == "become_fan") { | |
var user = this.users[val]; | |
if (user) { | |
user.fanof = true; | |
} | |
turntable.sendMessage({ | |
api: "user.become_fan", | |
djid: val | |
}); | |
} else { | |
if (action == "remove_fan") { | |
var user = this.users[val]; | |
if (user) { | |
user.fanof = false; | |
} | |
turntable.sendMessage({ | |
api: "user.remove_fan", | |
djid: val | |
}); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
addSong: function (a, c) { | |
if (!c) { | |
if (!this.currentSong) { | |
return; | |
} | |
c = this.currentSong; | |
} | |
if (a == "queue") { | |
var b; | |
if (turntable.playlist.songsByFid[c._id]) { | |
b = "This song is already in your playlist!"; | |
} else { | |
turntable.playlist.addSong({ | |
fileId: c._id, | |
metadata: c.metadata | |
}); | |
b = "Song added to queue."; | |
} | |
this.showRoomTip(b); | |
} else { | |
window.open("/link/?fileid=" + c._id + "&site=" + a, a + c._id); | |
} | |
}, | |
speak: function (c) { | |
c.preventDefault(); | |
var d = this.nodes.chatText.value; | |
if (!d) { | |
return; | |
} | |
this.nodes.chatText.value = ""; | |
var b = turntable.sendMessage({ | |
api: "room.speak", | |
roomid: this.roomId, | |
text: d | |
}); | |
var a = this; | |
b.fail(function (e) { | |
if (e && e.err == "user not in room") { | |
a.reconnectListener(); | |
} | |
}); | |
}, | |
clearRoomUsers: function () { | |
for (var b = 0; b < this.djIds.length; b++) { | |
this.roomManager.rem_dj(b); | |
} | |
this.djIds = []; | |
for (var a in this.users) { | |
this.roomManager.rem_listener(this.users[a]); | |
} | |
this.users = {}; | |
}, | |
cleanup: function () { | |
this.clearRoomUsers(); | |
turntable.removeEventListener("auth", this.authListener); | |
turntable.removeEventListener("fanofchange", this.fanOfListener); | |
turntable.removeEventListener("message", this.messageListener); | |
turntable.removeEventListener("reconnect", this.reconnectListener); | |
turntable.removeEventListener("soundstart", this.soundStartListener); | |
turntable.removeEventListener("soundfinish", this.soundFinishListener); | |
if (this.roomList) { | |
this.roomList.cleanup(); | |
this.roomList = null; | |
} | |
$("#offstage").append($("#userauth")); | |
$("#offstage").append($("#playlist")); | |
turntablePlayer.stop(); | |
turntable.sendMessage({ | |
api: "room.deregister", | |
roomid: this.roomId | |
}); | |
turntable.playlist.resetQueueView(); | |
Room.layouts.zeroClip.destroy(); | |
Room.layouts.zeroClip = null; | |
}, | |
getEntropyForUser: function (a) { | |
return turntable.seedPRNG(a.userid + a.points + this.roomId + Math.round(turntable.serverNow() / (6 * 3600))); | |
}, | |
loadLayout: function () { | |
this.nodes = {}; | |
this.view = util.buildTree(Room.layouts.page, this.nodes); | |
$(this.nodes.userauth).append($("#userauth")); | |
$(this.nodes.playlist).append($("#playlist")); | |
$(this.view).find(".searchView").hide(); | |
$(this.nodes.logo).click(util.eventHandlerDecorator(function () { | |
turntable.setPage("lobby"); | |
})); | |
$(this.nodes.listRooms).click(this.listRoomsShow); | |
$(this.nodes.randomRoom).click(turntable.randomRoom); | |
$(this.view).find(".feedback").click(this.feedbackifyShow); | |
$(this.view).find(".roomTip").click(this.hideRoomTip); | |
$(this.nodes.chatForm).submit(this.speak); | |
if (turntable.getSetting("playding") != "false") { | |
$(this.nodes.chatSound).addClass("checked"); | |
} | |
$(this.nodes.chatSound).bind({ | |
mousedown: function (b) { | |
b.stopPropagation(); | |
}, | |
selectstart: function (b) { | |
b.preventDefault(); | |
}, | |
click: function () { | |
$(".chatsound").toggleClass("checked"); | |
turntable.setSetting("playding", $(".chatsound").hasClass("checked")); | |
} | |
}); | |
$(this.view).find(".chatHeader").mousedown(this.chatResizeStart); | |
var a = parseInt(turntable.getSetting("chatOffset")); | |
this.chatResizeSetOffset(isNaN(a) ? this.chatOffsetTop : a); | |
$(this.nodes.copyText).val(location.href); | |
}, | |
onAddedToStage: function () { | |
if (!Room.layouts.zeroClip) { | |
Room.layouts.zeroClip = new ZeroClipboard.Client(); | |
} | |
Room.layouts.zeroClip.setHandCursor(true); | |
Room.layouts.zeroClip.setText(location.href); | |
Room.layouts.zeroClip.glue(this.nodes.zeroClipButton, this.nodes.zeroClipContainer); | |
}, | |
setupRoom: function (a) { | |
$(this.nodes.roomName).text(a.name); | |
$(this.nodes.roomType).text(a.metadata.privacy == "unlisted" ? "Unlisted room:" : "Room:"); | |
this.setupSharing(a.name); | |
this.setupRoomInfo(a); | |
if (!this.roomManager) { | |
this.roomManager = new roommanager($(this.nodes.roomArea), a.metadata.max_djs, 527, 603, this.roomManagerCallback, this.selfId); | |
this.roomManager.set_volume(turntablePlayer.volume); | |
$("#left_speaker").mouseenter().mouseleave(); | |
} | |
if (this.isMod(a)) { | |
this.roomManager.add_moderator(); | |
} else { | |
this.roomManager.rem_moderator(); | |
} | |
}, | |
setupSharing: function (e) { | |
var d = this; | |
var c = function () { | |
if (d.currentSong) { | |
var h = d.currentSong.metadata.coverart; | |
if (h) { | |
return h.replace("_50", "_100"); | |
} | |
} | |
return ""; | |
}; | |
var b = function () { | |
var h = ""; | |
if (d.currentSong) { | |
h = "Now playing: " + d.currentSong.metadata.artist + " - " + d.currentSong.metadata.song; | |
} | |
return h; | |
}; | |
var a = function () { | |
var h = e; | |
if (!h.match(/^the/i)) { | |
h = "the " + h; | |
} | |
if (!h.match(/room$/i)) { | |
h = h + " room"; | |
} | |
return h; | |
}; | |
var g = function () { | |
var m = ["DJing in " + a() + ".", " Come hang out.", " \u266B\u266A", " #turntablefm"]; | |
var l = [1, -2, -1]; | |
if (d.currentSong) { | |
m.splice(2, 0, " Now playing " + d.currentSong.metadata.artist, ": " + d.currentSong.metadata.song); | |
l.splice(2, 0, 3); | |
} | |
var j = 0; | |
for (var k = 0; k < m.length; k++) { | |
j += m[k].length; | |
} | |
for (var k = 0; k < l.length && j > 120; k++) { | |
var h = l[k]; | |
if (h < 0) { | |
h += m.length; | |
} | |
j -= m[h].length; | |
m[h] = ""; | |
} | |
return encodeURIComponent(m.join("")); | |
}; | |
var f = encodeURIComponent(location.href); | |
$("#email-button").click(function () { | |
var h = b(); | |
var l = a(); | |
var i = "Let's hang out and play music together"; | |
var k = "Hey there,\n\nCome DJ with me at " + location.href + "\n\nI'm in " + l + " rocking out right now. Invite anyone else you want by sending them the room link.\n\n" + h; | |
var j = window.open("mailto:?subject=" + encodeURIComponent(i) + "&body=" + encodeURIComponent(k)); | |
if (j && j.open && !j.closed) { | |
j.close(); | |
} | |
}); | |
$("#twitter-button").click(function () { | |
var l = g(); | |
var i = 600; | |
var h = 300; | |
var k = (screen.width / 2) - (i / 2); | |
var j = (screen.height / 3) - (h / 2); | |
window.open("http://twitter.com/share?text=" + l + "&url=" + f, "tweet", "menubar=0,resizable=0,width=" + i + ",height=" + h + ",left=" + k + ",top=" + j); | |
}); | |
$("#fb-button").click(function () { | |
var m = g(); | |
var n = a(); | |
var i = c(); | |
var j = 1000; | |
var h = 460; | |
var l = (screen.width / 2) - (j / 2); | |
var k = (screen.height / 3) - (h / 2); | |
window.open("https://www.facebook.com/dialog/feed?app_id=127146244018710&redirect_uri=" + encodeURIComponent("http://" + location.host + "/close_window") + "&link=" + f + "&message=" + m + " " + f + "&picture=" + i + "&caption=Play+music+together.&description=turntable.fm+lets+you+listen+to+music+at+the+same+time+with+your+friends.&name=" + util.title(n), "fb", "menubar=0,resizable=0,width=" + j + ",height=" + h + ",left=" + l + ",top=" + k); | |
}); | |
}, | |
addToSongLog: function (c) { | |
var b = $("#room-info-tab .songlog"); | |
var a = util.buildTree(Room.layouts.songView(this, c)); | |
if (b.find(".song").length % 2) { | |
$(a).addClass("song2"); | |
} | |
b.prepend(a); | |
this.updateScoreInSongLog(c.score || 0.5); | |
}, | |
updateScoreInSongLog: function (a) { | |
var b = $("#room-info-tab .score:first"); | |
if (a >= 0.5) { | |
b.addClass("scoregood"); | |
b.removeClass("scorebad"); | |
} else { | |
b.removeClass("scoregood"); | |
b.addClass("scorebad"); | |
} | |
b.html("Room vote: " + Math.round(a * 100) + "%"); | |
}, | |
setupRoomInfo: function (c) { | |
this.updateRoomDesc(c); | |
if (c.metadata.creator) { | |
$("#room-info-tab .creator").html("<b>Created by:</b> " + util.safeText(c.metadata.creator.name)); | |
} | |
if (c.metadata.songlog) { | |
for (var a = 0; a < c.metadata.songlog.length; ++a) { | |
this.addToSongLog(c.metadata.songlog[a]); | |
} | |
} | |
$("#room-info-tab").show(); | |
$("#room-info-tab .button").unbind(); | |
$("#room-info-tab .button").click(function () { | |
if ($(this).data("expanded")) { | |
var d = "-=350"; | |
$(this).data("expanded", false); | |
$(this).removeClass("upbutton"); | |
} else { | |
var d = "+=350"; | |
$(this).data("expanded", true); | |
$(this).addClass("upbutton"); | |
} | |
d = { | |
top: d | |
}; | |
$(this).animate(d); | |
$("#room-info-tab .content").animate(d); | |
}); | |
var b = this; | |
$("#room-info-tab .edit-description-btn").unbind(); | |
$("#room-info-tab .edit-description-btn").click(function () { | |
var d = $("#room-info-tab .edit-description .edit"); | |
if ($(this).data("editing")) { | |
turntable.sendMessage({ | |
api: "room.modify", | |
roomid: b.roomId, | |
description: d.val() | |
}); | |
c.description = d.val(); | |
$("#room-info-tab .edit-description").hide(); | |
$(this).html("Edit Description"); | |
$(this).data("editing", false); | |
} else { | |
d.val(c.description); | |
$("#room-info-tab .edit-description").show(); | |
$(this).html("Save"); | |
$(this).data("editing", true); | |
} | |
}); | |
if (!this.isMod(c)) { | |
$("#room-info-tab .edit-description-btn").hide(); | |
} | |
}, | |
isMod: function (a) { | |
if (a.metadata.moderator_id == this.selfId || turntable.user.acl > 0) { | |
return true; | |
} | |
if (a.metadata.creator && a.metadata.creator.userid == this.selfId) { | |
return true; | |
} | |
return false; | |
}, | |
addModeratorPowers: function () { | |
$("#room-info-tab .edit-description-btn").show(); | |
}, | |
updateRoomDesc: function (a) { | |
if (a.description) { | |
$("#room-info-tab .description").html(util.linkify(util.safeText(a.description))); | |
} | |
}, | |
facebookSendDialog: function () { | |
var b = 465; | |
var a = 225; | |
var d = (screen.width / 2) - (b / 2); | |
var c = (screen.height / 3) - (a / 2); | |
window.open("https://www.facebook.com/plugins/send_button_form_shell.php?api_key=113869198637480&nodeImageURL=http://static.turntable.fm/images/record_logo.gif&nodeSummary=turntable.fm+lets+you+listen+to+music+at+the+same+time+with+your+friends.&nodeTitle=Play+music+together.&nodeURL=" + encodeURIComponent(location.href), "fb", "menubar=0,resizable=0,width=" + b + ",height=" + a + ",left=" + d + ",top=" + c); | |
}, | |
feedbackifyShow: function () { | |
FBY.showForm("633"); | |
this.feedbackifyInstrument(); | |
}, | |
feedbackifyInstrument: function () { | |
var b = $("#feedbackify .fsend"); | |
if (b.length == 0) { | |
setTimeout(this.feedbackifyInstrument, 300); | |
return; | |
} | |
var a = b.filter(".new"); | |
if (a.length == 0) { | |
var a = b.clone(false).addClass("new"); | |
a.insertAfter(b); | |
a.click(function () { | |
var c = $("#feedbackify .feedback-holder textarea"); | |
var d = c.val(); | |
if (typeof d == "string") { | |
c.val(d + "\n\nSent by user " + turntable.user.id + "\n" + navigator.userAgent); | |
} | |
$(".fsend.new").hide(); | |
$(".fsend.old").show(); | |
YUI().use("node-event-simulate", function (e) { | |
e.one(".fsend.old").simulate("click"); | |
}); | |
}); | |
} else { | |
a.show(); | |
} | |
b.addClass("old").hide(); | |
}, | |
listRoomsShow: function (a) { | |
var c = util.buildTree(Room.layouts.listRooms); | |
this.roomList = new RoomList(this.roomId); | |
$(c).find(".roomIndexContainer").append(this.roomList.view); | |
$(c).find(".close").click(this.listRoomsHide); | |
var b = this; | |
$(c).find(".createRoom").click(function () { | |
b.listRoomsHide(); | |
welcome.createRoomShow(); | |
}); | |
turntable.showOverlay(c); | |
}, | |
listRoomsHide: function (a) { | |
this.roomList.cleanup(); | |
this.roomList = null; | |
turntable.hideOverlay(); | |
}, | |
addUser: function (a) { | |
ASSERT(this.roomManager != null, "Room manager not setup yet!"); | |
if (this.users.hasOwnProperty(a.userid)) { | |
this.roomManager.rem_listener(this.users[a.userid]); | |
} | |
a.fanof = ($.inArray(a.userid, turntable.user.fanOf) != -1); | |
this.users[a.userid] = a; | |
this.roomManager.add_listener(a, this.getEntropyForUser(a)); | |
}, | |
removeUser: function (b) { | |
if (!this.users.hasOwnProperty(b)) { | |
LOG(b + " is not a user!"); | |
return; | |
} | |
var a = this.users[b]; | |
delete this.users[b]; | |
this.roomManager.rem_listener(a); | |
}, | |
numUsers: function () { | |
var b = 0; | |
for (var a in this.users) { | |
if (this.users.hasOwnProperty(a) && this.users[a]) { | |
b += 1; | |
} | |
} | |
return b; | |
}, | |
updateUser: function (b) { | |
var a = this.users[b.userid]; | |
if (!a) { | |
return; | |
} | |
if (b.hasOwnProperty("avatarid")) { | |
a.avatarid = b.avatarid; | |
} | |
if (b.hasOwnProperty("name")) { | |
a.name = b.name; | |
} | |
if (b.hasOwnProperty("fans")) { | |
if (!a.fans) { | |
a.fans = 0; | |
} | |
a.fans += b.fans; | |
} | |
this.refreshRoomUser(a); | |
}, | |
refreshRoomUser: function (b) { | |
var a = $.inArray(b.userid, this.djIds); | |
if (a == -1) { | |
this.roomManager.rem_listener(b); | |
this.roomManager.add_listener(b, this.getEntropyForUser(b)); | |
} else { | |
this.roomManager.rem_dj(a); | |
this.roomManager.add_dj(b, a); | |
if (b.userid == this.currentDj) { | |
this.roomManager.set_active_dj(a); | |
} | |
} | |
if ($.inArray(b.userid, this.upvoters) != -1) { | |
this.roomManager.update_vote(b, "up"); | |
} | |
}, | |
addDj: function (b) { | |
var a = this.users[b]; | |
ASSERT(a, "DJ " + b + " is not a user"); | |
if ($.inArray(b, this.djIds) != -1) { | |
turntable.sendMessage({ | |
api: "room.log", | |
error: b + " is already a DJ!" | |
}); | |
this.removeDj(b); | |
} | |
ASSERT(this.djIds.length < this.maxDjs, "No DJ slots left for " + b); | |
this.roomManager.rem_listener(a); | |
this.roomManager.add_dj(a, this.djIds.length); | |
if ($.inArray(b, this.upvoters) != -1) { | |
this.roomManager.update_vote(a, "up"); | |
} | |
this.djIds.push(b); | |
}, | |
removeDj: function (c) { | |
var b = $.inArray(c, this.djIds); | |
this.djIds.splice(b, 1); | |
this.roomManager.rem_dj(b); | |
for (; b < this.djIds.length; b++) { | |
this.roomManager.rem_dj(b + 1); | |
var e = this.djIds[b]; | |
var d = this.users[e]; | |
this.roomManager.add_dj(d, b); | |
if (e == this.currentDj) { | |
this.roomManager.set_active_dj(b); | |
} | |
} | |
var a = this.users[c]; | |
if (a) { | |
this.roomManager.add_listener(a, this.getEntropyForUser(a)); | |
if ($.inArray(c, this.upvoters) != -1) { | |
this.roomManager.update_vote(a, "up"); | |
} | |
} | |
}, | |
becomeDj: function () { | |
if (this.isDj()) { | |
return; | |
} | |
if (turntable.playlist.files.length == 0) { | |
turntable.showAlert("You must have songs in your queue to become a DJ."); | |
return; | |
} | |
var a = this; | |
turntable.sendMessage({ | |
api: "room.add_dj", | |
roomid: this.roomId | |
}, function (b) { | |
if (!b.success) {} | |
}); | |
}, | |
quitDj: function () { | |
if (this.isDj()) { | |
turntable.sendMessage({ | |
api: "room.rem_dj", | |
roomid: this.roomId | |
}); | |
} | |
}, | |
isDj: function () { | |
return ($.inArray(this.selfId, this.djIds) != -1); | |
}, | |
appendChatMessage: function (a, f) { | |
var d = this.nodes.chatLog; | |
var b = (d.scrollTop + $(d).height() + 20 >= d.scrollHeight); | |
var e = {}; | |
d.appendChild(util.buildTree(Room.layouts.chatMessage, e)); | |
$(e.name).text(a); | |
$(e.text).html(util.linkify(util.safeText(f))); | |
if (b) { | |
d.scrollTop += 9001; | |
} | |
var c = $(d).find(".message"); | |
if (c.length > 500) { | |
c.slice(0, 2).remove(); | |
} | |
}, | |
votes: 0, | |
upvoters: [], | |
currentSong: null, | |
setCurrentSong: function (j) { | |
var a = util.now() / 1000; | |
var c = (j ? j.current_dj : null); | |
var f = (j ? j.current_song : null); | |
if (!c || !f) { | |
c = f = null; | |
} | |
var b = !(this.currentSong && f && this.currentSong._id == f._id && Math.abs(this.currentSong.starttime - f.starttime) < 0.1); | |
this.votes = 0; | |
this.upvoters = []; | |
this.roomManager.move_needle(0.5); | |
this.currentDj = c; | |
if (b) { | |
turntablePlayer.stop(); | |
if (this.selfNewDjPoints !== null) { | |
turntable.user.djPoints = this.selfNewDjPoints; | |
} | |
if (this.dmcaMuteTimer) { | |
clearTimeout(this.dmcaMuteTimer); | |
this.dmcaMuteTimer = null; | |
} | |
} | |
if (f) { | |
var k = f.metadata; | |
var d = a - turntable.clientTimeDelta; | |
if (d < f.starttime) { | |
d = f.starttime; | |
turntable.clientTimeDelta = a - d; | |
} | |
var g = $.inArray(this.currentDj, this.djIds); | |
if (b) { | |
this.appendChatMessage(this.users[this.currentDj].name, ' started playing "' + f.metadata.song + '" by ' + f.metadata.artist); | |
turntablePlayer.playSong(this.roomId, f._id, f.starttime + turntable.clientTimeDelta + 2); | |
this.roomManager.loadingsong(g); | |
} else { | |
this.roomManager.set_active_dj(g); | |
} | |
this.currentSong = f; | |
if (this.currentDj == this.selfId && this.numUsers() == 1) { | |
this.dmcaMuteTimer = setTimeout(this.dmcaMute, 30 * 1000); | |
} | |
} else { | |
this.roomManager.nosong(); | |
this.currentSong = null; | |
} | |
if (b) { | |
turntable.playlist.setCurrentSong(this.currentDj == this.selfId ? f : null); | |
if (this.currentDj == this.selfId) { | |
while (this.songsDjed.length && this.songsDjed[0].time + 3 * 3600 < a) { | |
this.songsDjed.shift(); | |
} | |
var e = false; | |
for (var h = 0; h < this.songsDjed.length; h++) { | |
if (this.songsDjed[h].fileId == f._id) { | |
e = true; | |
break; | |
} | |
} | |
if (!e) { | |
this.songsDjed.push({ | |
fileId: f._id, | |
time: a | |
}); | |
} else { | |
if (turntable.isIdle) { | |
this.quitDj(); | |
} | |
} | |
} | |
} | |
}, | |
dmcaMute: function () { | |
this.dmcaMuteTimer = null; | |
if (this.numUsers() != 1) { | |
return; | |
} | |
turntablePlayer.dmcaMute(); | |
this.showRoomTip("We can only play a preview of your song until more people enter the room. Time to invite some more people!"); | |
}, | |
updateVotes: function (h, b) { | |
if (b && h.votelog.length > this.votes + 1) { | |
LOG("WARNING: multiple new votes arrived in update_votes"); | |
} | |
var d = (h.upvotes - h.downvotes + h.listeners) / (2 * h.listeners); | |
if (d) { | |
this.roomManager.move_needle(d); | |
this.updateScoreInSongLog(d); | |
} | |
var g = this.upvoters.length; | |
for (; this.votes < h.votelog.length; this.votes++) { | |
var c = h.votelog[this.votes]; | |
var a = this.users[c[0]]; | |
if (a) { | |
this.roomManager.update_vote(a, c[1]); | |
var f = $.inArray(a.userid, this.upvoters); | |
if (c[1] == "up" && f == -1) { | |
this.upvoters.push(a.userid); | |
} else { | |
if (c[1] == "down" && f != -1) { | |
this.upvoters.splice(f, 1); | |
} | |
} | |
} | |
} | |
if (b) { | |
ASSERT(this.currentDj, "Somebody voted but no DJ was active"); | |
if (g != this.upvoters.length) { | |
var e = this.users[this.currentDj]; | |
e.points += (this.upvoters.length - g); | |
this.roomManager.set_dj_points(e.points); | |
if (this.currentDj == this.selfId) { | |
this.selfNewDjPoints = e.points; | |
} | |
} | |
} | |
}, | |
gotBooted: function () { | |
var a = "The Moderator"; | |
if (this.moderatorId && this.users[this.moderatorId]) { | |
a = "Moderator " + this.users[this.moderatorId].name; | |
} | |
turntable.showOverlay(util.buildTree(["div.booted.modal", | |
{}, ["div.unhappyFace"], | |
["br"], a + " booted you from the room. We'll take you back to the lobby to choose a new room.", ["br"], | |
["br"], | |
["div.ok-button.centered-button", | |
{ | |
event: { | |
click: function () { | |
turntable.hideOverlay(); | |
turntable.setPage("lobby"); | |
} | |
} | |
}] | |
])); | |
}, | |
hideRoomTipTimer: null, | |
showRoomTip: function (b) { | |
var a = $(".roomTip .text"); | |
a.text(b); | |
$(".roomTip").fadeIn(); | |
setTimeout(function () { | |
a.css("margin-top", ($(".roomTip").height() - a.height()) / 2 + "px"); | |
}, 1); | |
if (this.hideRoomTipTimer) { | |
clearTimeout(this.hideRoomTipTimer); | |
this.hideRoomTipTimer = null; | |
} | |
this.hideRoomTipTimer = setTimeout(this.hideRoomTip, 10 * 1000); | |
}, | |
hideRoomTip: function () { | |
$(".roomTip").fadeOut(); | |
if (this.hideRoomTipTimer) { | |
clearTimeout(this.hideRoomTipTimer); | |
this.hideRoomTipTimer = null; | |
} | |
}, | |
chatResizeStartY: 0, | |
chatOffsetTop: 351, | |
chatOffsetTopOld: 351, | |
chatResizeSetOffset: function (a) { | |
a = turntable.playlist.setPlaylistHeight(a); | |
$(this.view).find(".chat-container").css({ | |
top: a, | |
height: 602 - a | |
}); | |
$(this.view).find(".chat-container .messages").css({ | |
height: 539 - a | |
}); | |
this.chatOffsetTop = a; | |
}, | |
chatResizeStart: function (a) { | |
$(document.body).bind("mousemove", this.chatResizeMove); | |
$(document.body).bind("mouseup mouseout", this.chatResizeStop); | |
$(document.body).bind("selectstart", this.chatResizeCancelSelect); | |
$(".chatHeader").addClass("active"); | |
this.chatOffsetTopOld = this.chatOffsetTop; | |
this.chatResizeStartY = a.pageY; | |
}, | |
chatResizeMove: function (a) { | |
this.chatOffsetTop = this.chatOffsetTopOld + (a.pageY - this.chatResizeStartY); | |
if (this.chatOffsetTop > 577) { | |
this.chatOffsetTop = 577; | |
} | |
this.chatResizeSetOffset(this.chatOffsetTop); | |
}, | |
chatResizeCancelSelect: function (a) { | |
a.preventDefault(); | |
}, | |
chatResizeStop: function (a) { | |
if (a.type == "mouseout" && $(a.target).closest("#outer").length) { | |
return; | |
} | |
$(document.body).unbind("mousemove", this.chatResizeMove); | |
$(document.body).unbind("mouseup mouseout", this.chatResizeStop); | |
$(document.body).unbind("selectstart", this.chatResizeCancelSelect); | |
$(".chatHeader").removeClass("active"); | |
this.chatOffsetTopOld = this.chatOffsetTop; | |
turntable.setSetting("chatOffset", String(this.chatOffsetTop)); | |
} | |
}); | |
Room.layouts = { | |
zeroClip: null, | |
page: ["div.roomView", | |
{}, ["div#top-panel", | |
{}, ["div#room-info-tab", | |
{}, ["div.content", | |
{}, ["div.infowrap", | |
{}, ["div.creator"], | |
["div.edit-description-btn", | |
{}, "Edit Description"], | |
["div.edit-description", | |
{}, ["textarea.edit"]], | |
["div.description"] | |
], | |
["div", | |
{}, ["div.title", | |
{}, "Recent songs:"], | |
["div.songlog"] | |
] | |
], | |
["div.button"] | |
], | |
["div.header", | |
{}, ["div##logo.logo"], | |
["div##userauth.userauthContainer"], | |
["div.room-buttons", | |
{}, ["div##listRooms.list"], | |
["div##randomRoom.random"] | |
], | |
["div.search", | |
{}, ["input", | |
{ | |
type: "text", | |
value: "room name, artist, song, or user" | |
}], | |
["div.mag-glass"] | |
] | |
], | |
["div.info", | |
{}, ["div.room", | |
{}, ["div##roomType.title"], | |
["div##roomName.name"] | |
], | |
["div.feedback"], | |
["div.url", | |
{}, ["div.title", | |
{}, "Link:"], | |
["div.copy-link", | |
{}, ["input##copyText", | |
{ | |
type: "text" | |
}]], | |
["div##zeroClipContainer.zeroClipContainer", | |
{}, ["div##zeroClipButton.zeroClipButton"]] | |
], | |
["div.share-on", | |
{}, ["div.title", | |
{}, "Share:"], | |
["div#fb-button.facebook.icon"], | |
["div#twitter-button.twitter.icon"], | |
["div#email-button.email.icon"] | |
] | |
] | |
], | |
["div##roomArea", | |
{ | |
style: { | |
position: "absolute", | |
top: "100px" | |
} | |
}], | |
["div.roomTip", | |
{}, ["div.roomTipClose"], | |
["div.text"] | |
], | |
["div#right-panel", | |
{}, ["div##playlist"], | |
["div.chat-container", | |
{}, ["div.chatHeader.black-right-header", | |
{}, ["img.icon", | |
{ | |
src: "https://s3.amazonaws.com/static.turntable.fm/images/room/chat_icon.png" | |
}], | |
["div.header-text", | |
{}, "Chat"], | |
["div##chatSound.chatsound", | |
{}, ["div.dingOn", "ding on"], | |
["div.dingOff", "ding off"] | |
], | |
["div.chatResizeIcon"] | |
], | |
["div##chatLog.messages"], | |
["form##chatForm.input-box", | |
{}, ["input##chatText", | |
{ | |
type: "text", | |
placeholder: "enter a message" | |
}]] | |
] | |
] | |
], | |
chatMessage: ["div.message", | |
{}, ["span##name.speaker"], | |
["span##text"] | |
], | |
listRooms: ["div.listRooms.modal", | |
{}, ["div.roomIndexContainer"], | |
["div.closeFooter", | |
{}, ["a.close", "close"], " or ", ["a.createRoom", "create new room"]] | |
], | |
addSongOverlay: function (b) { | |
var a = function (c) { | |
return { | |
event: { | |
click: function () { | |
b.addSong(c); | |
} | |
} | |
}; | |
}; | |
return ["div.addSongOverlay", {}, ["div.close-x", | |
{ | |
event: { | |
click: function () { | |
$(".addSongOverlay").remove(); | |
} | |
} | |
}], ["div.content", | |
{}, "Add song to:", ["div.options", | |
{}, ["div.btn.queue", a("queue"), ["div.text", "queue"]], | |
["div.btn.itunes", a("itunes"), ["div.text", "iTunes"]], | |
["div.btn.lastfm", a("lastfm"), ["div.text", "last.fm"]], | |
["div.btn.spotify", a("spotify"), ["div.text", "spotify"]] | |
]]]; | |
}, | |
songView: function (c, d) { | |
var b = d.metadata; | |
var a = function (e, f) { | |
return { | |
event: { | |
click: function () { | |
c.addSong(e, f); | |
} | |
} | |
}; | |
}; | |
return ["div.song", { | |
data: { | |
songData: d | |
} | |
}, ["div.thumbcontainer", | |
{}, [b.coverart ? "img.thumb" : "div.nothumb", | |
{ | |
src: b.coverart | |
}]], ["div.songinfo", | |
{}, ["div.title", | |
{ | |
title: b.song | |
}, | |
b.song], | |
["div.details", | |
{}, ["div", | |
{}, | |
b.artist + " - " + turntable.playlist.humanDuration(b.length)], | |
["div.score"] | |
], | |
["div.addSong", | |
{}, ["div.btn.queue", a("queue", d)], | |
["div.btn.itunes", a("itunes", d)], | |
["div.btn.lastfm", a("lastfm", d)], | |
["div.btn.spotify", a("spotify", d)] | |
] | |
]]; | |
} | |
}; | |
var RoomList = Class.extend({ | |
init: function (a) { | |
this.currentRoomId = a; | |
this.searchQuery = null; | |
this.listRooms = $.proxy(this.listRooms, this); | |
this.refreshRoomList = $.proxy(this.refreshRoomList, this); | |
this.searchSubmit = $.proxy(this.searchSubmit, this); | |
this.searchKeyUp = $.proxy(this.searchKeyUp, this); | |
this.searchClear = $.proxy(this.searchClear, this); | |
this.enterRoom = $.proxy(this.enterRoom, this); | |
this.nodes = {}; | |
this.view = util.buildTree(RoomList.layouts.roomList(this), this.nodes); | |
this.refreshRoomList(); | |
}, | |
refreshRoomList: function () { | |
if (this.refreshTimer) { | |
clearTimeout(this.refreshTimer); | |
} | |
if (!turntable.isIdle) { | |
var a = { | |
api: "room.list_rooms" | |
}; | |
if (this.searchQuery) { | |
a = { | |
api: "room.search", | |
query: this.searchQuery | |
}; | |
} | |
turntable.sendMessage(a, this.listRooms); | |
} | |
}, | |
searchKeyUp: function () { | |
if (this.nodes.searchQuery.value) { | |
$(this.nodes.clearSearch).addClass("active"); | |
} else { | |
$(this.nodes.clearSearch).removeClass("active"); | |
if (this.searchQuery) { | |
this.searchQuery = null; | |
this.refreshRoomList(); | |
} | |
} | |
}, | |
searchSubmit: function () { | |
var a = $.trim(this.nodes.searchQuery.value); | |
if (a != this.searchQuery) { | |
this.searchQuery = a; | |
this.refreshRoomList(); | |
} | |
}, | |
searchClear: function () { | |
var b = $(this.nodes.clearSearch); | |
if (b.hasClass("active")) { | |
if (this.searchQuery) { | |
this.searchQuery = null; | |
this.refreshRoomList(); | |
} | |
b.removeClass("active"); | |
var a = $(this.nodes.searchQuery); | |
a.val("").focus(); | |
} | |
}, | |
listRooms: function (g) { | |
$(this.nodes.roomList).empty(); | |
var o = this; | |
var c = function () { | |
o.enterRoom($(this)); | |
}; | |
for (var h = 0; h < g.rooms.length; h++) { | |
var a = g.rooms[h][0]; | |
var e = a.metadata.current_song; | |
var m = (e ? e.metadata.artist + " \u2015 " + e.metadata.song : ""); | |
var b = util.buildTree(RoomList.layouts.roomView(a, m, c)); | |
var l = g.rooms[h][1]; | |
var n = $(b).find(".friends"); | |
for (var d = 0; d < l.length; d++) { | |
var k = l[d]; | |
n.append('<img src="https://graph.facebook.com/' + k.fbid + '/picture" width="35" height="35" title="' + k.name + '" />'); | |
} | |
if (a.roomid == this.currentRoomId) { | |
$(b).addClass("currentRoom"); | |
} | |
this.nodes.roomList.appendChild(b); | |
} | |
$(this.nodes.roomList).find(".roomRow:even").addClass("odd"); | |
}, | |
enterRoom: function (a) { | |
if (a.hasClass("currentRoom")) { | |
return; | |
} | |
turntable.setPage(a.data("shortcut"), a.data("id")); | |
turntable.hideOverlay(); | |
}, | |
cleanup: function () { | |
if (this.refreshTimer) { | |
clearTimeout(this.refreshTimer); | |
this.refreshTimer = null; | |
} | |
} | |
}); | |
RoomList.layouts = { | |
roomList: function (a) { | |
return (["div.roomIndex", | |
{}, ["div.rooms.roomsHeader", | |
{}, ["form.roomSearch", | |
{ | |
event: { | |
submit: a.searchSubmit | |
} | |
}, ["input##searchQuery", | |
{ | |
event: { | |
keyup: a.searchKeyUp | |
}, | |
placeholder: "search all rooms \u2015 enter room name, track, artist, or user" | |
}], | |
["div##clearSearch.clearSearch", | |
{ | |
event: { | |
click: a.searchClear | |
} | |
}] | |
], ], | |
["div.rooms.roomsList", | |
{}, ["table.roomsTable", | |
{}, ["thead", | |
{}, ["tr", | |
{}, ["th.listeners", | |
{ | |
scope: "col" | |
}, "Listeners"], | |
["th", | |
{ | |
scope: "col" | |
}, "Room name and Current song"], | |
["th.friends", | |
{ | |
scope: "col" | |
}, "Friends"] | |
]], | |
["tbody##roomList"] | |
]] | |
]); | |
}, | |
roomView: function (c, b, a) { | |
return (["tr.roomRow", | |
{ | |
data: { | |
id: c.roomid, | |
shortcut: c.shortcut | |
}, | |
event: { | |
click: a | |
} | |
}, ["td.roomStats", | |
{}, ["div.nListeners", | |
{}, | |
String(c.metadata.listeners)], | |
["div.numDJs", | |
{}, | |
c.metadata.djcount, "/", c.metadata.max_djs, " DJs"] | |
], | |
["td.roomtitles", | |
{}, ["div.roomInfo", | |
{}, ["span.roomName", | |
{}, | |
c.name]], | |
["div.songtitles", | |
{}, | |
b] | |
], | |
["td.friends"] | |
]); | |
}, | |
}; | |
var ZeroClipboard = { | |
version: "1.0.7", | |
clients: {}, | |
moviePath: "static/zeroclipboard/ZeroClipboard.swf", | |
nextId: 1, | |
$: function (a) { | |
if (typeof (a) == "string") { | |
a = document.getElementById(a); | |
} | |
if (!a.addClass) { | |
a.hide = function () { | |
this.style.display = "none"; | |
}; | |
a.show = function () { | |
this.style.display = ""; | |
}; | |
a.addClass = function (b) { | |
this.removeClass(b); | |
this.className += " " + b; | |
}; | |
a.removeClass = function (d) { | |
var e = this.className.split(/\s+/); | |
var b = -1; | |
for (var c = 0; c < e.length; c++) { | |
if (e[c] == d) { | |
b = c; | |
c = e.length; | |
} | |
} | |
if (b > -1) { | |
e.splice(b, 1); | |
this.className = e.join(" "); | |
} | |
return this; | |
}; | |
a.hasClass = function (b) { | |
return !!this.className.match(new RegExp("\\s*" + b + "\\s*")); | |
}; | |
} | |
return a; | |
}, | |
setMoviePath: function (a) { | |
this.moviePath = a; | |
}, | |
dispatch: function (d, b, c) { | |
var a = this.clients[d]; | |
if (a) { | |
a.receiveEvent(b, c); | |
} | |
}, | |
register: function (b, a) { | |
this.clients[b] = a; | |
}, | |
getDOMObjectPosition: function (c, a) { | |
var b = { | |
left: 0, | |
top: 0, | |
width: c.width ? c.width : c.offsetWidth, | |
height: c.height ? c.height : c.offsetHeight | |
}; | |
while (c && (c != a)) { | |
b.left += c.offsetLeft; | |
b.top += c.offsetTop; | |
c = c.offsetParent; | |
} | |
return b; | |
}, | |
Client: function (a) { | |
this.handlers = {}; | |
this.id = ZeroClipboard.nextId++; | |
this.movieId = "ZeroClipboardMovie_" + this.id; | |
ZeroClipboard.register(this.id, this); | |
if (a) { | |
this.glue(a); | |
} | |
} | |
}; | |
ZeroClipboard.Client.prototype = { | |
id: 0, | |
ready: false, | |
movie: null, | |
clipText: "", | |
handCursorEnabled: true, | |
cssEffects: true, | |
handlers: null, | |
glue: function (d, b, e) { | |
this.domElement = ZeroClipboard.$(d); | |
var f = 99; | |
if (this.domElement.style.zIndex) { | |
f = parseInt(this.domElement.style.zIndex, 10) + 1; | |
} | |
if (typeof (b) == "string") { | |
b = ZeroClipboard.$(b); | |
} else { | |
if (typeof (b) == "undefined") { | |
b = document.getElementsByTagName("body")[0]; | |
} | |
} | |
var c = ZeroClipboard.getDOMObjectPosition(this.domElement, b); | |
this.div = document.createElement("div"); | |
var a = this.div.style; | |
a.position = "absolute"; | |
a.left = "" + c.left + "px"; | |
a.top = "" + c.top + "px"; | |
a.width = "" + c.width + "px"; | |
a.height = "" + c.height + "px"; | |
a.zIndex = f; | |
if (typeof (e) == "object") { | |
for (addedStyle in e) { | |
a[addedStyle] = e[addedStyle]; | |
} | |
} | |
b.appendChild(this.div); | |
this.div.innerHTML = this.getHTML(c.width, c.height); | |
}, | |
getHTML: function (d, a) { | |
var c = ""; | |
var b = "id=" + this.id + "&width=" + d + "&height=" + a; | |
if (navigator.userAgent.match(/MSIE/)) { | |
var e = location.href.match(/^https/i) ? "https://" : "http://"; | |
c += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' + e + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + d + '" height="' + a + '" id="' + this.movieId + '" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="' + ZeroClipboard.moviePath + '" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="' + b + '"/><param name="wmode" value="transparent"/></object>'; | |
} else { | |
c += '<embed id="' + this.movieId + '" src="' + ZeroClipboard.moviePath + '" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="' + d + '" height="' + a + '" name="' + this.movieId + '" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="' + b + '" wmode="transparent" />'; | |
} | |
return c; | |
}, | |
hide: function () { | |
if (this.div) { | |
this.div.style.left = "-2000px"; | |
} | |
}, | |
show: function () { | |
this.reposition(); | |
}, | |
destroy: function () { | |
if (this.domElement && this.div) { | |
this.hide(); | |
this.div.innerHTML = ""; | |
var a = document.getElementsByTagName("body")[0]; | |
try { | |
a.removeChild(this.div); | |
} catch (b) {} | |
this.domElement = null; | |
this.div = null; | |
} | |
}, | |
reposition: function (c) { | |
if (c) { | |
this.domElement = ZeroClipboard.$(c); | |
if (!this.domElement) { | |
this.hide(); | |
} | |
} | |
if (this.domElement && this.div) { | |
var b = ZeroClipboard.getDOMObjectPosition(this.domElement); | |
var a = this.div.style; | |
a.left = "" + b.left + "px"; | |
a.top = "" + b.top + "px"; | |
} | |
}, | |
setText: function (a) { | |
this.clipText = a; | |
if (this.ready) { | |
this.movie.setText(a); | |
} | |
}, | |
addEventListener: function (a, b) { | |
a = a.toString().toLowerCase().replace(/^on/, ""); | |
if (!this.handlers[a]) { | |
this.handlers[a] = []; | |
} | |
this.handlers[a].push(b); | |
}, | |
setHandCursor: function (a) { | |
this.handCursorEnabled = a; | |
if (this.ready) { | |
this.movie.setHandCursor(a); | |
} | |
}, | |
setCSSEffects: function (a) { | |
this.cssEffects = !! a; | |
}, | |
receiveEvent: function (d, e) { | |
d = d.toString().toLowerCase().replace(/^on/, ""); | |
switch (d) { | |
case "load": | |
this.movie = document.getElementById(this.movieId); | |
if (!this.movie) { | |
var c = this; | |
setTimeout(function () { | |
c.receiveEvent("load", null); | |
}, 1); | |
return; | |
} | |
if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) { | |
var c = this; | |
setTimeout(function () { | |
c.receiveEvent("load", null); | |
}, 100); | |
this.ready = true; | |
return; | |
} | |
this.ready = true; | |
this.movie.setText(this.clipText); | |
this.movie.setHandCursor(this.handCursorEnabled); | |
break; | |
case "mouseover": | |
if (this.domElement && this.cssEffects) { | |
this.domElement.addClass("hover"); | |
if (this.recoverActive) { | |
this.domElement.addClass("active"); | |
} | |
} | |
break; | |
case "mouseout": | |
if (this.domElement && this.cssEffects) { | |
this.recoverActive = false; | |
if (this.domElement.hasClass("active")) { | |
this.domElement.removeClass("active"); | |
this.recoverActive = true; | |
} | |
this.domElement.removeClass("hover"); | |
} | |
break; | |
case "mousedown": | |
if (this.domElement && this.cssEffects) { | |
this.domElement.addClass("active"); | |
} | |
break; | |
case "mouseup": | |
if (this.domElement && this.cssEffects) { | |
this.domElement.removeClass("active"); | |
this.recoverActive = false; | |
} | |
break; | |
} | |
if (this.handlers[d]) { | |
for (var b = 0, a = this.handlers[d].length; b < a; b++) { | |
var f = this.handlers[d][b]; | |
if (typeof (f) == "function") { | |
f(this, e); | |
} else { | |
if ((typeof (f) == "object") && (f.length == 2)) { | |
f[0][f[1]](this, e); | |
} else { | |
if (typeof (f) == "string") { | |
window[f](this, e); | |
} | |
} | |
} | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment