Greasy Fork is available in English.

MonkeyConfig Modern Reloaded

Easy configuration dialog builder for user scripts

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greasyfork.org/scripts/439099/1203718/MonkeyConfig%20Modern%20Reloaded.js

  1. // ==UserScript==
  2. // @name MonkeyConfig Modern Reloaded
  3. // @namespace http://odyniec.net/
  4. // @description Easy configuration dialog builder for user scripts
  5. // @include *
  6. // ==/UserScript==
  7.  
  8. /*
  9. * MonkeyConfig
  10. * version 0.1.4
  11. *
  12. * Copyright (c) 2011-2013 Michal Wojciechowski (odyniec.net)
  13. * v0.1.4 - January 2020 - David Hosier (https://github.com/david-hosier/MonkeyConfig)
  14. */
  15.  
  16. function MonkeyConfig() {
  17. var cfg = this,
  18. /* Data object passed to the constructor */
  19. data,
  20. /* Configuration parameters (data.parameters or data.params) */
  21. params,
  22. /* Current values of configuration parameters */
  23. values = {},
  24. /* Identifier used to store/retrieve configuration */
  25. storageKey,
  26. /* Is the configuration dialog displayed? */
  27. displayed,
  28. /* Currently displayed window/layer */
  29. openWin, openLayer,
  30. /* DOM element wrapping the configuration form */
  31. container,
  32. /* Darkened overlay used in the layer display mode */
  33. overlay;
  34. /**
  35. * Initialize configuration
  36. *
  37. * @param newData New data object
  38. */
  39. function init(newData) {
  40. data = newData;
  41.  
  42. if (data) {
  43. params = data.parameters || data.params;
  44. if (data.buttons === undefined)
  45. /* Set default buttons */
  46. data.buttons = [ 'save', 'defaults', 'cancel' ];
  47. if (data.title === undefined)
  48. /*
  49. * If GM_getMetadata is available, get the name of the script
  50. * and use it in the dialog title
  51. */
  52. if (typeof GM_getMetadata == 'function') {
  53. var scriptName = GM_getMetadata('name');
  54. data.title = scriptName + ' Configuration';
  55. }
  56. else
  57. data.title = 'Configuration';
  58. }
  59. /* Make a safe version of title to be used as stored value identifier */
  60. var safeTitle = data && data.title ?
  61. data.title.replace(/[^a-zA-Z0-9]/g, '_') : '';
  62.  
  63. storageKey = '_MonkeyConfig_' + safeTitle + '_cfg';
  64. var storedValues;
  65. /* Load stored values (if present) */
  66. if (GM_getValue(storageKey))
  67. storedValues = JSON.parse(GM_getValue(storageKey));
  68.  
  69. for (var name in params) {
  70. /* If there's a value defined in the passed data object, use it */
  71. if (params[name]['value'] !== undefined)
  72. set(name, params[name].value);
  73. /* Check if there's a stored value for this parameter */
  74. else if (storedValues && storedValues[name] !== undefined)
  75. set(name, storedValues[name]);
  76. /* Otherwise, set the default value (if defined) */
  77. else if (params[name]['default'] !== undefined)
  78. set(name, params[name]['default']);
  79. else
  80. set(name, '');
  81. }
  82.  
  83. if (data.menuCommand) {
  84. /* Add an item to the User Script Commands menu */
  85. var caption = data.menuCommand !== true ? data.menuCommand :
  86. data.title;
  87. GM_registerMenuCommand(caption, function () { cfg.open(); });
  88. }
  89.  
  90. /* Expose public methods */
  91. cfg.open = open;
  92. cfg.close = close;
  93. cfg.get = get;
  94. cfg.set = function (name, value) {
  95. set(name, value);
  96. update();
  97. };
  98. }
  99. /**
  100. * Get the value of a configuration parameter
  101. *
  102. * @param name Name of the configuration parameter
  103. * @returns Value of the configuration parameter
  104. */
  105. function get(name) {
  106. return values[name];
  107. }
  108. /**
  109. * Set the value of a configuration parameter
  110. *
  111. * @param name Name of the configuration parameter
  112. * @param value New value of the configuration parameter
  113. */
  114. function set(name, value) {
  115. values[name] = value;
  116. }
  117. /**
  118. * Reset configuration parameters to default values
  119. */
  120. function setDefaults() {
  121. for (var name in params) {
  122. if (typeof params[name]['default'] !== 'undefined') {
  123. set(name, params[name]['default']);
  124. }
  125. }
  126. }
  127. /**
  128. * Render the configuration dialog
  129. */
  130. function render() {
  131. var html = '<div class="__MonkeyConfig_container">' +
  132. '<h1>' + data.title + '</h1>' +
  133. '<table>';
  134.  
  135. for (var name in params) {
  136. html += MonkeyConfig.formatters['tr'](name, params[name]);}
  137.  
  138. html += '<tr><td colspan="2" class="__MonkeyConfig_buttons">' +
  139. '<table><tr>';
  140.  
  141. /* Render buttons */
  142. for (var button in data.buttons) {
  143. html += '<td>';
  144. switch (data.buttons[button]) {
  145. case 'cancel':
  146. html += '<button type="button" ' +
  147. 'id="__MonkeyConfig_button_cancel">' +
  148. '<img src="data:image/png;base64,' +
  149. MonkeyConfig.res.icons.cancel + '" />&nbsp;' +
  150. 'Cancel</button>';
  151. break;
  152. case 'defaults':
  153. html += '<button type="button" ' +
  154. 'id="__MonkeyConfig_button_defaults">' +
  155. '<img src="data:image/png;base64,' +
  156. MonkeyConfig.res.icons.arrow_undo + '" />&nbsp;' +
  157. 'Set&nbsp;Defaults</button>';
  158. break;
  159. case 'save':
  160. html += '<button type="button" ' +
  161. 'id="__MonkeyConfig_button_save">' +
  162. '<img src="data:image/png;base64,' +
  163. MonkeyConfig.res.icons.tick + '" />&nbsp;' +
  164. 'Save</button>';
  165. break;
  166. }
  167. html += '</td>';
  168. }
  169. html += '</tr></table></td></tr>';
  170. html += "</table><div>";
  171.  
  172. return html;
  173. }
  174. /**
  175. * Update the fields in the dialog to reflect current values
  176. */
  177. function update() {
  178. /* Do nothing if the dialog is not currently displayed */
  179. if (!displayed)
  180. return;
  181. for (var name in params) {
  182. var value = values[name];
  183. switch (params[name].type) {
  184. case 'checkbox':
  185. var elem = container.querySelector('[name="' + name + '"]');
  186. elem.checked = !!value;
  187. break;
  188. case 'custom':
  189. params[name].set(value, container
  190. .querySelector('#__MonkeyConfig_parent_' + name));
  191. break;
  192. case 'number':
  193. case 'text':
  194. case 'color':
  195. var elem = container.querySelector('[name="' + name + '"]');
  196. elem.value = value;
  197. break;
  198. case 'select':
  199. var elem = container.querySelector('[name="' + name + '"]');
  200. if (elem.tagName.toLowerCase() == 'input') {
  201. if (elem.type && elem.type == 'radio') {
  202. /* Single selection with radio buttons */
  203. elem = container.querySelector(
  204. '[name="' + name + '"][value="' + value + '"]');
  205. elem.checked = true;
  206. }
  207. else if (elem.type && elem.type == 'checkbox') {
  208. /* Multiple selection with checkboxes */
  209. var checkboxes = container.querySelectorAll(
  210. 'input[name="' + name + '"]');
  211.  
  212. for (var i = 0; i < checkboxes.length; i++)
  213. checkboxes[i].checked =
  214. (value.indexOf(checkboxes[i].value) > -1);
  215. }
  216. }
  217. else if (elem.tagName.toLowerCase() == 'select')
  218. if (elem.multiple) {
  219. /* Multiple selection element */
  220. var options = container.querySelectorAll(
  221. 'select[name="' + name + '"] option');
  222. for (var i = 0; i < options.length; i++)
  223. options[i].selected =
  224. (value.indexOf(options[i].value) > -1);
  225. }
  226. else
  227. /* Single selection element */
  228. elem.value = value;
  229. break;
  230. }
  231. }
  232. }
  233. /**
  234. * Save button click event handler
  235. */
  236. function saveClick() {
  237. for (var name in params) {
  238. switch (params[name].type) {
  239. case 'checkbox':
  240. var elem = container.querySelector('[name="' + name + '"]');
  241. values[name] = elem.checked;
  242. break;
  243. case 'custom':
  244. values[name] = params[name].get(container
  245. .querySelector('#__MonkeyConfig_parent_' + name));
  246. break;
  247. case 'number':
  248. case 'text':
  249. case 'color':
  250. var elem = container.querySelector('[name="' + name + '"]');
  251. values[name] = elem.value;
  252. break;
  253. case 'select':
  254. var elem = container.querySelector('[name="' + name + '"]');
  255.  
  256. if (elem.tagName.toLowerCase() == 'input') {
  257. if (elem.type && elem.type == 'radio')
  258. /* Single selection with radio buttons */
  259. values[name] = container.querySelector(
  260. '[name="' + name + '"]:checked').value;
  261. else if (elem.type && elem.type == 'checkbox') {
  262. /* Multiple selection with checkboxes */
  263. values[name] = [];
  264. var inputs = container.querySelectorAll(
  265. 'input[name="' + name + '"]');
  266.  
  267. for (var i = 0; i < inputs.length; i++)
  268. if (inputs[i].checked)
  269. values[name].push(inputs[i].value);
  270. }
  271. }
  272. else if (elem.tagName.toLowerCase() == 'select' && elem.multiple) {
  273. /* Multiple selection element */
  274. values[name] = [];
  275. var options = container.querySelectorAll(
  276. 'select[name="' + name + '"] option');
  277.  
  278. for (var i = 0; i < options.length; i++)
  279. if (options[i].selected)
  280. values[name].push(options[i].value);
  281. }
  282. else
  283. values[name] = elem.value;
  284. break;
  285. }
  286. }
  287. GM_setValue(storageKey, JSON.stringify(values));
  288. close();
  289. if (data.onSave)
  290. data.onSave(values);
  291. location.reload();
  292. }
  293. /**
  294. * Cancel button click event handler
  295. */
  296. function cancelClick() {
  297. close();
  298. }
  299. /**
  300. * Set Defaults button click event handler
  301. */
  302. function defaultsClick() {
  303. setDefaults();
  304. update();
  305. }
  306.  
  307. /**
  308. * Open configuration dialog
  309. *
  310. * @param mode
  311. * Display mode ("iframe", "layer", or "window", defaults to
  312. * "iframe")
  313. * @param options
  314. * Display mode options
  315. */
  316. function open(mode, options) {
  317. function openDone() {
  318. /* Attach button event handlers */
  319. var button;
  320. if (button = container.querySelector('#__MonkeyConfig_button_save'))
  321. button.addEventListener('click', saveClick, true);
  322. if (button = container.querySelector('#__MonkeyConfig_button_cancel'))
  323. button.addEventListener('click', cancelClick, true);
  324. if (button = container.querySelector('#__MonkeyConfig_button_defaults'))
  325. button.addEventListener('click', defaultsClick, true);
  326. displayed = true;
  327. update();
  328. }
  329. switch (mode) {
  330. case 'window':
  331. var windowFeatures = {
  332. location: 'no',
  333. status: 'no',
  334. left: window.screenX,
  335. top: window.screenY,
  336. width: 100,
  337. height: 100
  338. };
  339. /* Additional features may be specified as an option */
  340. if (options && options.windowFeatures)
  341. for (var name in options.windowFeatures)
  342. windowFeatures[name] = options.windowFeatures[name];
  343.  
  344. var featuresArray = [];
  345. for (var name in windowFeatures)
  346. featuresArray.push(name + '=' + windowFeatures[name]);
  347.  
  348. var win = window.open('', data.title, featuresArray.join(','));
  349. /* Find head and body (then call the blood spatter analyst) */
  350. var head = win.document.getElementsByTagName('head')[0],
  351. body = win.document.getElementsByTagName('body')[0];
  352.  
  353. head.innerHTML = '<title>' + data.title + '</title>' +
  354. '<style type="text/css">' +
  355. MonkeyConfig.res.stylesheets.main + '</style>';
  356. body.className = '__MonkeyConfig_window';
  357. /* Place the rendered configuration dialog inside the window body */
  358. body.innerHTML = render();
  359.  
  360. /* Find the container (CBAN-3489) */
  361. container = win.document.querySelector('.__MonkeyConfig_container');
  362. /* Resize window to the dimensions of the container div */
  363. win.innerWidth = container.clientWidth;
  364. win.resizeBy(0, -win.innerHeight + container.clientHeight);
  365. /* Place the window centered relative to the parent */
  366. win.moveBy(Math.round((window.outerWidth - win.outerWidth) / 2),
  367. Math.round((window.outerHeight - win.outerHeight) / 2));
  368. openWin = win;
  369. openDone();
  370. break;
  371. case 'layer':
  372. if (!MonkeyConfig.styleAdded) {
  373. GM_addStyle(MonkeyConfig.res.stylesheets.main);
  374. MonkeyConfig.styleAdded = true;
  375. }
  376. var body = document.querySelector('body');
  377. /* Create the layer element */
  378. openLayer = document.createElement('div');
  379. openLayer.className = '__MonkeyConfig_layer';
  380. /* Create the overlay */
  381. overlay = document.createElement('div');
  382. overlay.className = '__MonkeyConfig_overlay';
  383. overlay.style.left = 0;
  384. overlay.style.top = 0;
  385. overlay.style.width = window.innerWidth + 'px';
  386. overlay.style.height = window.innerHeight + 'px';
  387. overlay.style.zIndex = 9999;
  388. body.appendChild(overlay);
  389. body.appendChild(openLayer);
  390. /*
  391. * Place the rendered configuration dialog inside the layer element
  392. */
  393. openLayer.innerHTML = render();
  394. /* Position the layer in the center of the viewport */
  395. openLayer.style.left = Math.round((window.innerWidth -
  396. openLayer.clientWidth) / 2) + 'px';
  397. openLayer.style.top = Math.round((window.innerHeight -
  398. openLayer.clientHeight) / 2) + 'px';
  399. openLayer.style.zIndex = 9999;
  400. container = document.querySelector('.__MonkeyConfig_container');
  401. openDone();
  402. break;
  403. case 'iframe':
  404. default:
  405. if (!MonkeyConfig.styleAdded) {
  406. GM_addStyle(MonkeyConfig.res.stylesheets.main);
  407. MonkeyConfig.styleAdded = true;
  408. }
  409. var body = document.querySelector('body');
  410. var iframe = document.createElement('iframe');
  411. /* Create the layer element */
  412. openLayer = document.createElement('div');
  413. openLayer.className = '__MonkeyConfig_layer';
  414. /* Create the overlay */
  415. overlay = document.createElement('div');
  416. overlay.className = '__MonkeyConfig_overlay';
  417. overlay.style.left = 0;
  418. overlay.style.top = 0;
  419. overlay.style.width = window.innerWidth + 'px';
  420. overlay.style.height = window.innerHeight + 'px';
  421. overlay.style.zIndex = 9999;
  422. iframe.id = '__MonkeyConfig_frame';
  423. /*
  424. * Make the iframe transparent so that it remains invisible until
  425. * the document inside it is ready
  426. */
  427. iframe.style.opacity = 0;
  428. iframe.src = 'about:blank';
  429. /* Make the iframe seamless with no border and no scrollbars */
  430. if (undefined !== iframe.frameborder)
  431. iframe.frameBorder = '0';
  432. if (undefined !== iframe.scrolling)
  433. iframe.scrolling = 'no';
  434. if (undefined !== iframe.seamless)
  435. iframe.seamless = true;
  436. /* Do the rest in the load event handler */
  437. iframe.addEventListener('load', function () {
  438. iframe.contentDocument.body.innerHTML = render();
  439. iframe.style.opacity = 1;
  440. /* Append the style to the head */
  441. var head = iframe.contentDocument.querySelector('head'),
  442. style = iframe.contentDocument.createElement('style');
  443. style.setAttribute('type', 'text/css');
  444. style.appendChild(iframe.contentDocument.createTextNode(
  445. MonkeyConfig.res.stylesheets.main));
  446. head.appendChild(style);
  447. var body = iframe.contentDocument.querySelector('body');
  448. body.className = '__MonkeyConfig_body';
  449. container = iframe.contentDocument
  450. .querySelector('.__MonkeyConfig_container');
  451.  
  452. iframe.width = container.clientWidth;
  453. iframe.height = container.clientHeight;
  454.  
  455. /* Position the layer in the center of the viewport */
  456. openLayer.style.left = Math.round((window.innerWidth -
  457. openLayer.clientWidth) / 2) + 'px';
  458. openLayer.style.top = Math.round((window.innerHeight -
  459. openLayer.clientHeight) / 2) + 'px';
  460. openLayer.style.zIndex = 9999;
  461. openDone();
  462. }, false);
  463.  
  464. setTimeout(function () {
  465. iframe.width = container.clientWidth;
  466. iframe.height = container.clientHeight;
  467. /* Position the layer in the center of the viewport */
  468. openLayer.style.left = Math.round((window.innerWidth -
  469. openLayer.clientWidth) / 2) + 'px';
  470. openLayer.style.top = Math.round((window.innerHeight -
  471. openLayer.clientHeight) / 2) + 'px';
  472. openLayer.style.zIndex = 9999;
  473. }, 0);
  474. body.appendChild(overlay);
  475. body.appendChild(openLayer);
  476. openLayer.appendChild(iframe);
  477. break;
  478. }
  479. }
  480. /**
  481. * Close configuration dialog
  482. */
  483. function close() {
  484. if (openWin) {
  485. openWin.close();
  486. openWin = undefined;
  487. }
  488. else if (openLayer) {
  489. openLayer.parentNode.removeChild(openLayer);
  490. openLayer = undefined;
  491. if (overlay) {
  492. overlay.parentNode.removeChild(overlay);
  493. overlay = undefined;
  494. }
  495. }
  496. displayed = false;
  497. }
  498.  
  499. init(arguments[0]);
  500. }
  501.  
  502. /**
  503. * Replace double quotes with entities so that the string can be safely used
  504. * in a HTML attribute
  505. *
  506. * @param string A string
  507. * @returns String with double quotes replaced with entities
  508. */
  509. MonkeyConfig.esc = function (string) {
  510. return string.replace(/"/g, '&quot;');
  511. };
  512.  
  513. MonkeyConfig.HTML = {
  514. '_field': function (name, options, data) {
  515. var html;
  516. if (options.type && MonkeyConfig.HTML[options.type])
  517. html = MonkeyConfig.HTML[options.type](name, options, data);
  518. else
  519. return;
  520. if (/\[FIELD\]/.test(options.html)) {
  521. html = options.html.replace(/\[FIELD\]/, html);
  522. }
  523. return html;
  524. },
  525. '_label': function (name, options, data) {
  526. var label = options['label'] ||
  527. name.substring(0, 1).toUpperCase() + name.substring(1)
  528. .replace(/_/g, '&nbsp;');
  529.  
  530. return '<label for="__MonkeyConfig_field_' + name + '">' + label +
  531. '</label>';
  532. },
  533. 'checkbox': function (name, options, data) {
  534. return '<input id="__MonkeyConfig_field_' + name +
  535. '" type="checkbox" name="' + name + '" />';
  536. },
  537. 'custom': function (name, options, data) {
  538. return options.html;
  539. },
  540. 'number': function (name, options, data) {
  541. return '<input id="__MonkeyConfig_field_' + name + '" ' +
  542. 'type="text" class="__MonkeyConfig_field_number" ' +
  543. 'name="' + name + '" />';
  544. },
  545. 'select': function (name, options, data) {
  546. var choices = {}, html = '';
  547. if (options.choices.constructor == Array) {
  548. /* options.choices is an array -- build key/value pairs */
  549. for (var i = 0; i < options.choices.length; i++)
  550. choices[options.choices[i]] = options.choices[i];
  551. }
  552. else
  553. /* options.choices is an object -- use it as it is */
  554. choices = options.choices;
  555.  
  556. if (!options.multiple) {
  557. /* Single selection */
  558. if (!/^radio/.test(options.variant)) {
  559. /* Select element */
  560. html += '<select id="__MonkeyConfig_field_' + name + '" ' +
  561. 'class="__MonkeyConfig_field_select" ' +
  562. 'name="' + name + '">';
  563. for (var value in choices)
  564. html += '<option value="' + MonkeyConfig.esc(value) + '">' +
  565. choices[value] + '</option>';
  566. html += '</select>';
  567. }
  568. else {
  569. /* Radio buttons */
  570. for (var value in choices) {
  571. html += '<label><input type="radio" name="' + name + '" ' +
  572. 'value="' + MonkeyConfig.esc(value) + '" />&nbsp;' +
  573. choices[value] + '</label>' +
  574. (/ column/.test(options.variant) ? '<br />' : '');
  575. }
  576. }
  577. }
  578. else {
  579. /* Multiple selection */
  580. if (!/^checkbox/.test(options.variant)) {
  581. /* Checkboxes */
  582. html += '<select id="__MonkeyConfig_field_' + name + '" ' +
  583. 'class="__MonkeyConfig_field_select" ' +
  584. 'multiple="multiple" ' +
  585. 'name="' + name + '">';
  586. for (var value in choices)
  587. html += '<option value="' + MonkeyConfig.esc(value) + '">' +
  588. choices[value] + '</option>';
  589. html += '</select>';
  590. }
  591. else {
  592. /* Select element */
  593. for (var value in choices) {
  594. html += '<label><input type="checkbox" ' +
  595. 'name="' + name + '" ' +
  596. 'value="' + MonkeyConfig.esc(value) + '" />&nbsp;' +
  597. choices[value] + '</label>' +
  598. (/ column/.test(options.variant) ? '<br />' : '');
  599. }
  600. }
  601. }
  602. return html;
  603. },
  604. 'text': function (name, options, data) {
  605. if (options.long)
  606. return '<textarea id="__MonkeyConfig_field_' + name + '" ' +
  607. 'class="__MonkeyConfig_field_text" ' +
  608. (!isNaN(options.long) ? 'rows="' + options.long + '" ' : '') +
  609. 'name="' + name + '"></textarea>';
  610. else
  611. return '<input id="__MonkeyConfig_field_' + name + '" ' +
  612. 'type="text" class="__MonkeyConfig_field_text" ' +
  613. 'name="' + name + '" />';
  614. },
  615. 'color': function(name, options, data) {
  616. return '<input id="__MonkeyConfig_field_' + name + '" ' +
  617. 'type="color" class="__MonkeyConfig_field_text" ' +
  618. 'name="' + name + '" />';
  619. }
  620. };
  621.  
  622. MonkeyConfig.formatters = {
  623. 'tr': function (name, options, data) {
  624. var html = '<tr>';
  625.  
  626. switch (options.type) {
  627. case 'checkbox':
  628. /* Checkboxes get special treatment */
  629. html += '<td id="__MonkeyConfig_parent_' + name + '" colspan="2">';
  630. html += MonkeyConfig.HTML['_field'](name, options, data) + ' ';
  631. html += MonkeyConfig.HTML['_label'](name, options, data);
  632. html += '</td>';
  633. break;
  634. default:
  635. html += '<td>';
  636. html += MonkeyConfig.HTML['_label'](name, options, data);
  637. html += '</td><td id="__MonkeyConfig_parent_' + name + '">';
  638. html += MonkeyConfig.HTML['_field'](name, options, data);
  639. html += '</td>';
  640. break;
  641. }
  642. html += '</tr>';
  643.  
  644. return html;
  645. }
  646. };
  647.  
  648. /* Has the stylesheet been added? */
  649. MonkeyConfig.styleAdded = false;
  650.  
  651. /* Resources */
  652. MonkeyConfig.res = {};
  653.  
  654. /* Icons */
  655. MonkeyConfig.res.icons = {
  656. 'arrow_undo': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0\
  657. U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAIJSURBVDjLpVM9aJNRFD35GsRSoUKKzQ/B\
  658. 0NJJF3EQlKrVgijSCBmC4NBFKihIcXBwEZdSHVoUwUInFUEkQ1DQ4CKiFsQsTrb5xNpgaZHw2Uog\
  659. 5t5zn0NJNFaw0guX97hwzuPcc17IOYfNlIdNVrhxufR6xJkZjAbSQGXjNAorqixSWFDV3KPhJ+UG\
  660. LtSQMPryrDscPwLnAHOEOQc6gkbUpIagGmApWIb/pZRX4fjj889nWiSQtgYyBZ1BTUEj6AjPa0P7\
  661. 1nb0Jfqwa+futIheHrzRn2yRQCUK/lOQhApBJVQJChHfnkCqOwWEQ+iORJHckUyX5ksvAEyGNuJC\
  662. +s6xCRXNHNxzKMmQ4luwgjfvZp69uvr2+IZcyJ8rjIporrxURggetnV0QET3rrPxzMNM2+n7p678\
  663. jUTrCiWhphAjVHR9DlR0WkSzf4IHxg5MSF0zXZEuVKWKSlCBCostS8zeG7oV64wPqxInbw86lbVX\
  664. KEQ8mkAqmUJ4SxieeVhcnANFC02C7N2h69HO2IXeWC8MDj2JnqaFNAMd8f3HKjx6+LxQRmnOz1OZ\
  665. axKIaF1VISYwB9ARZoQaYY6o1WpYCVYxt+zDn/XzVBv/MOWXW5J44ubRyVgkelFpmF/4BJVfOVDl\
  666. VyqLVBZI5manPjajDOdcswfG9k/3X9v3/vfZv7rFBanriIo++J/f+BMT+YWS6hXl7QAAAABJRU5E\
  667. rkJggg==',
  668. 'cancel': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0\
  669. U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHdSURBVDjLpZNraxpBFIb3a0ggISmmNISW\
  670. XmOboKihxpgUNGWNSpvaS6RpKL3Ry//Mh1wgf6PElaCyzq67O09nVjdVlJbSDy8Lw77PmfecMwZg\
  671. /I/GDw3DCo8HCkZl/RlgGA0e3Yfv7+DbAfLrW+SXOvLTG+SHV/gPbuMZRnsyIDL/OASziMxkkKkU\
  672. QTJJsLaGn8/iHz6nd+8mQv87Ahg2H9Th/BxZqxEkEgSrq/iVCvLsDK9awtvfxb2zjD2ARID+lVVl\
  673. babTgWYTv1rFL5fBUtHbbeTJCb3EQ3ovCnRC6xAgzJtOE+ztheYIEkqbFaS3vY2zuIj77AmtYYDu\
  674. sPy8/zuvunJkDKXM7tYWTiyGWFjAqeQnAD6+7ueNx/FLpRGAru7mcoj5ebqzszil7DggeF/DX1nB\
  675. N82rzPqrzbRayIsLhJqMPT2N83Sdy2GApwFqRN7jFPL0tF+10cDd3MTZ2AjNUkGCoyO6y9cRxfQo\
  676. wFUbpufr1ct4ZoHg+Dg067zduTmEbq4yi/UkYidDe+kaTcP4ObJIajksPd/eyx3c+N2rvPbMDPbU\
  677. FPZSLKzcGjKPrbJaDsu+dQO3msfZzeGY2TCvKGYQhdSYeeJjUt21dIcjXQ7U7Kv599f4j/oF55W4\
  678. g/2e3b8AAAAASUVORK5CYII=',
  679. 'tick': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0\
  680. U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGrSURBVDjLvZPZLkNhFIV75zjvYm7VGFNC\
  681. qoZUJ+roKUUpjRuqp61Wq0NKDMelGGqOxBSUIBKXWtWGZxAvobr8lWjChRgSF//dv9be+9trCwAI\
  682. /vIE/26gXmviW5bqnb8yUK028qZjPfoPWEj4Ku5HBspgAz941IXZeze8N1bottSo8BTZviVWrEh5\
  683. 46EO03EXpuJOdG63otJbjBKHkEp/Ml6yNYYzpuezWL4s5VMtT8acCMQcb5XL3eJE8VgBlR7BeMGW\
  684. 9Z4yT9y1CeyucuhdTGDxfftaBO7G4L+zg91UocxVmCiy51NpiP3n2treUPujL8xhOjYOzZYsQWAN\
  685. yRYlU4Y9Br6oHd5bDh0bCpSOixJiWx71YY09J5pM/WEbzFcDmHvwwBu2wnikg+lEj4mwBe5bC5h1\
  686. OUqcwpdC60dxegRmR06TyjCF9G9z+qM2uCJmuMJmaNZaUrCSIi6X+jJIBBYtW5Cge7cd7sgoHDfD\
  687. aAvKQGAlRZYc6ltJlMxX03UzlaRlBdQrzSCwksLRbOpHUSb7pcsnxCCwngvM2Rm/ugUCi84fycr4\
  688. l2t8Bb6iqTxSCgNIAAAAAElFTkSuQmCC'
  689. };
  690.  
  691. /* Stylesheets */
  692. MonkeyConfig.res.stylesheets = {
  693. 'main': '\
  694. body.__MonkeyConfig_window {\
  695. appearance: window !important;\
  696. -moz-appearance: window !important;\
  697. background: auto;\
  698. font-family: sans-serif !important;\
  699. height: 100% !important;\
  700. margin: 0 !important;\
  701. padding: 0 !important;\
  702. width: 100% !important;\
  703. }\
  704. \
  705. div.__MonkeyConfig_container {\
  706. display: table !important;\
  707. font-family: sans-serif !important;\
  708. padding: 0.3em !important;\
  709. }\
  710. \
  711. body.__MonkeyConfig_window div.__MonkeyConfig_container {\
  712. appearance: window !important;\
  713. -moz-appearance: window !important;\
  714. height: 100%;\
  715. width: 100%;\
  716. }\
  717. \
  718. div.__MonkeyConfig_container h1 {\
  719. border-bottom: solid 1px #999 !important;\
  720. font-family: sans-serif !important;\
  721. font-size: 120% !important;\
  722. margin: 0 !important;\
  723. padding: 0 0 0.3em 0 !important;\
  724. }\
  725. \
  726. div.__MonkeyConfig_container table {\
  727. border-spacing: 0 !important;\
  728. margin: 0 !important;\
  729. }\
  730. \
  731. div.__MonkeyConfig_container table td {\
  732. border: none !important;\
  733. line-height: 100% !important;\
  734. padding: 0.3em !important;\
  735. text-align: left !important;\
  736. vertical-align: top !important;\
  737. white-space: nowrap !important;\
  738. }\
  739. \
  740. div.__MonkeyConfig_container table td.__MonkeyConfig_buttons {\
  741. padding: 0.2em 0 !important;\
  742. }\
  743. \
  744. .__MonkeyConfig_field_number {\
  745. width: 5em !important;\
  746. }\
  747. \
  748. div.__MonkeyConfig_container td.__MonkeyConfig_buttons table {\
  749. border-top: solid 1px #999 !important;\
  750. width: 100% !important;\
  751. }\
  752. \
  753. div.__MonkeyConfig_container td.__MonkeyConfig_buttons td {\
  754. padding: 0.6em 0.3em 0.1em 0.3em !important;\
  755. text-align: center !important;\
  756. vertical-align: top;\
  757. }\
  758. \
  759. div.__MonkeyConfig_container td.__MonkeyConfig_buttons button {\
  760. appearance: button !important;\
  761. -moz-appearance: button !important;\
  762. background-position: 8px 50% !important;\
  763. background-repeat: no-repeat !important;\
  764. padding: 3px 8px 3px 24px !important;\
  765. padding: 3px 8px !important;\
  766. white-space: nowrap !important;\
  767. }\
  768. \
  769. div.__MonkeyConfig_container td.__MonkeyConfig_buttons button img {\
  770. vertical-align: middle !important;\
  771. }\
  772. \
  773. div.__MonkeyConfig_layer {\
  774. display: table !important;\
  775. position: fixed !important;\
  776. }\
  777. \
  778. div.__MonkeyConfig_layer div.__MonkeyConfig_container,\
  779. body.__MonkeyConfig_body > div.__MonkeyConfig_container {\
  780. background: #eee linear-gradient(180deg,\
  781. #f8f8f8 0, #ddd 100%) !important;\
  782. border-radius: 0.5em !important;\
  783. box-shadow: 2px 2px 16px #000 !important;\
  784. color: #000 !important;\
  785. font-family: sans-serif !important;\
  786. font-size: 11pt !important;\
  787. padding: 1em 1em 0.4em 1em !important;\
  788. }\
  789. \
  790. div.__MonkeyConfig_layer div.__MonkeyConfig_container td,\
  791. div.__MonkeyConfig_layer div.__MonkeyConfig_container label,\
  792. div.__MonkeyConfig_layer div.__MonkeyConfig_container input,\
  793. div.__MonkeyConfig_layer div.__MonkeyConfig_container select,\
  794. div.__MonkeyConfig_layer div.__MonkeyConfig_container textarea,\
  795. div.__MonkeyConfig_layer div.__MonkeyConfig_container button {\
  796. color: #000 !important;\
  797. font-family: sans-serif !important;\
  798. font-size: 11pt !important;\
  799. line-height: 100% !important;\
  800. margin: 0 !important;\
  801. vertical-align: baseline !important;\
  802. }\
  803. \
  804. div.__MonkeyConfig_container label {\
  805. line-height: 120% !important;\
  806. vertical-align: baseline !important;\
  807. }\
  808. \
  809. div.__MonkeyConfig_container textarea {\
  810. vertical-align: text-top !important;\
  811. width: 100%;\
  812. }\
  813. \
  814. div.__MonkeyConfig_layer div.__MonkeyConfig_container input[type="text"] {\
  815. appearance: textfield !important;\
  816. -moz-appearance: textfield !important;\
  817. background: #fff !important;\
  818. }\
  819. \
  820. div.__MonkeyConfig_layer div.__MonkeyConfig_container h1 {\
  821. font-weight: bold !important;\
  822. text-align: left !important;\
  823. }\
  824. \
  825. div.__MonkeyConfig_layer div.__MonkeyConfig_container td.__MonkeyConfig_buttons button,\
  826. body > div.__MonkeyConfig_container td.__MonkeyConfig_buttons button {\
  827. appearance: button !important;\
  828. -moz-appearance: button !important;\
  829. background: #ccc linear-gradient(180deg,\
  830. #ddd 0, #ccc 45%, #bbb 50%, #aaa 100%) !important;\
  831. border-style: solid !important;\
  832. border-width: 1px !important;\
  833. border-radius: 0.5em !important;\
  834. box-shadow: 0 0 1px #000 !important;\
  835. color: #000 !important;\
  836. font-size: 11pt !important;\
  837. }\
  838. \
  839. div.__MonkeyConfig_layer div.__MonkeyConfig_container td.__MonkeyConfig_buttons button:hover,\
  840. body > div.__MonkeyConfig_container td.__MonkeyConfig_buttons button:hover {\
  841. background: #d2d2d2 linear-gradient(180deg,\
  842. #e2e2e2 0, #d2d2d2 45%, #c2c2c2 50%, #b2b2b2 100%) !important;\
  843. }\
  844. \
  845. div.__MonkeyConfig_overlay {\
  846. background-color: #000 !important;\
  847. opacity: 0.6 !important;\
  848. position: fixed !important;\
  849. }\
  850. \
  851. iframe#__MonkeyConfig_frame {\
  852. border: none !important;\
  853. box-shadow: 2px 2px 16px #000 !important;\
  854. }\
  855. \
  856. body.__MonkeyConfig_body {\
  857. margin: 0 !important;\
  858. padding: 0 !important;\
  859. }\
  860. '
  861. };