מדיה ויקי:Gadget-TemplatesExternalLinks.js: הבדלים בין גרסאות בדף
חילוץ מקישור סטוי של "הארץ" |
מ שינוי של קיפודנחש |
||
| שורה 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]; | ||
| שורה 16: | שורה 18: | ||
return target; | return target; | ||
} | } | ||
function knownLinkTemplates() { | function knownLinkTemplates() { | ||
var constants = ["", | var constants = ["", | ||
| שורה 65: | שורה 67: | ||
"שם המין/זן" | "שם המין/זן" | ||
]; | ]; | ||
var templatesDic = { | var templatesDic = { | ||
"הארץ": [1, 2, 3, 4], | "הארץ": [1, 2, 3, 4], | ||
| שורה 144: | שורה 146: | ||
return templatesDic; | return templatesDic; | ||
} | } | ||
function templateRegex(templateName) { | function templateRegex(templateName) { | ||
var regexes = { | var regexes = { | ||
| שורה 198: | שורה 200: | ||
"העין השביעית": {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"}; | ||
| שורה 211: | שורה 213: | ||
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); | ||
| שורה 290: | שורה 292: | ||
doc.refCheckBox.onchange(); | doc.refCheckBox.onchange(); | ||
} | } | ||
function fireLinkTemplatePopup(templateName) { | function fireLinkTemplatePopup(templateName) { | ||
var linkTemplates = knownLinkTemplates(); | var linkTemplates = knownLinkTemplates(); | ||
| שורה 297: | שורה 299: | ||
popupPredefinedLinkTemplate(templateName, templateParams, templateRegex(templateName)); | popupPredefinedLinkTemplate(templateName, templateParams, templateRegex(templateName)); | ||
} | } | ||
function createSortedTemplatesList() { | function createSortedTemplatesList() { | ||
var fullList = knownLinkTemplates(); | var fullList = knownLinkTemplates(); | ||
| שורה 310: | שורה 312: | ||
return hnames.concat(names); | return hnames.concat(names); | ||
} | } | ||
function createLinkTemplatesSelections() { | function createLinkTemplatesSelections() { | ||
var select = document.createElement("select"); | var select = document.createElement("select"); | ||
| שורה 326: | שורה 328: | ||
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: []}; | ||
| שורה 344: | שורה 346: | ||
}); | }); | ||
} | } | ||
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); | ||