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

41 lines
954 B
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
}
function enable_theme(prefix, name) {
var theme = document.getElementById("current_theme");
if (theme) {
theme.remove();
}
if (name) {
var style = document.createElement("style");
style.setAttribute("id", "current_theme");
2016-03-08 06:21:20 +05:00
style.innerHTML='@import("'+prefix+"static/"+name+'.css")';
document.head.appendChild(style);
}
}