MonkeyConfig Modern Reloaded

Easy configuration dialog builder for user scripts

当前为 2022-01-25 提交的版本,查看 最新版本

此脚本不应直接安装,它是供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/439099/1012371/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. }
  292. /**
  293. * Cancel button click event handler
  294. */
  295. function cancelClick() {
  296. close();
  297. }
  298. /**
  299. * Set Defaults button click event handler
  300. */
  301. function defaultsClick() {
  302. setDefaults();
  303. update();
  304. }
  305.  
  306. /**
  307. * Open configuration dialog
  308. *
  309. * @param mode
  310. * Display mode ("iframe", "layer", or "window", defaults to
  311. * "iframe")
  312. * @param options
  313. * Display mode options
  314. */
  315. function open(mode, options) {
  316. function openDone() {
  317. /* Attach button event handlers */
  318. var button;
  319. if (button = container.querySelector('#__MonkeyConfig_button_save'))
  320. button.addEventListener('click', saveClick, true);
  321. if (button = container.querySelector('#__MonkeyConfig_button_cancel'))
  322. button.addEventListener('click', cancelClick, true);
  323. if (button = container.querySelector('#__MonkeyConfig_button_defaults'))
  324. button.addEventListener('click', defaultsClick, true);
  325. displayed = true;
  326. update();
  327. }
  328. switch (mode) {
  329. case 'window':
  330. var windowFeatures = {
  331. location: 'no',
  332. status: 'no',
  333. left: window.screenX,
  334. top: window.screenY,
  335. width: 100,
  336. height: 100
  337. };
  338. /* Additional features may be specified as an option */
  339. if (options && options.windowFeatures)
  340. for (var name in options.windowFeatures)
  341. windowFeatures[name] = options.windowFeatures[name];
  342.  
  343. var featuresArray = [];
  344. for (var name in windowFeatures)
  345. featuresArray.push(name + '=' + windowFeatures[name]);
  346.  
  347. var win = window.open('', data.title, featuresArray.join(','));
  348. /* Find head and body (then call the blood spatter analyst) */
  349. var head = win.document.getElementsByTagName('head')[0],
  350. body = win.document.getElementsByTagName('body')[0];
  351.  
  352. head.innerHTML = '<title>' + data.title + '</title>' +
  353. '<style type="text/css">' +
  354. MonkeyConfig.res.stylesheets.main + '</style>';
  355. body.className = '__MonkeyConfig_window';
  356. /* Place the rendered configuration dialog inside the window body */
  357. body.innerHTML = render();
  358.  
  359. /* Find the container (CBAN-3489) */
  360. container = win.document.querySelector('.__MonkeyConfig_container');
  361. /* Resize window to the dimensions of the container div */
  362. win.innerWidth = container.clientWidth;
  363. win.resizeBy(0, -win.innerHeight + container.clientHeight);
  364. /* Place the window centered relative to the parent */
  365. win.moveBy(Math.round((window.outerWidth - win.outerWidth) / 2),
  366. Math.round((window.outerHeight - win.outerHeight) / 2));
  367. openWin = win;
  368. openDone();
  369. break;
  370. case 'layer':
  371. if (!MonkeyConfig.styleAdded) {
  372. GM_addStyle(MonkeyConfig.res.stylesheets.main);
  373. MonkeyConfig.styleAdded = true;
  374. }
  375. var body = document.querySelector('body');
  376. /* Create the layer element */
  377. openLayer = document.createElement('div');
  378. openLayer.className = '__MonkeyConfig_layer';
  379. /* Create the overlay */
  380. overlay = document.createElement('div');
  381. overlay.className = '__MonkeyConfig_overlay';
  382. overlay.style.left = 0;
  383. overlay.style.top = 0;
  384. overlay.style.width = window.innerWidth + 'px';
  385. overlay.style.height = window.innerHeight + 'px';
  386. overlay.style.zIndex = 9999;
  387. body.appendChild(overlay);
  388. body.appendChild(openLayer);
  389. /*
  390. * Place the rendered configuration dialog inside the layer element
  391. */
  392. openLayer.innerHTML = render();
  393. /* Position the layer in the center of the viewport */
  394. openLayer.style.left = Math.round((window.innerWidth -
  395. openLayer.clientWidth) / 2) + 'px';
  396. openLayer.style.top = Math.round((window.innerHeight -
  397. openLayer.clientHeight) / 2) + 'px';
  398. openLayer.style.zIndex = 9999;
  399. container = document.querySelector('.__MonkeyConfig_container');
  400. openDone();
  401. break;
  402. case 'iframe':
  403. default:
  404. if (!MonkeyConfig.styleAdded) {
  405. GM_addStyle(MonkeyConfig.res.stylesheets.main);
  406. MonkeyConfig.styleAdded = true;
  407. }
  408. var body = document.querySelector('body');
  409. var iframe = document.createElement('iframe');
  410. /* Create the layer element */
  411. openLayer = document.createElement('div');
  412. openLayer.className = '__MonkeyConfig_layer';
  413. /* Create the overlay */
  414. overlay = document.createElement('div');
  415. overlay.className = '__MonkeyConfig_overlay';
  416. overlay.style.left = 0;
  417. overlay.style.top = 0;
  418. overlay.style.width = window.innerWidth + 'px';
  419. overlay.style.height = window.innerHeight + 'px';
  420. overlay.style.zIndex = 9999;
  421. iframe.id = '__MonkeyConfig_frame';
  422. /*
  423. * Make the iframe transparent so that it remains invisible until
  424. * the document inside it is ready
  425. */
  426. iframe.style.opacity = 0;
  427. iframe.src = 'about:blank';
  428. /* Make the iframe seamless with no border and no scrollbars */
  429. if (undefined !== iframe.frameborder)
  430. iframe.frameBorder = '0';
  431. if (undefined !== iframe.scrolling)
  432. iframe.scrolling = 'no';
  433. if (undefined !== iframe.seamless)
  434. iframe.seamless = true;
  435. /* Do the rest in the load event handler */
  436. iframe.addEventListener('load', function () {
  437. iframe.contentDocument.body.innerHTML = render();
  438. iframe.style.opacity = 1;
  439. /* Append the style to the head */
  440. var head = iframe.contentDocument.querySelector('head'),
  441. style = iframe.contentDocument.createElement('style');
  442. style.setAttribute('type', 'text/css');
  443. style.appendChild(iframe.contentDocument.createTextNode(
  444. MonkeyConfig.res.stylesheets.main));
  445. head.appendChild(style);
  446. var body = iframe.contentDocument.querySelector('body');
  447. body.className = '__MonkeyConfig_body';
  448. container = iframe.contentDocument
  449. .querySelector('.__MonkeyConfig_container');
  450.  
  451. iframe.width = container.clientWidth;
  452. iframe.height = container.clientHeight;
  453.  
  454. /* Position the layer in the center of the viewport */
  455. openLayer.style.left = Math.round((window.innerWidth -
  456. openLayer.clientWidth) / 2) + 'px';
  457. openLayer.style.top = Math.round((window.innerHeight -
  458. openLayer.clientHeight) / 2) + 'px';
  459. openLayer.style.zIndex = 9999;
  460. openDone();
  461. }, false);
  462.  
  463. setTimeout(function () {
  464. iframe.width = container.clientWidth;
  465. iframe.height = container.clientHeight;
  466. /* Position the layer in the center of the viewport */
  467. openLayer.style.left = Math.round((window.innerWidth -
  468. openLayer.clientWidth) / 2) + 'px';
  469. openLayer.style.top = Math.round((window.innerHeight -
  470. openLayer.clientHeight) / 2) + 'px';
  471. openLayer.style.zIndex = 9999;
  472. }, 0);
  473. body.appendChild(overlay);
  474. body.appendChild(openLayer);
  475. openLayer.appendChild(iframe);
  476. break;
  477. }
  478. }
  479. /**
  480. * Close configuration dialog
  481. */
  482. function close() {
  483. if (openWin) {
  484. openWin.close();
  485. openWin = undefined;
  486. }
  487. else if (openLayer) {
  488. openLayer.parentNode.removeChild(openLayer);
  489. openLayer = undefined;
  490. if (overlay) {
  491. overlay.parentNode.removeChild(overlay);
  492. overlay = undefined;
  493. }
  494. }
  495. displayed = false;
  496. }
  497.  
  498. init(arguments[0]);
  499. }
  500.  
  501. /**
  502. * Replace double quotes with entities so that the string can be safely used
  503. * in a HTML attribute
  504. *
  505. * @param string A string
  506. * @returns String with double quotes replaced with entities
  507. */
  508. MonkeyConfig.esc = function (string) {
  509. return string.replace(/"/g, '&quot;');
  510. };
  511.  
  512. MonkeyConfig.HTML = {
  513. '_field': function (name, options, data) {
  514. var html;
  515. if (options.type && MonkeyConfig.HTML[options.type])
  516. html = MonkeyConfig.HTML[options.type](name, options, data);
  517. else
  518. return;
  519. if (/\[FIELD\]/.test(options.html)) {
  520. html = options.html.replace(/\[FIELD\]/, html);
  521. }
  522. return html;
  523. },
  524. '_label': function (name, options, data) {
  525. var label = options['label'] ||
  526. name.substring(0, 1).toUpperCase() + name.substring(1)
  527. .replace(/_/g, '&nbsp;');
  528.  
  529. return '<label for="__MonkeyConfig_field_' + name + '">' + label +
  530. '</label>';
  531. },
  532. 'checkbox': function (name, options, data) {
  533. return '<input id="__MonkeyConfig_field_' + name +
  534. '" type="checkbox" name="' + name + '" />';
  535. },
  536. 'custom': function (name, options, data) {
  537. return options.html;
  538. },
  539. 'number': function (name, options, data) {
  540. return '<input id="__MonkeyConfig_field_' + name + '" ' +
  541. 'type="text" class="__MonkeyConfig_field_number" ' +
  542. 'name="' + name + '" />';
  543. },
  544. 'select': function (name, options, data) {
  545. var choices = {}, html = '';
  546. if (options.choices.constructor == Array) {
  547. /* options.choices is an array -- build key/value pairs */
  548. for (var i = 0; i < options.choices.length; i++)
  549. choices[options.choices[i]] = options.choices[i];
  550. }
  551. else
  552. /* options.choices is an object -- use it as it is */
  553. choices = options.choices;
  554.  
  555. if (!options.multiple) {
  556. /* Single selection */
  557. if (!/^radio/.test(options.variant)) {
  558. /* Select element */
  559. html += '<select id="__MonkeyConfig_field_' + name + '" ' +
  560. 'class="__MonkeyConfig_field_select" ' +
  561. 'name="' + name + '">';
  562. for (var value in choices)
  563. html += '<option value="' + MonkeyConfig.esc(value) + '">' +
  564. choices[value] + '</option>';
  565. html += '</select>';
  566. }
  567. else {
  568. /* Radio buttons */
  569. for (var value in choices) {
  570. html += '<label><input type="radio" name="' + name + '" ' +
  571. 'value="' + MonkeyConfig.esc(value) + '" />&nbsp;' +
  572. choices[value] + '</label>' +
  573. (/ column/.test(options.variant) ? '<br />' : '');
  574. }
  575. }
  576. }
  577. else {
  578. /* Multiple selection */
  579. if (!/^checkbox/.test(options.variant)) {
  580. /* Checkboxes */
  581. html += '<select id="__MonkeyConfig_field_' + name + '" ' +
  582. 'class="__MonkeyConfig_field_select" ' +
  583. 'multiple="multiple" ' +
  584. 'name="' + name + '">';
  585. for (var value in choices)
  586. html += '<option value="' + MonkeyConfig.esc(value) + '">' +
  587. choices[value] + '</option>';
  588. html += '</select>';
  589. }
  590. else {
  591. /* Select element */
  592. for (var value in choices) {
  593. html += '<label><input type="checkbox" ' +
  594. 'name="' + name + '" ' +
  595. 'value="' + MonkeyConfig.esc(value) + '" />&nbsp;' +
  596. choices[value] + '</label>' +
  597. (/ column/.test(options.variant) ? '<br />' : '');
  598. }
  599. }
  600. }
  601. return html;
  602. },
  603. 'text': function (name, options, data) {
  604. if (options.long)
  605. return '<textarea id="__MonkeyConfig_field_' + name + '" ' +
  606. 'class="__MonkeyConfig_field_text" ' +
  607. (!isNaN(options.long) ? 'rows="' + options.long + '" ' : '') +
  608. 'name="' + name + '"></textarea>';
  609. else
  610. return '<input id="__MonkeyConfig_field_' + name + '" ' +
  611. 'type="text" class="__MonkeyConfig_field_text" ' +
  612. 'name="' + name + '" />';
  613. },
  614. 'color': function(name, options, data) {
  615. return '<input id="__MonkeyConfig_field_' + name + '" ' +
  616. 'type="color" class="__MonkeyConfig_field_text" ' +
  617. 'name="' + name + '" />';
  618. }
  619. };
  620.  
  621. MonkeyConfig.formatters = {
  622. 'tr': function (name, options, data) {
  623. var html = '<tr>';
  624.  
  625. switch (options.type) {
  626. case 'checkbox':
  627. /* Checkboxes get special treatment */
  628. html += '<td id="__MonkeyConfig_parent_' + name + '" colspan="2">';
  629. html += MonkeyConfig.HTML['_field'](name, options, data) + ' ';
  630. html += MonkeyConfig.HTML['_label'](name, options, data);
  631. html += '</td>';
  632. break;
  633. default:
  634. html += '<td>';
  635. html += MonkeyConfig.HTML['_label'](name, options, data);
  636. html += '</td><td id="__MonkeyConfig_parent_' + name + '">';
  637. html += MonkeyConfig.HTML['_field'](name, options, data);
  638. html += '</td>';
  639. break;
  640. }
  641. html += '</tr>';
  642.  
  643. return html;
  644. }
  645. };
  646.  
  647. /* Has the stylesheet been added? */
  648. MonkeyConfig.styleAdded = false;
  649.  
  650. /* Resources */
  651. MonkeyConfig.res = {};
  652.  
  653. /* Icons */
  654. MonkeyConfig.res.icons = {
  655. 'arrow_undo': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0\
  656. U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAIJSURBVDjLpVM9aJNRFD35GsRSoUKKzQ/B\
  657. 0NJJF3EQlKrVgijSCBmC4NBFKihIcXBwEZdSHVoUwUInFUEkQ1DQ4CKiFsQsTrb5xNpgaZHw2Uog\
  658. 5t5zn0NJNFaw0guX97hwzuPcc17IOYfNlIdNVrhxufR6xJkZjAbSQGXjNAorqixSWFDV3KPhJ+UG\
  659. LtSQMPryrDscPwLnAHOEOQc6gkbUpIagGmApWIb/pZRX4fjj889nWiSQtgYyBZ1BTUEj6AjPa0P7\
  660. 1nb0Jfqwa+futIheHrzRn2yRQCUK/lOQhApBJVQJChHfnkCqOwWEQ+iORJHckUyX5ksvAEyGNuJC\
  661. +s6xCRXNHNxzKMmQ4luwgjfvZp69uvr2+IZcyJ8rjIporrxURggetnV0QET3rrPxzMNM2+n7p678\
  662. jUTrCiWhphAjVHR9DlR0WkSzf4IHxg5MSF0zXZEuVKWKSlCBCostS8zeG7oV64wPqxInbw86lbVX\
  663. KEQ8mkAqmUJ4SxieeVhcnANFC02C7N2h69HO2IXeWC8MDj2JnqaFNAMd8f3HKjx6+LxQRmnOz1OZ\
  664. axKIaF1VISYwB9ARZoQaYY6o1WpYCVYxt+zDn/XzVBv/MOWXW5J44ubRyVgkelFpmF/4BJVfOVDl\
  665. VyqLVBZI5manPjajDOdcswfG9k/3X9v3/vfZv7rFBanriIo++J/f+BMT+YWS6hXl7QAAAABJRU5E\
  666. rkJggg==',
  667. 'cancel': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0\
  668. U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHdSURBVDjLpZNraxpBFIb3a0ggISmmNISW\
  669. XmOboKihxpgUNGWNSpvaS6RpKL3Ry//Mh1wgf6PElaCyzq67O09nVjdVlJbSDy8Lw77PmfecMwZg\
  670. /I/GDw3DCo8HCkZl/RlgGA0e3Yfv7+DbAfLrW+SXOvLTG+SHV/gPbuMZRnsyIDL/OASziMxkkKkU\
  671. QTJJsLaGn8/iHz6nd+8mQv87Ahg2H9Th/BxZqxEkEgSrq/iVCvLsDK9awtvfxb2zjD2ARID+lVVl\
  672. babTgWYTv1rFL5fBUtHbbeTJCb3EQ3ovCnRC6xAgzJtOE+ztheYIEkqbFaS3vY2zuIj77AmtYYDu\
  673. sPy8/zuvunJkDKXM7tYWTiyGWFjAqeQnAD6+7ueNx/FLpRGAru7mcoj5ebqzszil7DggeF/DX1nB\
  674. N82rzPqrzbRayIsLhJqMPT2N83Sdy2GApwFqRN7jFPL0tF+10cDd3MTZ2AjNUkGCoyO6y9cRxfQo\
  675. wFUbpufr1ct4ZoHg+Dg067zduTmEbq4yi/UkYidDe+kaTcP4ObJIajksPd/eyx3c+N2rvPbMDPbU\
  676. FPZSLKzcGjKPrbJaDsu+dQO3msfZzeGY2TCvKGYQhdSYeeJjUt21dIcjXQ7U7Kv599f4j/oF55W4\
  677. g/2e3b8AAAAASUVORK5CYII=',
  678. 'tick': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0\
  679. U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGrSURBVDjLvZPZLkNhFIV75zjvYm7VGFNC\
  680. qoZUJ+roKUUpjRuqp61Wq0NKDMelGGqOxBSUIBKXWtWGZxAvobr8lWjChRgSF//dv9be+9trCwAI\
  681. /vIE/26gXmviW5bqnb8yUK028qZjPfoPWEj4Ku5HBspgAz941IXZeze8N1bottSo8BTZviVWrEh5\
  682. 46EO03EXpuJOdG63otJbjBKHkEp/Ml6yNYYzpuezWL4s5VMtT8acCMQcb5XL3eJE8VgBlR7BeMGW\
  683. 9Z4yT9y1CeyucuhdTGDxfftaBO7G4L+zg91UocxVmCiy51NpiP3n2treUPujL8xhOjYOzZYsQWAN\
  684. yRYlU4Y9Br6oHd5bDh0bCpSOixJiWx71YY09J5pM/WEbzFcDmHvwwBu2wnikg+lEj4mwBe5bC5h1\
  685. OUqcwpdC60dxegRmR06TyjCF9G9z+qM2uCJmuMJmaNZaUrCSIi6X+jJIBBYtW5Cge7cd7sgoHDfD\
  686. aAvKQGAlRZYc6ltJlMxX03UzlaRlBdQrzSCwksLRbOpHUSb7pcsnxCCwngvM2Rm/ugUCi84fycr4\
  687. l2t8Bb6iqTxSCgNIAAAAAElFTkSuQmCC'
  688. };
  689.  
  690. /* Stylesheets */
  691. MonkeyConfig.res.stylesheets = {
  692. 'main': '\
  693. body.__MonkeyConfig_window {\
  694. appearance: window !important;\
  695. -moz-appearance: window !important;\
  696. background: auto;\
  697. font-family: sans-serif !important;\
  698. height: 100% !important;\
  699. margin: 0 !important;\
  700. padding: 0 !important;\
  701. width: 100% !important;\
  702. }\
  703. \
  704. div.__MonkeyConfig_container {\
  705. display: table !important;\
  706. font-family: sans-serif !important;\
  707. padding: 0.3em !important;\
  708. }\
  709. \
  710. body.__MonkeyConfig_window div.__MonkeyConfig_container {\
  711. appearance: window !important;\
  712. -moz-appearance: window !important;\
  713. height: 100%;\
  714. width: 100%;\
  715. }\
  716. \
  717. div.__MonkeyConfig_container h1 {\
  718. border-bottom: solid 1px #999 !important;\
  719. font-family: sans-serif !important;\
  720. font-size: 120% !important;\
  721. margin: 0 !important;\
  722. padding: 0 0 0.3em 0 !important;\
  723. }\
  724. \
  725. div.__MonkeyConfig_container table {\
  726. border-spacing: 0 !important;\
  727. margin: 0 !important;\
  728. }\
  729. \
  730. div.__MonkeyConfig_container table td {\
  731. border: none !important;\
  732. line-height: 100% !important;\
  733. padding: 0.3em !important;\
  734. text-align: left !important;\
  735. vertical-align: top !important;\
  736. white-space: nowrap !important;\
  737. }\
  738. \
  739. div.__MonkeyConfig_container table td.__MonkeyConfig_buttons {\
  740. padding: 0.2em 0 !important;\
  741. }\
  742. \
  743. .__MonkeyConfig_field_number {\
  744. width: 5em !important;\
  745. }\
  746. \
  747. div.__MonkeyConfig_container td.__MonkeyConfig_buttons table {\
  748. border-top: solid 1px #999 !important;\
  749. width: 100% !important;\
  750. }\
  751. \
  752. div.__MonkeyConfig_container td.__MonkeyConfig_buttons td {\
  753. padding: 0.6em 0.3em 0.1em 0.3em !important;\
  754. text-align: center !important;\
  755. vertical-align: top;\
  756. }\
  757. \
  758. div.__MonkeyConfig_container td.__MonkeyConfig_buttons button {\
  759. appearance: button !important;\
  760. -moz-appearance: button !important;\
  761. background-position: 8px 50% !important;\
  762. background-repeat: no-repeat !important;\
  763. padding: 3px 8px 3px 24px !important;\
  764. padding: 3px 8px !important;\
  765. white-space: nowrap !important;\
  766. }\
  767. \
  768. div.__MonkeyConfig_container td.__MonkeyConfig_buttons button img {\
  769. vertical-align: middle !important;\
  770. }\
  771. \
  772. div.__MonkeyConfig_layer {\
  773. display: table !important;\
  774. position: fixed !important;\
  775. }\
  776. \
  777. div.__MonkeyConfig_layer div.__MonkeyConfig_container,\
  778. body.__MonkeyConfig_body > div.__MonkeyConfig_container {\
  779. background: #eee linear-gradient(180deg,\
  780. #f8f8f8 0, #ddd 100%) !important;\
  781. border-radius: 0.5em !important;\
  782. box-shadow: 2px 2px 16px #000 !important;\
  783. color: #000 !important;\
  784. font-family: sans-serif !important;\
  785. font-size: 11pt !important;\
  786. padding: 1em 1em 0.4em 1em !important;\
  787. }\
  788. \
  789. div.__MonkeyConfig_layer div.__MonkeyConfig_container td,\
  790. div.__MonkeyConfig_layer div.__MonkeyConfig_container label,\
  791. div.__MonkeyConfig_layer div.__MonkeyConfig_container input,\
  792. div.__MonkeyConfig_layer div.__MonkeyConfig_container select,\
  793. div.__MonkeyConfig_layer div.__MonkeyConfig_container textarea,\
  794. div.__MonkeyConfig_layer div.__MonkeyConfig_container button {\
  795. color: #000 !important;\
  796. font-family: sans-serif !important;\
  797. font-size: 11pt !important;\
  798. line-height: 100% !important;\
  799. margin: 0 !important;\
  800. vertical-align: baseline !important;\
  801. }\
  802. \
  803. div.__MonkeyConfig_container label {\
  804. line-height: 120% !important;\
  805. vertical-align: baseline !important;\
  806. }\
  807. \
  808. div.__MonkeyConfig_container textarea {\
  809. vertical-align: text-top !important;\
  810. width: 100%;\
  811. }\
  812. \
  813. div.__MonkeyConfig_layer div.__MonkeyConfig_container input[type="text"] {\
  814. appearance: textfield !important;\
  815. -moz-appearance: textfield !important;\
  816. background: #fff !important;\
  817. }\
  818. \
  819. div.__MonkeyConfig_layer div.__MonkeyConfig_container h1 {\
  820. font-weight: bold !important;\
  821. text-align: left !important;\
  822. }\
  823. \
  824. div.__MonkeyConfig_layer div.__MonkeyConfig_container td.__MonkeyConfig_buttons button,\
  825. body > div.__MonkeyConfig_container td.__MonkeyConfig_buttons button {\
  826. appearance: button !important;\
  827. -moz-appearance: button !important;\
  828. background: #ccc linear-gradient(180deg,\
  829. #ddd 0, #ccc 45%, #bbb 50%, #aaa 100%) !important;\
  830. border-style: solid !important;\
  831. border-width: 1px !important;\
  832. border-radius: 0.5em !important;\
  833. box-shadow: 0 0 1px #000 !important;\
  834. color: #000 !important;\
  835. font-size: 11pt !important;\
  836. }\
  837. \
  838. div.__MonkeyConfig_layer div.__MonkeyConfig_container td.__MonkeyConfig_buttons button:hover,\
  839. body > div.__MonkeyConfig_container td.__MonkeyConfig_buttons button:hover {\
  840. background: #d2d2d2 linear-gradient(180deg,\
  841. #e2e2e2 0, #d2d2d2 45%, #c2c2c2 50%, #b2b2b2 100%) !important;\
  842. }\
  843. \
  844. div.__MonkeyConfig_overlay {\
  845. background-color: #000 !important;\
  846. opacity: 0.6 !important;\
  847. position: fixed !important;\
  848. }\
  849. \
  850. iframe#__MonkeyConfig_frame {\
  851. border: none !important;\
  852. box-shadow: 2px 2px 16px #000 !important;\
  853. }\
  854. \
  855. body.__MonkeyConfig_body {\
  856. margin: 0 !important;\
  857. padding: 0 !important;\
  858. }\
  859. '
  860. };