Difference between revisions of "MediaWiki:Vector.js"

From Korean Wiki Project
Jump to: navigation, search
(testing to see if this is the way to edit the toolbar)
 
 
(15 intermediate revisions by one user not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for users using the Vector skin */
 
/* Any JavaScript here will be loaded for users using the Vector skin */
 
// <pre>
 
// <pre>
+
 
 
//SAL
 
//SAL
 
//inc("Utente:IPork/SAL.js");
 
//inc("Utente:IPork/SAL.js");
Line 15: Line 15:
 
'tools': {
 
'tools': {
 
'Ac': {
 
'Ac': {
label: 'AutoreCitato',
+
label: 'Underline text',
 
type: 'button',
 
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/6/6d/Button_AC.png',
+
icon: 'http://koreanwikiproject.com/wiki/images/Underline_button.png',
 
action: {
 
action: {
 
type: 'encapsulate',
 
type: 'encapsulate',
 
options: {
 
options: {
pre: "{{AutoreCitato||",
+
pre: "<u>",
post: "}}"
+
post: "</u>"
 
}
 
}
 
}
 
}
Line 33: Line 33:
 
'tools': {
 
'tools': {
 
'Center': {
 
'Center': {
label: 'Centra',
+
label: 'Skyblue font',
 
type: 'button',
 
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png',
+
icon: 'http://koreanwikiproject.com/wiki/images/Skyblue_font_button.png',
 
action: {
 
action: {
 
type: 'encapsulate',
 
type: 'encapsulate',
 
options: {
 
options: {
pre: "{{Centrato||",
+
pre: "<font color=DeepSkyBlue>",
post: "}}"
+
post: "</font>"
 
}
 
}
 
}
 
}
Line 51: Line 51:
 
'tools': {
 
'tools': {
 
'Section': {
 
'Section': {
label: 'Sezione',
+
label: 'Pink font',
 
type: 'button',
 
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/4/44/Button_comillas_latinas.png',
+
icon: 'http://koreanwikiproject.com/wiki/images/Pink_font_button.png',
 
action: {
 
action: {
 
type: 'encapsulate',
 
type: 'encapsulate',
 
options: {
 
options: {
pre: "<section begin=1 />",
+
pre: "<font color=deeppink>",
post: "<section begin=1 />"
+
post: "</font>"
 
}
 
}
 
}
 
}
Line 64: Line 64:
 
}
 
}
 
} );
 
} );
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
                $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
'section': 'advanced',
 
'section': 'advanced',
 
'group': 'format',
 
'group': 'format',
 
'tools': {
 
'tools': {
'Pt': {
+
'Section': {
label: 'Pt',
+
label: 'Green font',
 
type: 'button',
 
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/4/4b/Button_class_text.png',
+
icon: 'http://koreanwikiproject.com/wiki/images/Green_font_button.png',
 
action: {
 
action: {
 
type: 'encapsulate',
 
type: 'encapsulate',
 
options: {
 
options: {
pre: "{{pt||",
+
pre: "<font color=green>",
post: "}}"
+
post: "</font>"
 +
}
 +
}
 +
}
 +
}
 +
} );
 +
                $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
'section': 'advanced',
 +
'group': 'insert',
 +
'tools': {
 +
'Section': {
 +
label: 'Insert TTMIK top template',
 +
type: 'button',
 +
icon: 'http://koreanwikiproject.com/wiki/images/TTMIK_icon_top.png',
 +
action: {
 +
type: 'encapsulate',
 +
options: {
 +
pre: "{{TTMIK bottom}}",
 +
post: ""
 
}
 
}
 
}
 
}
Line 85: Line 103:
 
} );
 
} );
 
}
 
}
 
/* "Accoppo" il vecchio codice
 
// SEZIONE
 
if (mwCustomEditButtons) {
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
 
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/44/Button_comillas_latinas.png",
 
    "speedTip": "Section",
 
    "tagOpen": '<section begin="1" />',
 
    "tagClose": '<section end="1" />',
 
    "sampleText": "Sezione"};
 
};
 
// AUTORECITATO
 
if (mwCustomEditButtons) {
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
 
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/6/6d/Button_AC.png",
 
    "speedTip": "Autore Citato",
 
    "tagOpen": '{{AutoreCitato||',
 
    "tagClose": '}}',
 
    "sampleText": "Nome autore"};
 
}; */
 
 
// Template TEMPLATE
 
if (mwCustomEditButtons) {
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
 
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/4b/Button_class_text.png",
 
    "speedTip": "pt",
 
    "tagOpen": '{{pt|',
 
    "tagClose": '}}',
 
    "sampleText": "Nome_template"};
 
};
 
 
 
// §
 
if (mwCustomEditButtons) {
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
 
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/e2/Button_%C2%A7.png",
 
    "speedTip": "§",
 
    "tagOpen": '{{§||',
 
    "tagClose": '}}',
 
    "sampleText": "citazione"};
 
};
 
 
 
 
// Template TEMPLATE
 
if (mwCustomEditButtons) {
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
 
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/4b/Button_class_text.png",
 
    "speedTip": "tl",
 
    "tagOpen": '{{tl|',
 
    "tagClose": '}}',
 
    "sampleText": "Nome_template"};
 
};
 
 
 
 
 
//fixOCR
 
// Script di Filippo_V per aggancio di un pulsante a una funzione js qualsiasi
 
 
function pulsantini() {
 
var toolbar = null;
 
toolbar = document.getElementById("toolbar");
 
if (toolbar == null) return;
 
 
addToolbarButton('tb-ocr', 'javascript:postOCR()', 'http://upload.wikimedia.org/wikipedia/commons/9/96/Button_ocr_fix.png', '[postOCR]', 'Corregge gli errori comuni di scansione');
 
addToolbarButton('tb-ocr', 'javascript:apostrofi()','http://upload.wikimedia.org/wikipedia/commons/3/32/Button_apostrophe.PNG', '[apostrofi]', 'Converte gli apostrofi dattilografici in tipografici');;
 
}
 
addLoadEvent(pulsantini);
 
 
 
 
document.write('<script type="text/javascript" src="'
 
            + 'http://en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.js'
 
            + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
 
// <source lang="javascript">
 
 
 
 
// </source>
 
 
/*************
 
*** Regex menu framework
 
*** by [[m:user:Pathoschild]] <http://meta.wikimedia.org/wiki/User:Pathoschild/Scripts/Regex_menu_framework>
 
*** - adds a sidebar menu of user-defined scripts.
 
*************/
 
importScriptURI('http://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');
 
 
/* menu links */
 
// In the function below, add more lines like "regexTool('link text','function_name()')" to add
 
// links to the sidebar menu. The function name is the function defined in rfmscripts() below.
 
function rmflinks() {
 
regexTool('Custom regex','custom()'); // a default tool which performs regex input in a dynamic form           
 
        regexTool('PostOCR','postOCR()');
 
        regexTool('Apostrofi','apostrofi()');
 
        regexTool('A capo','acapo()');
 
 
 
}
 
 
/* scripts */
 
// Below, define the functions linked to from rmflinks() above. These functions can use any JavaScript,
 
// but there is a set of simplified tools documented at
 
// http://meta.wikimedia.org/wiki/User:Pathoschild/Script:Regex_menu_framework .
 
/* sidebar code for use with P/c's Regex code */
 
 
function DNBset() {
 
var editbox = document.getElementsByName('wpTextbox1')[0];
 
editbox.value = editbox.value.replace(/\{\{header\n \| title      \=.+\n \| author    \= \n \| translator \= \n \| section    \= \n \| previous  \= \n \| next      \= \n \| notes      \= \n\}\}\n/, '{{subst:DNBset\n |article= \n |previous= \n |next= \n |volume = \n |contributor = \n |wikipedia = \n |extra_notes= \n |from= \n |to= \n |section= \n}}');
 
}
 
 
function postOCR() {
 
var editbox = document.getElementsByName('wpTextbox1')[0];
 
editbox.value = editbox.value.replace(/'/g, '’')
 
.replace(/’’’/g, '\'\'\'')
 
.replace(/’’/g, '\'\'')
 
.replace(/E’ /g, 'È ')
 
.replace(/v’ /g, 'v’')
 
.replace(/n’ /g, 'n’')
 
.replace(/s’ /g, 's’')
 
.replace(/t’ /g, 't’')
 
.replace(/m’ /g, 'm’')
 
.replace(/l’ /g, 'l’')
 
.replace(/eh’ /g, 'ch’')
 
.replace(/ alia /g, ' alla ')
 
.replace(/ piu /g, ' più ')
 
.replace(/ perche /g, ' perchè ')
 
.replace(/lP/g, 'll’')
 
.replace(/I’/g, 'l’')
 
.replace(/1’/g, 'l’')
 
.replace(/ :/g, ': ')
 
        .replace(/([dlznt])’ /g, "$1’")
 
        .replace(/[(\[] /g, " $1")
 
        .replace(/ \n/g, '\n')
 
.replace(/-\n/g, '')
 
        .replace(/ ,/g, ", ")
 
        .replace(/ ;/g, "; ")
 
        .replace(/ !/g, "! ")
 
        .replace(/ \?/g, "? ")
 
        .replace(/ \./g, ". ")
 
        .replace(/ :/g, ": ")
 
        .replace(/« /g, "«")
 
        .replace(/ »/g, "»")
 
        ;
 
}
 
function apostrofi() {
 
var editbox = document.getElementsByName('wpTextbox1')[0];
 
editbox.value = editbox.value.replace(/'/g, '’')
 
.replace(/’’’/g, '\'\'\'')
 
.replace(/’’/g, '\'\'')
 
 
        ;
 
}
 
function acapo() {
 
var editbox = document.getElementsByName('wpTextbox1')[0];
 
editbox.value = editbox.value.replace(/\n\n/g, '<acapo>')
 
.replace(/-\n/g, '')
 
        .replace(/\n/g, ' ')
 
.replace(/<acapo>/g, '\n\n')
 
.replace(/E’ /g, 'È ')
 
 
        ;
 
}
 
 
 
 
 
//</pre>
 

Latest revision as of 11:04, 28 November 2010

/* Any JavaScript here will be loaded for users using the Vector skin */
// <pre>

//SAL
//inc("Utente:IPork/SAL.js");
 
// PULSANTI ADDIZIONALI per skin Vector :-)
// AutoreCitato: confronta codice sotto con vecchia versione per monobook. La funzione è autonoma, 
// non richiede il caricamento di altri script!
if ( typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined' ) {
	$j(document).ready( function() {
		$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'Ac': {
					label: 'Underline text',
					type: 'button',
					icon: 'http://koreanwikiproject.com/wiki/images/Underline_button.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<u>",
							post: "</u>"
						}
					}
				}
			}
		} );
                $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'Center': {
					label: 'Skyblue font',
					type: 'button',
					icon: 'http://koreanwikiproject.com/wiki/images/Skyblue_font_button.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<font color=DeepSkyBlue>",
							post: "</font>"
						}
					}
				}
			}
		} ); 
                		$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'Section': {
					label: 'Pink font',
					type: 'button',
					icon: 'http://koreanwikiproject.com/wiki/images/Pink_font_button.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<font color=deeppink>",
							post: "</font>"
						}
					}
				}
			}
		} );
                		$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'Section': {
					label: 'Green font',
					type: 'button',
					icon: 'http://koreanwikiproject.com/wiki/images/Green_font_button.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<font color=green>",
							post: "</font>"
						}
					}
				}
			}
		} );
                		$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'insert',
			'tools': {
				'Section': {
					label: 'Insert TTMIK top template',
					type: 'button',
					icon: 'http://koreanwikiproject.com/wiki/images/TTMIK_icon_top.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "{{TTMIK bottom}}",
							post: ""
						}
					}
				}
			}
		} );
 
	} );
}