/* archive.js */ var alreadyLoaded = false; var $chatArea = document.getElementById("chatarea"); var $selHub = document.getElementById("selHub"); var $frmHub = document.getElementById("frmHub"); function urldesc(s) { return decodeURIComponent(s.replace(/\+/g, " ")); } function cookie_set(key, value) { document.cookie = (key+"="+value+"; expires=Sat, 20 Sep 2059 09:05:12; path=/"); } function cookie_clear(key) { document.cookie = (key+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"); } function cookie_get(key) { var parts = document.cookie.split("; ").map(function(x) { return x.split("="); }); for (var i = 0, e = parts.length; i !== e; ++i) { if (parts[i][0] == key) { return parts[i][1]; } } return null; } function highlight(str) { return str .replace(/(\[\d\d\d\d-\d\d-\d\d\s\d\d\:\d\d\:\d\d\] )(\*.+)/g, "$1$2") .replace( /\[(\d\d\d\d-\d\d-\d\d)\s(\d\d\:\d\d)\:(\d\d)\]/g, '[$1 $2:$3]' ) .replace(/(\[[0-9:\-\s]*?\])/g, '$1') .replace(/(\<\;[^\s]+?\>\;)/g, "$1") .replace(/(\*\*\*.+)/g, "$1") .replace(/(\>\;imp[^\n\r\<]*)/g, "$1") .replace(/(https?:\/\/.+?)([\s|<])/g, "$1$2") .replace(/magnet:\?.+dn=([^\< ]+)/g, function(match, m1) { return "[MAGNET] " + urldesc(m1) + ""; }) ; } function fontSize(change) { var curSize = cookie_get("fontsize"); if (curSize === null) { curSize = 12; } else { curSize = + curSize; } curSize += change; cookie_set("fontsize", curSize); $chatArea.style["fontSize"] = ""+curSize+"px"; } function toggleMenu() { var $container = document.getElementById("menu-container"); $container.style.display = ($container.style.display == 'block') ? 'none' : 'block'; } function highlightLine(no) { var lines = $chatArea.innerHTML.split('
'); lines[no] = '' + lines[no] + ''; $chatArea.innerHTML = lines.join('
'); } function onLoad() { if (alreadyLoaded) { return; } alreadyLoaded = true; // $chatArea.innerHTML = highlight( $chatArea.innerHTML ); // document.getElementById("logo").addEventListener("click", toggleMenu); // if ( ! /\/search\//.test(window.location.pathname) && document.location.hash.substr(0, 6) === '#line-' ) { highlightLine( parseInt(document.location.hash.substr(6), 10) ); document.location.hash = ''; } // fontSize(0); // $selHub.onchange = function() { if ( /\/search\//.test(window.location.pathname) ) { window.location.pathname = $selHub.value + "/search/" + encodeURIComponent( i('searchbox').value ); } else if ( /\/rx\//.test(window.location.pathname) ) { window.location.pathname = $selHub.value + "/rx/" + encodeURIComponent( i('searchbox').value ) } else { $frmHub.submit(); } }; // } window.addEventListener('load', onLoad);