diff --git a/weave/unwoven-site/collators/index.html b/weave/unwoven-site/collators/index.html index 3d52301..fcf7d67 100644 --- a/weave/unwoven-site/collators/index.html +++ b/weave/unwoven-site/collators/index.html @@ -1,24 +1,23 @@ - - Liot R: Collators - @@/head.html - - - -
- @@/nav.html -

Collators New

-
-
-
- << - < - > - >> - -
-
- - + + Liot R: Collators + @@/head.html + + + +
+ @@/nav.html +

+ Collators New +

+
+
+ << + < + > + >> + +
+
+ +; diff --git a/weave/unwoven-site/collators/new/index.js b/weave/unwoven-site/collators/new/index.js index 90012bb..4f112bb 100644 --- a/weave/unwoven-site/collators/new/index.js +++ b/weave/unwoven-site/collators/new/index.js @@ -1,16 +1,16 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const bonus_1 = require("../../bonus"); -const liotr_1 = require("../../liotr"); +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +const bonus_1 = require('../../bonus'); +const liotr_1 = require('../../liotr'); const liotR = new liotr_1.LiotR(); var COMPARATORS = [ - 'EQUALS', - 'NEQUALS', - 'TFNEQUALS', - 'OVER', - 'OVEROR', - 'UNDER', - 'UNDEROR' + 'EQUALS', + 'NEQUALS', + 'TFNEQUALS', + 'OVER', + 'OVEROR', + 'UNDER', + 'UNDEROR' ]; var OPERATORS = ['AND', 'OR', 'NAND', 'NOR', 'XOR', 'SAME']; var filterList; @@ -18,58 +18,60 @@ var reg = location.href.match(/after=(-?[0-9]+)/); var after = reg ? parseInt(reg[1]) : 0; var filters = []; bonus_1.load(() => { - liotR.listFilters({}, res => { - if (res.err) { - console.log(res.err); - return; - } - filters = res.filters; - //for(var filter of res.filters)filters.push({id:filter.id,name:filter.name}) - }); + liotR.listFilters({}, res => { + if (res.err) { + console.log(res.err); + return; + } + filters = res.filters; + //for(var filter of res.filters)filters.push({id:filter.id,name:filter.name}) + }); }); function addFilter() { - var select = document.createElement('select'); - for (var filter of filters) { - var option = document.createElement('option'); - option.value = filter.id; - option.innerHTML = filter.name; - select.appendChild(option); - } - var rem = document.createElement('label'); - rem.innerHTML = '-'; - var item = document.createElement('div'); - item.appendChild(rem); - item.appendChild(select); - bonus_1.grab('filter-list').insertBefore(item, bonus_1.grab('add-filter')); - bonus_1.bind(rem, 'click', k => { - item.parentNode.removeChild(item); - }); + var select = document.createElement('select'); + for (var filter of filters) { + var option = document.createElement('option'); + option.value = filter.id; + option.innerHTML = filter.name; + select.appendChild(option); + } + var rem = document.createElement('label'); + rem.innerHTML = '-'; + var item = document.createElement('div'); + item.appendChild(rem); + item.appendChild(select); + bonus_1.grab('filter-list').insertBefore(item, bonus_1.grab('add-filter')); + bonus_1.bind(rem, 'click', k => { + item.parentNode.removeChild(item); + }); } function save() { - //addc('save-button', 'disabled'); - err('Creating collator...'); - var name = bonus_1.grab('collator-name').value; - var filtrets = []; - var selects = document.getElementsByTagName('select'); - for (var i of selects) - filtrets.push(i.value); - liotR.addCollators({ - collators: [ - { - name: name, - filters: filtrets - } - ] - }, res => { - if (res.err) { - console.log(res.err); - return; - } - location.href = '/collators'; - }); + //addc('save-button', 'disabled'); + err('Creating collator...'); + var name = bonus_1.grab('collator-name').value; + var filtrets = []; + var selects = document.getElementsByTagName('select'); + for (var i of selects) filtrets.push(i.value); + liotR.addCollators( + { + collators: [ + { + name: name, + filters: filtrets + } + ] + }, + res => { + if (res.err) { + console.log(res.err); + return; + } + location.href = '/collators'; + } + ); } function err(text) { - bonus_1.grab('compile-errors').innerHTML = text || 'Ready'; - bonus_1.setc('compile-errors', 'invalid-json', text); - bonus_1.setc('save-button', 'disabled', text); + bonus_1.grab('compile-errors').innerHTML = text || 'Ready'; + bonus_1.setc('compile-errors', 'invalid-json', text); + bonus_1.setc('save-button', 'disabled', text); } diff --git a/weave/unwoven-site/collectors/index.html b/weave/unwoven-site/collectors/index.html index 731a720..0cfad95 100644 --- a/weave/unwoven-site/collectors/index.html +++ b/weave/unwoven-site/collectors/index.html @@ -1,25 +1,23 @@ - - Liot R: Collectors - @@/head.html - - - -
- @@/nav.html -

Collectors New

- -
-
-
- << - < - > - >> - -
-
- - + + Liot R: Collectors + @@/head.html + + + +
+ @@/nav.html +

+ Collectors New +

+
+
+ << + < + > + >> + +
+
+ +; diff --git a/weave/unwoven-site/distributors/index.html b/weave/unwoven-site/distributors/index.html index 1c8c979..ae4313d 100644 --- a/weave/unwoven-site/distributors/index.html +++ b/weave/unwoven-site/distributors/index.html @@ -1,24 +1,23 @@ - - Liot R: Distributors - @@/head.html - - - -
- @@/nav.html -

Distributors New

-
-
-
- << - < - > - >> - -
-
- - + + Liot R: Distributors + @@/head.html + + + +
+ @@/nav.html +

+ Distributors New +

+
+
+ << + < + > + >> + +
+
+ +; diff --git a/weave/unwoven-site/filters/index.html b/weave/unwoven-site/filters/index.html index 5dae833..2cf078f 100644 --- a/weave/unwoven-site/filters/index.html +++ b/weave/unwoven-site/filters/index.html @@ -1,24 +1,23 @@ - - Liot R: Filters - @@/head.html - - - -
- @@/nav.html -

Filters New

-
-
-
- << - < - > - >> -
- -
- - + + Liot R: Filters + @@/head.html + + + +
+ @@/nav.html +

+ Filters New +

+
+
+ << + < + > + >> +
+ +
+ +; diff --git a/weave/unwoven-site/liotr.js b/weave/unwoven-site/liotr.js index d024526..ddb7eb7 100644 --- a/weave/unwoven-site/liotr.js +++ b/weave/unwoven-site/liotr.js @@ -1,163 +1,162 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); exports.LiotR = void 0; // just `npm i XMLHttpRequest` if you're running this in Node.js if (typeof XMLHttpRequest === 'undefined') { - XMLHttpRequest = require('XMLHttpRequest'); + XMLHttpRequest = require('XMLHttpRequest'); } class LiotR { - /** - * The URL of the Liot R server to connect to. - */ - SERVER = 'http://localhost:7474'; //eye.lyku.org - /** - * Session ID of the current login session. Currently unused. - */ - SESSION = null; - /** - * Post data to the Liot R server - * @namespace API - * @function post - * @param {object} data - the JSON to send to the server. Should contain an action. - * @param {function} callback - the function to call when the post completes or errors (response = {err: 'Description'}). - * @returns {object} the XMLHttpRequest creating for the post. - */ - post = (data, callback) => { - const xml = new XMLHttpRequest(); - if (typeof callback == 'function') { - xml.addEventListener('load', () => { - //alert(xml.response) - callback(JSON.parse(xml.responseText)); - }); - xml.addEventListener('error', () => { - callback({ err: 'Unable to contact server.' }); - }); - } - if (this.SESSION) - data.sessionid = this.SESSION; - //alert(JSON.stringify(data)) - xml.open('POST', this.SERVER); - xml.setRequestHeader('Content-type', 'application/json'); - xml.send(JSON.stringify(data)); - return xml; - }; - /** - * Creates one or more packet collectors. - * @namespace API - * @function addCollectors - * @param {object} data - the parameters of the query - * @param {array} data.filters - the details of the filters to insert - * @param {function} callback - the function to call when the post completes or errors. - * @returns {object} the XMLHttpRequest creating for the post. - */ - addCollectors = (data, callback) => { - data.action = 'add collectors'; - return this.post(data, callback); - }; - /** - * Lists any packet collectors. - * @namespace API - * @function listCollectors - * @param {object} data - The parameters of the query - * @param {number} [data.after = 0] - Skip this many collectors. Default 0. - * @param {number} [data.count = 100] - Return up to this many collectors. Default 100. - * @param {function} callback - The function to call when the post completes or errors. - * @returns {object} The XMLHttpRequest creating for the post. - */ - listCollectors = (data, callback) => { - data.action = 'list collectors'; - return this.post(data, callback); - }; - /** - * Retreives specified packet collectors. - * @namespace API - * @function getCollectors - * @param {object} data - The parameters of the query - * @param {array} data.ids - List of string IDs. - * @param {function} callback - The function to call when the post completes or errors. - * @returns {object} The XMLHttpRequest creating for the post. - */ - getCollectors = (data, callback) => { - data.action = 'get collectors'; - return this.post(data, callback); - }; - /** - * Lists any packet collectors. - * @namespace API - * @function deleteCollectors - * @param {object} data - The parameters of the query - * @param {number} [data.after = 0] - Skip this many collectors. Default 0. - * @param {number} [data.count = 100] - Return up to this many collectors. Default 100. - * @param {function} callback - The function to call when the post completes or errors. - * @returns {object} The XMLHttpRequest creating for the post. - */ - deleteCollectors = (data, callback) => { - data.action = 'delete collectors'; - return this.post(data, callback); - }; - listFilters = (data, callback) => { - data.action = 'list filters'; - return this.post(data, callback); - }; - addFilters = (data, callback) => { - data.action = 'add filters'; - return this.post(data, callback); - }; - getFilters = (data, callback) => { - data.action = 'get filters'; - return this.post(data, callback); - }; - deleteFilters = (data, callback) => { - data.action = 'delete filters'; - return this.post(data, callback); - }; - countFilterReferences = (data, callback) => { - data.action = 'count filter references'; - return this.post(data, callback); - }; - listFilterReferrers = (data, callback) => { - data.action = 'list filter referrers'; - return this.post(data, callback); - }; - addCollators = (data, callback) => { - data.action = 'add collators'; - return this.post(data, callback); - }; - listCollators = (data, callback) => { - data.action = 'list collators'; - return this.post(data, callback); - }; - getCollators = (data, callback) => { - data.action = 'get collators'; - return this.post(data, callback); - }; - deleteCollators = (data, callback) => { - data.action = 'delete collators'; - return this.post(data, callback); - }; - countCollatorReferences = (data, callback) => { - data.action = 'count collator references'; - return this.post(data, callback); - }; - addDistributors = (data, callback) => { - data.action = 'add distributors'; - return this.post(data, callback); - }; - listDistributors = (data, callback) => { - data.action = 'list distributors'; - return this.post(data, callback); - }; - getDistributors = (data, callback) => { - data.action = 'get distributors'; - return this.post(data, callback); - }; - deleteDistributors = (data, callback) => { - data.action = 'delete distributors'; - return this.post(data, callback); - }; - pushUpdate = (data, callback) => { - data.action = 'push update'; - return this.post(data, callback); - }; + /** + * The URL of the Liot R server to connect to. + */ + SERVER = 'http://localhost:7474'; //eye.lyku.org + /** + * Session ID of the current login session. Currently unused. + */ + SESSION = null; + /** + * Post data to the Liot R server + * @namespace API + * @function post + * @param {object} data - the JSON to send to the server. Should contain an action. + * @param {function} callback - the function to call when the post completes or errors (response = {err: 'Description'}). + * @returns {object} the XMLHttpRequest creating for the post. + */ + post = (data, callback) => { + const xml = new XMLHttpRequest(); + if (typeof callback == 'function') { + xml.addEventListener('load', () => { + //alert(xml.response) + callback(JSON.parse(xml.responseText)); + }); + xml.addEventListener('error', () => { + callback({ err: 'Unable to contact server.' }); + }); + } + if (this.SESSION) data.sessionid = this.SESSION; + //alert(JSON.stringify(data)) + xml.open('POST', this.SERVER); + xml.setRequestHeader('Content-type', 'application/json'); + xml.send(JSON.stringify(data)); + return xml; + }; + /** + * Creates one or more packet collectors. + * @namespace API + * @function addCollectors + * @param {object} data - the parameters of the query + * @param {array} data.filters - the details of the filters to insert + * @param {function} callback - the function to call when the post completes or errors. + * @returns {object} the XMLHttpRequest creating for the post. + */ + addCollectors = (data, callback) => { + data.action = 'add collectors'; + return this.post(data, callback); + }; + /** + * Lists any packet collectors. + * @namespace API + * @function listCollectors + * @param {object} data - The parameters of the query + * @param {number} [data.after = 0] - Skip this many collectors. Default 0. + * @param {number} [data.count = 100] - Return up to this many collectors. Default 100. + * @param {function} callback - The function to call when the post completes or errors. + * @returns {object} The XMLHttpRequest creating for the post. + */ + listCollectors = (data, callback) => { + data.action = 'list collectors'; + return this.post(data, callback); + }; + /** + * Retreives specified packet collectors. + * @namespace API + * @function getCollectors + * @param {object} data - The parameters of the query + * @param {array} data.ids - List of string IDs. + * @param {function} callback - The function to call when the post completes or errors. + * @returns {object} The XMLHttpRequest creating for the post. + */ + getCollectors = (data, callback) => { + data.action = 'get collectors'; + return this.post(data, callback); + }; + /** + * Lists any packet collectors. + * @namespace API + * @function deleteCollectors + * @param {object} data - The parameters of the query + * @param {number} [data.after = 0] - Skip this many collectors. Default 0. + * @param {number} [data.count = 100] - Return up to this many collectors. Default 100. + * @param {function} callback - The function to call when the post completes or errors. + * @returns {object} The XMLHttpRequest creating for the post. + */ + deleteCollectors = (data, callback) => { + data.action = 'delete collectors'; + return this.post(data, callback); + }; + listFilters = (data, callback) => { + data.action = 'list filters'; + return this.post(data, callback); + }; + addFilters = (data, callback) => { + data.action = 'add filters'; + return this.post(data, callback); + }; + getFilters = (data, callback) => { + data.action = 'get filters'; + return this.post(data, callback); + }; + deleteFilters = (data, callback) => { + data.action = 'delete filters'; + return this.post(data, callback); + }; + countFilterReferences = (data, callback) => { + data.action = 'count filter references'; + return this.post(data, callback); + }; + listFilterReferrers = (data, callback) => { + data.action = 'list filter referrers'; + return this.post(data, callback); + }; + addCollators = (data, callback) => { + data.action = 'add collators'; + return this.post(data, callback); + }; + listCollators = (data, callback) => { + data.action = 'list collators'; + return this.post(data, callback); + }; + getCollators = (data, callback) => { + data.action = 'get collators'; + return this.post(data, callback); + }; + deleteCollators = (data, callback) => { + data.action = 'delete collators'; + return this.post(data, callback); + }; + countCollatorReferences = (data, callback) => { + data.action = 'count collator references'; + return this.post(data, callback); + }; + addDistributors = (data, callback) => { + data.action = 'add distributors'; + return this.post(data, callback); + }; + listDistributors = (data, callback) => { + data.action = 'list distributors'; + return this.post(data, callback); + }; + getDistributors = (data, callback) => { + data.action = 'get distributors'; + return this.post(data, callback); + }; + deleteDistributors = (data, callback) => { + data.action = 'delete distributors'; + return this.post(data, callback); + }; + pushUpdate = (data, callback) => { + data.action = 'push update'; + return this.post(data, callback); + }; } exports.LiotR = LiotR; diff --git a/weave/unwoven-site/script.js b/weave/unwoven-site/script.js index 5a427bb..8733bb2 100644 --- a/weave/unwoven-site/script.js +++ b/weave/unwoven-site/script.js @@ -1,57 +1,62 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const bonus_1 = require("./bonus"); +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +const bonus_1 = require('./bonus'); function grab(elem, root) { - return typeof elem === 'string' - ? (grab(root) || document).getElementById(elem) - : elem; + return typeof elem === 'string' + ? (grab(root) || document).getElementById(elem) + : elem; } function bind(elem, trigger, func) { - elem.addEventListener(trigger, func); + elem.addEventListener(trigger, func); } function load(func) { - bind(window, 'DOMContentLoaded', func); + bind(window, 'DOMContentLoaded', func); } function xss(text) { - return text.replace('<', '<'); + return text.replace('<', '<'); } function nelem(type) { - return document.createElement(type); + return document.createElement(type); } function namify(rec, type, editing) { - var name = xss(rec.name || ''), id = xss(rec.id); - var edit = `edit${editing ? 'ing' : ''}`; - return ((name.length - ? name - : 'Unnamed ' + type[0].toUpperCase() + type.substr(1) + '') + - edit + - " [" + - id + - ']'); - /*return rec.name && rec.name.length ? + var name = xss(rec.name || ''), + id = xss(rec.id); + var edit = `edit${editing ? 'ing' : ''}`; + return ( + (name.length + ? name + : 'Unnamed ' + type[0].toUpperCase() + type.substr(1) + '') + + edit + + " [" + + id + + ']' + ); + /*return rec.name && rec.name.length ? name + edit + " ["+id+"]" : `[${id}]` + edit;*/ } function appendCollators(collators, to, id) { - for (var i = 0; i < collators.length; i++) { - var rec = collators[i]; - var bubble = nelem('div'); - bonus_1.addc(bubble, 'bubble'); - var top = nelem('div'); - bonus_1.addc(top, 'bubble-top'); - bubble.appendChild(top); - var nameBox = nelem('label'); - nameBox.innerHTML = namify(rec, 'collator', id == rec.id); - //xss((rec.name || "["+rec.id+"]") + ""); - var idBox = nelem('label'); - idBox.innerHTML = xss(rec.id); - var valBox = nelem('label'); - //addc(valBox, 'filters-tooltip'); - var filternames = ''; - var filterNodes = []; - for (var filtret of rec.filtrets) { - filternames += (filtret.name || filtret.id.substring(0, 10)) + ', '; - /*var filterBox = nelem('div'); + for (var i = 0; i < collators.length; i++) { + var rec = collators[i]; + var bubble = nelem('div'); + bonus_1.addc(bubble, 'bubble'); + var top = nelem('div'); + bonus_1.addc(top, 'bubble-top'); + bubble.appendChild(top); + var nameBox = nelem('label'); + nameBox.innerHTML = namify(rec, 'collator', id == rec.id); + //xss((rec.name || "["+rec.id+"]") + ""); + var idBox = nelem('label'); + idBox.innerHTML = xss(rec.id); + var valBox = nelem('label'); + //addc(valBox, 'filters-tooltip'); + var filternames = ''; + var filterNodes = []; + for (var filtret of rec.filtrets) { + filternames += (filtret.name || filtret.id.substring(0, 10)) + ', '; + /*var filterBox = nelem('div'); addc(filterBox, 'bubble'); addc(filterBox, 'subble'); var filterName = nelem('label'); @@ -62,83 +67,79 @@ function appendCollators(collators, to, id) { filterBox.appendChild(filterCode); filterNodes.push(filterBox); appendDropper(filterBox);*/ - } - filternames = - '(' + filternames.substring(0, filternames.length - 2) + ')'; - valBox.innerHTML = xss(filternames); - top.appendChild(nameBox); - //top.appendChild(valBox); - for (var n of filterNodes) - bubble.appendChild(n); - //bubble.appendChild(idBox); - //console.log(filtret.code) - to.appendChild(bubble); - appendFilters(rec.filtrets, bubble, id); - appendDropper(bubble); - appendSpecifics(bubble, rec.id, 'collator'); - //bindBubble(bubble,rec) - } - if (!collators.length) - appendPlaceholder('collators', to); + } + filternames = + '(' + filternames.substring(0, filternames.length - 2) + ')'; + valBox.innerHTML = xss(filternames); + top.appendChild(nameBox); + //top.appendChild(valBox); + for (var n of filterNodes) bubble.appendChild(n); + //bubble.appendChild(idBox); + //console.log(filtret.code) + to.appendChild(bubble); + appendFilters(rec.filtrets, bubble, id); + appendDropper(bubble); + appendSpecifics(bubble, rec.id, 'collator'); + //bindBubble(bubble,rec) + } + if (!collators.length) appendPlaceholder('collators', to); } function appendPlaceholder(type, to) { - var span = nelem('div'); - bonus_1.addc(span, 'placehodler'); - span.innerHTML = 'No ' + type; - to.appendChild(span); + var span = nelem('div'); + bonus_1.addc(span, 'placehodler'); + span.innerHTML = 'No ' + type; + to.appendChild(span); } function appendFilters(filters, filterList, id) { - for (var i = 0; i < filters.length; i++) { - var rec = filters[i]; - var bubble = nelem('div'); - bonus_1.addc(bubble, 'bubble'); - var top = nelem('div'); - bonus_1.addc(top, 'bubble-top'); - bubble.appendChild(top); - var nameBox = nelem('label'); - nameBox.innerHTML = namify(rec, 'filter', id == rec.id); //xss((rec.name || rec.id)); - var idBox = nelem('label'); - idBox.innerHTML = xss(rec.id); - var valBox = nelem('pre'); - valBox.innerHTML = codify(xss(rec.code)); - top.appendChild(nameBox); - bubble.appendChild(valBox); - //bubble.appendChild(idBox); - filterList.appendChild(bubble); - appendDropper(bubble); - //bindBubble(bubble,rec) - appendSpecifics(bubble, rec.id, 'filter'); - } - if (!filters.length) - appendPlaceholder('filters', filterList); + for (var i = 0; i < filters.length; i++) { + var rec = filters[i]; + var bubble = nelem('div'); + bonus_1.addc(bubble, 'bubble'); + var top = nelem('div'); + bonus_1.addc(top, 'bubble-top'); + bubble.appendChild(top); + var nameBox = nelem('label'); + nameBox.innerHTML = namify(rec, 'filter', id == rec.id); //xss((rec.name || rec.id)); + var idBox = nelem('label'); + idBox.innerHTML = xss(rec.id); + var valBox = nelem('pre'); + valBox.innerHTML = codify(xss(rec.code)); + top.appendChild(nameBox); + bubble.appendChild(valBox); + //bubble.appendChild(idBox); + filterList.appendChild(bubble); + appendDropper(bubble); + //bindBubble(bubble,rec) + appendSpecifics(bubble, rec.id, 'filter'); + } + if (!filters.length) appendPlaceholder('filters', filterList); } function appendCollectors(filters, filterList, id) { - for (var i = 0; i < filters.length; i++) { - var rec = filters[i]; - var bubble = nelem('div'); - bonus_1.addc(bubble, 'bubble'); - var top = nelem('div'); - bonus_1.addc(top, 'bubble-top'); - bubble.appendChild(top); - var nameBox = nelem('label'); - nameBox.innerHTML = namify(rec, 'collector', id == rec.id); //xss((rec.name || rec.id)); - var idBox = nelem('label'); - idBox.innerHTML = xss(rec.id); - var valBox = nelem('pre'); - valBox.innerHTML = valify(xss(JSON.stringify(rec, null, 3))); - top.appendChild(nameBox); - bubble.appendChild(valBox); - //bubble.appendChild(idBox); - filterList.appendChild(bubble); - appendDropper(bubble); - //bindBubble(bubble,rec) - appendSpecifics(bubble, rec.id, 'collector'); - } - if (!filters.length) - appendPlaceholder('collectors', filterList); + for (var i = 0; i < filters.length; i++) { + var rec = filters[i]; + var bubble = nelem('div'); + bonus_1.addc(bubble, 'bubble'); + var top = nelem('div'); + bonus_1.addc(top, 'bubble-top'); + bubble.appendChild(top); + var nameBox = nelem('label'); + nameBox.innerHTML = namify(rec, 'collector', id == rec.id); //xss((rec.name || rec.id)); + var idBox = nelem('label'); + idBox.innerHTML = xss(rec.id); + var valBox = nelem('pre'); + valBox.innerHTML = valify(xss(JSON.stringify(rec, null, 3))); + top.appendChild(nameBox); + bubble.appendChild(valBox); + //bubble.appendChild(idBox); + filterList.appendChild(bubble); + appendDropper(bubble); + //bindBubble(bubble,rec) + appendSpecifics(bubble, rec.id, 'collector'); + } + if (!filters.length) appendPlaceholder('collectors', filterList); } function appendSpecifics(bubble, id, type) { - /*var bottom = nelem('div'); + /*var bottom = nelem('div'); addc(bottom, 'bubble-bottom'); var edit = nelem('a'); edit.innerHTML = "Edit " + type[0].toUpperCase() + type.substring(1); @@ -147,75 +148,79 @@ function appendSpecifics(bubble, id, type) { bubble.appendChild(bottom);*/ } function stringValue(value) { - switch (typeof value) { - case 'object': - value = JSON.stringify(value); - case 'string': - if (value.length < 30) { - if (value.length == 0) - value = 'NO VALUE'; - return value; - } - else { - return value.substring(0, 27) + '...'; - } - break; - case 'number': - return value + ''; - break; - } - return value; + switch (typeof value) { + case 'object': + value = JSON.stringify(value); + case 'string': + if (value.length < 30) { + if (value.length == 0) value = 'NO VALUE'; + return value; + } else { + return value.substring(0, 27) + '...'; + } + break; + case 'number': + return value + ''; + break; + } + return value; } function codify(string) { - string = string - .replace(/([:,]) ([0-9]+)(,|\n| \])/g, '$1 %%n%%$2%%n%%$3') - //.replace(/([0-9]+)/g, '%%n%%$1%%n%%') - .replace(/"(\$.+?)"/g, '%%v%%$1%%v%%') - //.replace(/(?:^\s+)([^%])("[^$].+?")([^%])/g, "$1%%s%%$2%%s%%$3") - .replace(/^(\s+)"([A-Z]+)"/gm, '$1%%c%%$2%%c%%') - .replace(/"([^$].+?)"/g, '%%s%%$1%%s%%') - .replace(/%%n%%(.+?)%%n%%/g, '$1') - .replace(/%%s%%(.+?)%%s%%/g, '$1') - .replace(/%%c%%(.+?)%%c%%/g, '$1') - .replace(/%%v%%(.+?)%%v%%/g, '$1'); - return string; - /*.replace(/([0-9])+/g,'$1') + string = string + .replace(/([:,]) ([0-9]+)(,|\n| \])/g, '$1 %%n%%$2%%n%%$3') + //.replace(/([0-9]+)/g, '%%n%%$1%%n%%') + .replace(/"(\$.+?)"/g, '%%v%%$1%%v%%') + //.replace(/(?:^\s+)([^%])("[^$].+?")([^%])/g, "$1%%s%%$2%%s%%$3") + .replace(/^(\s+)"([A-Z]+)"/gm, '$1%%c%%$2%%c%%') + .replace(/"([^$].+?)"/g, '%%s%%$1%%s%%') + .replace(/%%n%%(.+?)%%n%%/g, '$1') + .replace(/%%s%%(.+?)%%s%%/g, '$1') + .replace(/%%c%%(.+?)%%c%%/g, '$1') + .replace(/%%v%%(.+?)%%v%%/g, '$1'); + return string; + /*.replace(/([0-9])+/g,'$1') .replace(/(?!|: [{\[])/g,'$1')*/ } function valify(string) { - string = string - .replace(/([:,]) ([0-9]+)(,|\n| \])/g, '$1 %%n%%$2%%n%%$3') - .replace(/"(\$.+?)"/g, '%%v%%$1%%v%%') - //.replace(/(?:^\s+)([^%])("[^$].+?")([^%])/g, "$1%%s%%$2%%s%%$3") - .replace(/^(\s+)"([A-Z]+)"/gm, '$1%%c%%$2%%c%%') - .replace(/"([^$].+?)"/g, '%%s%%$1%%s%%') - .replace(/%%n%%(.+?)%%n%%/g, '$1') - .replace(/%%s%%([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})%%s%%/g, '$1') - .replace(/%%s%%(.+?)%%s%%/g, '$1') - .replace(/%%c%%(.+?)%%c%%/g, '$1') - .replace(/%%v%%(.+?)%%v%%/g, '$1') - .replace(/([:,]) (true|false)(,|\n| \])/g, '$1 $2$3'); - return string; - /*.replace(/([0-9])+/g,'$1') + string = string + .replace(/([:,]) ([0-9]+)(,|\n| \])/g, '$1 %%n%%$2%%n%%$3') + .replace(/"(\$.+?)"/g, '%%v%%$1%%v%%') + //.replace(/(?:^\s+)([^%])("[^$].+?")([^%])/g, "$1%%s%%$2%%s%%$3") + .replace(/^(\s+)"([A-Z]+)"/gm, '$1%%c%%$2%%c%%') + .replace(/"([^$].+?)"/g, '%%s%%$1%%s%%') + .replace(/%%n%%(.+?)%%n%%/g, '$1') + .replace( + /%%s%%([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})%%s%%/g, + '$1' + ) + .replace(/%%s%%(.+?)%%s%%/g, '$1') + .replace(/%%c%%(.+?)%%c%%/g, '$1') + .replace(/%%v%%(.+?)%%v%%/g, '$1') + .replace( + /([:,]) (true|false)(,|\n| \])/g, + '$1 $2$3' + ); + return string; + /*.replace(/([0-9])+/g,'$1') .replace(/(?!|: [{\[])/g,'$1')*/ } function appendDropper(bubble) { - var dropper = nelem('div'); - dropper.innerHTML = 'V'; - bonus_1.addc(dropper, 'dropper'); - bind(bubble.children[0], 'click', e => { - bonus_1.togc(bubble, 'dropped'); - //e.preventDefault(); - return false; - }); - bubble.appendChild(dropper); + var dropper = nelem('div'); + dropper.innerHTML = 'V'; + bonus_1.addc(dropper, 'dropper'); + bind(bubble.children[0], 'click', e => { + bonus_1.togc(bubble, 'dropped'); + //e.preventDefault(); + return false; + }); + bubble.appendChild(dropper); } function bindBubble(bubble, rec) { - bind(bubble, 'click', () => { - location.href = '/filters/edit?id=' + rec.id; - }); + bind(bubble, 'click', () => { + location.href = '/filters/edit?id=' + rec.id; + }); } function getPageId() { - var id = location.href.match(/\?id=(.+)$/); - return id ? id[1] : 0; + var id = location.href.match(/\?id=(.+)$/); + return id ? id[1] : 0; }