Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/static/nntpchan.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

//
// nntpchan.js -- frontend ui niceness
//
// insert a backlink for a post given its short hash
function nntpchan_backlink(shorthash)
{
var elem = document.getElementById("postform_message");
if ( elem )
{
2015-10-19 18:20:30 +05:00
elem.value += ">>" + shorthash.substr(0,10) + "\n";
}
}
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:50:58 +05:00
function get_storage() {
var st = null;
if (window.localStorage) {
st = window.localStorage;
} else if (localStorage) {
st = localStorage;
}
return st;
}
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:57:14 +05:00
st.nntpchan_prefix = prefix;
st.nntpchan_theme = name;
2016-03-08 06:50:58 +05:00
}
}
2016-03-08 07:00:54 +05:00
function main() {
// do other initialization here
}
// apply themes
var st = get_storage();
enable_theme(st.nntpchan_prefix, st.nntpchan_theme);