Date.prototype.toMwDate = function() { // converting to mw timestamp
var format = self.format;
return this.getFullYear() + format(this.getMonth() + 1) + format(this.getDate()) + format(this.getHours()) + format(this.getMinutes()) + '00';
};
this.format = function(str) {
var num = '00' + str;
return num.substr(num.length - 2);
};
var ThisDate = new Date();
var BNday = new Date();
BNday.setDate(BNday.getDate() - 90);
var params = {
"action": "query",
"format": "json",
"list": "usercontribs",
"uclimit": "100",
//"ucuser": mw.config.get('wgRelevantUserName'),
"ucuser": mw.config.get('wgUserName'),
"ucdir": "older",
"ucnamespace": '0|6|8|10|12|14|100',
"ucprop": "timestamp"
};
$.getJSON('/w/api.php', params, function(res) {
var contribs = res.query.usercontribs;
var contribsLength = contribs.length;
var left = (100 - contribsLength)
if(left <= 0)
{
var date = new Date(contribs[99].timestamp);
date = new Date(date.setDate(date.getDate() + 90));
var label = "יש זכות הצבעה עד " + date.toLocaleDateString();
var color = "#19f0196e"
}
else
{
var label = left + " עריכות לז\"ה";
var color = "#ff00008a";
}
var new_NavTop = [{
label: label ,
color: color,
url: "",
index: 1
}];
var ppersonal = document.getElementById("p-personal");
var NavTop = ppersonal ? ppersonal.getElementsByTagName("ul")[0] : null;
if (!NavTop) return;
for (var i = 0; i < new_NavTop.length; i++) {
var newListItem = document.createElement("li");
var newLink = document.createElement("b");
//newLink.setAttribute("href", new_NavTop[i].url);
if (new_NavTop[i].hasOwnProperty("title")) {
newLink.setAttribute("title", new_NavTop[i].title);
}
newLink.appendChild(document.createTextNode(new_NavTop[i].label));
newLink.style.backgroundColor = new_NavTop[i].color;
newLink.onclick = new_NavTop[i].onclick;
newListItem.appendChild(newLink);
if (new_NavTop[i].hasOwnProperty("index")) {
NavTop.insertBefore(newListItem, NavTop.childNodes[new_NavTop[i].index]);
} else {
NavTop.appendChild(newListItem);
}
}
});