FlightGear wiki:Instant-Refs: Difference between revisions

Jump to navigation Jump to search
m
→‎The Script: directly copy to the clipboard using the corresponding greasemonkey API (may need to be genralized if used with TamperMonkey)
m (→‎The Script: directly copy to the clipboard using the corresponding greasemonkey API (may need to be genralized if used with TamperMonkey))
Line 90: Line 90:


<syntaxhighlight lang="javascript" enclose="div">
<syntaxhighlight lang="javascript" enclose="div">
// ==UserScript==
// ==UserScript==
// @name        Instant-Cquotes
// @name        Instant-Cquotes
// @version    0.19
// @version    0.20
// @description Automatically converts mailing list and forum quotes into Mediawiki markup.
// @description Automatically converts mailing list and forum quotes into Mediawiki markup.
// @author      Hooray, bigstones, Philosopher & Red Leader
// @author      Hooray, bigstones, Philosopher & Red Leader
Line 105: Line 106:
// @grant      GM_addStyle
// @grant      GM_addStyle
// @grant      GM_getResourceText
// @grant      GM_getResourceText
// @grant      GM_setClipboard
// @noframes
// @noframes
// ==/UserScript==
// ==/UserScript==
Line 185: Line 187:
   }
   }
};
};
// this being a greasemonkey user-script, we are not
// subject to usual browser restrictions
function setClipboard(msg) {
  // http://wiki.greasespot.net/GM_setClipboard
  GM_setClipboard(msg);
}
var METHODS = {
var METHODS = {
   // Shows a window.prompt() message box
   // Shows a window.prompt() message box
   msgbox: function (msg) {
   msgbox: function (msg) {
     window.prompt('Copy to clipboard', msg);
     window.prompt('Copy to clipboard', msg);
    setClipboard(msg);
   },
   },
   // Show a jQuery dialog
   // Show a jQuery dialog
Line 202: Line 214:
           text: 'Select all',
           text: 'Select all',
           click: function () {
           click: function () {
            setClipboard(msg);
             $('#quotedtext').select();
             $('#quotedtext').select();
           }
           }
Line 208: Line 221:
           text: 'OK',
           text: 'OK',
           click: function () {
           click: function () {
            setClipboard(msg);
             $(this).dialog('close');
             $(this).dialog('close');
           }
           }

Navigation menu