Configuration Dialog

A enhanced configuration dialog for Userscripts.

Version vom 08.02.2019. Aktuellste Version

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greasyforks.org/scripts/45343/668866/Configuration%20Dialog.js

Autor
Devy
Version
0.0.1.20190208100029
Erstellt am
30.04.2018
Letzte Aktualisierung
08.02.2019
Größe
30,9 KB
Lizenz
n/a

Configuration dialog for Grease- and Tampermonkey Userscripts.

More information

Requirements

  • // @grant GM_getValue
  • // @grant GM_setValue
  • JQuery 2.1.1+

Configuration Example

{
    'title': 'Test Window', //Title of the window
    'id': 'settings_window', //ID of the window div

    "theme": "mac/win10/winXP", //Select a theme for the window
    'theme_selector': true, //Show Theme-Selector
    'theme_section_color': true, //Section color matches the window style

    "height": "75", //Initial height in percent
    "width": "75", //Initial width in percent

    'confirm_close': "Ungespeicherte Änderungen. Wirklich verwerfen?", //Confirm message on dialog close without having saved
    'confirm_revert': "Alle Änderungen verwerfen?", //Confirm message for reseting the current changes
    'confirm_reset': "Einstellungen auf Standard zurücksetzen?", //Confirm message for factory reset

    "top": {
        "minimize": "true", //Option to show minimize button
        "maximize": "true", //Option to show maximize button
        "close": "true" //Option to show close button
    },

    "font": {
        "size": "18px",  //Font size of content
        "family": "Consolas" //Font family of content
    },

    "savebutton": "true",  //Display of save button
    "revertbutton": "true", //Display of revert button
    "completeresetbutton": "true", //Display of factory reset button

    'content':
    [
        {
            "type": "p",
            "label": "This is just a normal Text."
        },
        {
            "type": "h1",
            "label": "This ist just a normal header."
        },
        {
            "type": "section",
            "label": "I'm a section",
            "collapsible": true,    //If section should be collapsible
            "collapsed": false      //If section should be collapsed by default
        },
        {
            "type": "subsection",
            "label": "I'm a subsection"
            "collapsible": true,    //If subsection should be collapsible
            "collapsed": false      //If subsection should be collapsed by default
        },
        {
            "label": "Text input field",
            "type": "input",
            "id": "username",
            "default": "default name"
        },
        {
            "label": "Checkbox",
            "type": "checkbox",
            "id": "checkbox",
            "default": false
        },
        {
            "type": "subsection",
            "label": "I'm a subsection"
        },
        {
            "label": "Dropdown field",
            "type": "select",
            "id": "selection",
            "options": [ "Pizza", "Pasta", "Cookies", "Döner" ],
            "default": "Cookies",
            "require": "checkbox"   //Requires the checkbox "checkbox" to be checked, otherwise it gets disabled
        },
        {
            "label": "Numeric field",
            "type": "numeric",
            "id": "numeric",
            "default": "0",
            "min": "10",
            "max": "40"
        },
        {
            "label": "Color field",
            "type": "color",
            "id": "color",
            "default": "#000000"
        },
    ]
}

Load a Configuration

configurationWindow.create( <JSON CODE> );

Show Configuration Window

configurationWindow.open();

Open Configuration Window via the context menu

  • // @grant GM_registerMenuCommand
GM_registerMenuCommand("Menu Item Name", function() { configurationWindow.open(); });
长期地址
遇到问题?请前往 GitHub 提 Issues。