// JScript source code // common JavaScript code // Author: Akzhan Abdulin // This code is common to all my DarkClan scripts. var dcACommonScriptVersion = 200; var popupDivId = "popupDiv"; var defaultTipOpacity = 85; var popupXOffset = 30; var popupYOffset = 10; var popupWidth = 200; var popupTimer = ""; var popupActive = false; var menuDivId = "menuDiv"; var pmenuDivId = "pmenuDiv"; var defaultMenuOpacity = 92; var menuXOffset = -64; var menuYOffset = 5; var clearMenuOnceWhenClosed = false; var dc_menuItemCount = 0; var persistMenuReady = false; var persistMenuOpened = false; var cursorX = 0; var cursorY = 0; var moz = (document.getElementById && !document.all); // string manipulation function replacestr(source, what, replaceWith) { var retValue = []; var i; while (true) { i = source.indexOf(what); if (i >= 0) { retValue.push(source.substr(0, i)); retValue.push(replaceWith); source = source.substr(i + what.length); } else { break; } } retValue.push(source); return retValue.join(''); } var htmlEntities = new Array( { what: '<', replaceWith: '<' }, { what: '>', replaceWith: '>' }, { what: "'", replaceWith: ''' }, { what: '"', replaceWith: '"' } ); function htmlstring(s) { for (var i = 0; i < htmlEntities.length; i++) { s = replacestr(s, htmlEntities[i].what, htmlEntities[i].replaceWith); } return s; } function format(fmt) { var retValue = fmt; for (var i = 1; i < format.arguments.length; i++) { var sp = '{' + (i - 1) + '}'; retValue = replacestr(retValue, sp, '' + format.arguments[i]); } return retValue; } function trim(s) { var li = 0; var ri = s.length - 1; for (; li < ri; li++) { if (s.charAt(li) != ' ') { break; } } for (; ri >= li; ri--) { if (s.charAt(ri) != ' ') { break; } } return s.substring(li, ri); } // browser compatibility if(document.all && !document.getElementById) { document.getElementById = function(id) { return document.all[id]; } } // images preloading function dc_preimg() { for (var i = 0; i < dc_preimg.arguments.length; i++) { var img = new Image(); img.src = dc_preimg.arguments[i]; } } // popups function showPopup(message) { var obj_id = document.getElementById(popupDivId); obj_id.innerHTML = message; objWidth = obj_id.offsetWidth; popupActive = true; if (uiOptions.useTransitionEffects) { obj_id.filters['blendtrans'].apply(); } obj_id.style.visibility = "visible"; if (uiOptions.useTransitionEffects) { obj_id.filters['blendtrans'].play(); } followMouse(); } function followMouse() { if (!popupActive) { return; } var obj_id = document.getElementById(popupDivId); var x = 0; var y = 0; if(cursorX > document.body.clientWidth / 2 && cursorX < document.body.clientWidth) { x = cursorX - objWidth; y = cursorY + popupYOffset; } else { x = cursorX + popupXOffset; y = cursorY + popupYOffset; } obj_id.style.left = x + "px"; obj_id.style.top = y + "px"; popupTimer = setTimeout("followMouse()", 50); } function hidePopup() { var obj_id = document.getElementById(popupDivId); obj_id.style.visibility = "hidden"; clearTimeout(popupTimer); popupActive = false; } // menus function prepareMenuCore(menu) { if (is.ie) { menu.style.backgroundColor = 'window'; menu.style.color = 'windowtext'; menu.style.borderColor = 'windowtext'; } } function prepareMenu() { var menu = document.getElementById(menuDivId); prepareMenuCore(menu); } function showMenuCore(menu, capture) { var x = cursorX; var y = cursorY; menu.style.left = x + "px"; menu.style.top = y + "px"; hidePopup(); if (menu.style.visibility != "visible") { if (uiOptions.useTransitionEffects) { menu.filters['blendtrans'].apply(); } menu.style.visibility = "visible"; if (uiOptions.useTransitionEffects) { menu.filters['blendtrans'].play(); } if (is.ie) { var trange = document.body.createTextRange(); trange.moveToElementText(menu); trange.scrollIntoView(); } } if ((capture == null || capture) && menu.setCapture && uiOptions.captureMouse) { menu.setCapture(false); } } function showMenu(content, capture) { if (document.releaseCapture) { document.releaseCapture(); } if (persistMenuOpened) { hideMenuCore(); } var menu = document.getElementById(menuDivId); menu.innerHTML = content; showMenuCore(menu, capture); persistMenuOpened = false; } function initPersistMenu(menu) { prepareMenuCore(menu); } function dropPersistMenuSection(pid) { pid = 'pmid_' + pid; var pd = document.getElementById(pid); if (pd != null) { pd.style.display = 'none'; pd.innerHTML = ''; } } function hasPersistMenuSection(pid) { pid = 'pmid_' + pid; var pd = document.getElementById(pid); return (pd != null) && (pd.innerHTML != ''); } function hidePersistSections(menu) { if (!menu.childNodes) { return; } for (var i = 0; i < menu.childNodes.length; i++) { var elt = menu.childNodes[i]; if (elt.id.indexOf('pmid_') != 0) { continue; } elt.style.display = 'none'; } } function showPersistMenuSection(pid, capture) { if (document.releaseCapture) { document.releaseCapture(); } hideMenuCore(); var menu = document.getElementById(pmenuDivId); hidePersistSections(menu); pid = 'pmid_' + pid; var pd = document.getElementById(pid); pd.style.display = ''; showMenuCore(menu, capture); persistMenuOpened = true; } function showPersistMenu(pid, content, capture) { if (document.releaseCapture) { document.releaseCapture(); } hideMenuCore(); var menu = document.getElementById(pmenuDivId); if (!persistMenuReady) { initPersistMenu(menu); } hidePersistSections(menu); pid = 'pmid_' + pid; var pd = document.getElementById(pid); if (pd == null) { pd = document.createElement('div'); pd.id = pid; pd.innerHTML = content; menu.appendChild(pd); } else { if (pd.innerHTML != content) { pd.innerHTML = content; } pd.style.display = ''; } showMenuCore(menu, capture); persistMenuOpened = true; } function reshowMenu(capture) { var menu = document.getElementById(persistMenuOpened ? pmenuDivId : menuDivId); hidePopup(); menu.style.visibility = "visible"; if ((capture == null || capture) && menu.setCapture && uiOptions.captureMouse) { menu.setCapture(false); } } function hideMenu() { if (document.releaseCapture) { document.releaseCapture(); } hideMenuCore(); } function hideMenuCore() { var menu = document.getElementById(menuDivId); if (clearMenuOnceWhenClosed) { menu.innerHTML = ''; clearMenuOnceWhenClosed = false; } menu.style.visibility = 'hidden'; var menu = document.getElementById(pmenuDivId); menu.style.visibility = 'hidden'; hidePersistSections(menu); hidePopup(); closeInfoSpace(); } function onMenuClick() { var menu = document.getElementById(persistMenuOpened ? pmenuDivId : menuDivId); if (!is.ie) { return; } var o = window.event.srcElement; if (menu != o && !menu.contains(o)) { hideMenu(); } } function getMenuItemHtml(html, action) { return format('{0}', html, action); } function onCellOver(id) { var elt = document.getElementById(id); if (elt != null) { elt.className = "ABLinkH"; } } function onCellOut(id) { var elt = document.getElementById(id); if (elt == null) { return; } elt.className = "ABLink"; } function onCellClick_Core(id) { var oldv = clearMenuOnceWhenClosed; clearMenuOnceWhenClosed = false; var r = onCellClick(id); clearMenuOnceWhenClosed = oldv; return r; } function onCellClick(id) { onCellOut(id); hideMenu(); return true; } function getCellMenuItemHtml_Core(html, action, over, out) { if (over == null) { over = ''; } if (out == null) { out = ''; } var newid = 'cmi_' + dc_menuItemCount; dc_menuItemCount++; var qnewid = "'" + newid + "'"; return format('