mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
menu more and tools
- items: allow 'upg' to be an array - filter: fixed logic error in checks - Markup: prevent handling of [menu], as PageTemplate is nyi - Power: advanced features (hide reagents or sellprice; recoloring, renaming, iconizing of links) - search: side-icon for titles - smarty: added template-vars to cache (has to be fixed sooner or later) - identify as HTML5 (fixed a strange bug with displaced list-pegs) - removed several typos
This commit is contained in:
843
static/widgets/power.js
Normal file
843
static/widgets/power.js
Normal file
@@ -0,0 +1,843 @@
|
||||
if (typeof $WH == "undefined") {
|
||||
$WH = { wowheadRemote: true };
|
||||
|
||||
/* custom */
|
||||
for (i in document.scripts) {
|
||||
if (!document.scripts[i].src)
|
||||
continue;
|
||||
|
||||
var match = document.scripts[i].src.match(/(https?:\/\/[^\/]+)((\/[\w\d-_%]+)*)\/widgets\/power\.js/i);
|
||||
if (match) {
|
||||
var g_host = match[1];
|
||||
var g_staticUrl = match[1] + match[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof $WowheadPower == "undefined") {
|
||||
var $WowheadPower = new function () {
|
||||
var isRemote = $WH.wowheadRemote;
|
||||
var
|
||||
opt = { applyto: 3 },
|
||||
head = document.getElementsByTagName("head")[0],
|
||||
whcss,
|
||||
currentType,
|
||||
currentId,
|
||||
currentLocale,
|
||||
currentDomain,
|
||||
currentParams,
|
||||
currentA,
|
||||
|
||||
cursorX,
|
||||
cursorY,
|
||||
|
||||
mode = 0,
|
||||
|
||||
eventAttached = false,
|
||||
|
||||
npcs = {},
|
||||
objects = {},
|
||||
items = {},
|
||||
quests = {},
|
||||
spells = {},
|
||||
achievements = {},
|
||||
profiles = {},
|
||||
|
||||
showLogo = 1,
|
||||
|
||||
STATUS_NONE = 0,
|
||||
STATUS_QUERYING = 1,
|
||||
STATUS_ERROR = 2,
|
||||
STATUS_NOTFOUND = 3,
|
||||
STATUS_OK = 4,
|
||||
STATUS_SCALES = 5,
|
||||
|
||||
SCALES_NONE = 0,
|
||||
SCALES_LOADED = 1,
|
||||
SCALES_QUERYING = 2,
|
||||
|
||||
TYPE_NPC = 1,
|
||||
TYPE_OBJECT = 2,
|
||||
TYPE_ITEM = 3,
|
||||
TYPE_QUEST = 5,
|
||||
TYPE_SPELL = 6,
|
||||
TYPE_ACHIEVEMENT = 10,
|
||||
TYPE_PROFILE = 100,
|
||||
|
||||
CURSOR_HSPACE = 15,
|
||||
CURSOR_VSPACE = 15,
|
||||
|
||||
_LANG = {
|
||||
loading: "Loading...",
|
||||
noresponse: "No response from server :(",
|
||||
achievementcomplete: "Achievement earned by $1 on $2/$3/$4"
|
||||
},
|
||||
LOOKUPS = {
|
||||
1: [npcs, "npc", "NPC" ],
|
||||
2: [objects, "object", "Object" ],
|
||||
3: [items, "item", "Item" ],
|
||||
5: [quests, "quest", "Quest" ],
|
||||
6: [spells, "spell", "Spell" ],
|
||||
10: [achievements, "achievement", "Achievement"],
|
||||
100: [profiles, "profile", "Profile" ]
|
||||
},
|
||||
SCALES = {
|
||||
3: { url: "?data=item-scaling" }
|
||||
},
|
||||
LOCALES = {
|
||||
0: "enus",
|
||||
2: "frfr",
|
||||
3: "dede",
|
||||
6: "eses",
|
||||
8: "ruru"
|
||||
},
|
||||
REDIRECTS = {
|
||||
wotlk: "www",
|
||||
ptr: "www"
|
||||
};
|
||||
|
||||
if (isRemote) {
|
||||
var Locale = { id: 0, name: "enus" };
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (isRemote) {
|
||||
var script = document.createElement("script");
|
||||
// script.src = (document.location.protocol != "https:" ? "http:": document.location.protocol) + "//wowjs.zamimg.com/js/basic.js?5";
|
||||
script.src = g_host + "/static/js/basic.js";
|
||||
head.appendChild(script);
|
||||
}
|
||||
else {
|
||||
attachEvent();
|
||||
}
|
||||
|
||||
for (var type in SCALES) {
|
||||
for (var localeId in LOCALES) {
|
||||
SCALES[type][localeId] = SCALES_NONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initCSS() {
|
||||
if (typeof aowow_tooltips == "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!("hide" in aowow_tooltips)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof whcss != "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!document.styleSheets) {
|
||||
return
|
||||
}
|
||||
|
||||
var style = document.createElement("style");
|
||||
style.type = "text/css";
|
||||
head.appendChild(style);
|
||||
|
||||
if (!window.createPopup) {
|
||||
head.appendChild(document.createTextNode(""));
|
||||
}
|
||||
|
||||
whcss = document.styleSheets[document.styleSheets.length - 1];
|
||||
for (var k in aowow_tooltips.hide) {
|
||||
if (!aowow_tooltips.hide[k]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (whcss.insertRule) {
|
||||
whcss.insertRule(".wowhead-tooltip .whtt-" + k + "{display : none}", whcss.cssRules.length);
|
||||
}
|
||||
else if (whcss.addRule) {
|
||||
whcss.addRule(".wowhead-tooltip .whtt-" + k, "display : none", -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function attachEvent() {
|
||||
if (eventAttached) {
|
||||
return;
|
||||
}
|
||||
|
||||
eventAttached = true;
|
||||
$WH.aE(document, "mouseover", onMouseOver);
|
||||
}
|
||||
|
||||
function onDOMReady(func) {
|
||||
if (typeof jQuery != "undefined") {
|
||||
jQuery(func);
|
||||
return
|
||||
}
|
||||
/in/.test(document.readyState) ? setTimeout(onDOMReady.bind(null, func), 9) : func();
|
||||
}
|
||||
|
||||
this.init = function () {
|
||||
if (isRemote) {
|
||||
$WH.ae(head, $WH.ce("link", {
|
||||
type: "text/css",
|
||||
// href: (document.location.protocol != "https:" ? "http:": document.location.protocol) + "//wowcss.zamimg.com/css/basic.css?5",
|
||||
href: g_host + "/static/css/basic.css",
|
||||
rel: "stylesheet"
|
||||
}));
|
||||
|
||||
if ($WH.Browser.ie67) {
|
||||
$WH.ae(head, $WH.ce("link", {
|
||||
type: "text/css",
|
||||
// href: "http://static.wowhead.com/css/basic_ie67.css?4",
|
||||
href: g_host + "/static/css/global_ie67.css",
|
||||
rel: "stylesheet"
|
||||
}));
|
||||
|
||||
if ($WH.Browser.ie6) {
|
||||
$WH.ae(head, $WH.ce("link", {
|
||||
type: "text/css",
|
||||
// href: "http://static.wowhead.com/css/basic_ie6.css?4",
|
||||
href: g_host + "/static/css/global_ie6.css",
|
||||
rel: "stylesheet"
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
attachEvent();
|
||||
|
||||
onDOMReady(function () {
|
||||
if (typeof aowow_tooltips != "undefined") {
|
||||
for (var i = 0; i < document.links.length; i++) {
|
||||
var link = document.links[i];
|
||||
scanElement(link);
|
||||
}
|
||||
|
||||
initCSS();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function updateCursorPos(e) {
|
||||
var pos = $WH.g_getCursorPos(e);
|
||||
cursorX = pos.x;
|
||||
cursorY = pos.y;
|
||||
}
|
||||
|
||||
function scanElement(t, e) {
|
||||
if (t.nodeName != "A" && t.nodeName != "AREA") {
|
||||
return -2323;
|
||||
}
|
||||
|
||||
if (!t.href.length && !t.rel) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (t.rel && t.rel.indexOf("np") != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var
|
||||
i0,
|
||||
i1,
|
||||
i2,
|
||||
url,
|
||||
params = {};
|
||||
|
||||
currentParams = params;
|
||||
|
||||
var p = function (url, k, v) {
|
||||
if (k == "buff" || k == "sock" || k == "map") {
|
||||
params[k] = true;
|
||||
}
|
||||
else if (k == "rand" || k == "ench" || k == "lvl" || k == "c") {
|
||||
params[k] = parseInt(v);
|
||||
}
|
||||
else if (k == "gems" || k == "pcs" || k == "know") {
|
||||
params[k] = v.split(":");
|
||||
}
|
||||
else if (k == "who" || k == "domain") {
|
||||
params[k] = v;
|
||||
}
|
||||
else if (k == "when") {
|
||||
params[k] = new Date(parseInt(v));
|
||||
}
|
||||
else if (k == "premium") {
|
||||
params[k] = true;
|
||||
}
|
||||
else if (k == "text") {
|
||||
params[k] = true;
|
||||
}
|
||||
};
|
||||
|
||||
if (opt.applyto & 1) {
|
||||
i1 = 2;
|
||||
i2 = 3;
|
||||
if (t.href.indexOf("http://") == 0 || t.href.indexOf("https://") == 0) {
|
||||
i0 = 1;
|
||||
// url = t.href.match(/^https?:\/\/(.+?)?\.?wowhead\.com(?:\:\d+)?\/\??(item|quest|spell|achievement|npc|object)=([0-9]+)/);
|
||||
url = t.href.match(/^http:\/\/(.*)\/\??(item|quest|spell|achievement|npc|object)=([0-9]+)/);
|
||||
if (url == null) {
|
||||
// url = t.href.match(/^http:\/\/(.+?)?\.?wowhead\.com\/\?(profile)=([^&#]+)/)
|
||||
url = t.href.match(/^http:\/\/(.*)\/\??(profile)=([^&#]+)/);
|
||||
}
|
||||
|
||||
showLogo = 0;
|
||||
}
|
||||
else {
|
||||
url = t.href.match(/()\?(item|quest|spell|achievement|npc|object)=([0-9]+)/);
|
||||
if (url == null) {
|
||||
url = t.href.match(/()\?(profile)=([^&#]+)/);
|
||||
}
|
||||
|
||||
showLogo = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (url == null && t.rel && (opt.applyto & 2)) {
|
||||
i0 = 0;
|
||||
i1 = 1;
|
||||
i2 = 2;
|
||||
url = t.rel.match(/(item|quest|spell|achievement|npc|object).?([0-9]+)/);
|
||||
if (url == null) {
|
||||
url = t.rel.match(/(profile).?([^&#]+)/);
|
||||
}
|
||||
showLogo = 1;
|
||||
}
|
||||
|
||||
t.href.replace(/([a-zA-Z]+)=?([a-zA-Z0-9:-]*)/g, p);
|
||||
if (t.rel) {
|
||||
t.rel.replace(/([a-zA-Z]+)=?([a-zA-Z0-9:-]*)/g, p);
|
||||
}
|
||||
|
||||
if (params.gems && params.gems.length > 0) {
|
||||
var i;
|
||||
for (i = Math.min(3, params.gems.length - 1); i >= 0; --i) {
|
||||
if (parseInt(params.gems[i])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
|
||||
if (i == 0) {
|
||||
delete params.gems;
|
||||
}
|
||||
else if (i < params.gems.length) {
|
||||
params.gems = params.gems.slice(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (url) {
|
||||
var
|
||||
locale,
|
||||
domain = "www";
|
||||
|
||||
currentA = t;
|
||||
if (params.domain) {
|
||||
domain = params.domain;
|
||||
}
|
||||
else if (i0 && url[i0]) {
|
||||
// domain = url[i0];
|
||||
domain = url[i0].split(".")[0];
|
||||
}
|
||||
|
||||
if (REDIRECTS[domain]) {
|
||||
domain = REDIRECTS[domain];
|
||||
}
|
||||
|
||||
locale = $WH.g_getLocaleFromDomain(domain);
|
||||
|
||||
/* edit start */
|
||||
if ($WH.in_array(['fr', 'de', 'es', 'ru', 'en'], domain) == -1) {
|
||||
for (i in document.scripts) {
|
||||
if (!document.scripts[i].src)
|
||||
continue;
|
||||
|
||||
var dmn = document.scripts[i].src.match(/power\/aowowPower.js\?(lang|locale)=(en|fr|de|es|ru)/i);
|
||||
if (dmn) {
|
||||
domain = dmn[2];
|
||||
locale = $WH.g_getLocaleFromDomain(dmn[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* end of edit */
|
||||
|
||||
currentDomain = domain;
|
||||
if (t.href.indexOf("#") != -1 && document.location.href.indexOf(url[i1] + "=" + url[i2]) != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
mode = t.parentNode.className.indexOf("icon") == 0 && t.parentNode.nodeName == "DIV" ? 1 : 0;
|
||||
if (!t.onmouseout) {
|
||||
if (mode == 0) {
|
||||
t.onmousemove = onMouseMove;
|
||||
}
|
||||
t.onmouseout = onMouseOut;
|
||||
}
|
||||
|
||||
if (e) {
|
||||
updateCursorPos(e);
|
||||
}
|
||||
|
||||
var
|
||||
type = $WH.g_getIdFromTypeName(url[i1]),
|
||||
typeId = url[i2];
|
||||
|
||||
display(type, typeId, locale, params);
|
||||
|
||||
if (e || typeof aowow_tooltips == "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = LOOKUPS[type][0][getFullId(typeId, params)];
|
||||
|
||||
var timeout = function (t) {
|
||||
if (data.status[locale] != STATUS_OK && data.status[locale] != STATUS_NOTFOUND) {
|
||||
window.setTimeout(function () {
|
||||
timeout(t);
|
||||
}, 5);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (aowow_tooltips.renamelinks) {
|
||||
eval("name = data.name_" + LOCALES[locale]);
|
||||
if (name) {
|
||||
t.innerHTML = '<span>' + name + '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if (aowow_tooltips.iconizelinks && (type == TYPE_ITEM || type == TYPE_ACHIEVEMENT || type == TYPE_SPELL) && data.icon) {
|
||||
// t.children[0].style.marginLeft = "18px";
|
||||
t.className += " icontinyl";
|
||||
t.style.paddingLeft = "18px !important";
|
||||
t.style.verticalAlign = "center";
|
||||
// t.style.background = "url(" + (document.location.protocol != "https:" ? "http:": document.location.protocol) + "//wowimg.zamimg.com/images/wow/icons/tiny/" + data.icon.toLocaleLowerCase() + ".gif) left center no-repeat"
|
||||
t.style.background = "url(" + g_host + "/static/images/wow/icons/tiny/" + data.icon.toLocaleLowerCase() + ".gif) left center no-repeat"
|
||||
}
|
||||
|
||||
if (aowow_tooltips.colorlinks) {
|
||||
if (type == TYPE_ITEM) {
|
||||
t.className += " q" + data.quality;
|
||||
}
|
||||
}
|
||||
};
|
||||
timeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseOver(e) {
|
||||
e = $WH.$E(e);
|
||||
var t = e._target;
|
||||
var i = 0;
|
||||
while (t != null && i < 5 && scanElement(t, e) == -2323) {
|
||||
t = t.parentNode;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseMove(e) {
|
||||
e = $WH.$E(e);
|
||||
updateCursorPos(e);
|
||||
$WH.Tooltip.move(cursorX, cursorY, 0, 0, CURSOR_HSPACE, CURSOR_VSPACE);
|
||||
}
|
||||
|
||||
function onMouseOut() {
|
||||
currentType = null;
|
||||
currentA = null;
|
||||
$WH.Tooltip.hide();
|
||||
}
|
||||
|
||||
function getTooltipField(locale, n) {
|
||||
var prefix = "tooltip";
|
||||
|
||||
if (currentParams && currentParams.buff) {
|
||||
prefix = "buff";
|
||||
}
|
||||
|
||||
if (currentParams && currentParams.text) {
|
||||
prefix = "text";
|
||||
}
|
||||
|
||||
if (currentParams && currentParams.premium) {
|
||||
prefix = "tooltip_premium";
|
||||
}
|
||||
|
||||
return prefix + (n ? n : "") + "_" + LOCALES[locale];
|
||||
}
|
||||
|
||||
function getIconField() {
|
||||
return (currentParams && currentParams.text) ? "text_icon" : "icon";
|
||||
}
|
||||
|
||||
function getSpellsField(locale) {
|
||||
return (currentParams && currentParams.buff ? "buff" : "") + "spells_" + LOCALES[locale];
|
||||
}
|
||||
|
||||
function initElement(type, id, locale) {
|
||||
var arr = LOOKUPS[type][0];
|
||||
|
||||
if (arr[id] == null) {
|
||||
arr[id] = {};
|
||||
}
|
||||
|
||||
if (arr[id].status == null) {
|
||||
arr[id].status = {};
|
||||
}
|
||||
|
||||
if (arr[id].response == null) {
|
||||
arr[id].response = {};
|
||||
}
|
||||
|
||||
if (arr[id].status[locale] == null) {
|
||||
arr[id].status[locale] = STATUS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
function display(type, id, locale, params) {
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
|
||||
var fullId = getFullId(id, params);
|
||||
currentType = type;
|
||||
currentId = fullId;
|
||||
currentLocale = locale;
|
||||
currentParams = params;
|
||||
|
||||
initElement(type, fullId, locale);
|
||||
|
||||
var arr = LOOKUPS[type][0];
|
||||
if (arr[fullId].status[locale] == STATUS_OK || arr[fullId].status[locale] == STATUS_NOTFOUND) {
|
||||
showTooltip(arr[fullId][getTooltipField(locale)], arr[fullId][getIconField()], arr[fullId].map, arr[fullId][getSpellsField(locale)], arr[fullId][getTooltipField(locale, 2)]);
|
||||
}
|
||||
else if (arr[fullId].status[locale] == STATUS_QUERYING || arr[fullId].status[locale] == STATUS_SCALES) {
|
||||
showTooltip(_LANG.loading);
|
||||
}
|
||||
else {
|
||||
request(type, id, locale, null, params);
|
||||
}
|
||||
}
|
||||
|
||||
function request(type, id, locale, stealth, params) {
|
||||
var fullId = getFullId(id, params);
|
||||
var arr = LOOKUPS[type][0];
|
||||
|
||||
if (arr[fullId].status[locale] != STATUS_NONE && arr[fullId].status[locale] != STATUS_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
arr[fullId].status[locale] = STATUS_QUERYING;
|
||||
|
||||
if (!stealth) {
|
||||
arr[fullId].timer = setTimeout(function () {
|
||||
showLoading.apply(this, [type, fullId, locale]);
|
||||
}, 333);
|
||||
}
|
||||
|
||||
var p = "";
|
||||
for (var i in params) {
|
||||
if (i != "rand" && i != "ench" && i != "gems" && i != "sock" && i != "lvl") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof params[i] == "object") {
|
||||
p += "&" + i + "=" + params[i].join(":");
|
||||
}
|
||||
else if (params[i] === true) {
|
||||
p += "&" + i;
|
||||
}
|
||||
else {
|
||||
p += "&" + i + "=" + params[i];
|
||||
}
|
||||
}
|
||||
|
||||
// var url = "http://" + $WH.g_getDomainFromLocale(locale) + ".wowhead.com"
|
||||
// var url = (document.location.protocol != "https:" ? "http:": document.location.protocol) + "//" + localeDomain + ".wowhead.com";
|
||||
var
|
||||
localeDomain = $WH.g_getDomainFromLocale(locale),
|
||||
url = g_host + "/";
|
||||
|
||||
// $WH.g_ajaxIshRequest(url + "?" + LOOKUPS[type][1] + "=" + id + "&power" + p);
|
||||
$WH.g_ajaxIshRequest(url + "?" + LOOKUPS[type][1] + "=" + id + "&domain=" + localeDomain + "&power" + p);
|
||||
if (SCALES[type] && SCALES[type][locale] == SCALES_NONE) {
|
||||
$WH.g_ajaxIshRequest(url + SCALES[type].url);
|
||||
SCALES[type][locale] = SCALES_QUERYING;
|
||||
}
|
||||
}
|
||||
|
||||
function showTooltip(html, icon, map, spellData, html2) {
|
||||
if (currentA && currentA._fixTooltip) {
|
||||
html = currentA._fixTooltip(html, currentType, currentId, currentA);
|
||||
}
|
||||
|
||||
initCSS();
|
||||
var notFound = false;
|
||||
if (!html) {
|
||||
html = LOOKUPS[currentType][2] + " not found :(";
|
||||
icon = "inv_misc_questionmark";
|
||||
notFound = true;
|
||||
}
|
||||
else {
|
||||
if (currentParams != null) {
|
||||
if (currentParams.pcs && currentParams.pcs.length) {
|
||||
var n = 0;
|
||||
for (var i = 0, len = currentParams.pcs.length; i < len; ++i) {
|
||||
var m;
|
||||
if (m = html.match(new RegExp("<span><!--si([0-9]+:)*" + currentParams.pcs[i] + '(:[0-9]+)*--><a href="\\?item=(\\d+)">(.+?)</a></span>'))) {
|
||||
html = html.replace(m[0], '<span class="q8"><!--si' + currentParams.pcs[i] + '--><a href="?item=' + m[3] + '">' + (($WH.isset("g_items") && g_items[currentParams.pcs[i]]) ? g_items[currentParams.pcs[i]]["name_" + LOCALES[currentLocale]] : m[4]) + "</a></span>");
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
html = html.replace("(0/", "(" + n + "/");
|
||||
html = html.replace(new RegExp("<span>\\(([0-" + n + "])\\)", "g"), '<span class="q2">($1)');
|
||||
}
|
||||
}
|
||||
|
||||
if (currentParams.c) {
|
||||
html = html.replace(/<span class="c([0-9]+?)">(.+?)<\/span><br \/>/g, '<span class="c$1" style="display: none">$2</span>');
|
||||
html = html.replace(new RegExp('<span class="c(' + currentParams.c + ')" style="display: none">(.+?)</span>', "g"), '<span class="c$1">$2</span><br />');
|
||||
}
|
||||
|
||||
if (currentParams.know && currentParams.know.length) {
|
||||
html = $WH.g_setTooltipSpells(html, currentParams.know, spellData);
|
||||
}
|
||||
|
||||
if (currentParams.lvl) {
|
||||
html = $WH.g_setTooltipLevel(html, currentParams.lvl, currentParams.buff);
|
||||
}
|
||||
// custom start
|
||||
else if ($WH.gc('compare_level') && window.location.href.match(/\?compare/i)) {
|
||||
html = $WH.g_setTooltipLevel(html, $WH.gc('compare_level'), currentParams.buff);
|
||||
}
|
||||
// custom end
|
||||
|
||||
if (currentParams.who && currentParams.when) {
|
||||
html = html.replace("<table><tr><td><br />", '<table><tr><td><br /><span class="q2">' + $WH.sprintf(_LANG.achievementcomplete, currentParams.who, currentParams.when.getMonth() + 1, currentParams.when.getDate(), currentParams.when.getFullYear()) + "</span><br /><br />");
|
||||
html = html.replace(/class="q0"/g, 'class="r3"');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentParams.map && map && map.getMap) {
|
||||
html2 = map.getMap();
|
||||
}
|
||||
|
||||
if (mode == 1) {
|
||||
$WH.Tooltip.setIcon(null);
|
||||
$WH.Tooltip.show(currentA, html, null, null, null, html2);
|
||||
}
|
||||
else {
|
||||
$WH.Tooltip.setIcon(icon);
|
||||
$WH.Tooltip.showAtXY(html, cursorX, cursorY, CURSOR_HSPACE, CURSOR_VSPACE, html2);
|
||||
}
|
||||
|
||||
if (isRemote && $WH.Tooltip.logo) {
|
||||
$WH.Tooltip.logo.style.display = (showLogo ? "block": "none");
|
||||
}
|
||||
}
|
||||
|
||||
function showLoading(type, id, locale) {
|
||||
if (currentType == type && currentId == id && currentLocale == locale) {
|
||||
showTooltip(_LANG.loading);
|
||||
var arr = LOOKUPS[type][0];
|
||||
|
||||
arr[id].timer = setTimeout(function () {
|
||||
notFound.apply(this, [type, id, locale]);
|
||||
}, 3850);
|
||||
}
|
||||
}
|
||||
|
||||
function notFound(type, id, locale) {
|
||||
var arr = LOOKUPS[type][0];
|
||||
arr[id].status[locale] = STATUS_ERROR;
|
||||
|
||||
if (currentType == type && currentId == id && currentLocale == locale) {
|
||||
showTooltip(_LANG.noresponse);
|
||||
}
|
||||
}
|
||||
|
||||
function getFullId(id, params) {
|
||||
return id + (params.rand ? "r" + params.rand : "") + (params.ench ? "e" + params.ench : "") + (params.gems ? "g" + params.gems.join(",") : "") + (params.sock ? "s" : "");
|
||||
}
|
||||
|
||||
this.loadScales = function (type, locale) {
|
||||
var arr = LOOKUPS[type][0];
|
||||
for (var i in LOCALES) {
|
||||
if (locale == i || (!locale && !isNaN(i))) {
|
||||
SCALES[type][i] = SCALES_LOADED;
|
||||
for (var id in arr) {
|
||||
if (arr[id].status[i] == STATUS_SCALES && arr[id].response[i]) {
|
||||
arr[id].response[i]();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.register = function (type, id, locale, json) {
|
||||
var arr = LOOKUPS[type][0];
|
||||
initElement(type, id, locale);
|
||||
|
||||
if (SCALES[type] && SCALES[type][locale] != SCALES_LOADED) {
|
||||
arr[id].status[locale] = STATUS_SCALES;
|
||||
arr[id].response[locale] = this.register.bind(this, type, id, locale, json);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arr[id].timer) {
|
||||
clearTimeout(arr[id].timer);
|
||||
arr[id].timer = null;
|
||||
}
|
||||
|
||||
if (!$WH.wowheadRemote && json.map) {
|
||||
if (arr[id].map == null) {
|
||||
arr[id].map = new Mapper({
|
||||
parent: $WH.ce("div"),
|
||||
zoom: 3,
|
||||
zoomable: false,
|
||||
buttons: false
|
||||
});
|
||||
}
|
||||
arr[id].map.update(json.map);
|
||||
delete json.map;
|
||||
}
|
||||
|
||||
$WH.cO(arr[id], json);
|
||||
|
||||
if (arr[id].status[locale] == STATUS_QUERYING || arr[id].status[locale] == STATUS_SCALES) {
|
||||
if (arr[id][getTooltipField(locale)]) {
|
||||
arr[id].status[locale] = STATUS_OK;
|
||||
}
|
||||
else {
|
||||
arr[id].status[locale] = STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentType == type && id == currentId && currentLocale == locale) {
|
||||
showTooltip(arr[id][getTooltipField(locale)], arr[id].icon, arr[id].map, arr[id][getSpellsField(locale)], arr[id][getTooltipField(locale, 2)]);
|
||||
}
|
||||
};
|
||||
|
||||
this.registerNpc = function (id, locale, json) {
|
||||
this.register(TYPE_NPC, id, locale, json);
|
||||
};
|
||||
|
||||
this.registerObject = function (id, locale, json) {
|
||||
this.register(TYPE_OBJECT, id, locale, json);
|
||||
};
|
||||
|
||||
this.registerItem = function (id, locale, json) {
|
||||
this.register(TYPE_ITEM, id, locale, json);
|
||||
};
|
||||
|
||||
this.registerQuest = function (id, locale, json) {
|
||||
this.register(TYPE_QUEST, id, locale, json);
|
||||
};
|
||||
|
||||
this.registerSpell = function (id, locale, json) {
|
||||
this.register(TYPE_SPELL, id, locale, json);
|
||||
};
|
||||
|
||||
this.registerAchievement = function (id, locale, json) {
|
||||
this.register(TYPE_ACHIEVEMENT, id, locale, json);
|
||||
};
|
||||
|
||||
this.registerProfile = function (id, locale, json) {
|
||||
this.register(TYPE_PROFILE, id, locale, json);
|
||||
};
|
||||
|
||||
this.displayTooltip = function (type, id, locale, params) {
|
||||
display(type, id, locale, params);
|
||||
};
|
||||
|
||||
this.request = function (type, id, locale, params) {
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
|
||||
var fullId = getFullId(id, params);
|
||||
initElement(type, fullId, locale);
|
||||
|
||||
request(type, id, locale, 1, params);
|
||||
};
|
||||
|
||||
this.requestItem = function (id, params) {
|
||||
this.request(TYPE_ITEM, id, Locale.id, params);
|
||||
};
|
||||
|
||||
this.requestSpell = function (id) {
|
||||
this.request(TYPE_SPELL, id, Locale.id);
|
||||
};
|
||||
|
||||
this.getStatus = function (type, id, locale) {
|
||||
var arr = LOOKUPS[type][0];
|
||||
if (arr[id] != null) {
|
||||
return arr[id].status[locale];
|
||||
}
|
||||
else {
|
||||
return STATUS_NONE;
|
||||
}
|
||||
};
|
||||
|
||||
this.getItemStatus = function (id, locale) {
|
||||
this.getStatus(TYPE_ITEM, id, locale);
|
||||
};
|
||||
|
||||
this.getSpellStatus = function (id, locale) {
|
||||
this.getStatus(TYPE_SPELL, id, locale);
|
||||
};
|
||||
|
||||
this.refreshLinks = function () {
|
||||
if (typeof aowow_tooltips != "undefined") {
|
||||
for (var i = 0; i < document.links.length; i++) {
|
||||
var link = document.links[i];
|
||||
var node = link.parentNode;
|
||||
var isTooltipChild = false;
|
||||
|
||||
while (node != null) {
|
||||
if ((" " + node.className + " ").replace(/[\n\t]/g, " ").indexOf(" wowhead-tooltip ") > -1) {
|
||||
isTooltipChild = true;
|
||||
break;
|
||||
}
|
||||
node = node.parentNode
|
||||
}
|
||||
|
||||
if (!isTooltipChild) {
|
||||
scanElement(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.hideTooltip();
|
||||
};
|
||||
|
||||
this.setParent = function (newParent) {
|
||||
$WH.Tooltip.reset();
|
||||
$WH.Tooltip.prepare(newParent);
|
||||
};
|
||||
|
||||
if (isRemote) {
|
||||
this.set = function (foo) {
|
||||
$WH.cO(opt, foo);
|
||||
};
|
||||
|
||||
this.showTooltip = function (e, tooltip, icon) {
|
||||
updateCursorPos(e);
|
||||
showTooltip(tooltip, icon);
|
||||
};
|
||||
|
||||
this.hideTooltip = function () {
|
||||
$WH.Tooltip.hide();
|
||||
};
|
||||
|
||||
this.moveTooltip = function (e) {
|
||||
onMouseMove(e);
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
};
|
||||
114
static/widgets/power/demo.html
Normal file
114
static/widgets/power/demo.html
Normal file
@@ -0,0 +1,114 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>'Powered by Wowhead' Demo</title>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
|
||||
<script src="../power.js?lang=en" type="text/javascript"></script>
|
||||
<script>var aowow_tooltips = { "colorlinks": true, "iconizelinks": true, "renamelinks": true, "hide": { "reagents": true, "sellprice": true }}</script>
|
||||
|
||||
<style type="text/css">
|
||||
body { padding: 50px 15px 15px 15px; margin: 0; font-family: Arial; color: white; background: black }
|
||||
a { color: #FFD100; cursor: pointer; outline: none }
|
||||
a:hover { color: white }
|
||||
h2 { font-size: 20px; margin-top: 0; padding-top: 0; line-height: 1.5em }
|
||||
h2 small { font-size: 13px; font-weight: normal }
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h2>'Powered by Wowhead' Demo<br /><small><a href="/">« Return to the site</a></small></h2>
|
||||
|
||||
<div style="float: left; width: 400px; margin-right: 64px">
|
||||
|
||||
<i>Items</i><br /><br />
|
||||
|
||||
<a href="/?item=31015" class="q4">Skyshatter Cover</a><br />
|
||||
<a href="/?item=30987" class="q4">Lightbringer Faceguard</a><br /><br />
|
||||
|
||||
<a href="/?item=48718" rel="lvl=42" class="q7">Repurposed Lava Dredger</a> <small>(Level 42 scaling)</small><br /><br />
|
||||
|
||||
<a href="http://www.example.com" rel="item=28288" class="q3">Abacus of Violent Odds</a> <small>(Custom URL)</small><br />
|
||||
<a href="/?item=22589&lvl=80" class="q5">Atiesh, Greatstaff of the Guardian</a> <small>(Level 80 conversions)</small><br />
|
||||
<a href="/?item=25697" rel="gems=23121&ench=2647&pcs=25697:25695:25696" class="q3">Felstalker Bracers</a> <small>(Enchant, gem, set bonus)</small><br />
|
||||
<a href="/?item=31928" rel="rand=-63&ench=2931" class="q3">Dark Band of Agility</a> <small>(Random enchantment, enchant)</small><br />
|
||||
<a href="/?item=32474" rel="ench=3003&gems=32409:31865" class="q3">Surestrike Goggles v2.0</a> <small>(Enchant, gems)</small><br /><br />
|
||||
|
||||
<hr />
|
||||
|
||||
<i>Spells</i><br /><br />
|
||||
<a href="/?spell=18562">Swiftmend</a><br />
|
||||
<a href="/?spell=589">Shadow Word: Pain</a><br />
|
||||
<a href="/?spell=36257">Blacksmithing: Bulwark of the Ancient Kings</a><br /><br />
|
||||
|
||||
<a href="/?spell=1126" rel="buff">Mark of the Wild</a> <small>(Buff)</small><br /><br />
|
||||
|
||||
<hr />
|
||||
|
||||
<i>Quests</i><br /><br />
|
||||
<a href="/?quest=826">Zalazane</a><br />
|
||||
<a href="/?quest=11389">Wanted: Arcatraz Sentinels</a><br />
|
||||
<a href="/?quest=11058">An Apexis Relic</a><br />
|
||||
<a href="/?quest=9637">Kalynna's Request</a><br /><br />
|
||||
|
||||
<hr />
|
||||
|
||||
<i>Achievements</i><br /><br />
|
||||
<a href="/?achievement=277">'Tis the Season</a><br />
|
||||
<a href="/?achievement=1558" rel="who=Shadowrogue&when=1273022820000">100 Fish</a> <small>(Earned)</small><br /><br />
|
||||
|
||||
<hr />
|
||||
|
||||
<i>Profiles</i><br /><br />
|
||||
<a href="/?profile=us.draenor.drekdarok">Drekdarok</a><br />
|
||||
<a href="/?profile=10344553">DPS</a><br /><br/>
|
||||
|
||||
<a href="http://www.example.com" rel="profile=us.draenor.drekdarok">Drekdarok</a><small> (Custom URL)</small><br />
|
||||
<a href="http://www.example.com" rel="profile=10344553">DPS</a><small> (Custom URL)</small><br />
|
||||
<hr />
|
||||
|
||||
<i>Custom</i><br /><br />
|
||||
<a href="javascript:;" onmouseover="$WowheadPower.showTooltip(event, 'Hello :0', 'inv_sword_14')" onmousemove="$WowheadPower.moveTooltip(event)" onmouseout="$WowheadPower.hideTooltip();">Hai to you!</a><br /><br />
|
||||
|
||||
<hr />
|
||||
|
||||
<i>Image Map</i><br /><br />
|
||||
|
||||
<map id="planetmap" name="planetmap">
|
||||
<area shape="rect" coords="0,0,82,126" href="/?item=30987" target="_blank" alt="Sun" />
|
||||
<area shape="circle" coords="90,58,3" href="/?spell=1126" target="_blank" alt="Mercury" />
|
||||
<area shape="circle" coords="124,58,8" href="/?quest=11058" target="_blank" alt="Venus" />
|
||||
</map>
|
||||
<img src="http://www.w3schools.com/TAGS/planets.gif" width="145" height="126" alt="" border="0" usemap ="#planetmap" />
|
||||
|
||||
</div>
|
||||
|
||||
<div style="float: left">
|
||||
<i>Localized links</i> <small>(requires your site to use UTF-8 encoding)</small><br /><br />
|
||||
|
||||
<b>Deutsch:</b> <a href="http://de.wowhead.com/item=31015">Skyshatter Cover</a><br />
|
||||
<b>Français:</b> <a href="http://www.wowhead.com/item=31015" rel="domain=fr">Skyshatter Cover</a><br />
|
||||
<b>Español:</b> <a href="http://es.wowhead.com/item=31015">Skyshatter Cover</a><br />
|
||||
<b>Русский:</b> <a href="http://ru.wowhead.com/item=31015">Skyshatter Cover</a><br />
|
||||
</div>
|
||||
|
||||
<div style="clear: both"></div>
|
||||
|
||||
<div style="width: 30px; height: 800px"></div>
|
||||
|
||||
<center>
|
||||
<a href="/?item=30301">Item #30301</a><br />
|
||||
<a href="/?item=99999">Item #99999</a>
|
||||
</center>
|
||||
|
||||
<a style="position: absolute; right: 0; bottom: 0; background: black" href="/?item=30319">Item #30319</a>
|
||||
<a style="position: absolute; left: 0; bottom: 0; background: black" href="/?item=22589">Item #22589</a>
|
||||
<a style="position: absolute; right: 0; top: 0; background: black" href="/?item=8171">Item #8171</a>
|
||||
<a style="position: absolute; left: 0; top: 0; background: black" href="/?item=6479">Item #6479!</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
161
static/widgets/power/power.css
Normal file
161
static/widgets/power/power.css
Normal file
@@ -0,0 +1,161 @@
|
||||
.wowhead-tooltip {
|
||||
position:absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
z-index:100000006;
|
||||
}
|
||||
|
||||
.wowhead-tooltip table {
|
||||
border-spacing:0;
|
||||
border-collapse:collapse;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
.wowhead-tooltip table, .wowhead-tooltip td, .wowhead-tooltip th, .wowhead-tooltip tbody {
|
||||
border:0!important;
|
||||
}
|
||||
|
||||
.wowhead-tooltip tr {
|
||||
background:transparent!important;
|
||||
border:0!important;
|
||||
}
|
||||
|
||||
.wowhead-tooltip td, .wowhead-tooltip th {
|
||||
background:transparent url(../../images/tooltip.png);
|
||||
font-family:Verdana, sans-serif;
|
||||
font-size:12px;
|
||||
line-height:17px;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.wowhead-tooltip th {
|
||||
padding:3px;
|
||||
border:0;
|
||||
height:auto;
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
.wowhead-tooltip td {
|
||||
padding:8px 4px 1px 9px;
|
||||
text-align:left;
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
.wowhead-tooltip b {
|
||||
font-size:14px;
|
||||
line-height:19px;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
.wowhead-tooltip div.indent {
|
||||
padding-left:.6em;
|
||||
}
|
||||
|
||||
.wowhead-tooltip td th, .wowhead-tooltip td td {
|
||||
background:none;
|
||||
}
|
||||
|
||||
.wowhead-tooltip td th {
|
||||
padding:0 0 0 4em;
|
||||
text-align:right;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
.wowhead-tooltip td td {
|
||||
padding:0;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.wowhead-tooltip p {
|
||||
position:absolute;
|
||||
left:-44px;
|
||||
top:-1px;
|
||||
width:44px;
|
||||
height:44px;
|
||||
background:4px 4px no-repeat;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
.wowhead-tooltip p div {
|
||||
width:44px;
|
||||
height:44px;
|
||||
background-image:url(../../images/icon_border_medium.png);
|
||||
}
|
||||
|
||||
.wowhead-tooltip a {
|
||||
text-decoration:none!important;
|
||||
}
|
||||
|
||||
.wowhead-tooltip-powered {
|
||||
background:url(../../images/powered.png) no-repeat;
|
||||
width:53px;
|
||||
height:33px;
|
||||
position:absolute;
|
||||
right:-56px;
|
||||
top:2px;
|
||||
}
|
||||
|
||||
a.moneyitem, a.moneysocketmeta, a.moneysocketred, a.moneysocketyellow, a.moneysocketblue, a.moneysocketprismatic {
|
||||
text-decoration:none!important;
|
||||
border-bottom:1px solid transparent;
|
||||
}
|
||||
|
||||
a.moneyitem:hover, a.moneysocketmeta:hover, a.moneysocketred:hover, a.moneysocketyellow:hover, a.moneysocketblue:hover, a.moneysocketprismatic:hover {
|
||||
border-bottom:1px solid white;
|
||||
}
|
||||
|
||||
.moneyitem, .moneygold, .moneysilver, .moneycopper, .moneyalliance, .moneyhorde, .moneyarena, .moneyachievement, .moneysocketmeta, .moneysocketred, .moneysocketyellow, .moneysocketblue, .moneysocketprismatic {
|
||||
color:white;
|
||||
background:no-repeat right center;
|
||||
}
|
||||
|
||||
.moneyitem { padding-right:18px; }
|
||||
.moneygold { padding-right:15px; background-image:url(../../images/money-gold.gif); }
|
||||
.moneysilver { padding-right:15px; background-image:url(../../images/money-silver.gif); }
|
||||
.moneycopper { padding-right:15px; background-image:url(../../images/money-copper.gif); }
|
||||
.moneyalliance { padding-right:12px; background-image:url(../../images/money-alliance.gif); }
|
||||
.moneyhorde { padding-right:17px; background-image:url(../../images/money-horde.gif); }
|
||||
.moneyarena { padding-right:18px; background-image:url(../../images/money-arena.gif); }
|
||||
.moneyachievement { padding-right:13px; background-image:url(../../images/money-achievement.gif); }
|
||||
.moneysocketmeta { padding-right:18px; background-image:url(../../images/socket-meta.gif); }
|
||||
.moneysocketred { padding-right:18px; background-image:url(../../images/socket-red.gif); }
|
||||
.moneysocketyellow { padding-right:18px; background-image:url(../../images/socket-yellow.gif); }
|
||||
.moneysocketblue { padding-right:18px; background-image:url(../../images/socket-blue.gif); }
|
||||
.moneysocketprismatic { padding-right:18px; background-image:url(../../images/socket-prismatic.gif); }
|
||||
|
||||
.socket-meta { padding-left:26px; background:url(../../images/socket-meta.gif) no-repeat left center; }
|
||||
.socket-red { padding-left:26px; background:url(../../images/socket-red.gif) no-repeat left center; }
|
||||
.socket-yellow { padding-left:26px; background:url(../../images/socket-yellow.gif) no-repeat left center; }
|
||||
.socket-blue { padding-left:26px; background:url(../../images/socket-blue.gif) no-repeat left center; }
|
||||
.socket-prismatic { padding-left:26px; background:url(../../images/socket-prismatic.gif) no-repeat left center; }
|
||||
|
||||
.q { color:#ffd100!important; }
|
||||
|
||||
.q0, .q0 a { color:#9d9d9d!important; }
|
||||
.q1, .q1 a { color:#ffffff!important; }
|
||||
.q2, .q2 a { color:#1eff00!important; }
|
||||
.q3, .q3 a { color:#0070dd!important; }
|
||||
.q4, .q4 a { color:#a335ee!important; }
|
||||
.q5, .q5 a { color:#ff8000!important; }
|
||||
.q6, .q6 a { color:#e5cc80!important; }
|
||||
.q7, .q7 a { color:#e5cc80!important; }
|
||||
.q8, .q8 a { color:#ffff98!important; }
|
||||
.q9, .q9 a { color:#71d5ff!important; }
|
||||
.q10, .q10 a { color:#ff0000!important; }
|
||||
|
||||
.r1 { color:#FF8040!important; }
|
||||
.r2 { color:#FFFF00!important; }
|
||||
.r3 { color:#40BF40!important; }
|
||||
.r4 { color:#808080!important; }
|
||||
|
||||
.c1, .c1 a { color:#C69B6D!important; }
|
||||
.c2, .c2 a { color:#F48CBA!important; }
|
||||
.c3, .c3 a { color:#AAD372!important; }
|
||||
.c4, .c4 a { color:#FFF468!important; }
|
||||
.c5, .c5 a { color:#FFFFFF!important; }
|
||||
.c6, .c6 a { color:#C41E3B!important; }
|
||||
.c7, .c7 a { color:#2359FF!important; }
|
||||
.c8, .c8 a { color:#68CCEF!important; }
|
||||
.c9, .c9 a { color:#9382C9!important; }
|
||||
.c11, .c11 a { color:#FF7C0A!important; }
|
||||
3
static/widgets/power/power_ie.css
Normal file
3
static/widgets/power/power_ie.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.wowhead-tooltip th {
|
||||
height: 8px;
|
||||
}
|
||||
11
static/widgets/power/power_ie6.css
Normal file
11
static/widgets/power/power_ie6.css
Normal file
@@ -0,0 +1,11 @@
|
||||
.wowhead-tooltip td, .wowhead-tooltip th {
|
||||
background-image:url(../../images/tooltip.gif);
|
||||
}
|
||||
.wowhead-tooltip p div {
|
||||
background:none;
|
||||
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../images/icon_border_medium.png');
|
||||
}
|
||||
.wowhead-tooltip-powered {
|
||||
background:none;
|
||||
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../images/powered.png');
|
||||
}
|
||||
56
static/widgets/searchbox.js
Normal file
56
static/widgets/searchbox.js
Normal file
@@ -0,0 +1,56 @@
|
||||
(function () {
|
||||
function create(w, h) {
|
||||
var
|
||||
scripts = document.getElementsByTagName('SCRIPT'),
|
||||
body;
|
||||
|
||||
/* sarjuuk: workaround to avoid hardcoding the url of the body */
|
||||
if (scripts && scripts.length > 0) {
|
||||
for (var i in scripts) {
|
||||
if (!scripts[i].src) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var m = scripts[i].src.match(/(.*)\/widgets\/searchbox\.js$/);
|
||||
if (!m) {
|
||||
continue;
|
||||
}
|
||||
|
||||
body = m[1] + '/widgets/searchbox/searchbox.html';
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* end */
|
||||
|
||||
var buff = '<iframe src="' + body + '" width="' + w + '" height="' + h + '" frameborder="0" class="aowow-searchbox"';
|
||||
buff += "></iframe>";
|
||||
|
||||
document.write(buff);
|
||||
}
|
||||
|
||||
function init() {
|
||||
var formats = {
|
||||
"160x200": { width: 160, height: 200 },
|
||||
"160x120": { width: 160, height: 120 },
|
||||
"120x200": { width: 120, height: 200 },
|
||||
"120x120": { width: 120, height: 120 },
|
||||
"150x120": { width: 150, height: 120 }
|
||||
};
|
||||
|
||||
var dim;
|
||||
|
||||
if (typeof aowow_searchbox_format != "undefined") {
|
||||
if (formats[aowow_searchbox_format]) {
|
||||
dim = formats[aowow_searchbox_format];
|
||||
}
|
||||
}
|
||||
|
||||
if (!dim) {
|
||||
dim = formats["160x200"];
|
||||
}
|
||||
|
||||
create(dim.width, dim.height);
|
||||
}
|
||||
|
||||
init();
|
||||
})();
|
||||
98
static/widgets/searchbox/searchbox.css
Normal file
98
static/widgets/searchbox/searchbox.css
Normal file
@@ -0,0 +1,98 @@
|
||||
body {
|
||||
overflow:hidden;
|
||||
background:black;
|
||||
color:white;
|
||||
font-family:Arial,sans-serif;
|
||||
text-align:center;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
a {
|
||||
color:#FFD100;
|
||||
outline:0;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color:#FFF;
|
||||
}
|
||||
|
||||
img {
|
||||
border:0;
|
||||
}
|
||||
|
||||
form {
|
||||
padding:0;
|
||||
margin:0;
|
||||
display:inline;
|
||||
}
|
||||
|
||||
a.logo {
|
||||
display:block;
|
||||
width:100%;
|
||||
height:60px;
|
||||
background:url(../../images/logos/medium.gif) center top/100% auto no-repeat;
|
||||
margin:10px 0;
|
||||
}
|
||||
|
||||
form.search {
|
||||
display:block;
|
||||
padding:0 5px;
|
||||
}
|
||||
|
||||
form.search span {
|
||||
position:relative;
|
||||
}
|
||||
|
||||
form.search input {
|
||||
width:85%;
|
||||
font-size:13px;
|
||||
border:1px solid #ADADAD;
|
||||
background:white url(../../images/ui/form/input-textbox-bg.gif) repeat-x;
|
||||
outline:0;
|
||||
height: 18px;
|
||||
-webkit-border-radius:3px;
|
||||
-moz-border-radius:3px;
|
||||
border-radius:3px;
|
||||
}
|
||||
|
||||
form.search a {
|
||||
z-index:1;
|
||||
width:22px;
|
||||
height:22px;
|
||||
display:block;
|
||||
position:absolute;
|
||||
right:-10px;
|
||||
top:-1px;
|
||||
background:url(../../images/header/search.gif) left top no-repeat;
|
||||
}
|
||||
|
||||
form.search a:hover {
|
||||
background-position: left bottom;
|
||||
}
|
||||
|
||||
.expanded {
|
||||
position:absolute;
|
||||
left:0;
|
||||
top:120px;
|
||||
width:100%;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.links {
|
||||
color:#666;
|
||||
font-size:11px;
|
||||
line-height:2em;
|
||||
}
|
||||
|
||||
.links a {
|
||||
margin:0 .8em;
|
||||
text-decoration:none;
|
||||
color:#FFCD55;
|
||||
}
|
||||
|
||||
.links a:hover,.linklist a.open {
|
||||
color:#F6E6B3;
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
24
static/widgets/searchbox/searchbox.html
Normal file
24
static/widgets/searchbox/searchbox.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Aowow</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<base target="_blank" />
|
||||
<link rel="stylesheet" type="text/css" href="searchbox.css" />
|
||||
<script type="text/javascript" src="/static/js/jquery-1.4.2.min.js"></script>
|
||||
<script type="text/javascript" src="searchbox.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/" class="logo"></a>
|
||||
<form action="/" class="search">
|
||||
<span><a href="#"></a><input type="text" name="search" /></span>
|
||||
</form>
|
||||
|
||||
<div class="expanded">
|
||||
<div class="links"><a href="/?talent">Talent Calculator</a></div>
|
||||
<div class="links"><a href="/?profiles">Profiler</a></div>
|
||||
<div class="links"><a href="/?maps">Maps</a></div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
37
static/widgets/searchbox/searchbox.js
Normal file
37
static/widgets/searchbox/searchbox.js
Normal file
@@ -0,0 +1,37 @@
|
||||
var SearchBox = new function () {
|
||||
function bindEvents() {
|
||||
$("form.search").submit(onSubmit);
|
||||
$("form.search a").attr("href", "javascript:;").click(onClick);
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
var val = this.elements.search.value;
|
||||
if (!$.trim(val)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onClick() {
|
||||
$("form.search").submit();
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready(bindEvents);
|
||||
};
|
||||
|
||||
if (!Function.prototype.bind) {
|
||||
Function.prototype.bind = function () {
|
||||
var
|
||||
c = this,
|
||||
a = $WH.$A(arguments),
|
||||
b = a.shift();
|
||||
|
||||
return function () {
|
||||
return c.apply(b, a.concat($WH.$A(arguments)))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function isset(a) {
|
||||
return typeof window[a] != "undefined";
|
||||
}
|
||||
Reference in New Issue
Block a user