// Needed for IE because it's dumb 'abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video'.replace(/\w+/g,function(n){document.createElement(n)}) /*********/ /* ROLES */ /*********/ var U_GROUP_TESTER = 0x1; var U_GROUP_ADMIN = 0x2; var U_GROUP_EDITOR = 0x4; var U_GROUP_MOD = 0x8; var U_GROUP_BUREAU = 0x10; var U_GROUP_DEV = 0x20; var U_GROUP_VIP = 0x40; var U_GROUP_BLOGGER = 0x80; var U_GROUP_PREMIUM = 0x100; var U_GROUP_LOCALIZER = 0x200; var U_GROUP_SALESAGENT = 0x400; var U_GROUP_SCREENSHOT = 0x800; var U_GROUP_VIDEO = 0x1000; var U_GROUP_APIONLY = 0x2000; var U_GROUP_PENDING = 0x4000; /******************/ /* ROLE SHORTCUTS */ /******************/ var U_GROUP_STAFF = U_GROUP_ADMIN | U_GROUP_EDITOR | U_GROUP_MOD | U_GROUP_BUREAU | U_GROUP_DEV | U_GROUP_BLOGGER | U_GROUP_LOCALIZER | U_GROUP_SALESAGENT; var U_GROUP_EMPLOYEE = U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_DEV; var U_GROUP_GREEN_TEXT = U_GROUP_MOD | U_GROUP_BUREAU | U_GROUP_DEV; var U_GROUP_MODERATOR = U_GROUP_ADMIN | U_GROUP_MOD | U_GROUP_BUREAU; var U_GROUP_COMMENTS_MODERATOR = U_GROUP_BUREAU | U_GROUP_MODERATOR | U_GROUP_LOCALIZER; var U_GROUP_PREMIUM_PERMISSIONS = U_GROUP_PREMIUM | U_GROUP_STAFF | U_GROUP_VIP; var g_users = {}; function g_isUsernameValid(username) { return (username.match(/[^a-z0-9]/i) == null && username.length >= 4 && username.length <= 16); } var User = new function() { var self = this; /**********/ /* PUBLIC */ /**********/ self.hasPermissions = function(roles) { if (!roles) { return true; } return !!(g_user.roles & roles); } /**********/ /* PRIVATE */ /**********/ }; function Ajax(url, opt) { if (!url) { return; } var _; try { _ = new XMLHttpRequest() } catch(e) { try { _ = new ActiveXObject("Msxml2.XMLHTTP") } catch(e) { try { _ = new ActiveXObject("Microsoft.XMLHTTP") } catch(e) { if (window.createRequest) { _ = window.createRequest(); } else { alert(LANG.message_ajaxnotsupported); return; } } } } this.request = _; $WH.cO(this, opt); this.method = this.method || (this.params && 'POST') || 'GET'; _.open(this.method, url, this.async == null ? true: this.async); _.onreadystatechange = Ajax.onReadyStateChange.bind(this); if (this.method.toUpperCase() == 'POST') { _.setRequestHeader('Content-Type', (this.contentType || 'application/x-www-form-urlencoded') + '; charset=' + (this.encoding || 'UTF-8')); } _.send(this.params); } Ajax.onReadyStateChange = function() { if (this.request.readyState == 4) { if (this.request.status == 0 || (this.request.status >= 200 && this.request.status < 300)) { this.onSuccess != null && this.onSuccess(this.request, this); } else { this.onFailure != null && this.onFailure(this.request, this); } if (this.onComplete != null) { this.onComplete(this.request, this); } } }; var DomContentLoaded = new function() { var _now = []; var _del = []; this.now = function() { $WH.array_apply(_now, function(f) { f(); }); }; this.delayed = function() { $WH.array_apply(_del, function(f) { f(); }); DomContentLoaded = null; }; this.addEvent = function(f) { _now.push(f); }; this.addDelayedEvent = function(f) { _del.push(f); } }; function g_addCss(b) { var c = $WH.ce("style"); c.type = "text/css"; if (c.styleSheet) { c.styleSheet.cssText = b } else { $WH.ae(c, $WH.ct(b)) } var a = $WH.gE(document, "head")[0]; $WH.ae(a, c) } function g_setTextNodes(c, b) { if (c.nodeType == 3) { c.nodeValue = b } else { for (var a = 0; a < c.childNodes.length; ++a) { g_setTextNodes(c.childNodes[a], b) } } } function g_setInnerHtml(d, c, a) { if (d.nodeName.toLowerCase() == a) { d.innerHTML = c } else { for (var b = 0; b < d.childNodes.length; ++b) { g_setInnerHtml(d.childNodes[b], c, a) } } } function g_getTextContent(c) { var a = ""; for (var b = 0; b < c.childNodes.length; ++b) { if (c.childNodes[b].nodeValue) { a += c.childNodes[b].nodeValue } else { if (c.childNodes[b].nodeName == "BR") { if ($WH.Browser.ie67) { a += "\r" } else { a += "\n" } } } a += g_getTextContent(c.childNodes[b]) } return a } function g_pickerWheel(evt) { evt = $WH.$E(evt); if (evt._wheelDelta < 0) this.scrollTop += 27; else this.scrollTop -= 27; } function g_setSelectedLink(c, b) { if (!g_setSelectedLink.groups) { g_setSelectedLink.groups = {} } var a = g_setSelectedLink.groups; if (a[b]) { a[b].className = a[b].className.replace("selected", "") } c.className += " selected"; a[b] = c } function g_setCheckedRow(c, b) { if (!g_setCheckedRow.groups) { g_setCheckedRow.groups = {} } var a = g_setCheckedRow.groups; if (a[b]) { a[b].className = a[b].className.replace("checked", "") } c.className += " checked"; a[b] = c } function g_toggleDisplay(a) { if (a.style.display == "none") { a.style.display = ""; return true } else { a.style.display = "none"; return false } } function g_enableScroll(a) { if (!a) { $WH.aE(document, "mousewheel", g_enableScroll.F); $WH.aE(window, "DOMMouseScroll", g_enableScroll.F) } else { $WH.dE(document, "mousewheel", g_enableScroll.F); $WH.dE(window, "DOMMouseScroll", g_enableScroll.F) } } g_enableScroll.F = function(a) { if (a.stopPropagation) { a.stopPropagation() } if (a.preventDefault) { a.preventDefault() } a.returnValue = false; a.cancelBubble = true; return false }; function g_createRange(c, a) { range = {}; for (var b = c; b <= a; ++b) { range[b] = b } return range } function g_sortIdArray(a, b, c) { a.sort(c ? function(e, d) { return $WH.strcmp(b[e][c], b[d][c]) }: function(e, d) { return $WH.strcmp(b[e], b[d]) }) } function g_sortJsonArray(e, d, f, a) { var c = []; for (var b in e) { if (d[b] && (a == null || a(d[b]))) { c.push(b) } } if (f != null) { c.sort(f) } else { g_sortIdArray(c, d) } return c } function g_urlize(str, allowLocales, profile) { var ta = $WH.ce('textarea'); ta.innerHTML = str.replace(//g,">"); str = ta.value; str = $WH.str_replace(str, ' / ', '-'); str = $WH.str_replace(str, "'", ''); if (profile) { str = $WH.str_replace(str, '(', ''); str = $WH.str_replace(str, ')', ''); var accents = { "ß": "ss", "á": "a", "ä": "a", "à": "a", "â": "a", "è": "e", "ê": "e", "é": "e", "ë": "e", "í": "i", "î": "i", "ì": "i", "ï": "i", "ñ": "n", "ò": "o", "ó": "o", "ö": "o", "ô": "o", "ú": "u", "ü": "u", "û": "u", "ù": "u", "œ": "oe", "Á": "A", "Ä": "A", "À": "A", "Â": "A", "È": "E", "Ê": "E", "É": "E", "Ë": "E", "Í": "I", "Î": "I", "Ì": "I", "Ï": "I", "Ñ": "N", "Ò": "O", "Ó": "O", "Ö": "O", "Ô": "O", "Ú": "U", "Ü": "U", "Û": "U", "Ù": "U", "œ": "Oe" }; for (var character in accents) { str = str.replace(new RegExp(character, "g"), accents[character]); } } str = $WH.trim(str); if (allowLocales) { str = $WH.str_replace(str, ' ', '-'); } else { str = str.replace(/[^a-z0-9]/ig, '-'); } str = $WH.str_replace(str, '--', '-'); str = $WH.str_replace(str, '--', '-'); str = $WH.rtrim(str, '-'); str = str.replace(/[A-Z]/g, function(x) { return x.toLowerCase(); }); return str; } function g_createHeader(c) { var k = $WH.ce("dl"), p = (c == 5); for (var j = 0, l = mn_path.length; j < l; ++j) { var f = $WH.ce("dt"); var q = $WH.ce("a"); var m = $WH.ce("ins"); var g = $WH.ce("big"); var e = $WH.ce("span"); var o = mn_path[j][0]; var h = (o == c); var d = (!h && mn_path[j][3]); if (p && o == 5) { d = true; mn_path[j][3] = mn_profiles } if (d) { Menu.add(q, mn_path[j][3]); } else { q.onmouseover = Menu._hide } if (mn_path[j][2]) { q.href = mn_path[j][2] } else { q.href = "javascript:;"; $WH.ns(q); q.style.cursor = "default" } if (h) { q.className = "selected" } $WH.ae(g, $WH.ct(mn_path[j][1].charAt(0))); $WH.ae(m, g); $WH.ae(m, $WH.ct(mn_path[j][1].substr(1))); $WH.ae(q, m); $WH.ae(q, e); $WH.ae(f, q); $WH.ae(k, f) } $WH.ae($WH.ge("toptabs-generic"), k); var b = $WH.ge("topbar-buttons"); if (c != null && c >= 0 && c < mn_path.length) { c = parseInt(c); switch (c) { case 0: // Database Menu.addButtons(b, [ [0, LANG.menu_browse, null, mn_database], // Browse Menu.findItem(mn_tools, [8]), // Utilities Menu.findItem(mn_tools, [8, 4]) // Random Page ]); break; case 1: // Tools Menu.addButtons(b, [ [0, LANG.calculators, null, mn_tools.slice(0,4)], // Calculators Menu.findItem(mn_tools, [1]), // Maps Menu.findItem(mn_tools, [8]), // Utilities Menu.findItem(mn_tools, [6]), // Guides ]); break; case 2: Menu.addButtons(b, Menu.implode(mn_more)); break; case 5: pr_initTopBarSearch(); break } } else { $WH.ae(b, $WH.ct(String.fromCharCode(160))); } } function g_updateHeader(a) { $WH.ee($WH.ge("toptabs-generic")); $WH.ee($WH.ge("topbar-buttons")); g_createHeader(a) } function g_initHeader(a) { g_createHeader(a); var d = $WH.ge("livesearch-generic"); var b = d.previousSibling; var c = d.parentNode; $WH.ns(b); b.onclick = function() { this.parentNode.onsubmit() }; if ($WH.Browser.ie) { setTimeout(function() { d.value = "" }, 1) } if (d.value == "") { d.className = "search-database" } d.onmouseover = function() { if ($WH.trim(this.value) != "") { this.className = "" } }; d.onfocus = function() { this.className = "" }; d.onblur = function() { if ($WH.trim(this.value) == "") { this.className = "search-database"; this.value = "" } }; c.onsubmit = function() { var e = this.elements[0].value; if ($WH.trim(e) == "") { return false } this.submit() } } function g_initHeaderMenus() { var c = $WH.ge("toptabs-menu-user"); if (c) { menu = [[0, LANG.userpage, "?user=" + g_user.name], [0, LANG.settings, "?account"], [0, LANG.signout, "?account=signout"]]; if (location.href.match(new RegExp("/?user=" + g_user.name + "$", "i"))) { menu[0].checked = 1 } else { if (location.href.indexOf("?account") != -1) { menu[1].checked = 1 } } Menu.add(c, menu); c.href = "?user=" + g_user.name } c = $WH.ge("toptabs-menu-profiles"); if (c) { c.menu = []; if (g_user.characters) { c.menu.push([, LANG.tab_characters]); for (var f = 0, b = g_user.characters.length; f < b; ++f) { var h = g_user.characters[f], e = [0, h.name + " (" + h.realmname + LANG.hyphen + h.region.toUpperCase() + ")", "?profile=" + h.region + "." + h.realm + "." + g_cleanCharacterName(h.name)]; e.smallIcon = h.icon ? h.icon: "chr_" + g_file_races[h.race] + "_" + g_file_genders[h.gender] + "_" + g_file_classes[h.classs] + "0" + (h.level > 59 ? (Math.floor((h.level - 60) / 10) + 2) : 1); c.menu.push(e) } } c.menu.push([, LANG.tab_profiles]); if (g_user.profiles) { for (var f = 0, b = g_user.profiles.length; f < b; ++f) { var h = g_user.profiles[f], e = [0, h.name, "?profile=" + h.id]; e.smallIcon = h.icon ? h.icon: "chr_" + g_file_races[h.race] + "_" + g_file_genders[h.gender] + "_" + g_file_classes[h.classs] + "0" + (h.level > 59 ? (Math.floor((h.level - 60) / 10) + 2) : 1); c.menu.push(e) } } var e = [0, "(" + LANG.button_new + ")", "?profile&new"]; e.smallIcon = "inv_misc_questionmark"; c.menu.push(e); c.menu.rightAligned = 1; Menu.add(c, c.menu); c.href = "?user=" + g_user.name + (g_user.profiles ? "#profiles": (g_user.characters ? "#characters": "")) } c = $WH.ge("toptabs-menu-language"); if (c) { var g = "www", d = location.href, j = location.hostname.indexOf("."); if (j != -1 && j <= 5) { g = location.hostname.substr(0, j) } j = d.indexOf("#"); if (j != -1) { d = d.substr(0, j) } //menu = [[0, "Deutsch", (g_locale.id != 3 ? d.replace(g, "de") : null)], [0, "English", (g_locale.id != 0 ? d.replace(g, "www") : null)], [0, "Espa" + String.fromCharCode(241) + "ol", (g_locale.id != 6 ? d.replace(g, "es") : null)], [0, "Fran" + String.fromCharCode(231) + "ais", (g_locale.id != 2 ? d.replace(g, "fr") : null)], [0, String.fromCharCode(1056, 1091, 1089, 1089, 1082, 1080, 1081), (g_locale.id != 8 ? d.replace(g, "ru") : null)]]; var rel = d.match(/()\?((item|quest|spell|achievement|npc|object)=([0-9]+))/); rel = (rel && rel[2]) ? rel[2] : ""; menu = [ [0, "Deutsch", (g_locale.id != 3 ? "?locale=3" : null), , {rel: rel + " domain=de"}], [0, "English", (g_locale.id != 0 ? "?locale=0" : null), , {rel: rel + " domain=en"}], [0, "Espa" + String.fromCharCode(241) + "ol", (g_locale.id != 6 ? "?locale=6" : null), , {rel: rel + " domain=es"}], [0, "Fran" + String.fromCharCode(231) + "ais", (g_locale.id != 2 ? "?locale=2" : null), , {rel: rel + " domain=fr"}], [0, String.fromCharCode(1056, 1091, 1089, 1089, 1082, 1080, 1081), (g_locale.id != 8 ? "?locale=8" : null), , {rel: rel + " domain=ru"}] ]; menu.rightAligned = 1; if (g_locale.id != 25) { menu[{ 0 : 1, 2 : 3, 3 : 0, 6 : 2, 8 : 4 } [g_locale.id]].checked = 1 } Menu.add(c, menu); } $('#toplinks-feedback').attr('href', 'javascript:;').click(function() { ContactTool.show(); }); } function g_initPath(q, f) { var h = mn_path, c = null, k = null, p = 0, l = $WH.ge("main-precontents"), o = $WH.ce("div"); $WH.ee(l); if (g_initPath.lastIt) { g_initPath.lastIt.checked = null } o.className = "path"; if (f != null) { var m = $WH.ce("div"); m.className = "path-right"; var r = $WH.ce("a"); r.href = "javascript:;"; r.id = "fi_toggle"; $WH.ns(r); r.onclick = fi_toggle; if (f) { r.className = "disclosure-on"; $WH.ae(r, $WH.ct(LANG.fihide)) } else { r.className = "disclosure-off"; $WH.ae(r, $WH.ct(LANG.fishow)) } $WH.ae(m, r); $WH.ae(l, m) } for (var g = 0; g < q.length; ++g) { var r, b, t = 0; for (var e = 0; e < h.length; ++e) { if (h[e][0] == q[g]) { t = 1; h = h[e]; h.checked = 1; break } } if (!t) { p = 1; break } r = $WH.ce("a"); b = $WH.ce("span"); if (h[2]) { r.href = h[2] } else { r.href = "javascript:;"; $WH.ns(r); r.style.textDecoration = "none"; r.style.color = "white"; r.style.cursor = "default" } if (g < q.length - 1 && h[3]) { b.className = "menuarrow" } //$WH.ae(r, $WH.ct(h[4] == null ? h[1] : h[4])); $WH.ae(r, $WH.ct(h[1])); if (g == 0) { Menu.add(r, mn_path); } else { Menu.add(r, c[3]); } $WH.ae(b, r); $WH.ae(o, b); k = b; c = h; h = h[3]; if (!h) { p = 1; break } } if (p && k) { k.className = "" } else { if (c && c[3]) { k.className = "menuarrow"; r = $WH.ce("a"); b = $WH.ce("span"); r.href = "javascript:;"; $WH.ns(r); r.style.textDecoration = "none"; r.style.paddingRight = "16px"; r.style.color = "white"; r.style.cursor = "default"; $WH.ae(r, $WH.ct("...")); Menu.add(r, c[3]); $WH.ae(b, r); $WH.ae(o, b) } } // not really usefull // var m = $WH.ce("div"); // m.className = "clear"; // $WH.ae(o, m); $WH.ae(l, o); g_initPath.lastIt = c } function g_addTooltip(b, c, a) { if (!a && c.indexOf("") == -1) { a = "q" } b.onmouseover = function(d) { $WH.Tooltip.showAtCursor(d, c, 0, 0, a) }; b.onmousemove = $WH.Tooltip.cursorUpdate; b.onmouseout = $WH.Tooltip.hide } function g_addStaticTooltip(b, c, a) { if (!a && c.indexOf("
") == -1) { a = "q" } b.onmouseover = function(d) { $WH.Tooltip.show(b, c, 0, 0, a) }; b.onmouseout = $WH.Tooltip.hide } function g_formatTimeElapsed(delay) { function OMG(value, unit, abbrv) { if (abbrv && LANG.timeunitsab[unit] == '') { abbrv = 0; } if (abbrv) { return value + ' ' + LANG.timeunitsab[unit]; } else { return value + ' ' + (value == 1 ? LANG.timeunitssg[unit] : LANG.timeunitspl[unit]); } } var range = [31557600, 2629800, 604800, 86400, 3600, 60, 1], subunit = [1, 3, 3, -1, 5, -1, -1]; delay = Math.max(delay, 1); for (var i = 3, len = range.length; i < len; ++i) { if (delay >= range[i]) { var i1 = i; var v1 = Math.floor(delay / range[i1]); if (subunit[i1] != -1) { var i2 = subunit[i1]; delay %= range[i1]; var v2 = Math.floor(delay / range[i2]); if (v2 > 0) { return OMG(v1, i1, 1) + ' ' + OMG(v2, i2, 1); } } return OMG(v1, i1, 0); } } return '(n/a)'; } function g_GetStaffColorFromRoles(roles) { if (roles & U_GROUP_ADMIN) { return 'comment-blue'; } if (roles & U_GROUP_GREEN_TEXT) { // Mod, Bureau, Dev return 'comment-green'; } if (roles & U_GROUP_VIP) { // VIP return 'comment-gold'; } return ''; } function g_formatDate(sp, elapsed, theDate, time, alone) { var today = new Date(); var event_day = new Date(); event_day.setTime(today.getTime() - (1000 * elapsed)); var txt; var event_day_midnight = new Date(event_day.getYear(), event_day.getMonth(), event_day.getDate()); var today_midnight = new Date(today.getYear(), today.getMonth(), today.getDate()); var delta = (today_midnight.getTime() - event_day_midnight.getTime()); delta /= 1000; delta /= 86400; delta = Math.round(delta); if (elapsed >= 2592000) { /* More than a month ago */ txt = LANG.date_on + g_formatDateSimple(theDate, time); } else if (delta > 1) { txt = $WH.sprintf(LANG.ddaysago, delta); if (sp) { var _ = new Date(); _.setTime(theDate.getTime() + (g_localTime - g_serverTime)); sp.className += ' tip'; sp.title = _.toLocaleString(); } } else if (elapsed >= 43200) { if (today.getDay() == event_day.getDay()) { txt = LANG.today; } else { txt = LANG.yesterday; } txt = g_formatTimeSimple(event_day, txt); if (sp) { var _ = new Date(); _.setTime(theDate.getTime() + (g_localTime - g_serverTime)); sp.className += ' tip'; sp.title = _.toLocaleString(); } } else { /* Less than 12 hours ago */ var txt = $WH.sprintf(LANG.date_ago, g_formatTimeElapsed(elapsed)); if (sp) { var _ = new Date(); _.setTime(theDate.getTime() + (g_localTime - g_serverTime)); sp.className += ' tip'; sp.title = _.toLocaleString(); } } if (alone == 1) { txt = txt.substr(0, 1).toUpperCase() + txt.substr(1); } if (sp) { $WH.ae(sp, $WH.ct(txt)); } else { return txt; } } function g_formatDateSimple(d, time) { function __twoDigits(n) { return (n < 10 ? '0' + n : n); } var b = "", day = d.getDate(), month = d.getMonth() + 1, year = d.getFullYear(); if (year <= 1970) { b += LANG.unknowndate_stc; } else { b += $WH.sprintf(LANG.date_simple, __twoDigits(day), __twoDigits(month), year); } if (time != null) { b = g_formatTimeSimple(d, b); } return b; } function g_formatTimeSimple(d, txt, noPrefix) { function __twoDigits(n) { return (n < 10 ? '0' + n : n); } var hours = d.getHours(), minutes = d.getMinutes(); if (txt == null) { txt = ''; } txt += (noPrefix ? ' ' : LANG.date_at); if (hours == 12) { txt += LANG.noon; } else if (hours == 0) { txt += LANG.midnight; } else if (hours > 12) { txt += (hours - 12) + ':' + __twoDigits(minutes) + ' ' + LANG.pm; } else { txt += hours + ':' + __twoDigits(minutes) + ' ' + LANG.am; } return txt; } function g_createGlow(txt, cn) { var s = $WH.ce('span'); for (var i = -1; i <= 1; ++i) { for (var j = -1; j <= 1; ++j) { var d = $WH.ce('div'); d.style.position = 'absolute'; d.style.whiteSpace = 'nowrap'; d.style.left = i + 'px'; d.style.top = j + 'px'; if (i == 0 && j == 0) { d.style.zIndex = 4; } else { d.style.color = 'black'; d.style.zIndex = 2; } //$WH.ae(d, $WH.ct(txt)); d.innerHTML = txt; $WH.ae(s, d); } } s.style.position = 'relative'; s.className = 'glow' + (cn != null ? ' ' + cn : ''); var ph = $WH.ce('span'); ph.style.visibility = 'hidden'; $WH.ae(ph, $WH.ct(txt)); $WH.ae(s, ph); return s; } function g_createProgressBar(opt) { if (opt == null) { opt = {}; } if (typeof opt.text == 'undefined') { opt.text = ' '; } if (opt.color == null) { opt.color = 'rep0'; } if (opt.width == null || opt.width > 100) { opt.width = 100; } var el, div; if (opt.hoverText) { el = $WH.ce('a'); el.href = 'javascript:;'; } else { el = $WH.ce('span'); } el.className = 'progressbar'; if (opt.text || opt.hoverText) { div = $WH.ce('div'); div.className = 'progressbar-text'; if (opt.text) { var del = $WH.ce('del'); $WH.ae(del, $WH.ct(opt.text)); $WH.ae(div, del); } if (opt.hoverText) { var ins = $WH.ce('ins'); $WH.ae(ins, $WH.ct(opt.hoverText)); $WH.ae(div, ins); } $WH.ae(el, div); } div = $WH.ce('div'); div.className = 'progressbar-' + opt.color; div.style.width = opt.width + '%'; if (opt.height) { div.style.height = opt.height; } $WH.ae(div, $WH.ct(String.fromCharCode(160))); $WH.ae(el, div); if (opt.text) { var div = $WH.ce('div'); div.className = 'progressbar-text progressbar-hidden'; $WH.ae(div, $WH.ct(opt.text)); $WH.ae(el, div); } return el; } function g_createReputationBar(totalRep) { var P = g_createReputationBar.P; if (!totalRep) { totalRep = 0; } totalRep += 42000; if (totalRep < 0) { totalRep = 0; } else if (totalRep > 84999) { totalRep = 84999; } var currentRep = totalRep, maxRep, standing = 0; for (var i = 0, len = P.length; i < len; ++i) { if (P[i] > currentRep) { break; } if (i < len - 1) { currentRep -= P[i]; standing = i + 1; } } maxRep = P[standing]; var opt = { text: g_reputation_standings[standing], hoverText: currentRep + ' / ' + maxRep, color: 'rep' + standing, width: parseInt(currentRep / maxRep * 100) }; return g_createProgressBar(opt); } g_createReputationBar.P = [36000, 3000, 3000, 3000, 6000, 12000, 21000, 999]; function g_createAchievementBar(points, outOf, overall, bonus) { if (!points) { points = 0; } var opt = { text: points + (bonus > 0 ? '(+' + bonus + ')': '') + (outOf > 0 ? ' / ' + outOf: ''), color: (overall ? 'rep7' : 'ach' + (outOf > 0 ? 0 : 1)), width: (outOf > 0 ? parseInt(points / outOf * 100) : 100) }; return g_createProgressBar(opt); } function g_getMoneyHtml(money, side, costItems, costCurrency, achievementPoints) { var ns = 0, html = ''; if (side == 1 || side == 'alliance') { side = 1; } else if (side == 2 || side == 'horde') { side = 2; } else { side = 3; } if (money >= 10000) { ns = 1; var display = Math.floor(money / 10000); html += '' + $WH.number_format(display) + ''; money %= 10000; } if (money >= 100) { if (ns) { html += ' '; } else { ns = 1; } var display = Math.floor(money / 100); html += '' + display + ''; money %= 100; } if (money >= 1) { if (ns) { html += ' '; } else { ns = 1; } html += '' + money + ''; } if (costItems != null) { for (var i = 0; i < costItems.length; ++i) { if (ns) { html += ' '; } else { ns = 1; } var itemId = costItems[i][0]; var count = costItems[i][1]; var icon = (g_items[itemId] && g_items[itemId].icon ? g_items[itemId].icon : 'inv_misc_questionmark'); html += '' + count + ''; } } if (costCurrency != null) { for (var i = 0; i < costCurrency.length; ++i) { if (ns) { html += ' '; } else { ns = 1; } var currencyId = costCurrency[i][0]; var count = costCurrency[i][1]; var icon = (g_gatheredcurrencies[currencyId] && g_gatheredcurrencies[currencyId].icon ? g_gatheredcurrencies[currencyId].icon : ['inv_misc_questionmark', 'inv_misc_questionmark']); if (side == 3 && icon[0] == icon[1]) { side = 1; } // sarjuuk: custom start if (currencyId == 103) { // arena html += '' + $WH.number_format(count) + ''; } else if (currencyId == 104) { // honor html += '' + (side == 3 ? '' : '') + $WH.number_format(count) + (side == 3 ? '' : '') + ''; } else { // tokens html += '' + count + ''; } // sarjuuk: custom end // html += '' + (side == 3 ? '' : '') + count + (side == 3 ? '' : '') + ''; } } if (achievementPoints > 0) { if (ns) { html += ' '; } else { ns = 1; } html += '' + $WH.number_format(achievementPoints) + ''; } return html; } function g_numberFormat(f, b, l, h) { var c = f, a = b; var e = function(r, q) { var i = Math.pow(10, q); return (Math.round(r * i) / i).toString() }; c = !isFinite( + c) ? 0 : +c; a = !isFinite( + a) ? 0 : Math.abs(a); var p = (typeof h === "undefined") ? ",": h; var d = (typeof l === "undefined") ? ".": l; var o = (a > 0) ? e(c, a) : e(Math.round(c), a); var m = e(Math.abs(c), a); var k, g; if (m >= 1000) { k = m.split(/\D/); g = k[0].length % 3 || 3; k[0] = o.slice(0, g + (c < 0)) + k[0].slice(g).replace(/(\d{3})/g, p + "$1"); o = k.join(d) } else { o = o.replace(".", d) } var j = o.indexOf(d); if (a >= 1 && j !== -1 && (o.length - j - 1) < a) { o += new Array(a - (o.length - j - 1)).join(0) + "0" } else { if (a >= 1 && j === -1) { o += d + new Array(a).join(0) + "0" } } return o } function g_expandSite() { $WH.ge("wrapper").className = "nosidebar"; var a = $WH.ge("topbar-expand"); if (a) { $WH.de(a) } a = $WH.ge("sidebar"); if (a) { $WH.de(a) } } function g_insertTag(d, a, i, j) { var b = $(d); b.focus(); if (b.selectionStart != null) { var l = b.selectionStart, h = b.selectionEnd, k = b.scrollLeft, c = b.scrollTop; var g = b.value.substring(l, h); if (typeof j == "function") { g = j(g) } b.value = b.value.substr(0, l) + a + g + i + b.value.substr(h); b.selectionStart = b.selectionEnd = h + a.length; b.scrollLeft = k; b.scrollTop = c } else { if (document.selection && document.selection.createRange) { var f = document.selection.createRange(); if (f.parentElement() != b) { return } var g = f.text; if (typeof j == "function") { g = j(g) } f.text = a + g + i } } if (b.onkeyup) { b.onkeyup() } } function g_isDateValid(date) { var match = /^(20[0-2]\d)-([01]\d)-([0-3]\d) ([0-2]\d):([0-5]\d):([0-5]\d)$/.exec(date); return match; } function g_isIpAddress(str) { return /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/.test(str); } function g_isEmailValid(email) { return email.match(/^([a-z0-9._-]+)(\+[a-z0-9._-]+)?(@[a-z0-9.-]+\.[a-z]{2,4})$/i) != null; } function g_getCurrentDomain() { if (g_getCurrentDomain.CACHE) { return g_getCurrentDomain.CACHE; } var hostname = location.hostname; if (!g_isIpAddress(hostname)) { // Only keep the last 2 parts var parts = hostname.split('.'); if(parts.length > 2) { parts.splice(0, parts.length - 2); } hostname = parts.join('.'); } g_getCurrentDomain.CACHE = hostname; return hostname; } function g_onAfterTyping(a, d, c) { var e; var b = function() { if (e) { clearTimeout(e); e = null } e = setTimeout(d, c) }; a.onkeyup = b } function g_onClick(c, d) { var b = 0; function a(e) { if (b) { if (b != e) { return } } else { b = e } d(true) } c.oncontextmenu = function() { a(1); return false }; c.onmouseup = function(f) { f = $WH.$E(f); if (f._button == 3 || f.shiftKey || f.ctrlKey) { a(2) } else { if (f._button == 1) { d(false) } } return false } } function g_isLeftClick(a) { a = $WH.$E(a); return (a && a._button == 1) } function g_isExternalUrl(url) { if(!url) { return false; } if (url.indexOf('http') != 0 && url.indexOf('//') != 0) { return false; } else if (url.indexOf(g_getCurrentDomain()) != -1) { return false; } return true; } function g_createOrRegex(search, negativeGroup) { search = search.replace(/(\(|\)|\|\+|\*|\?|\$|\^)/g, '\\$1'); var parts = search.split(' '), strRegex= ''; for (var j = 0, len = parts.length; j < len; ++j) { if (j > 0) { strRegex += '|'; } strRegex += parts[j]; } // The additional group is necessary so we dont replace %s return new RegExp((negativeGroup != null ? '(' + negativeGroup + ')?' : '') + '(' + strRegex + ')', 'gi'); } function g_getHash() { return '#' + decodeURIComponent(location.href.split('#')[1] || ''); } // Lets you add/remove/edit the query parameters in the passed URL function g_modifyUrl(url, params, opt) { if (!opt) { opt = $.noop; } // Preserve existing hash var hash = ''; if (url.match(/(#.+)$/)) { hash = RegExp.$1; url = url.replace(hash, ''); } $.each(params, function(paramName, newValue) { var needle; var paramPrefix; var paramValue; var matches = url.match(new RegExp('(&|\\?)?' + paramName + '=?([^&]+)?')); if (matches != null) { needle = matches[0]; paramPrefix = matches[1]; paramValue = decodeURIComponent(matches[2]); } // Remove if (newValue == null) { if (!needle) { return; // If param wasn't there, no need to remove anything } paramValue = null; } // Append else if (newValue.substr(0, 2) == '+=') { if (paramValue && opt.onAppendCollision) { paramValue = opt.onAppendCollision(paramValue, newValue.substr(2), opt.menuUrl); } else if (!paramValue && opt.onAppendEmpty) { paramValue = opt.onAppendEmpty(newValue.substr(2), opt.menuUrl); } else { if (!paramValue) { paramValue = ''; } paramValue += $.trim(newValue.substr(2)); } } // Set else { paramValue = newValue; } // Replace existing param if (needle) { var replacement = ''; if (paramPrefix) { // Preserve existing prefix replacement += paramPrefix; } if (paramValue != null) { replacement += paramName; if (paramValue) { replacement += '=' + $WH.urlencode2(paramValue); } } url = url.replace(needle, replacement); } // Add new param else if (paramValue || newValue == null || newValue.substr(0,2) != '+=') { url += (url.indexOf('?') == -1 ? '?' : '&') + paramName; if (paramValue) { url += '=' + $WH.urlencode2(paramValue); } } }); // Polish url = url.replace('?&', '?'); url = url.replace(/&&/g, '&'); url = url.replace(/\/\?/g, '/'); url = url.replace(/(&|\?)+$/, ''); // Remove trailing & and ? characters return url + hash; } DomContentLoaded.addEvent(function () { $WH.array_apply($WH.gE(document, 'dfn'), function(x){ var text = x.title; x.title = ''; x.className += ' tip'; if (text.indexOf('LANG.') == 0) { // custom for less redundant texts text = eval(text); } g_addTooltip(x, text, 'q'); }); // if i understand this right, this code binds an onCopy eventHandler to every child node of class="text"-nodes with the attribute unselectable="on" // causing the text to disappear for 1ms, causing the empty node to be copied ... w/e, i'm not going to use this /* $('.text').bind('copy', function() { $('*[unselectable]', this).each(function(i, v) { var txt = $(v).text(); $(v).text(''); setTimeout(function() { $(v).text(txt) }, 1); }); }); */ }); function g_GetExpansionClassName(expansion) { switch (expansion) { case 0: return null; case 1: return "icon-bc-right"; case 2: return "icon-wotlk-right"; } return null; } function g_addPages(l, b) { function p(r, d) { var i; if (r == b.page) { i = $WH.ce("span"); i.className = "selected" } else { i = $WH.ce("a"); i.href = (r > 1 ? b.url + b.sep + r + b.pound: b.url + b.pound) } $WH.ae(i, $WH.ct(d != null ? d: r)); return i } if (!b.pound) { b.pound = "" } if (!b.sep) { b.sep = "." } if (b.allOrNothing && b.nPages <= 1) { return } var c = (b.align && b.align == "left"); var e = $WH.ce("div"), k, q = $WH.ce("var"); e.className = "pages"; if (c) { e.className += " pages-left" } if (b.nPages > 1) { k = $WH.ce("div"); k.className = "pages-numbers"; var o = Math.max(2, b.page - 3); var h = Math.min(b.nPages - 1, b.page + 3); var m = []; if (b.page != b.nPages) { m.push(p(b.page + 1, LANG.lvpage_next + String.fromCharCode(8250))) } m.push(p(b.nPages)); if (h < b.nPages - 1) { var a = $WH.ce("span"); $WH.ae(a, $WH.ct("...")); m.push(a) } for (var g = h; g >= o; --g) { m.push(p(g)) } if (o > 2) { var a = $WH.ce("span"); $WH.ae(a, $WH.ct("...")); m.push(a) } m.push(p(1)); if (b.page != 1) { m.push(p(b.page - 1, String.fromCharCode(8249) + LANG.lvpage_previous)) } if (c) { m.reverse() } for (var g = 0, j = m.length; g < j; ++g) { $WH.ae(k, m[g]) } k.firstChild.style.marginRight = "0"; k.lastChild.style.marginLeft = "0" } var q = $WH.ce("var"); $WH.ae(q, $WH.ct($WH.sprintf(LANG[b.wording[b.nItems == 1 ? 0 : 1]], b.nItems))); if (b.nPages > 1) { var a = $WH.ce("span"); $WH.ae(a, $WH.ct(String.fromCharCode(8211))); $WH.ae(q, a); var f = $WH.ce("a"); f.className = "gotopage"; f.href = "javascript:;"; $WH.ns(f); if ($WH.Browser.ie) { $WH.ae(f, $WH.ct(" ")) } f.onclick = function() { var d = prompt($WH.sprintf(LANG.prompt_gotopage, 1, b.nPages), b.page); if (d != null) { d |= 0; if (d != b.page && d >= 1 && d <= b.nPages) { document.location.href = (d > 1 ? b.url + b.sep + d + b.pound: b.url + b.pound) } } }; f.onmouseover = function(d) { $WH.Tooltip.showAtCursor(d, LANG.tooltip_gotopage, 0, 0, "q") }; f.onmousemove = $WH.Tooltip.cursorUpdate; f.onmouseout = $WH.Tooltip.hide; $WH.ae(q, f) } if (c) { $WH.ae(e, q); if (k) { $WH.ae(e, k) } } else { if (k) { $WH.ae(e, k) } $WH.ae(e, q) } $WH.ae(l, e) } function g_disclose(a, b) { b.className = "disclosure-" + (g_toggleDisplay(a) ? "on": "off"); return false } function co_addYourComment() { tabsContribute.focus(0); var ta = $WH.gE(document.forms['addcomment'], "textarea")[0]; ta.focus() } function co_cancelReply() { $WH.ge("replybox-generic").style.display = "none"; document.forms.addcomment.elements.replyto.value = "" } function co_validateForm(f) { var ta = $WH.gE(f, "textarea")[0]; if (g_user.permissions & 1) { return true; } if (Listview.funcBox.coValidate(ta)) { return true; } return false } function ss_submitAScreenshot() { tabsContribute.focus(1) } function ss_validateForm(f) { if (!f.elements.screenshotfile.value.length) { alert(LANG.message_noscreenshot); return false; } return true; } function ss_appendSticky() { var _ = $WH.ge("infobox-sticky-ss"); var type = g_pageInfo.type; var typeId = g_pageInfo.typeId; var pos = $WH.in_array(lv_screenshots, 1, function(a) { return a.sticky; }); if (pos != -1) { var screenshot = lv_screenshots[pos]; var a = $WH.ce("a"); a.href = "#screenshots:id=" + screenshot.id; a.onclick = function(a) { ScreenshotViewer.show({ screenshots: lv_screenshots, pos: pos }); return $WH.rf2(a); }; var size = (lv_videos && lv_videos.length ? [120, 90] : [150, 150]); var img = $WH.ce("img"), scale = Math.min(size[0] / screenshot.width, size[1] / screenshot.height); img.src = g_staticUrl + "/uploads/screenshots/thumb/" + screenshot.id + ".jpg"; img.width = Math.round(scale * screenshot.width); img.height = Math.round(scale * screenshot.height); img.className = "border"; $WH.ae(a, img); $WH.ae(_, a); var th = $WH.ge('infobox-screenshots'); var a = $WH.ce("a"); $WH.ae(a, $WH.ct(th.innerText + " (" + lv_screenshots.length + ")")); a.href = "#screenshots" a.title = $WH.sprintf(LANG.infobox_showall, lv_screenshots.length); a.onclick = function() { tabsRelated.focus((lv_videos && lv_videos.length) || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)) ? -2 : -1); return false; }; $WH.ee(th); $WH.ae(th, a); } else { var a; if (g_user.id > 0) { a = ''; } else { a = ''; } _.innerHTML = $WH.sprintf(LANG.infobox_noneyet, a + LANG.infobox_submitone + "") } } var vi_thumbnails = { 1 : "http://i3.ytimg.com/vi/$1/default.jpg" }; var vi_siteurls = { 1 : "http://www.youtube.com/watch?v=$1" }; var vi_sitevalidation = { 1 : /^http:\/\/www\.youtube\.com\/watch\?v=([^& ]{11})/ }; function vi_submitAVideo() { tabsContribute.focus(2) } function vi_validateForm(f) { if (!f.elements['videourl'].value.length) { alert(LANG.message_novideo); return false; } var urlmatch = false; for (var i in vi_sitevalidation) { if (f.elements['videourl'].value.match(vi_sitevalidation[i])) { urlmatch = true; break } } if (!urlmatch) { alert(LANG.message_novideo); return false; } return true; } function vi_appendSticky() { var _ = $WH.ge("infobox-sticky-vi"); var type = g_pageInfo.type; var typeId = g_pageInfo.typeId; var pos = $WH.in_array(lv_videos, 1, function(a) { return a.sticky }); if (pos != -1) { var video = lv_videos[pos]; var a = $WH.ce("a"); a.href = "#videos:id=" + video.id; a.onclick = function(e) { VideoViewer.show({ videos: lv_videos, pos: pos }); return $WH.rf2(e) }; var img = $WH.ce("img"); img.src = $WH.sprintf(vi_thumbnails[video.videoType], video.videoId); img.className = "border"; $WH.ae(a, img); $WH.ae(_, a); var th = $WH.ge('infobox-videos'); var a = $WH.ce("a"); $WH.ae(a, $WH.ct(th.innerText + " (" + lv_videos.length + ")")); a.href = "#videos" a.title = $WH.sprintf(LANG.infobox_showall, lv_videos.length); a.onclick = function() { tabsRelated.focus(-1); return false; }; $WH.ee(th); $WH.ae(th, a); } else { var a; if (g_user.id > 0) { a = '' } else { a = '' } _.innerHTML = $WH.sprintf(LANG.infobox_noneyet, a + LANG.infobox_suggestone + "") } } var g_videos = []; var VideoViewer = new function() { var videos, pos, imgWidth, imgHeight, scale, oldHash, mode = 0, collectionId, pageTitle, // IE flash embed fix container, screen, imgDiv, aPrev, aNext, aCover, aOriginal, divFrom, divCaption; function computeDimensions() { var video = videos[pos]; var captionExtraHeight = Math.max(divCaption.offsetHeight - 18, 0), availHeight = Math.max(50, Math.min(520, $WH.g_getWindowSize().h - 72 - captionExtraHeight)), scale = Math.min(1, availHeight / 520); imgWidth = Math.round(scale * 880); imgHeight = Math.round(scale * 520); aPrev.style.height = aNext.style.height = aCover.style.height = (imgHeight - 95) + 'px'; Lightbox.setSize(Math.max(480, imgWidth) + 20, imgHeight + 52 + captionExtraHeight); } function getPound(pos) { var video = videos[pos], buff = '#videos:'; if (mode == 0) { buff += 'id=' + video.id; } else { buff += collectionId + ':' + (pos + 1); } return buff; } function render(resizing) { if (resizing && (scale == 1) && $WH.g_getWindowSize().h > container.offsetHeight) { return; } container.style.visibility = 'hidden'; var video = videos[pos]; computeDimensions(); if (!resizing) { if (video.videoType == 1) { imgDiv.innerHTML = Markup.toHtml('[youtube=' + video.videoId + ' width=' + imgWidth + ' height=' + imgHeight + ' autoplay=true]', {mode:Markup.MODE_ARTICLE}); } aOriginal.href = $WH.sprintf(vi_siteurls[video.videoType], video.videoId); if (!video.user && typeof g_pageInfo == 'object') { video.user = g_pageInfo.username; } var hasFrom1 = (video.date && video.user), hasFrom2 = (videos.length > 1); if (hasFrom1) { var postedOn = new Date(video.date), elapsed = (g_serverTime - postedOn) / 1000; var a = divFrom.firstChild.childNodes[1]; a.href = '?user=' + video.user; a.innerHTML = video.user; var s = divFrom.firstChild.childNodes[3]; $WH.ee(s); Listview.funcBox.coFormatDate(s, elapsed, postedOn); divFrom.firstChild.style.display = ''; } else { divFrom.firstChild.style.display = 'none'; } var s = divFrom.childNodes[1]; $WH.ee(s); if (video.user) { if (hasFrom1) { $WH.ae(s, $WH.ct(' ' + LANG.dash + ' ')); } var a = $WH.ce('a'); a.href = 'javascript:;'; a.onclick = ContactTool.show.bind(ContactTool, { mode: 5, video: video }); a.className = 'icon-report'; g_addTooltip(a, LANG.report_tooltip, 'q2'); $WH.ae(a, $WH.ct(LANG.report)); $WH.ae(s, a); } s = divFrom.childNodes[2]; if (hasFrom2) { var buff = ''; if (video.user) { buff = LANG.dash; } buff += (pos + 1) + LANG.lvpage_of + videos.length; s.innerHTML = buff; s.style.display = ''; } else { s.style.display = 'none'; } divFrom.style.display = (hasFrom1 || hasFrom2 ? '': 'none'); var hasCaption = (video.caption != null && video.caption.length); var hasSubject = (video.subject != null && video.subject.length && video.type && video.typeId); if (hasCaption || hasSubject) { var html = ''; if (hasSubject) { html += LANG.types[video.type][0] + LANG.colon; html += ''; html += video.subject; html += ''; } if (hasCaption) { if (hasSubject) { html += LANG.dash; } html += (video.noMarkup ? video.caption: Markup.toHtml(video.caption, { mode: Markup.MODE_SIGNATURE })); } divCaption.innerHTML = html; divCaption.style.display = ''; } else { divCaption.style.display = 'none'; } if (videos.length > 1) { aPrev.href = getPound(peekPos(-1)); aNext.href = getPound(peekPos(1)); aPrev.style.display = aNext.style.display = ''; aCover.style.display = 'none'; } else { aPrev.style.display = aNext.style.display = 'none'; aCover.style.display = ''; } location.replace(getPound(pos)); } Lightbox.reveal(); container.style.visibility = 'visible'; setTimeout(fixTitle, 1); } function peekPos(change) { var foo = pos; foo += change; if (foo < 0) { foo = videos.length - 1; } else if (foo >= videos.length) { foo = 0; } return foo; } function prevVideo() { pos = peekPos(-1); render(); return false; } function nextVideo() { pos = peekPos(1); render(); return false; } function fixTitle() { if (pageTitle) { document.title = pageTitle; } } function onKeyUp(e) { e = $WH.$E(e); switch (e.keyCode) { case 37: // Left prevVideo(); break; case 39: // Right nextVideo(); break; } } function onResize() { render(1); } function onHide() { $WH.ee(imgDiv); if (videos.length > 1) { $WH.dE(document, 'keyup', onKeyUp) ; } if (oldHash && mode == 0) { if (oldHash.indexOf(':id=') != -1) { oldHash = '#videos'; } location.replace(oldHash); } else { location.replace('#.'); } fixTitle(); } function onShow(dest, first, opt) { if (typeof opt.videos == 'string') { videos = g_videos[opt.videos]; mode = 1; collectionId = opt.videos; } else { videos = opt.videos; mode = 0; collectionId = null; } container = dest; pos = 0; if (opt.pos && opt.pos >= 0 && opt.pos < videos.length) { pos = opt.pos; } if (first) { dest.className = 'screenshotviewer'; screen = $WH.ce('div'); screen.className = 'screenshotviewer-screen'; aPrev = $WH.ce('a'); aNext = $WH.ce('a'); aPrev.className = 'screenshotviewer-prev'; aNext.className = 'screenshotviewer-next'; aPrev.href = 'javascript:;'; aNext.href = 'javascript:;'; var foo = $WH.ce('span'); var b = $WH.ce('b'); // $WH.ae(b, $WH.ct(LANG.previous)); $WH.ae(foo, b); $WH.ae(aPrev, foo); var foo = $WH.ce('span'); var b = $WH.ce('b'); // $WH.ae(b, $WH.ct(LANG.next)); $WH.ae(foo, b); $WH.ae(aNext, foo); aPrev.onclick = prevVideo; aNext.onclick = nextVideo; aCover = $WH.ce('a'); aCover.className = 'screenshotviewer-cover'; aCover.href = 'javascript:;'; aCover.onclick = Lightbox.hide; var foo = $WH.ce('span'); var b = $WH.ce('b'); $WH.ae(b, $WH.ct(LANG.close)); $WH.ae(foo, b); $WH.ae(aCover, foo); $WH.ae(screen, aPrev); $WH.ae(screen, aNext); $WH.ae(screen, aCover); imgDiv = $WH.ce('div'); $WH.ae(screen, imgDiv); $WH.ae(dest, screen); var aClose = $WH.ce('a'); // aClose.className = 'dialog-x'; aClose.className = 'screenshotviewer-close'; aClose.href = 'javascript:;'; aClose.onclick = Lightbox.hide; // $WH.ae(aClose, $WH.ct(LANG.close)); $WH.ae(aClose, $WH.ce('span')); $WH.ae(dest, aClose); aOriginal = $WH.ce('a'); // aOriginal.className = 'dialog-arrow'; aOriginal.className = 'screenshotviewer-original'; aOriginal.href = 'javascript:;'; aOriginal.target = '_blank'; // $WH.ae(aOriginal, $WH.ct(LANG.original)); $WH.ae(aOriginal, $WH.ce('span')); $WH.ae(dest, aOriginal); divFrom = $WH.ce('div'); divFrom.className = 'screenshotviewer-from'; var sp = $WH.ce('span'); $WH.ae(sp, $WH.ct(LANG.lvscreenshot_from)); $WH.ae(sp, $WH.ce('a')); $WH.ae(sp, $WH.ct(' ')); $WH.ae(sp, $WH.ce('span')); $WH.ae(divFrom, sp); $WH.ae(divFrom, $WH.ce('span')); $WH.ae(divFrom, $WH.ce('span')); $WH.ae(dest, divFrom); divCaption = $WH.ce('div'); divCaption.className = 'screenshotviewer-caption'; $WH.ae(dest, divCaption); var d = $WH.ce('div'); d.className = 'clear'; $WH.ae(dest, d); } oldHash = location.hash; if (videos.length > 1) { $WH.aE(document, 'keyup', onKeyUp); } render(); } this.checkPound = function() { pageTitle = $WH.gE(document, 'title').innerHTML; if (location.hash && location.hash.indexOf('#videos') == 0) { if (!g_listviews['videos']) { // Standalone video viewer var parts = location.hash.split(':'); if (parts.length == 3) { var collection = g_videos[parts[1]], p = parseInt(parts[2]); if (collection && p >= 1 && p <= collection.length) { VideoViewer.show({ videos: parts[1], pos: p - 1 }); } } } } } this.show = function(opt) { Lightbox.show('videoviewer', { onShow: onShow, onHide: onHide, onResize: onResize },opt); return false; } DomContentLoaded.addEvent(this.checkPound) }; var Dialog = function() { var _self = this, _template, _onSubmit = null, _templateName, _funcs = {}, _data, _inited = false, _form = $WH.ce('form'), _elements = {}; _form.onsubmit = function() { _processForm(); return false }; this.show = function(template, opt) { if (template) { _templateName = template; _template = Dialog.templates[_templateName]; _self.template = _template; } else { return; } if (_template.onInit && !_inited) { (_template.onInit.bind(_self, _form, opt))(); } if (opt.onBeforeShow) { _funcs.onBeforeShow = opt.onBeforeShow.bind(_self, _form); } if (_template.onBeforeShow) { _template.onBeforeShow = _template.onBeforeShow.bind(_self, _form); } if (opt.onShow) { _funcs.onShow = opt.onShow.bind(_self, _form); } if (_template.onShow) { _template.onShow = _template.onShow.bind(_self, _form); } if (opt.onHide) { _funcs.onHide = opt.onHide.bind(_self, _form); } if (_template.onHide) { _template.onHide = _template.onHide.bind(_self, _form); } if (opt.onSubmit) { _funcs.onSubmit = opt.onSubmit; } if (_template.onSubmit) _onSubmit = _template.onSubmit.bind(_self, _form); if (opt.data) { _inited = false; _data = {}; $WH.cO(_data, opt.data); } _self.data = _data; Lightbox.show('dialog-' + _templateName, { onShow: _onShow, onHide: _onHide }); }; this.getValue = function(id) { return _getValue(id); }; this.setValue = function(id, value) { _setValue(id, value); }; this.getSelectedValue = function(id) { return _getSelectedValue(id); }; this.getCheckedValue = function(id) { return _getCheckedValue(id); }; function _onShow(dest, first) { if (first || !_inited) { _initForm(dest); } if (_template.onBeforeShow) { _template.onBeforeShow(); } if (_funcs.onBeforeShow) { _funcs.onBeforeShow(); } Lightbox.setSize(_template.width, _template.height); dest.className = 'dialog'; _updateForm(); if (_template.onShow) { _template.onShow(); } if (_funcs.onShow) { _funcs.onShow(); } } function _initForm(dest) { $WH.ee(dest); $WH.ee(_form); var container = $WH.ce('div'); container.className = 'text'; $WH.ae(dest, container); $WH.ae(container, _form); if (_template.title) { var h = $WH.ce('h1'); $WH.ae(h, $WH.ct(_template.title)); $WH.ae(_form, h); } var t = $WH.ce('table'), tb = $WH.ce('tbody'), mergeCell = false; $WH.ae(t, tb); $WH.ae(_form, t); for (var i = 0, len = _template.fields.length; i < len; ++i) { var field = _template.fields[i], element; if (!mergeCell) { tr = $WH.ce('tr'); th = $WH.ce('th'); td = $WH.ce('td'); } field.__tr = tr; if (_data[field.id] == null) { _data[field.id] = (field.value ? field.value: ''); } var options; if (field.options) { options = []; if (field.optorder) { $WH.cO(options, field.optorder); } else { for (var j in field.options) { options.push(j); } } if (field.sort) { options.sort(function(a, b) { return field.sort * $WH.strcmp(field.options[a], field.options[b]); }); } } switch (field.type) { case 'caption': th.colSpan = 2; th.style.textAlign = 'left'; th.style.padding = 0; if (field.compute) { (field.compute.bind(_self, null, _data[field.id], _form, th, tr))(); } else if (field.label) { $WH.ae(th, $WH.ct(field.label)); } $WH.ae(tr, th); $WH.ae(tb, tr); continue; break; case 'textarea': var f = element = $WH.ce('textarea'); f.name = field.id; if (field.disabled) { f.disabled = true; } f.rows = field.size[0]; f.cols = field.size[1]; td.colSpan = 2; if (field.label) { th.colSpan = 2; th.style.textAlign = 'left'; th.style.padding = 0; td.style.padding = 0; $WH.ae(th, $WH.ct(field.label)); $WH.ae(tr, th); $WH.ae(tb, tr); tr = $WH.ce('tr'); } $WH.ae(td, f); break; case 'select': var f = element = $WH.ce('select'); f.name = field.id; if (field.size) { f.size = field.size; } if (field.disabled) { f.disabled = true; } if (field.multiple) { f.multiple = true; } for (var j = 0, len2 = options.length; j < len2; ++j) { var o = $WH.ce('option'); o.value = options[j]; $WH.ae(o, $WH.ct(field.options[options[j]])); $WH.ae(f, o) } $WH.ae(td, f); break; case 'dynamic': td.colSpan = 2; td.style.textAlign = 'left'; td.style.padding = 0; if (field.compute) (field.compute.bind(_self, null, _data[field.id], _form, td, tr))(); $WH.ae(tr, td); $WH.ae(tb, tr); element = td; break; case 'checkbox': case 'radio': var k = 0; element = []; for (var j = 0, len2 = options.length; j < len2; ++j) { var s = $WH.ce('span'), f, l, uniqueId = 'sdfler46' + field.id + '-' + options[j]; if (j > 0 && !field.noInputBr) { $WH.ae(td, $WH.ce('br')); } if ($WH.Browser.ie6 && field.type == 'radio') { l = $WH.ce("