"सदस्य:Hareesh Sivasubramanian/common.js": अवतरणों में अंतर

Content deleted Content added
Creating common.js. Added Interwiki Translator code by Jayarathina
 
No edit summary
पंक्ति 1:
/*
var txt, myMsgBx, langCookie = "iwtLangPref",
Thanks to [[User:Jayarathina]] for the script.
customizeToolbar = function() {
Live long and prosper!!
txt = $("#wpTextbox1");
*/
txt.wikiEditor("addToToolbar", {
var replaceList = {
sections: {
interWikiLinker: {
type: "toolbar",
label: "InterWiki Translator",
groups: {
tamSorting: {
tools: {
searchReplaceList: {
labelMsg: "விருப்பப் பட்டியலில் இருக்கும் சொற்களைத் தேடிக்கண்டுபிடித்து மாற்றவும்",
type: "button",
icon: "//upload.wikimedia.org/wikipedia/commons/thumb/1/17/System-search.svg/200px-System-search.svg.png",
action: {
type: "callback",
execute: function(a) {
if (0 === e)
if ("undefined" == typeof relpaceList) {
var c = "",
c = "undefined" != typeof en_words ? 'IWTஇல் மாற்றங்கள் செய்யப்பட்டுள்ளன. உங்கள் விருப்பப்பட்டியலை புதுப்பிக்கவும் «<small><a href="//ta.wikipedia.org/wiki/பயனர்:Jayarathina/iwt#Replace_list_of_predefined_words">மேலும் அறிய</a></small>»' :
"விருப்பப் பட்டியல் கொடுக்கப்படவில்லை";
alert1(c, 1.5, "#fed")
} else {
a = txt.val();
for (c in relpaceList) a = a.replace("string" !== typeof relpaceList[c] ? RegExp(relpaceList[c]) : RegExp(relpaceList[c], "gi"), c);
txt.val(a);
alert1("நிறைவுற்றது", 1.5, "#efd")
}
}
}
}
}
},
linker: {
tools: {
interWikiLink: {
labelMsg: "பிற மொழி விக்கி இணைப்புகளுக்கு இணையான தமிழ் விக்கி இணைப்புகளைத் தேடிக்கண்டுபிடித்து மாற்றவும்",
type: "button",
icon: "//upload.wikimedia.org/wikipedia/commons/thumb/2/20/Go-jump.svg/200px-Go-jump.svg.png",
action: {
type: "callback",
execute: function(a) {
if (0 === e) {
a = m(txt[0]);
var c = txt.val();
a.start != a.end ? (c = c.slice(a.start, a.end), alert1("தேர்வு செய்யப்பட்ட உரையின் இணைப்புகளுக்கு மட்டும் ",
"10", "#E0EEF7")) : alert1("", "10", "#E0EEF7");
myMsgBx.appendWrite("கருவி இயங்குகின்றது.... காத்திருக்கவும்...");
if (a = c.match(/\[\[([^\]]+(?:[^|\]]*\|)?)\]\]/gmi)) {
e = 0;
p = !1;
for (var c = [], b = 0; b < a.length; b++) {
var d = a[b].substr(2, a[b].length - 4),
h = d.indexOf("[["); - 1 < h && (d = d.substr(h + 2, d.length));
/(?:F|f)ile:|(?:I|i)mage:/.test(d) || (d = d.split("|")[0],
d = d.split("#")[0], d = $.trim(d), 0 === d.length || /[஀-௿]+/.test(d) || /^\d+$/g.test(d) || -1 != c.indexOf(d) || (c.push(d), r(d)))
}
0 === e ? myMsgBx.appendWrite("<br/>நிறைவுற்றது: தகுந்த இணைப்புகள் ஏதுமில்லை") : (myMsgBx.appendWrite("<br/>விக்கி இணைப்புகளின் எண்ணிக்கை: " +
e), $(".msgDisplay_floatingMenu").hide(), txt.attr("readonly", "readonly"), txt.css({
"background-color": "#F0F0F0"
}), document.body.style.cursor = "wait")
} else myMsgBx.appendWrite("<span style='display:block;background:#fed;'>விக்கி இணைப்புகள் ஏதுமில்லை</span>")
}
}
}
},
pref: {
labelMsg: "பிற மொழி விக்கியின் குறியீட்டினை மாற்ற",
type: "button",
icon: "//upload.wikimedia.org/wikipedia/commons/thumb/1/11/Preferences-system.svg/200px-Preferences-system.svg.png",
action: {
type: "callback",
execute: function(a) {
a = prompt("எந்த மொழி விக்கிப்பீடியாவிலிருந்து இணைப்புகளைப் பெறவேண்டும்? \n\n(சுருக்கக் குறியீடு மட்டும்)",
getCookie(langCookie));
null != a && "" != a && setCookie(langCookie, a, 365)
}
}
}
}
}
}
}
}
});
var m = function(a) {
a.focus();
var c = 0,
b = 0,
d, h, e;
"number" == typeof a.selectionStart && "number" ==
typeof a.selectionEnd ? (c = a.selectionStart, b = a.selectionEnd) : (h = document.selection.createRange()) && h.parentElement() == a && (e = a.value.length, d = a.value.replace(/\r\n/g, "\n"), b = a.createTextRange(), b.moveToBookmark(h.getBookmark()), a = a.createTextRange(), a.collapse(!1), -1 < b.compareEndPoints("StartToEnd", a) ? c = b = e : (c = -b.moveStart("character", -e), c += d.slice(0, c).split("\n").length - 1, -1 < b.compareEndPoints("EndToEnd", a) ? b = e : (b = -b.moveEnd("character", -e), b += d.slice(0, b).split("\n").length - 1)));
return {
start: c,
end: b
}
},
e = 0,
p = !1,
r = function(a) {
e++;
null == getCookie(langCookie) && setCookie(langCookie, "en", 365);
$.ajax({
url: "//" +
getCookie(langCookie) + ".wikipedia.org/w/api.php?action=query&format=json&callback=?",
dataType: "json",
type: "GET",
cache: !0,
data: {
prop: "langlinks",
lllang: "hi",
titles: a,
redirects: ""
},
beforeSend: function() {
myMsgBx.appendWrite("<span id='" + a + "' style='display:block;background:#FFFCC5;' >" + e + "." + a + " </span>")
}
}).done(function(c) {
p = !0;
var b = $("<p />").html("<span class='a' id='" + a + "'></span>").find(".a").attr("id"),
b = $("#msgDisplay_interWikiLinker > [id='" + b + "']");
try {
for (var d in c.query.pages) {
wikitext =
c.query.pages[d].langlinks[0]["*"];
wikitext = $.trim(wikitext);
0 < wikitext.length && (a = a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), txt.val(txt.val().replace(RegExp("\\[\\[" + a + "( *)(\\]\\]|\\||#)", "gi"), "[[" + wikitext + "$1$2")), b.append(" »» " + wikitext + " (ஆயிற்று)").css("background", "#efd"));
break
}
} catch (e) {
b.append(" »» இணைப்பில்லை (" + e.message + ")").css("background", "#fed")
}
}).always(function() {
e--;
0 === e && (txt.removeAttr("readonly"), txt.css({
"background-color": "#FFFFFF"
}), document.body.style.cursor = "default", $(".msgDisplay_floatingMenu").show(), myMsgBx.appendWrite("<span style='display:block;background:#EFD;'>நிறைவுற்றது</span>"))
});
setTimeout(function() {
p || 0 == e || (alert1('தரவு வழங்கல் பிழை. உங்கள் பிற மொழி விக்கியின் குறியீட்டினை <a href="//' +
getCookie(langCookie) + '.wikipedia.org" target="_blank">சரிபார்க்கவும்</a>.', 1.5, "#fed"), txt.removeAttr("readonly"), txt.css({
"background-color": "#FFFFFF"
}), document.body.style.cursor = "default", $(".msgDisplay_floatingMenu").show(), e = 0)
}, 1E4)
}
}; - 1 !== $.inArray(mw.config.get("wgAction"), ["edit", "submit"]) && mw.loader.using("user.options", function() {
mw.user.options.get("usebetatoolbar") && (mw.loader.using("ext.wikiEditor.toolbar", function() {
$(document).ready(customizeToolbar)
}), $.ajax({
url: "//en.wikipedia.org/w/index.php?title=User:V111P/js/msgDisplay.js&action=raw&ctype=text/javascript",
dataType: "script",
cache: !0
}).done(function() {
null == getCookie(langCookie) && setCookie(langCookie, "en", 365);
myMsgBx = mediaWiki.libs.msgDisplay("interWikiLinker").config({
insertRelTo: "#wikiEditor-ui-toolbar",
insertRel: "append"
});
alert1("", "1", "#FFFCC5");
$(".msgDisplay_floatingMenu").prepend("<small>Close </small>»»»");
$(".msgDisplay_menuButton").remove();
$(".msgDisplay_okButton").remove();
$(".msgDisplay_helpLink").remove();
$(".msgDisplay_upButton").remove();
$(".msgDisplay_expandedSection").removeClass("msgDisplay_expandedSection").addClass("msgDisplay_menuButton");
myMsgBx.remove()
}))
});
 
//==================== Article sectioning =============================
function setCookie(g, m, k) {
'==संदर्भ==': '==References==',
k = "undefined" === k ? 30 : k;
'==बाहरी कड़ियाँ==': '==External links==',
var n = new Date;
'==इतिहास==': '==History==',
n.setTime(n.getTime() + 864E5 * k);
'== संदर्भ ==': '== References ==',
document.cookie = g + "=" + m + ";expires=" + n.toUTCString() + ";path=/"
'== इतिहास ==': '== History ==',
}
'== बाहरी कड़ियाँ ==': '== External links ==',
'== यह भी देखें ==': '== See also ==',
'==यह भी देखें==': '==See also==',
};
 
//Custom Script:
function getCookie(g) {
return (g = document.cookie.match("(^|;) ?" + g + "=([^;]*)(;|$)")) ? g[2] : null
}
 
function setCookie(e,t,n){n="undefined"===n?30:n;var r=new Date;r.setTime(r.getTime()+864e5*n);document.cookie=e+"="+t+";expires="+r.toUTCString()+";path=/"}function getCookie(e){return(e=document.cookie.match("(^|;) ?"+e+"=([^;]*)(;|$)"))?e[2]:null}function alert1(e,t,n){myMsgBx.config({height:t+"em",background:n}).show().append(e).write()}var txt,myMsgBx,langCookie="iwtLangPref",customizeToolbar=function(){txt=$("#wpTextbox1");txt.wikiEditor("addToToolbar",{sections:{interWikiLinker:{type:"toolbar",label:"InterWiki Translator",groups:{tamSorting:{tools:{searchReplaceList:{labelMsg:"விருப்பப் பட்டியலில் இருக்கும் சொற்களைத் தேடிக்கண்டுபிடித்து மாற்றவும்",type:"button",icon:"//upload.wikimedia.org/wikipedia/commons/thumb/1/17/System-search.svg/200px-System-search.svg.png",action:{type:"callback",execute:function(e){if(0===t)if("undefined"==typeof replaceList){var n="",n="undefined"!=typeof en_words?'IWTஇல் மாற்றங்கள் செய்யப்பட்டுள்ளன. உங்கள் விருப்பப்பட்டியலை புதுப்பிக்கவும் «<small><a href="//ta.wikipedia.org/wiki/பயனர்:Jayarathina/iwt#Replace_list_of_predefined_words">மேலும் அறிய</a></small>»':"விருப்பப் பட்டியல் கொடுக்கப்படவில்லை";alert1(n,1.5,"#fed")}else{e=txt.val();for(n in replaceList)e=e.replace("string"!==typeof replaceList[n]?RegExp(replaceList[n]):RegExp(replaceList[n],"gi"),n);txt.val(e);alert1("நிறைவுற்றது",1.5,"#efd")}}}}}},linker:{tools:{interWikiLink:{labelMsg:"பிற மொழி விக்கி இணைப்புகளுக்கு இணையான தமிழ் விக்கி இணைப்புகளைத் தேடிக்கண்டுபிடித்து மாற்றவும்",type:"button",icon:"//upload.wikimedia.org/wikipedia/commons/thumb/2/20/Go-jump.svg/200px-Go-jump.svg.png",action:{type:"callback",execute:function(i){if(0===t){i=e(txt[0]);var s=txt.val();i.start!=i.end?(s=s.slice(i.start,i.end),alert1("தேர்வு செய்யப்பட்ட உரையின் இணைப்புகளுக்கு மட்டும் ","10","#E0EEF7")):alert1("","10","#E0EEF7");myMsgBx.appendWrite("கருவி இயங்குகின்றது.... காத்திருக்கவும்...");if(i=s.match(/\[\[([^\]]+(?:[^|\]]*\|)?)\]\]/gmi)){t=0;n=!1;for(var s=[],o=0;o<i.length;o++){var u=i[o].substr(2,i[o].length-4),a=u.indexOf("[[");-1<a&&(u=u.substr(a+2,u.length));/(?:F|f)ile:|(?:I|i)mage:/.test(u)||(u=u.split("|")[0],u=u.split("#")[0],u=$.trim(u),0===u.length||/[஀-௿]+/.test(u)||/^\d+$/g.test(u)||-1!=s.indexOf(u)||(s.push(u),r(u)))}0===t?myMsgBx.appendWrite("<br/>நிறைவுற்றது: தகுந்த இணைப்புகள் ஏதுமில்லை"):(myMsgBx.appendWrite("<br/>விக்கி இணைப்புகளின் எண்ணிக்கை: "+t),$(".msgDisplay_floatingMenu").hide(),txt.attr("readonly","readonly"),txt.css({"background-color":"#F0F0F0"}),document.body.style.cursor="wait")}else myMsgBx.appendWrite("<span style='display:block;background:#fed;'>விக்கி இணைப்புகள் ஏதுமில்லை</span>")}}}},pref:{labelMsg:"பிற மொழி விக்கியின் குறியீட்டினை மாற்ற",type:"button",icon:"//upload.wikimedia.org/wikipedia/commons/thumb/1/11/Preferences-system.svg/200px-Preferences-system.svg.png",action:{type:"callback",execute:function(e){e=prompt("எந்த மொழி விக்கிப்பீடியாவிலிருந்து இணைப்புகளைப் பெறவேண்டும்? \n\n(சுருக்கக் குறியீடு மட்டும்)",getCookie(langCookie));null!=e&&""!=e&&setCookie(langCookie,e,365)}}}}}}}}});var e=function(e){e.focus();var t=0,n=0,r,i,s;"number"==typeof e.selectionStart&&"number"==typeof e.selectionEnd?(t=e.selectionStart,n=e.selectionEnd):(i=document.selection.createRange())&&i.parentElement()==e&&(s=e.value.length,r=e.value.replace(/\r\n/g,"\n"),n=e.createTextRange(),n.moveToBookmark(i.getBookmark()),e=e.createTextRange(),e.collapse(!1),-1<n.compareEndPoints("StartToEnd",e)?t=n=s:(t=-n.moveStart("character",-s),t+=r.slice(0,t).split("\n").length-1,-1<n.compareEndPoints("EndToEnd",e)?n=s:(n=-n.moveEnd("character",-s),n+=r.slice(0,n).split("\n").length-1)));return{start:t,end:n}},t=0,n=!1,r=function(e){t++;null==getCookie(langCookie)&&setCookie(langCookie,"en",365);$.ajax({url:"//"+getCookie(langCookie)+".wikipedia.org/w/api.php?action=query&format=json&callback=?",dataType:"json",type:"GET",cache:!0,data:{prop:"langlinks",lllang:"hi",titles:e,redirects:""},beforeSend:function(){myMsgBx.appendWrite("<span id='"+e+"' style='display:block;background:#FFFCC5;' >"+t+"."+e+" </span>")}}).done(function(t){n=!0;var r=$("<p />").html("<span class='a' id='"+e+"'></span>").find(".a").attr("id"),r=$("#msgDisplay_interWikiLinker > [id='"+r+"']");try{for(var i in t.query.pages){wikitext=t.query.pages[i].langlinks[0]["*"];wikitext=$.trim(wikitext);0<wikitext.length&&(e=e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),txt.val(txt.val().replace(RegExp("\\[\\["+e+"( *)(\\]\\]|\\||#)","gi"),"[["+wikitext+"$1$2")),r.append(" »» "+wikitext+" (ஆயிற்று)").css("background","#efd"));break}}catch(s){r.append(" »» இணைப்பில்லை ("+s.message+")").css("background","#fed")}}).always(function(){t--;0===t&&(txt.removeAttr("readonly"),txt.css({"background-color":"#FFFFFF"}),document.body.style.cursor="default",$(".msgDisplay_floatingMenu").show(),myMsgBx.appendWrite("<span style='display:block;background:#EFD;'>நிறைவுற்றது</span>"))});setTimeout(function(){n||0==t||(alert1('தரவு வழங்கல் பிழை. உங்கள் பிற மொழி விக்கியின் குறியீட்டினை <a href="//'+getCookie(langCookie)+'.wikipedia.org" target="_blank">சரிபார்க்கவும்</a>.',1.5,"#fed"),txt.removeAttr("readonly"),txt.css({"background-color":"#FFFFFF"}),document.body.style.cursor="default",$(".msgDisplay_floatingMenu").show(),t=0)},1e4)}};-1!==$.inArray(mw.config.get("wgAction"),["edit","submit"])&&mw.loader.using("user.options",function(){mw.user.options.get("usebetatoolbar")&&(mw.loader.using("ext.wikiEditor.toolbar",function(){$(document).ready(customizeToolbar)}),$.ajax({url:"//en.wikipedia.org/w/index.php?title=User:V111P/js/msgDisplay.js&action=raw&ctype=text/javascript",dataType:"script",cache:!0}).done(function(){null==getCookie(langCookie)&&setCookie(langCookie,"en",365);myMsgBx=mediaWiki.libs.msgDisplay("interWikiLinker").config({insertRelTo:"#wikiEditor-ui-toolbar",insertRel:"append"});alert1("","1","#FFFCC5");$(".msgDisplay_floatingMenu").prepend("<small>Close </small>»»»");$(".msgDisplay_menuButton").remove();$(".msgDisplay_okButton").remove();$(".msgDisplay_helpLink").remove();$(".msgDisplay_upButton").remove();$(".msgDisplay_expandedSection").removeClass("msgDisplay_expandedSection").addClass("msgDisplay_menuButton");myMsgBx.remove()}))});
function alert1(g, m, k) {
 
myMsgBx.config({
// Original Script URL:
height: m + "em",
// importScriptURI('//ta.wikipedia.org/w/index.php?title=User:Jayarathina/iwt.js&action=raw&ctype=text/javascript');
background: k
importScript('User:Js/ajaxPreview.js'); // [[user:js/ajaxPreview]]
}).show().append(g).write()
}