MediaWiki:Common.js/w/Wikibooks:Dialog/echo
Appearance
| This is the JavaScript for all users. You can propose changes on the discussion page or at the proposals reading room. Errors made here can disrupt Wikibooks. You can test changes in your personal JavaScript first. Due to caching, changes can take up to 31 days before propagating to all users. |
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5;
- Konqueror: simply click the Reload button, or press F5;
- Opera users may need to completely clear their cache in Tools→Preferences.
/* For [[{{evalx|(get-substring (get-arg 3) (+ 1 (length (get-arg 2))))|{{dialog/js prefix}}|{{PAGENAME}}}}]]. See [[Special:WhatLinksHere/{{#titleparts:{{PAGENAME}}||2}}]]. [[Category:Dialog javascript pages|echo]] */
function reservedParams() { return { 'DIALOG-ECHO-VERSION': '0.3 (2015-11-10)' }; }
function primaryVerb() {
function doEcho(actionParams, authData, other) {
function handleRollback() {
$('input.wikidialog-echo-rollback').attr('disabled',true);
if (window.wikidialog.rollback()) return;
alert("Sorry, something's gone wrong; unable to go back using this button.");
$('input.wikidialog-echo-rollback').attr('disabled',false);
}
//
// message at the top
//
var s = '<big><b>Echo dialog data</b></big>';
if (window.wikidialog.canRollback()) {
s += '\n<p>To return to the previous display, use this button: ' +
'<span class="wikidialog-echo-rollback">x</span>' +
'; or the "back" navigation function on your browser.</p>';
}
//
// data fields
//
for (var p in actionParams) {
if (actionParams[p]) {
s += '\n<hr></hr>\n<p><b>' + p + ':</b></p>\n<p><code>' +
window.wikidialog.safeHtml(actionParams[p]) + '</code></p>';
} else {
s += '\n<hr></hr>\n<p><b>' + p + '</b></p>';
}
}
//
// authentication
//
s += '\n<hr></hr>\n<hr></hr>';
s += '\n<p>origin: ' + authData.origin + '<p>';
s += '<p>proxy: ' + authData.proxy + '</p>';
//
// other
//
if (other.length > 0) {
s += '\n<hr></hr>\n<hr></hr>';
for (var k = 0; k < other.length; k++) {
if (k > 0) s += ',';
s += '<br/>' + other[k];
}
}
//
// message at the bottom
//
s += '\n<hr></hr>\n<hr></hr>' +
'To examine dialog states currently stored, you can consult the <a href="' +
mw.util.getUrl(mw.config.get('wgSiteName') + ':Dialog/diagnostic panel') +
'">diagnostic panel</a>; if you have just arrived here, ' +
'the most recently listed dialog state on the panel should be the one ' +
"you got here from. The data set shown here won't be listed on the " +
"panel, but should be accessible using the panel's expert mode.";
//
// show
//
$('div.wikidialog-echo').replaceWith(s);
$('.wikidialog-echo-rollback').replaceWith(function () {
return $(document.createElement('input')).attr('type','button')
.addClass('wikidialog-echo-rollback').val('back')
.attr('title','back').click(handleRollback);
});
}
window.wikidialog.receiveAnonymous(
function () {
var actionParams = this;
var r = reservedParams();
for (var p in r) {
actionParams[p] = r[p];
}
var authData = arguments[0];
var other = [];
for (var k = 1; k < arguments.length; k++) {
other[k - 1] = arguments[k];
}
doEcho(actionParams, authData, other);
}
);
}
$.getScript( // [[MediaWiki:Dialog/receive]]
mw.config.get('wgScript') + '?title=' + mw.util.wikiUrlencode('MediaWiki:Dialog/receive') + '&action=raw&ctype=text/javascript',
primaryVerb
);