/* archive.js */
var alreadyLoaded = false;
var $chatArea = document.getElementById("chatarea");
var $selHub = document.getElementById("selHub");
var $frmHub = document.getElementById("frmHub");
function toggle_element(id) {
var e = document.getElementById(id);
e.style.display = (e.style.display == 'none') ? 'block' : 'none';
}
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() {
toggle_element("tr1");
toggle_element("tr2");
toggle_element("spm");
}
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 );
//
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);