„Benutzer:OS/common.js“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
OS (Diskussion | Beiträge) Gelöscht da es nicht funktioniert |
OS (Diskussion | Beiträge) Artikelmonitor (JavaScript) |
||
Zeile 1: | Zeile 1: | ||
/* |
|||
* 2015-04-05 |
|||
* @see https://tools.wmflabs.org/render/stools/articleMonitor |
|||
* |
|||
* Changelog: |
|||
* - 2015-04-10: Toollabs API-URIs korrigiert, Globale JS Konfigurationsvariablen durch mw.config.get() ersetzt |
|||
*/ |
|||
var asqmReq = false; |
|||
var closeButton = "<img border=\"0\" onclick=\"$('#asqmContainer').css('visibility', 'hidden')\" " + |
|||
"src=\"/media/wikipedia/foundation/2/20/CloseWindow19x19.png\" " + |
|||
"style=\"position:absolute; right: 10px; cursor: pointer\">"; |
|||
if ( mw.config.get( "wgNamespaceNumber" ) == 0) { |
|||
$('<li id="ca-asqm" style="position: relative;"><span><a onclick="javascript:asqm()" ' + |
|||
'title="Statistiken und weitere Analysen zu diesem Artikel anzeigen">Artikelmonitor</a></span>' + |
|||
'<div id="asqmContainer" style="visibility: hidden; position:absolute; right: 0; ' + |
|||
'font-size: 0.8em; border: 1px solid silver; margin: -5px 0 0 -1px; padding: 10px; ' + |
|||
'z-index: 1000; background: white;"></div></li>').insertAfter("#ca-history"); |
|||
} |
|||
function asqm() { |
|||
if ($('#asqmContainer').css('visibility') == 'hidden') { |
|||
$('#asqmContainer').css('visibility', 'visible'); |
|||
if (!asqmReq) { |
|||
$('#asqmContainer').html('<img src="//tools.wmflabs.org/render/stools/res/img/load.gif" style="padding: 20px;" />'); |
|||
$.getJSON("//tools.wmflabs.org/render/stools/articleMonitor/query/json/id/" + |
|||
mw.config.get( "wgArticleId" ) + "/lang/" + mw.config.get( "wgContentLanguage" ) + "/asqmid/2a7193e0?callback=?", function(data) { |
|||
var output = "<table>"; |
|||
$.each(data.asqmResponse, function(key, groupObj) { |
|||
output += "<tr><td colspan='2' style='text-align: left; padding-top: 10px; font-weight: bold;'>" + |
|||
groupObj.title + "</td></tr>"; |
|||
$.each(groupObj.items, function(itemTitle, value) { |
|||
var link = ""; |
|||
if ($.isArray(value)) { |
|||
if (value[0] === "multipart") { |
|||
var val = ""; |
|||
$.each(value, function(index, part) { |
|||
if (index === 0) return true; |
|||
if ($.isArray(part)) { |
|||
link = part[1]; |
|||
val += "<a href='" + link + "' target='_blank' style='font-size: 1em; padding: 0; height: 1em;'>" + |
|||
part[0] + "</a>"; |
|||
} else { |
|||
val += part; |
|||
} |
|||
}); |
|||
value = val; |
|||
} else { |
|||
value = "<a href='" + value[1] + "' target='_blank' style='font-size: 1em; padding: 0; height: 1em;'>" + |
|||
value[0] + "</a>"; |
|||
} |
|||
} |
|||
output += "<tr><td style='padding-right: 10px;'>" + itemTitle + "</td><td>" + value.toString() + "</td></tr>"; |
|||
}); |
|||
}); |
|||
output += "</table>"; |
|||
asqmReq = true; |
|||
$('#asqmContainer').html(closeButton + output); |
|||
}); |
|||
} |
|||
} else { |
|||
$('#asqmContainer').css('visibility', 'hidden'); |
|||
} |
|||
} |
Version vom 16. April 2015, 13:15 Uhr
/*
* 2015-04-05
* @see https://tools.wmflabs.org/render/stools/articleMonitor
*
* Changelog:
* - 2015-04-10: Toollabs API-URIs korrigiert, Globale JS Konfigurationsvariablen durch mw.config.get() ersetzt
*/
var asqmReq = false;
var closeButton = "<img border=\"0\" onclick=\"$('#asqmContainer').css('visibility', 'hidden')\" " +
"src=\"/media/wikipedia/foundation/2/20/CloseWindow19x19.png\" " +
"style=\"position:absolute; right: 10px; cursor: pointer\">";
if ( mw.config.get( "wgNamespaceNumber" ) == 0) {
$('<li id="ca-asqm" style="position: relative;"><span><a onclick="javascript:asqm()" ' +
'title="Statistiken und weitere Analysen zu diesem Artikel anzeigen">Artikelmonitor</a></span>' +
'<div id="asqmContainer" style="visibility: hidden; position:absolute; right: 0; ' +
'font-size: 0.8em; border: 1px solid silver; margin: -5px 0 0 -1px; padding: 10px; ' +
'z-index: 1000; background: white;"></div></li>').insertAfter("#ca-history");
}
function asqm() {
if ($('#asqmContainer').css('visibility') == 'hidden') {
$('#asqmContainer').css('visibility', 'visible');
if (!asqmReq) {
$('#asqmContainer').html('<img src="//tools.wmflabs.org/render/stools/res/img/load.gif" style="padding: 20px;" />');
$.getJSON("//tools.wmflabs.org/render/stools/articleMonitor/query/json/id/" +
mw.config.get( "wgArticleId" ) + "/lang/" + mw.config.get( "wgContentLanguage" ) + "/asqmid/2a7193e0?callback=?", function(data) {
var output = "<table>";
$.each(data.asqmResponse, function(key, groupObj) {
output += "<tr><td colspan='2' style='text-align: left; padding-top: 10px; font-weight: bold;'>" +
groupObj.title + "</td></tr>";
$.each(groupObj.items, function(itemTitle, value) {
var link = "";
if ($.isArray(value)) {
if (value[0] === "multipart") {
var val = "";
$.each(value, function(index, part) {
if (index === 0) return true;
if ($.isArray(part)) {
link = part[1];
val += "<a href='" + link + "' target='_blank' style='font-size: 1em; padding: 0; height: 1em;'>" +
part[0] + "</a>";
} else {
val += part;
}
});
value = val;
} else {
value = "<a href='" + value[1] + "' target='_blank' style='font-size: 1em; padding: 0; height: 1em;'>" +
value[0] + "</a>";
}
}
output += "<tr><td style='padding-right: 10px;'>" + itemTitle + "</td><td>" + value.toString() + "</td></tr>";
});
});
output += "</table>";
asqmReq = true;
$('#asqmContainer').html(closeButton + output);
});
}
} else {
$('#asqmContainer').css('visibility', 'hidden');
}
}