מדיה ויקי:Gadget-tasks.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload), או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh), או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
$( function() { var page = 'משתמש:' + mw.config.get('wgUserName') + '/משימות'; function showPage(e) { e.preventDefault(); mw.loader.using( ['mediawiki.api'] ).then( function() { new mw.Api({ ajax: { cache: false } }).get( { action: 'parse', page: page, smaxage: 0, disableeditsection: true } ).done( function( data ) { if ( data && data.parse && data.parse.text && data.parse.text['*'] ) showContent( page, data.parse.text['*'] ); } ); // parse returned } ); // using api returned } // showpage.sho function showRaw() { $.ajax( { url: mw.util.wikiScript(), data: { action: 'raw', title: page }, dataType: 'text' } ).done( function( data ) { showContent( page, data, true ); } ); } function showContent( title, content, raw ) { mw.loader.using( [ 'jquery.ui', 'mediawiki.api' ] ).then( function() { var dialog, api = new mw.Api({ ajax: { cache: false } }), inside = raw ? $( '<textarea>' ) .attr( { raws: 25, resize: true } ) .val( content ) .css( { 'width': $('body').width() * (window.my_93_width || 0.8), 'height' : $('body').height() * (window.my_93_height || 0.8), overflow: 'auto' } ) : $( '<div>' ) .css( { 'max-width': $('body').width() * 0.9, 'max-height' : $('body').height() * 0.8, overflow: 'auto' } ) .append( content ), buttons = [ {text: 'שמירה וסגירה', click: doSaveClose} ], buttons1 = [ {text: 'עריכה', click: doEdit} ]; function doSaveClose() { api.postWithEditToken( { action: 'edit', title: title, text: inside.val(), smaxage: 0, summary: dialog.find('input').val() || "גאדג'ט משימות" } ).done(function(d) { if (d && d.edit && d.edit.result == 'Success') mw.notify('הדף עודכן בהצלחה!'); }); dialog.dialog( 'close' ); } function doEdit() { showRaw(); dialog.dialog( 'close' ); } dialog = $( '<div>' ) .dialog( { title: title, width: 'auto', height: 'auto', position: [$('body').width() * 0.05, $('body').height() * 0.05], buttons: raw ? buttons : buttons1 } ) .append( inside ); if (raw) {dialog.append('<form><input type="text" placeholder="תקציר עריכה חלופי"' + ' style="width:95%;margin:10px 3px 0;" title="כברירת מחדל יירשם גאדג\'ט משימות"/></form>'); } } ); // using dialog returned } $( mw.util.addPortletLink( 'p-personal', '#', 'משימות' , 'pt-remainder', '', '', '#pt-mytalk') ) .click( showPage ); } );