Jump to content

မီႇတီႇယႃႇဝီႇၶီႇ:Common.js/w/Wikibooks:Dialog

လုၵ်ႉတီႈ ဝီႇၶီႇပပ်ႉ မႃး

/* For [[]]. See Special:WhatLinksHere/w/Wikibooks:Dialog. */

if (location.search) {

   function converterVersion() { return '0.3 (2015-11-06)'; }
   function showHere(content) {
       $('div.wikidialog-url-converter').replaceWith(

'

' + content + '

');

   }
   function wikidialogShow(callback) {
       if (('wikidialog' in window) && ('show' in window.wikidialog)) {
           window.wikidialog.show();
           if (callback) callback();
       }
       else $.getScript( // MediaWiki:Gadget-wikidialog.js
           mw.config.get('wgScript') + '?title=' + mw.util.wikiUrlencode('MediaWiki:Gadget-wikidialog.js') +
                                       '&action=raw&ctype=text/javascript',
           function () {
               if (callback) callback();
           }
       );
   }
   function safeHtml(s) { // just being safe; note, ampersands would mess up formatting
       return s.replace(/\</g,).replace(/\>/g,);
   };
   function getQueryParams() {
       var q = location.search.substring(1).split(/[&]/);
       var result = {};
       for (var k=0; k<q.length; k++) {
           var j = q[k].search('=');
           if (j > 0) result[safeHtml(q[k].substring(0,j))] = safeHtml(q[k].substring(j+1));
       }
       return result;
   }
   var queryParams = getQueryParams();
   if (! ('dialog-action' in queryParams)) showHere('Missing query dialog-action parameter.');
   else {
       //
       // assemble html
       //
       var fields = ;
       var button = 'action=' + queryParams['dialog-action'] +
                                                                         '&label=' + queryParams['dialog-action']; // Template:Dialog/button
       var summary = ;
       for (var p in queryParams) {
           if (p == 'dialog-action') continue;
           if (p == 'dialog-confirm') continue;
           if (p == 'wikidialogrolledback') continue;
           if (p == 'wikidialogid') continue;
           fields += 'cols=&rows=&' + queryParams[p] + ''; // Template:dialog/textarea
           button += '&' + p + ':button-local-field-' + p;

summary += '\n


\n

' + p + ':

\n

' + queryParams[p] + '

';

       }

button += '&' + summary + '



\nUrl converter version ' + converterVersion();

       if (! (('dialog-confirm' in queryParams) || ('wikidialogrolledback' in queryParams)))

button = '

' + button + '

';

       var s = button + fields;
       //
       // deploy
       //
       showHere(s);
       wikidialogShow(function () {
           if (! ('dialog-confirm' in queryParams) || ('wikidialogrolledback' in queryParams))
               $("input.wikidialog-button").click();
           else if ('dialog-confirm' in queryParams)
               $.getScript( // MediaWiki:Dialog/receive
                   mw.config.get('wgScript') + '?title=' + mw.util.wikiUrlencode('MediaWiki:Dialog/receive') +
                                               '&action=raw&ctype=text/javascript',
                   function () { window.wikidialog.purelySelfContained(); }
           );
       });
   }

}