MediaWiki:Gadget-Signaturnachtrag.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Sonderzeichen-Bug behoben, SGPack-Script eingebunden statt (unvollständig) nachgebaut, Code teils vereinfacht und formatiert |
Ghost (Diskussion | Beiträge) K Fixes |
||
| Zeile 17: | Zeile 17: | ||
var z = document.getElementById("wpSummary").value; | var z = document.getElementById("wpSummary").value; | ||
if (z.substring((z.length - 16)) != "Signaturnachtrag") | if (z.substring((z.length - 16)) != "Signaturnachtrag") | ||
var c = (z.length && (z.substring((z.length - 3)) != "*/ ") ? ", " : ""); | |||
document.getElementById("wpSummary").value += c+"Signaturnachtrag"; | document.getElementById("wpSummary").value += c+"Signaturnachtrag"; | ||
}, 'json'); | }, 'json'); | ||
else mw. | else mw.SGPack.insertSelect(this); | ||
this.options.selectedIndex=0; | this.options.selectedIndex=0; | ||
}; | }; | ||
}); | }); | ||
}); | }); | ||
Aktuelle Version vom 30. November 2025, 15:23 Uhr
//Signaturnachtrag automatisch ausfüllen
$(function()
{
$("select[name^='DDSelect-']").each(function(i)
{
this.onchange = function()
{
if (this.options[this.options.selectedIndex].innerHTML == '(IP-)Signaturnachtrag') $.get(wgServer+wgScriptPath+'/api.php?action=query&format=json&titles='+encodeURIComponent(wgPageName)+'&prop=revisions&meta=siteinfo|allmessages&ammessages=jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec',
function(data)
{
if ("string" == typeof data)
data = JSON.parse(data);
var x = data.query.pages[wgArticleId].revisions[0].timestamp.split(/[- :TZ]/);
var zeit =
new Date(Date.UTC(x[0], x[1]-1, x[2], x[3], x[4], x[5])+data.query.general.timeoffset*60*1000);
mw.toolbar.insertTags("{"+"{"+"subst:"+(data.query.pages[wgArticleId].revisions[0].anon===''?"IP-":"")+"Signaturnachtrag|"+data.query.pages[wgArticleId].revisions[0].user+"|"+(zeit.getUTCHours()<10?"0":"")+zeit.getUTCHours()+":"+(zeit.getUTCMinutes()<10?"0":"")+zeit.getUTCMinutes()+", "+zeit.getUTCDate()+". "+data.query.allmessages[zeit.getUTCMonth()]["*"]+" "+zeit.getUTCFullYear()+" (CE"+(data.query.general.timeoffset==120?"S":"")+"T)|"+wgUserName+"}"+"}", '', '');
var z = document.getElementById("wpSummary").value;
if (z.substring((z.length - 16)) != "Signaturnachtrag")
var c = (z.length && (z.substring((z.length - 3)) != "*/ ") ? ", " : "");
document.getElementById("wpSummary").value += c+"Signaturnachtrag";
}, 'json');
else mw.SGPack.insertSelect(this);
this.options.selectedIndex=0;
};
});
});