2017-08-13 01:57:08 +00:00
|
|
|
/* archive.js */
|
|
|
|
|
2017-12-09 22:57:59 +00:00
|
|
|
var alreadyLoaded = false;
|
|
|
|
|
|
|
|
var $chatArea = document.getElementById("chatarea");
|
|
|
|
var $selHub = document.getElementById("selHub");
|
|
|
|
var $frmHub = document.getElementById("frmHub");
|
2017-08-13 01:57:08 +00:00
|
|
|
|
2017-12-09 22:57:59 +00:00
|
|
|
function toggle_element(id) {
|
|
|
|
var e = document.getElementById(id);
|
2017-08-13 01:57:08 +00:00
|
|
|
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<span class=\"sys\">$2</span>")
|
|
|
|
.replace(
|
|
|
|
/\[(\d\d\d\d-\d\d-\d\d)\s(\d\d\:\d\d)\:(\d\d)\]/g,
|
|
|
|
'<span class="timestamp">[<span class="ts_split_d">$1 </span><span class="ts_split_hm">$2</span><span class="ts_split_s">:$3</span>]</span>'
|
|
|
|
)
|
|
|
|
.replace(/(\[[0-9:\-\s]*?\])/g, '<span class="timestamp">$1</span>')
|
|
|
|
.replace(/(\<\;[^\s]+?\>\;)/g, "<span class=\"chat\">$1</span>")
|
|
|
|
.replace(/(\*\*\*.+)/g, "<span class=\"sys\">$1</span>")
|
|
|
|
.replace(/(\>\;imp[^\n\r\<]*)/g, "<span class=\"gt\">$1</span>")
|
|
|
|
.replace(/(https?:\/\/.+?)([\s|<])/g, "<a href=\"$1\" rel=\"noreferrer\">$1</a>$2")
|
|
|
|
.replace(/magnet:\?.+dn=([^\< ]+)/g, function(match, m1) {
|
|
|
|
return "<a href=\"" + match + "\">[MAGNET] " + urldesc(m1) + "</a>";
|
|
|
|
})
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
function fontSize(change) {
|
|
|
|
var curSize = cookie_get("fontsize");
|
|
|
|
if (curSize === null) {
|
|
|
|
curSize = 12;
|
|
|
|
} else {
|
|
|
|
curSize = + curSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
curSize += change;
|
|
|
|
|
|
|
|
cookie_set("fontsize", curSize);
|
|
|
|
|
2017-12-09 22:57:59 +00:00
|
|
|
$chatArea.style["fontSize"] = ""+curSize+"px";
|
2017-08-13 01:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleMenu() {
|
2017-12-09 22:57:59 +00:00
|
|
|
toggle_element("tr1");
|
|
|
|
toggle_element("tr2");
|
|
|
|
toggle_element("spm");
|
2017-08-13 01:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function highlightLine(no) {
|
2017-12-09 22:57:59 +00:00
|
|
|
var lines = $chatArea.innerHTML.split('<br>');
|
2017-08-13 01:57:08 +00:00
|
|
|
|
|
|
|
lines[no] = '<span class="line-highlighted">' + lines[no] + '</span>';
|
|
|
|
|
2017-12-09 22:57:59 +00:00
|
|
|
$chatArea.innerHTML = lines.join('<br>');
|
2017-08-13 01:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onLoad() {
|
|
|
|
|
|
|
|
if (alreadyLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
alreadyLoaded = true;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2017-12-09 22:57:59 +00:00
|
|
|
$chatArea.innerHTML = highlight( $chatArea.innerHTML );
|
2017-08-13 01:57:08 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2017-12-09 22:57:59 +00:00
|
|
|
$selHub.onchange = function() {
|
2017-08-13 01:57:08 +00:00
|
|
|
if ( /\/search\//.test(window.location.pathname) ) {
|
2017-12-09 22:57:59 +00:00
|
|
|
window.location.pathname = $selHub.value + "/search/" + encodeURIComponent( i('searchbox').value );
|
2017-08-13 01:57:08 +00:00
|
|
|
|
|
|
|
} else if ( /\/rx\//.test(window.location.pathname) ) {
|
2017-12-09 22:57:59 +00:00
|
|
|
window.location.pathname = $selHub.value + "/rx/" + encodeURIComponent( i('searchbox').value )
|
2017-08-13 01:57:08 +00:00
|
|
|
|
|
|
|
} else {
|
2017-12-09 22:57:59 +00:00
|
|
|
$frmHub.submit();
|
2017-08-13 01:57:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('load', onLoad);
|