Archived
1
0

add nntpchan feed ticker to mod panel

This commit is contained in:
Jeff Becker 2016-03-07 11:42:21 -05:00
parent e0de5dfbf5
commit 56f8fc8b91
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
2 changed files with 45 additions and 7 deletions

View File

@ -87,19 +87,25 @@ function nntpchan_admin_board(method) {
}) })
} }
function nntpchan_admin(method, param) { function nntpchan_admin(method, param, handler_cb) {
nntpchan_mod({ if (handler_cb) {
name:"admin", // we got a handler already set
parser: function(target) { } else {
return method; // no handler set
}, var handler_cb = function(j) {
handle: function(j) {
if (j.result) { if (j.result) {
return document.createTextNode(j.result); return document.createTextNode(j.result);
} else { } else {
return "nothing happened?"; return "nothing happened?";
} }
}
}
nntpchan_mod({
name:"admin",
parser: function(target) {
return method;
}, },
handle: handler_cb,
method: ( param && "POST" ) || "GET", method: ( param && "POST" ) || "GET",
data: param data: param
}) })
@ -136,6 +142,28 @@ function nntpchan_delete() {
}); });
} }
function update_nntpchan_feed_ticker(elem) {
nntpchan_admin("feed.list", null, function(j) {
if (j) {
if (j.error) {
console.log("nntpchan_feed_ticker: error, "+j.error);
} else {
// remove all children
while(elem.children.length) {
elem.children[0].remove();
}
var result = j.result;
for (var idx = 0; idx < result.length; idx++) {
var item = result[idx];
var entry = document.createElement("div");
console.log(item);
elem.appendChild(entry);
}
}
}
});
}
function nntpchan_mod(mod_action) { function nntpchan_mod(mod_action) {

View File

@ -95,6 +95,16 @@
</div> </div>
</div> </div>
<div id="nntpchan_mod_result"></div> <div id="nntpchan_mod_result"></div>
<div id="nntpchan_feeds"></div>
<script>
// start nntp feed stats ticker
var e = document.getElementById("nntpchan_feeds");
if (e) {
setInterval(2000, function() {
update_nntpchan_feed_ticker(e);
}
}
</script>
<noscript> <noscript>
<b>{{#i18n.Translations}}{{nojs_info}}{{/i18n.Translations}}</b> <b>{{#i18n.Translations}}{{nojs_info}}{{/i18n.Translations}}</b>
</noscript> </noscript>