מדיה ויקי:Gadget-TemplatesExternalLinks.js: הבדלים בין גרסאות בדף
ויקישיבה |
סידור. |
||
| שורה 27: | שורה 27: | ||
b.urlInput.type = "text"; | b.urlInput.type = "text"; | ||
b.urlInput.maxLength = 600; | b.urlInput.maxLength = 600; | ||
b.urlInput.style.width = " | b.urlInput.style.width = "12em"; | ||
body.appendChild(b.urlInput); | body.appendChild(b.urlInput); | ||
b.type = "button"; | b.type = "button"; | ||
b.value = "חילוץ פרמטרים | b.value = "חילוץ פרמטרים מהקישור"; | ||
b.regexDict = regexDict; | b.regexDict = regexDict; | ||
b.doc = doc; | b.doc = doc; | ||
| שורה 94: | שורה 94: | ||
body.appendChild(b); | body.appendChild(b); | ||
} | } | ||
function knownLinkTemplates() { | function knownLinkTemplates() { | ||
var constants = [ | var constants = [ | ||
| שורה 240: | שורה 200: | ||
"דעת":[1,39,27], | "דעת":[1,39,27], | ||
"ויקישיבה":["שם הערך בויקישיבה"], | "ויקישיבה":["שם הערך בויקישיבה"], | ||
}; | }; | ||
for (var key in templatesDic) | for (var key in templatesDic) | ||
| שורה 306: | שורה 263: | ||
return regexes[templateName]; | return regexes[templateName]; | ||
} | } | ||
function fireLinkTemplatePopup(templateName) { | |||
var linkTemplates = knownLinkTemplates(); | |||
var templateParams = linkTemplates[templateName]; | |||
if (templateParams && templateParams.constructor == Array && templateParams.length > 0) | |||
popupPredefinedLinkTemplate(templateName, templateParams, templateRegex(templateName)); | |||
} | |||
function createLinkTemplatesSelections() { | |||
var select = document.createElement("select"); | |||
select.id = "linkTemplatesList"; | |||
select.onchange = function() { | |||
fireLinkTemplatePopup(this.value); | |||
this.selectedIndex = 0; | |||
return false; | |||
} | |||
var fullList = knownLinkTemplates(); | |||
var names = [], hnames = []; | |||
var re = /[a-zA-Z]/; | |||
for (x in fullList) | |||
if (re.test(x.charAt(0))) | |||
names.push(x); | |||
else | |||
hnames.push(x); | |||
hnames.sort(); | |||
names.sort(function(a,b){var la=a.toLowerCase(),lb=b.toLowerCase();return la>lb?1:la<lb?-1:0;}); | |||
var allnames = hnames.concat(names); | |||
select.options.add(new Option("אשף תבניות", "")); | |||
for (var i = 0; i < allnames.length; i++) | |||
select.options.add(new Option(allnames[i], allnames[i])); | |||
var toolbar = document.getElementById("toolbar"); | |||
if (toolbar) | |||
toolbar.appendChild(select); | |||
} | |||
if (wgAction == 'edit') | |||
addOnloadHook(createLinkTemplatesSelections); | |||