FlightGear wiki:Instant-Refs: Difference between revisions

Jump to navigation Jump to search
output methods, version, enclose
m (Slight fixes + suggestion to remove IE stuff)
(output methods, version, enclose)
Line 68: Line 68:
== The Script ==
== The Script ==
{{Note|This code is put into the public domain, anybody interested in working with/contributing to the code, is invited to directly edit this wiki article.}}
{{Note|This code is put into the public domain, anybody interested in working with/contributing to the code, is invited to directly edit this wiki article.}}
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript" enclose="div">
// ==UserScript==
// ==UserScript==
// @name      Instant-Cquotes
// @name      Instant-Cquotes
Line 74: Line 74:
// @description Automatically converts mailing list and forum quotes into Mediawiki markup.
// @description Automatically converts mailing list and forum quotes into Mediawiki markup.
// @namespace  http://wiki.flightgear.org/
// @namespace  http://wiki.flightgear.org/
// @version    0.12
// @version    0.14
// @icon      http://wiki.flightgear.org/images/6/62/FlightGear_logo.png
// @icon      http://wiki.flightgear.org/images/6/62/FlightGear_logo.png
// @require    http://code.jquery.com/jquery-1.11.1.min.js
// @require    http://code.jquery.com/jquery-1.11.1.min.js
Line 154: Line 154:
var OUTPUT = OutputMethods().msgbox;
var OUTPUT = OutputMethods().msgbox;
   
   
function OutputMethods() {
function OutputMethods(){
     var methods = {
     var methods = {
popup: function(msg){
        // Shows an alert(); message box  
chrome.runtime.sendMessage({authen: "Instant-Cquotes", text: msg});
         msgbox: function(msg){
},
             if (window.prompt("Copy to clipboard: Ctrl+C, Enter", msg) !== null){
        // shows a message box  
         msgbox: function(msg) {
             if (window.prompt ("Copy to clipboard: Ctrl+C, Enter", msg) !== null)
                 window.getSelection().removeAllRanges(); // deselect all text
                 window.getSelection().removeAllRanges(); // deselect all text
            }
         },
         },
 
         // XXX: experimental
         // Show a jQuery UI dialog
        // show msg in a jQuery UI dialog
         jqueryDiag: function(msg){
         jqueryDiag: function(msg) {
             var diagDiv = $('<div id="MyDialog"><textarea id="quotedtext" rows="10" cols="80" style="width: 290px; height: 290px">' + msg + '</textarea></div>');
             var diagDiv = $('<div id="MyDialog"><textarea id="quotedtext" rows="10" cols="80" readonly>' + msg + '</textarea></div>');
 
             var diagParam = {
             var diagParam = { title: "Copy your quote with CTRL-C",
                title: "Copy your quote with Ctrl-c",
                              modal: true,
                modal: true,
                              buttons: [{ text: "Select all", click: function () { $('quotedtext').select(); } },
                width: 'auto',
                                        { text: "Cancel", click: function () { $(this).dialog("close"); } }]
                buttons: [
                    { text: "Select all", click: function(){ $('#quotedtext').select(); } },
                    { text: "Cancel", click: function(){ $(this).dialog('close'); } }
                ]
             };
             };
 
             diagDiv.dialog(diagParam);
             diagDiv.dialog(diagParam);
         }
         },
     };
     };
 
     return methods;
     return methods;
};
};

Navigation menu