مستخدم:Ziad/backup.js
![]() | يمكن توفير توثيق لسكربت المستخدم هذا في الصفحة : مستخدم:Ziad/backup. |
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.
<nowiki>// define custom buttons (id, class, popup title, image src, width, height, alt text, onClick and parameters)
var wikEdConfig = {};
wikEdConfig.button = [];
wikEdConfig.button[100] = ['wikEdDiv', 'wikEdButton', 'Make the selection a html DIV element', 'http://www.onedesigns.com/support/my-plugins/support-forum/images/support-forum-no.png', '16', '16', 'DIV', 'javascript:WikEdEditButton(this, this.id, null, TestHandler);' ];
wikEdConfig.button[101] = ['wikEdtemplate', 'wikEdButton', 'This is a test button', 'http://cdn1.iconfinder.com/data/icons/fatcow/16x16_0780/script_code.png', '16', '16', 'Test', 'javascript:WikEdEditButton(this, this.id, null, wiki);' ];
wikEdConfig.button[102] = ['wikEdyyy', 'wikEdButton', 'This is a test button', 'http://cdn1.iconfinder.com/data/icons/Vista-Inspirate_1.0/16x16/mimetypes/template_source.png', '16', '16', 'Test', 'javascript:WikEdEditButton(this, this.id, null,yyy );' ];
// define custom button bars (id outer, class outer, id inner, class inner, height, grip title, button numbers)
wikEdConfig.buttonBar = {};
wikEdConfig.buttonBar.custom1 = ['wikEdButtonBarCustom1', 'wikEdButtonBarCustom1', 'wikEdButtonsCustom1', 'wikEdButtonsCustom1', 44, 'My custom buttons', [100, 102, 'br', 101] ];
// define the function which is called upon clicking the custom button
// this example code adds or removes div tags around the selected text
function TestHandler(obj) {
// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
// focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
}
else {
obj.changed = obj.cursor;
}
// make the changes to the plain target text
// remove the previously added formatting
if ( /{{شطب|(.*?)&}}/i.test(obj.changed.plain) ) {
obj.changed.plain = obj.changed.plain.replace(/{{شطب|(.*?)}}/gi, '$1');
}
// add the text formatting
else {
obj.changed.plain = '{{شطب|' + obj.changed.plain + '}}';
}
// keep the changed text selected, needed to remove the formatting with a second custom button click
obj.changed.keepSel = true;
return;
}
function yyy(obj){
// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
// focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
}
else {
obj.changed = obj.cursor;
}
// make the changes to the plain target text
// remove the previously added formatting
if ( /{{(.*?)}}/i.test(obj.changed.plain) ) {
obj.changed.plain = obj.changed.plain.replace(/{{(.*?)}}/gi, '$1');
}
// add the text formatting
else {
obj.changed.plain = '{{' + obj.changed.plain + '}}';
}
// keep the changed text selected, needed to remove the formatting with a second custom button click
obj.changed.keepSel = true;
return;
}
function wiki(obj){
// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
// focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
}
else {
obj.changed = obj.cursor;
}
// make the changes to the plain target text
// remove the previously added formatting
if ( /{{ويكي(.*?)}}/i.test(obj.changed.plain) ) {
obj.changed.plain = obj.changed.plain.replace(/{{ويكي(.*?)}}/gi, '$1');
}
// add the text formatting
else {
obj.changed.plain = '{{ويكي}}';
}
// keep the changed text selected, needed to remove the formatting with a second custom button click
obj.changed.keepSel = true;
return;
}</nowiki>