From 4be6d03eb80eabdf5c162caad44cc4bb8709509e Mon Sep 17 00:00:00 2001 From: Dario Giovannetti Date: Fri, 13 Mar 2020 22:22:01 +0800 Subject: [PATCH 01/53] Add ESlint --- .eslintrc.js | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..8ffbb9b --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,92 @@ +module.exports = { + 'root': true, + 'parserOptions': { + 'ecmaVersion': 2018, + 'sourceType': 'module', + }, + 'env': { + 'node': true, + }, + 'extends': [ + 'eslint:all', + ], + 'rules': { + 'array-bracket-newline': ['error', 'consistent'], + 'array-element-newline': 'off', + 'arrow-body-style': 'off', + 'brace-style': ['error', '1tbs', {'allowSingleLine': true}], + 'camelcase': 'warn', + 'capitalized-comments': 'off', + 'no-constant-condition': ['error', {'checkLoops': false}], + 'comma-dangle': ['error', 'always-multiline'], + 'curly': ["error", "multi-line"], + 'dot-location': ["error", "property"], + 'eqeqeq': ['error', 'smart'], + 'func-names': 'off', + 'func-style': 'off', + 'function-call-argument-newline': ['error', 'consistent'], + 'guard-for-in': 'off', + 'id-length': 'off', + 'indent': ['error', 2], + 'init-declarations': 'off', + 'line-comment-position': 'off', + 'linebreak-style': ['error', 'unix'], + 'lines-around-comment': 'off', + 'max-len': ['warn', {'ignoreTrailingComments': true}], + 'max-lines-per-function': 'off', + 'max-statements': 'off', + 'max-statements-per-line': 'off', + 'multiline-comment-style': ['error', 'separate-lines'], + 'multiline-ternary': ['error', 'always-multiline'], + 'newline-per-chained-call': 'off', + 'no-alert': 'warn', + 'no-confusing-arrow': 'off', + 'no-console': 'warn', + 'no-continue': 'off', + 'no-empty': ['error', {'allowEmptyCatch': true}], + 'no-eq-null': 'off', + 'no-extra-parens': 'off', + 'no-extra-semi': 'error', + 'no-inline-comments': 'off', + 'no-labels': 'off', + 'no-magic-numbers': 'off', + 'no-mixed-operators': 'off', + 'no-multi-assign': 'off', + 'no-multi-str': 'off', + 'no-nested-ternary': 'off', + 'no-plusplus': 'off', + 'no-prototype-builtins': 'off', + 'no-ternary': 'off', + 'no-underscore-dangle': 'off', + 'no-unused-expressions': ['error', { + 'allowShortCircuit': true, + 'allowTernary': true, + 'allowTaggedTemplates': true + }], + 'no-unused-vars': 'warn', + 'no-use-before-define': 'warn', + 'no-warning-comments': 'off', + 'object-curly-newline': 'off', + 'object-property-newline': ['error', { + 'allowAllPropertiesOnSameLine': true, + }], + 'one-var': ['error', 'never'], + 'padded-blocks': ['error', 'never'], + 'prefer-arrow-callback': ['error', {'allowNamedFunctions': true}], + 'prefer-destructuring': 'off', + 'prefer-template': 'off', + 'quote-props': ['error', 'as-needed'], + // BUG[setup]: 'avoidEscape' should be true by default but apparently it's not? + 'quotes': ['error', 'single', {'avoidEscape': true}], + 'require-jsdoc': 'off', + 'semi': ['error', 'never'], + 'semi-style': ['error', 'first'], + 'sort-imports': 'off', + 'sort-keys': 'off', + 'space-before-function-paren': ['error', { + 'anonymous': 'always', + 'named': 'never', + 'asyncArrow': 'always', + }], + }, + } diff --git a/package.json b/package.json index 70ed5dc..ca1a69b 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "devDependencies": { "babel-core": "^6.26.3", "babel-preset-env": "^1.7.0", - "coffeescript": "^2.5.1" + "coffeescript": "^2.5.1", + "eslint": "^6.8.0" }, "babel": { "presets": [ From 0b93e147a19c7a144daa94bdc5c8259c67cd9dde Mon Sep 17 00:00:00 2001 From: Dario Giovannetti Date: Fri, 13 Mar 2020 22:39:04 +0800 Subject: [PATCH 02/53] Properly compile everythin with CoffeeScript and Babel --- dist/GMAPIEmulation.js | 24 ++-- dist/async.js | 28 ++-- dist/blob.js | 32 ++--- dist/bootstrap-datepicker.js | 50 ++++---- dist/bootstrap-table.js | 29 +++-- dist/choice.js | 47 ++++--- dist/compatibility.js | 6 +- dist/css.js | 6 +- dist/datetime.js | 8 +- dist/dom.js | 26 +++- dist/format.js | 6 +- dist/groupAsyncGeneratorByNested.js | 191 ++++++++++++++++++++++++++++ dist/http.js | 29 ++++- dist/hyperscript.js | 25 ++-- dist/image-uploader.js | 139 +++++++++++++------- dist/iterateFormData.js | 46 +++++++ dist/iterateMultilineMatches.js | 131 +++++++++++++++++++ dist/jquery-ui-datepicker.js | 28 ++-- dist/maplink.js | 12 +- dist/math.js | 4 - dist/modal.js | 26 ++-- dist/obj.js | 9 +- dist/postFiles.js | 46 +++++++ dist/regexp.js | 11 +- dist/spa.js | 8 +- dist/str.js | 38 ++++-- dist/table.js | 66 ++++++---- dist/tabulator.js | 134 +++++++++++++++---- dist/toc.js | 22 ++-- dist/zoom.js | 37 +++--- package.json | 9 +- 31 files changed, 943 insertions(+), 330 deletions(-) create mode 100644 dist/groupAsyncGeneratorByNested.js create mode 100644 dist/iterateFormData.js create mode 100644 dist/iterateMultilineMatches.js create mode 100644 dist/postFiles.js diff --git a/dist/GMAPIEmulation.js b/dist/GMAPIEmulation.js index 3c33f46..d1dfdaf 100644 --- a/dist/GMAPIEmulation.js +++ b/dist/GMAPIEmulation.js @@ -3,28 +3,22 @@ // Generated by CoffeeScript 2.5.1 // JavaScript auxiliary library // Copyright (C) 2012 Dario Giovannetti - // This file is part of JavaScript auxiliary library. - // JavaScript auxiliary library is free software: you can redistribute it // and/or modify it under the terms of the GNU General Public License // as published by the Free Software Foundation, either version 3 // of the License, or (at your option) any later version. - // JavaScript auxiliary library is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // You should have received a copy of the GNU General Public License // along with JavaScript auxiliary library. // If not, see . if (typeof GM_xmlhttpRequest === "undefined" || GM_xmlhttpRequest === null) { window.GM_xmlhttpRequest = function () { - var header, req; - // This function emulates GM_xmlhttpRequest only partially + var header, req; // This function emulates GM_xmlhttpRequest only partially // Notably cross-origin requests are not supported - // params = { // method: , // url: , @@ -35,7 +29,6 @@ if (typeof GM_xmlhttpRequest === "undefined" || GM_xmlhttpRequest === null) { // onload: , // onerror: , // onreadystatechange: , - // // Not yet implemented // //binary: , // //mozBackgroundRequest: , @@ -47,36 +40,47 @@ if (typeof GM_xmlhttpRequest === "undefined" || GM_xmlhttpRequest === null) { // //failOnRedirect: , // //redirectionLimit: , // } + if (params.method == null) { params.method = "GET"; } + if (params.data == null) { params.data = null; } + if (params.headers == null) { params.headers = {}; } + if (params.user == null) { params.user = null; } + if (params.password == null) { params.password = null; } + if (params.onload == null) { params.onload = function (req) {}; } + if (params.onerror == null) { params.onerror = function (req) {}; } + if (params.onreadystatechange == null) { params.onreadystatechange = function (req) {}; } + params.async = true; req = new XMLHttpRequest(); req.open(params.method, params.url, params.async, params.user, params.password); + for (header in params.headers) { req.setRequestHeader(header, params.headers[header]); } + req.onreadystatechange = function () { var err, response; response = { @@ -86,6 +90,7 @@ if (typeof GM_xmlhttpRequest === "undefined" || GM_xmlhttpRequest === null) { status: req.status, statusText: req.statusText }; + try { // Not yet implemented //finalUrl: , @@ -94,7 +99,9 @@ if (typeof GM_xmlhttpRequest === "undefined" || GM_xmlhttpRequest === null) { err = error; response.responseJSON = void 0; } + params.onreadystatechange(response); + if (req.readyState === 4) { if (req.status === 200) { return params.onload(response); @@ -103,6 +110,7 @@ if (typeof GM_xmlhttpRequest === "undefined" || GM_xmlhttpRequest === null) { } } }; + req.send(params.data); return { abort: function abort() { diff --git a/dist/async.js b/dist/async.js index f576af0..4811f5a 100644 --- a/dist/async.js +++ b/dist/async.js @@ -3,19 +3,15 @@ // Generated by CoffeeScript 2.5.1 // JavaScript auxiliary library // Copyright (C) 2012 Dario Giovannetti - // This file is part of JavaScript auxiliary library. - // JavaScript auxiliary library is free software: you can redistribute it // and/or modify it under the terms of the GNU General Public License // as published by the Free Software Foundation, either version 3 // of the License, or (at your option) any later version. - // JavaScript auxiliary library is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // You should have received a copy of the GNU General Public License // along with JavaScript auxiliary library. // If not, see . @@ -24,18 +20,20 @@ module.exports.executeAsync = function (functions, id) { var callContinue, fid; id++; + if (functions[id]) { fid = functions[id]; + callContinue = function callContinue() { return _this.executeAsync(functions, id); }; + return fid[0](fid[1], callContinue); } }; module.exports.recurseTreeAsync = function (params) { - var parent; - // params = { + var parent; // params = { // node: , // parentIndex: , // siblingIndex: , @@ -48,7 +46,6 @@ module.exports.recurseTreeAsync = function (params) { // stage: , // nodesList: // } - // nodesList: [ // { // node: , @@ -59,9 +56,7 @@ module.exports.recurseTreeAsync = function (params) { // }, // {...} // ] - // Example: - // recurseTreeAsync({ // node: , // callChildren: , @@ -69,17 +64,15 @@ module.exports.recurseTreeAsync = function (params) { // callEnd: , // callArgs: // }); - // callChildren(params) { // params.children = ; // recurseTreeAsync(params); // } - // callNode(params) { // recurseTreeAsync(params); // } - // callEnd(params) {} + switch (params.stage) { case void 0: params.parentIndex = null; @@ -89,16 +82,19 @@ module.exports.recurseTreeAsync = function (params) { params.nodesList = []; params.stage = 1; return this.recurseTreeAsync(params); + case 1: - params.stage = 2; - // Prevent infinite loops + params.stage = 2; // Prevent infinite loops + if (params.ancestors.indexOf(params.node) === -1) { return params.callChildren(params); } else { params.children = "loop"; return this.recurseTreeAsync(params); } + break; + case 2: params.nodesList.push({ node: params.node, @@ -109,6 +105,7 @@ module.exports.recurseTreeAsync = function (params) { }); params.stage = 3; return params.callNode(params); + case 3: if (params.children.length && params.children !== "loop") { // Go to the first child @@ -125,6 +122,7 @@ module.exports.recurseTreeAsync = function (params) { params.siblingIndex++; params.node = parent.children[params.siblingIndex]; params.children = []; + if (params.node) { params.stage = 1; } else { @@ -135,10 +133,12 @@ module.exports.recurseTreeAsync = function (params) { params.ancestors = parent.ancestors.slice(0); params.stage = 3; } + return this.recurseTreeAsync(params); } else { // End of recursion return params.callEnd(params); } + } }; \ No newline at end of file diff --git a/dist/blob.js b/dist/blob.js index 11e2da5..c80b035 100644 --- a/dist/blob.js +++ b/dist/blob.js @@ -1,21 +1,17 @@ -'use strict'; +"use strict"; // Generated by CoffeeScript 2.5.1 // lib.cs.misc - Check the status of code repositories under a root directory. // Copyright (C) 2016 Dario Giovannetti - // This file is part of lib.cs.misc. - // lib.cs.misc is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - // lib.cs.misc is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // You should have received a copy of the GNU General Public License // along with lib.cs.misc. If not, see . module.exports.extjQuery = function ($) { @@ -25,38 +21,42 @@ module.exports.extjQuery = function ($) { blob = new Blob([text], { type: 'text/plain' }); - $(this).attr("href", window.URL.createObjectURL(blob)).attr('download', filename); - // This is supposed to be called from a click event, so don't run + $(this).attr("href", window.URL.createObjectURL(blob)).attr('download', filename); // This is supposed to be called from a click event, so don't run // .get(0).click() here + return $(this); }); }; -}; +}; // http://stackoverflow.com/a/5100158 + -// http://stackoverflow.com/a/5100158 module.exports.dataURItoBlob = function (dataURI) { // convert base64/URLEncoded data component to raw binary data held in a // string byteString; var byteString, i, ia, j, mimeString, ref; + if (dataURI.split(',')[0].indexOf('base64') >= 0) { byteString = atob(dataURI.split(',')[1]); } else { byteString = unescape(dataURI.split(',')[1]); - } - // separate out the mime component - mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; - // write the bytes of the string to a typed array + } // separate out the mime component + + + mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; // write the bytes of the string to a typed array + ia = new Uint8Array(byteString.length); + for (i = j = 0, ref = byteString.length; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { ia[i] = byteString.charCodeAt(i); } + return new Blob([ia], { type: mimeString }); -}; +}; // http://stackoverflow.com/a/30407840 + -// http://stackoverflow.com/a/30407840 module.exports.dataURLtoBlob = function (dataurl) { var arr, bstr, mime, n, u8arr; arr = dataurl.split(','); @@ -64,9 +64,11 @@ module.exports.dataURLtoBlob = function (dataurl) { bstr = atob(arr[1]); n = bstr.length; u8arr = new Uint8Array(n); + while (n--) { u8arr[n] = bstr.charCodeAt(n); } + return new Blob([u8arr], { type: mime }); diff --git a/dist/bootstrap-datepicker.js b/dist/bootstrap-datepicker.js index daaadd0..082c067 100644 --- a/dist/bootstrap-datepicker.js +++ b/dist/bootstrap-datepicker.js @@ -1,36 +1,33 @@ -'use strict'; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +"use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + // Generated by CoffeeScript 2.5.1 // lib.cs.misc - Check the status of code repositories under a root directory. // Copyright (C) 2016 Dario Giovannetti - // This file is part of lib.cs.misc. - // lib.cs.misc is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - // lib.cs.misc is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // You should have received a copy of the GNU General Public License // along with lib.cs.misc. If not, see . var $, BootstrapDatePickerAltDisplay; - $ = require('jquery'); require('bootstrap'); require('bootstrap-datepicker'); -BootstrapDatePickerAltDisplay = function () { +BootstrapDatePickerAltDisplay = /*#__PURE__*/function () { function BootstrapDatePickerAltDisplay() { var _this = this; @@ -40,13 +37,15 @@ BootstrapDatePickerAltDisplay = function () { _classCallCheck(this, BootstrapDatePickerAltDisplay); var ref, ref1; + if (config.format_date == null) { config.format_date = function (widget) { return widget.get_date(); }; - } - // Simply setting it as type="hidden" would show the popup in the + } // Simply setting it as type="hidden" would show the popup in the // top-left corner of the screen + + this.picker = $('').css({ width: 0, height: 0, @@ -65,17 +64,21 @@ BootstrapDatePickerAltDisplay = function () { }).addClass('datepicker-display').click(function () { return _this.picker.datepicker('show'); }); + if (config.name != null) { this.picker.attr('name', config.name); } + if (config.size != null) { this.display.attr('size', config.size); } - if (config.class != null) { - this.display.addClass(config.class); - } - // This block triggers 'change' on the picker, execute after configuring + + if (config["class"] != null) { + this.display.addClass(config["class"]); + } // This block triggers 'change' on the picker, execute after configuring // everything + + if (config.initial_value != null) { this.set_date(config.initial_value); this.picker.trigger('change'); @@ -83,16 +86,17 @@ BootstrapDatePickerAltDisplay = function () { } _createClass(BootstrapDatePickerAltDisplay, [{ - key: 'get_date', + key: "get_date", value: function get_date() { return this.picker.datepicker('getDate'); } }, { - key: 'set_date', + key: "set_date", value: function set_date(date) { if (typeof date === 'string') { date = new Date(date); } + return this.picker.datepicker('setDate', date); } }]); @@ -102,25 +106,27 @@ BootstrapDatePickerAltDisplay = function () { module.exports.extjQuery = function ($) { return $.fn.bootstrapDatepickerAltDisplay = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return this.each(function () { var config, dpconfig, ref, ref1, widget; + if (typeof args[0] === 'string') { var _widget$picker; - widget = $(this).data('widget'); - // BUG: This is broken because the main + widget = $(this).data('widget'); // BUG: This is broken because the main // bootstrapDatepickerAltDisplay method returns @each + return (_widget$picker = widget.picker).datepicker.apply(_widget$picker, args); } + config = (ref = args[0]) != null ? ref : {}; dpconfig = (ref1 = args[1]) != null ? ref1 : {}; - widget = new BootstrapDatePickerAltDisplay(config, dpconfig); - // Append the picker before the display, so that the popup + widget = new BootstrapDatePickerAltDisplay(config, dpconfig); // Append the picker before the display, so that the popup // appears on the left + return $(this).data('widget', widget).append(widget.picker, widget.display); }); }; diff --git a/dist/bootstrap-table.js b/dist/bootstrap-table.js index e557e7f..00a1365 100644 --- a/dist/bootstrap-table.js +++ b/dist/bootstrap-table.js @@ -1,46 +1,41 @@ -'use strict'; +"use strict"; // Generated by CoffeeScript 2.5.1 // lib.cs.misc - Check the status of code repositories under a root directory. // Copyright (C) 2016 Dario Giovannetti - // This file is part of lib.cs.misc. - // lib.cs.misc is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - // lib.cs.misc is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // You should have received a copy of the GNU General Public License // along with lib.cs.misc. If not, see . var $, Papa; - $ = require('jquery'); require('bootstrap'); require('bootstrap-table'); -Papa = require('papaparse'); +Papa = require('papaparse'); // TODO: Change this to a proper BootstrapTable extension -// TODO: Change this to a proper BootstrapTable extension module.exports.exportBootstrapTableToCSV = function (table, button) { var blob, column, csv, drow, field, fields, i, index, j, k, len, len1, len2, link, options, ref, ref1, row, rows; options = table.bootstrapTable('getOptions'); fields = []; ref = options.columns[0]; + for (i = 0, len = ref.length; i < len; i++) { column = ref[i]; - field = {}; - // TODO: Document that the title of the first field should not be just + field = {}; // TODO: Document that the title of the first field should not be just // "ID", otherwise Excel will think it is a SYLK file and raise // warnings // https://annalear.ca/2010/06/10/why-excel-thinks-your-csv-is-a-sylk/ + if (column.CSVexportAs == null) { field.title = column.title; } else if (column.CSVexportAs !== false) { @@ -48,7 +43,9 @@ module.exports.exportBootstrapTableToCSV = function (table, button) { } else { continue; } + field.fieldName = column.field; + if (column.CSVexporter != null) { field.exporter = column.CSVexporter; } else { @@ -56,27 +53,35 @@ module.exports.exportBootstrapTableToCSV = function (table, button) { return value; }; } + fields.push(field); } + rows = []; ref1 = table.bootstrapTable('getData'); + for (index = j = 0, len1 = ref1.length; j < len1; index = ++j) { drow = ref1[index]; row = []; + for (k = 0, len2 = fields.length; k < len2; k++) { field = fields[k]; row.push(field.exporter(drow[field.fieldName], drow, index)); } + rows.push(row); } + csv = Papa.unparse({ fields: function () { var l, len3, results; results = []; + for (l = 0, len3 = fields.length; l < len3; l++) { field = fields[l]; results.push(field.title); } + return results; }(), data: rows @@ -87,8 +92,8 @@ module.exports.exportBootstrapTableToCSV = function (table, button) { link = $("").attr({ "download": options.CSVexportFileName, "href": window.URL.createObjectURL(blob) - }).insertAfter(button); - // .trigger("click"); doesn't work + }).insertAfter(button); // .trigger("click"); doesn't work + link[0].click(); return link.remove(); }; \ No newline at end of file diff --git a/dist/choice.js b/dist/choice.js index 9e5b06d..7ee2774 100644 --- a/dist/choice.js +++ b/dist/choice.js @@ -1,45 +1,48 @@ -'use strict'; +"use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } + +function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Generated by CoffeeScript 2.5.1 // lib.cs.misc - Check the status of code repositories under a root directory. // Copyright (C) 2016 Dario Giovannetti - // This file is part of lib.cs.misc. - // lib.cs.misc is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - // lib.cs.misc is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // You should have received a copy of the GNU General Public License // along with lib.cs.misc. If not, see . var $, datetime, h, indexOf = [].indexOf; - $ = require('jquery'); - h = require('hyperscript'); - datetime = require('./datetime'); module.exports.Choice = function (options, selected, props) { var i, len, opt, option, select, text, val; select = h('select', props); + for (i = 0, len = options.length; i < len; i++) { opt = options[i]; + if (Array.isArray(opt)) { var _opt = opt; @@ -50,34 +53,42 @@ module.exports.Choice = function (options, selected, props) { } else { text = val = opt; } + option = h('option', { value: val }, text); + if (val === selected) { option.selected = true; } + select.appendChild(option); } + return select; }; module.exports.Multichoice = function (legend, items, checked, attributes) { var fieldset, i, input, item, len; fieldset = $('
').append($('').text(legend)).attr(attributes); + for (i = 0, len = items.length; i < len; i++) { item = items[i]; input = $('').val(item).attr({ 'type': 'checkbox' }).attr(attributes); + if (indexOf.call(checked, item) >= 0) { input.attr('checked', ''); } + fieldset.append($('
').append(item, input)); } + return fieldset; }; -module.exports.WeekDaySelector = function () { +module.exports.WeekDaySelector = /*#__PURE__*/function () { function WeekDaySelector(selected_days, baseid) { var radio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; @@ -86,34 +97,40 @@ module.exports.WeekDaySelector = function () { var i, id, index, input, len, name, ref, wday; this.container = $('').addClass('weekdayselector'); ref = datetime.WEEKDAYS_SHORT; + for (index = i = 0, len = ref.length; i < len; index = ++i) { wday = ref[index]; - id = baseid + '-' + index; - name = '' + baseid; + id = "".concat(baseid, "-").concat(index); + name = "".concat(baseid); input = $('').attr({ 'type': radio ? 'radio' : 'checkbox', 'name': name, 'id': id }).val(index).appendTo(this.container); + if (selected_days.indexOf(index) > -1) { input.prop("checked", true); } + $('