2015-09-05 02:09:43 +05:00
|
|
|
//
|
|
|
|
// nntpchan.js -- frontend ui niceness
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
// insert a backlink for a post given its short hash
|
2015-09-05 02:20:02 +05:00
|
|
|
function nntpchan_backlink(shorthash)
|
|
|
|
{
|
2015-09-05 02:09:43 +05:00
|
|
|
var elem = document.getElementById("postform_message");
|
2015-09-05 02:20:02 +05:00
|
|
|
if ( elem )
|
|
|
|
{
|
2015-10-19 18:20:30 +05:00
|
|
|
elem.value += ">>" + shorthash.substr(0,10) + "\n";
|
2015-09-05 02:20:02 +05:00
|
|
|
}
|
2015-09-05 02:09:43 +05:00
|
|
|
}
|
2016-01-20 21:42:18 +05:00
|
|
|
|
|
|
|
var banner_count = 3;
|
|
|
|
|
|
|
|
// inject a banner into an element
|
|
|
|
function nntpchan_inject_banners(elem, prefix) {
|
|
|
|
var n = Math.floor(Math.random() * banner_count);
|
2016-01-20 21:49:38 +05:00
|
|
|
var banner = prefix + "static/banner_"+n+".jpg";
|
2016-01-20 21:42:18 +05:00
|
|
|
var e = document.createElement("img");
|
|
|
|
e.src = banner;
|
2016-01-20 21:52:04 +05:00
|
|
|
e.id = "nntpchan_banner";
|
2016-01-20 22:11:38 +05:00
|
|
|
elem.appendChild(e);
|
2016-01-20 21:42:18 +05:00
|
|
|
}
|
2016-03-08 06:18:28 +05:00
|
|
|
|
2016-03-08 06:50:58 +05:00
|
|
|
function get_storage() {
|
|
|
|
var st = null;
|
|
|
|
if (window.localStorage) {
|
|
|
|
st = window.localStorage;
|
|
|
|
} else if (localStorage) {
|
|
|
|
st = localStorage;
|
|
|
|
}
|
|
|
|
return st;
|
|
|
|
}
|
|
|
|
|
2016-03-08 06:18:28 +05:00
|
|
|
function enable_theme(prefix, name) {
|
|
|
|
|
|
|
|
var theme = document.getElementById("current_theme");
|
|
|
|
if (theme) {
|
2016-03-08 06:25:29 +05:00
|
|
|
theme.href = prefix + "static/"+ name + ".css";
|
2016-03-08 06:50:58 +05:00
|
|
|
var st = get_storage();
|
2016-03-08 06:55:05 +05:00
|
|
|
st.setItem("nntpchan_prefix", prefix);
|
|
|
|
st.setItem("nntpchan_theme", name);
|
2016-03-08 06:50:58 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-08 06:51:41 +05:00
|
|
|
document.onload = function() {
|
2016-03-08 06:50:58 +05:00
|
|
|
var st = get_storage();
|
|
|
|
if (st.nntpchan) {
|
2016-03-08 06:55:05 +05:00
|
|
|
enable_theme(st.nntpchan_prefix, st.nntpchan_theme);
|
2016-03-08 06:18:28 +05:00
|
|
|
}
|
|
|
|
}
|