مدیاویکی:Gadget-Commenthighlighter.js: تفاوت میان نسخهها
ظاهر
imported>Reza1615 صفحهای جدید حاوی '// install Wikipedia:User:PleaseStand/Comment highlighter browsing tool importScriptURI('http://en.wikipedia.org/w/index.php?title=User:P...' ایجاد کرد |
imported>Yamaha5 به روزرسانی mw.config.get("wgUserName") |
||
| (۸ نسخهٔ میانی ویرایش شده توسط ۳ کاربر نشان داده نشد) | |||
| خط ۱: | خط ۱: | ||
// | //<pre><nowiki> | ||
// highlight-comments.js - written by PleaseStand, 2010. | |||
// Source: http://en.wikipedia.org/wiki/User:PleaseStand/highlight-comments.js | |||
// NOTE: This script is in the public domain (not copyrighted). For details, see | |||
// http://en.wikipedia.org/wiki/Template:PD-self | |||
// DESCRIPTION: Highlights your posts to discussion pages | |||
// (at least a significant part). This is just the JS part; you need a | |||
// corresponding CSS line to actually affect text color. An example: | |||
// .mycomment { background: #ff9; } | |||
/*global window, document, jQuery, | |||
HighlightCommentsJsDefault, HighlightCommentsJsDescription */ | |||
// Function names | |||
var HighlightCommentsJsHighlight, HighlightCommentsJsUnhighlight; | |||
// Global variables | |||
var HighlightCommentsJsWrapped = false, HighlightCommentsJsTries = 40, | |||
HighlightCommentsJsSwitch; | |||
HighlightCommentsJsHighlight = function(){ | |||
// Lists the tags that can contain comments/indented text respectively. | |||
var commentTags = "dd,li,p"; | |||
var indentTags = "dl,ol,ul"; | |||
if(!HighlightCommentsJsWrapped) { | |||
// Do the work, adding span wrappers | |||
jQuery("a[title=\"" + (mw.config.get("wgFormattedNamespaces")[2] + ":" + | |||
mw.config.get("wgUserName")).replace(/"/g, "\\\"") + "\"]").closest(commentTags). | |||
contents().not(indentTags). | |||
wrap(jQuery("<span class=\"mycomment\"/>")); | |||
// Set the flag that wrapping is done | |||
HighlightCommentsJsWrapped = true; | |||
} else { | |||
// Just change the classes | |||
jQuery(".mycomment-off").removeClass("mycomment-off"). | |||
addClass("mycomment"); | |||
} | |||
var ns = null; | |||
if(HighlightCommentsJsSwitch) { | |||
ns = HighlightCommentsJsSwitch.parentNode.removeChild(HighlightCommentsJsSwitch); | |||
} | |||
HighlightCommentsJsSwitch = mw.util.addPortletLink("p-cactions", | |||
"javascript:HighlightCommentsJsUnhighlight()", "نوشتهٔ من، بدون رنگ", | |||
"ca-highlightcomments", | |||
"Disable highlighting of your own comments on this page", null, ns); | |||
}; | |||
HighlightCommentsJsUnhighlight = function(){ | |||
// Change the classes | |||
jQuery(".mycomment").removeClass("mycomment").addClass("mycomment-off"); | |||
var ns = null; | |||
if(HighlightCommentsJsSwitch) { | |||
ns = HighlightCommentsJsSwitch.parentNode.removeChild(HighlightCommentsJsSwitch); | |||
} | |||
HighlightCommentsJsSwitch = mw.util.addPortletLink("p-cactions", | |||
"javascript:HighlightCommentsJsHighlight()", "نوشتهٔ من، رنگی", | |||
"ca-highlightcomments", | |||
"Enable highlighting of your own comments on this page", null, ns); | |||
}; | |||
function HighlightCommentsJsLoaded() { | |||
var desc; | |||
if(typeof HighlightCommentsJsDescription == "undefined") { | |||
// Default toolbox link text | |||
desc = "Toggle comment highlighting"; | |||
} else { | |||
// User-defined toolbox link text | |||
desc = HighlightCommentsJsDescription; | |||
} | |||
if(typeof HighlightCommentsJsDefault == "undefined" || !HighlightCommentsJsDefault) { | |||
// Create and add the menu item or tab | |||
HighlightCommentsJsSwitch = mw.util.addPortletLink("p-cactions", | |||
"javascript:HighlightCommentsJsHighlight()", "نوشتهٔ من، رنگی", | |||
"ca-highlightcomments", | |||
"فعال کردن ابزار پررنگ کنندهٔ نظرهای شما در صفحههای بحث و نظرخواهی"); | |||
} else { | |||
HighlightCommentsJsSwitch = null; | |||
HighlightCommentsJsHighlight(); | |||
} | |||
} | |||
mw.loader.using( 'mediawiki.util', function () { | |||
$(HighlightCommentsJsLoaded); | |||
} ); | |||
//</nowiki></pre> | |||
نسخهٔ کنونی تا ۸ مهٔ ۲۰۲۰، ساعت ۱۵:۵۹
//<pre><nowiki>
// highlight-comments.js - written by PleaseStand, 2010.
// Source: http://en.wikipedia.org/wiki/User:PleaseStand/highlight-comments.js
// NOTE: This script is in the public domain (not copyrighted). For details, see
// http://en.wikipedia.org/wiki/Template:PD-self
// DESCRIPTION: Highlights your posts to discussion pages
// (at least a significant part). This is just the JS part; you need a
// corresponding CSS line to actually affect text color. An example:
// .mycomment { background: #ff9; }
/*global window, document, jQuery,
HighlightCommentsJsDefault, HighlightCommentsJsDescription */
// Function names
var HighlightCommentsJsHighlight, HighlightCommentsJsUnhighlight;
// Global variables
var HighlightCommentsJsWrapped = false, HighlightCommentsJsTries = 40,
HighlightCommentsJsSwitch;
HighlightCommentsJsHighlight = function(){
// Lists the tags that can contain comments/indented text respectively.
var commentTags = "dd,li,p";
var indentTags = "dl,ol,ul";
if(!HighlightCommentsJsWrapped) {
// Do the work, adding span wrappers
jQuery("a[title=\"" + (mw.config.get("wgFormattedNamespaces")[2] + ":" +
mw.config.get("wgUserName")).replace(/"/g, "\\\"") + "\"]").closest(commentTags).
contents().not(indentTags).
wrap(jQuery("<span class=\"mycomment\"/>"));
// Set the flag that wrapping is done
HighlightCommentsJsWrapped = true;
} else {
// Just change the classes
jQuery(".mycomment-off").removeClass("mycomment-off").
addClass("mycomment");
}
var ns = null;
if(HighlightCommentsJsSwitch) {
ns = HighlightCommentsJsSwitch.parentNode.removeChild(HighlightCommentsJsSwitch);
}
HighlightCommentsJsSwitch = mw.util.addPortletLink("p-cactions",
"javascript:HighlightCommentsJsUnhighlight()", "نوشتهٔ من، بدون رنگ",
"ca-highlightcomments",
"Disable highlighting of your own comments on this page", null, ns);
};
HighlightCommentsJsUnhighlight = function(){
// Change the classes
jQuery(".mycomment").removeClass("mycomment").addClass("mycomment-off");
var ns = null;
if(HighlightCommentsJsSwitch) {
ns = HighlightCommentsJsSwitch.parentNode.removeChild(HighlightCommentsJsSwitch);
}
HighlightCommentsJsSwitch = mw.util.addPortletLink("p-cactions",
"javascript:HighlightCommentsJsHighlight()", "نوشتهٔ من، رنگی",
"ca-highlightcomments",
"Enable highlighting of your own comments on this page", null, ns);
};
function HighlightCommentsJsLoaded() {
var desc;
if(typeof HighlightCommentsJsDescription == "undefined") {
// Default toolbox link text
desc = "Toggle comment highlighting";
} else {
// User-defined toolbox link text
desc = HighlightCommentsJsDescription;
}
if(typeof HighlightCommentsJsDefault == "undefined" || !HighlightCommentsJsDefault) {
// Create and add the menu item or tab
HighlightCommentsJsSwitch = mw.util.addPortletLink("p-cactions",
"javascript:HighlightCommentsJsHighlight()", "نوشتهٔ من، رنگی",
"ca-highlightcomments",
"فعال کردن ابزار پررنگ کنندهٔ نظرهای شما در صفحههای بحث و نظرخواهی");
} else {
HighlightCommentsJsSwitch = null;
HighlightCommentsJsHighlight();
}
}
mw.loader.using( 'mediawiki.util', function () {
$(HighlightCommentsJsLoaded);
} );
//</nowiki></pre>