sadasya:SM7/common.js: ke revisions ke biich ke antar

Content deleted Content added
SM7 (Baat | yogdaan)
d r
SM7 (Baat | yogdaan)
Contwnt ke " // Tag it ! importScript('sadasya:SM7/tagIt.js');" se replace kar dewa gais hae
Tag: Replaced
Rekha 1:
var tagItYes_nomdate = null;
(function ($) { // Wrap with anonymous function
function tagItTab() {
var $h, $hb, $newa,
// A list of subpages of WikiProject Stub sorting/Stub types/ that are relevant to this
a = ['tag0' , 'tag1', 'tag2'];
 
// Tag it !
$h = $("<div></div>", { "id": "tagIttab" })
importScript('sadasya:SM7/tagIt.js');
.css({
"color": "#000000",
"background-color": "#fff8f8",
"text-align": "center"
});
for (var i = 0; i < a.length; i++) {
$newa = $("<a href=\"#\"></a>");
$newa.click(function (e) {
e.preventDefault();
tagItMenu($(this).text());
});
$newa.text(a[i]);
$h.append($newa);
if ((i + 1) < a.length) {
$h.append(" &bull; ");
}
}
$("#contentSub").append($h);
 
$hb = $("<div></div>", {
"color": "#000000",
"background-color": "#fffff8"
});
$hb.attr("id", "tagItmenu");
$("#contentSub").append($hb);
}
 
function tagItMenuRender(data) {
var $parseData = $(data.parse.text["*"]);
$parseData.find("a").each(function () {
var link = $(this).attr("href"),
index = link.indexOf("F:");
if (index === -1) {
$(this).attr({
"href": null,
"title": null
});
$(this).css({
"color": "#000000",
"text-decoration": "none"
});
} else {
$(this).attr("href", mw.config.get("wgServer") + mw.config.get("wgScript")
+ "?title=" + encodeURIComponent(mw.config.get("wgPageName"))
+ "&action=edit&autoaddtagIt=" + encodeURIComponent(link.slice(index + 2)));
}
});
$("#tagItmenu").html($parseData);
}
 
function tagItMenuFail() {
$("#tagItmenu").html("Failed to load tags.");
}
 
function tagItMenu(stubType) {
// Add loading message
$("#tagItmenu").html("Loading tags, please wait...");
 
// Fetch the relevant subpage of the WikiProject
$.ajax({
url: mw.config.get("wgServer") + mw.config.get("wgScriptPath") + '/api.php?action=parse&prop=text&text=' + encodeURIComponent('__NOTOC____NOEDITSECTION__\{\{User:SM7/sandbox/' + stubType + '}}') + '&format=json',
dataType: "json",
success: tagItMenuRender,
error: tagItMenuFail
});
}
 
$(function () {
if (mw.config.get("wgNamespaceNumber") === 0 && mw.config.get("wgAction") === "view"
&& $("#ca-edit").length !== 0) {
var portletLink = mw.util.addPortletLink('p-cactions', '#', 'Oh! Tag It!', 'ca-tagIt', 'Add a tag to this page', '');
$(portletLink).click(function (e) {
e.preventDefault();
if (!$("#tagIttab").length) {
tagItTab();
}
});
}
if (location.href.indexOf("&autoaddtagIt=") !== -1 && $("#wpTextbox1").length !== 0) {
var x = decodeURIComponent(location.href.split("&autoaddtagIt=")[1]);
var txt = document.editform.wpTextbox1; //Get text for replacing pre-existing stub tags
if (tagItYes_nomdate === null) {
tagItYes_nomdate = prompt("Give reason/date etc. as needed !", '');
}
$("#wpTextbox1").val("{" + "{" + x + "|" + tagItYes_nomdate + "}}\n" + $("#wpTextbox1").val()); // add to the end of the article
$("#wpSummary").val("[[m:User:SM7#TagIt|TagIt]] adding " + x + " Tag.");
$("#wpPreview").trigger("click");
}
});
} (jQuery)); // End wrap with anonymous function