מדיה ויקי:Gadget-TemplatesExternalLinks.js: הבדלים בין גרסאות בדף

מ משתמש:קיפודנחש/vector.js/templatesPopup.js הועבר למשתמש:קיפודנחש/common.js/templatesPopup.js: התווסף לממשק הכללי (common) - נחסוך קצת כאב לבודקים הנאמנים, שלא ירא...
שורה 1: שורה 1:
//Adds wizard for using templates for external links
//אשף תבניות קישורים
//Written by [[User:קיפודנחש]]
 
function createTemplate(doc) {
function createTemplate(doc) {
var par = ["{{" + doc.templateName];
var par = ["{{" + doc.templateName];
שורה 18: שורה 16:
return target;
return target;
}
}
 
function knownLinkTemplates() {
function knownLinkTemplates() {
var constants = ["",
var constants = ["",
שורה 67: שורה 65:
"שם המין/זן"
"שם המין/זן"
];
];
 
var templatesDic = {
var templatesDic = {
"הארץ": [1, 2, 3, 4],
"הארץ": [1, 2, 3, 4],
שורה 146: שורה 144:
return templatesDic;
return templatesDic;
}
}
 
function templateRegex(templateName) {
function templateRegex(templateName) {
var regexes = {
var regexes = {
שורה 200: שורה 198:
"העין השביעית": {regex: /the7eye\.org\.il\/([^\/]+)\/Pages\/(.*)\.aspx/, params: [5,3]}
"העין השביעית": {regex: /the7eye\.org\.il\/([^\/]+)\/Pages\/(.*)\.aspx/, params: [5,3]}
}
}
// these guys are all the same - it's best to handle them as such.
// these guys are all the same - it's best to handle them as such.
var historic = {"דבר": "DAV", "מעריב": "MAR", "הצבי": "HZV", "הצפירה": "HZF", "המגיד": "MGD", "המליץ": "HMZ", "חבצלת": "HZT", "PalPost": "PLS"};
var historic = {"דבר": "DAV", "מעריב": "MAR", "הצבי": "HZV", "הצפירה": "HZF", "המגיד": "MGD", "המליץ": "HMZ", "חבצלת": "HZT", "PalPost": "PLS"};
שורה 213: שורה 211:
return regexes[templateName];
return regexes[templateName];
}
}
 
function popupPredefinedLinkTemplate(templateName, paramList, regexDict) {
function popupPredefinedLinkTemplate(templateName, paramList, regexDict) {
var height = 160 + 20 * paramList.length + (regexDict ? 60 : 0);
var height = 160 + 20 * paramList.length + (regexDict ? 60 : 0);
שורה 292: שורה 290:
doc.refCheckBox.onchange();
doc.refCheckBox.onchange();
}
}
 
function fireLinkTemplatePopup(templateName) {
function fireLinkTemplatePopup(templateName) {
var linkTemplates = knownLinkTemplates();
var linkTemplates = knownLinkTemplates();
שורה 299: שורה 297:
popupPredefinedLinkTemplate(templateName, templateParams, templateRegex(templateName));
popupPredefinedLinkTemplate(templateName, templateParams, templateRegex(templateName));
}
}
 
function createSortedTemplatesList() {
function createSortedTemplatesList() {
var fullList = knownLinkTemplates();
var fullList = knownLinkTemplates();
שורה 312: שורה 310:
return hnames.concat(names);
return hnames.concat(names);
}
}
 
function createLinkTemplatesSelections() {
function createLinkTemplatesSelections() {
var select = document.createElement("select");
var select = document.createElement("select");
שורה 328: שורה 326:
toolbar.appendChild(select);
toolbar.appendChild(select);
}
}
 
function updatePreview() { this.doc.previewNode.data = createTemplate(this.doc); }
function updatePreview() { this.doc.previewNode.data = createTemplate(this.doc); }
 
function advancedFire(context) {
function advancedFire(context) {
fireLinkTemplatePopup(this.template);
fireLinkTemplatePopup(this.template);
}
}
 
function createAdvanceToolKit() {
function createAdvanceToolKit() {
     var gadget = {label: 'אשף תבניות קישורים', type: 'select', list: []};
     var gadget = {label: 'אשף תבניות קישורים', type: 'select', list: []};
שורה 346: שורה 344:
});
});
}
}
 
if (typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined')
if (typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined')
$j(document).ready(createAdvanceToolKit);
$j(document).ready(createAdvanceToolKit);
if (wgAction == 'edit')
if (wgAction == 'edit')
hookEvent("load", createLinkTemplatesSelections);
hookEvent("load", createLinkTemplatesSelections);