diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/home.js | 3 | ||||
-rw-r--r-- | src/map.js | 32 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/home.js b/src/home.js index 8906079..3dc79ef 100644 --- a/src/home.js +++ b/src/home.js @@ -3,6 +3,9 @@ import { checkallHandler, closeSubmenus } from './fn/fn'; window.addEventListener('load', () => { let checkboxes = document.getElementsByName('pagesid[]'); let checkall = document.getElementById('checkall'); + if (!checkall) { + return; + } let checkbox = document.createElement('input'); checkbox.type = 'checkbox'; checkbox.addEventListener('input', checkallHandler.bind({ checkboxes })); diff --git a/src/map.js b/src/map.js new file mode 100644 index 0000000..4723318 --- /dev/null +++ b/src/map.js @@ -0,0 +1,32 @@ +import cytoscape from 'cytoscape'; +import coseBilkent from 'cytoscape-cose-bilkent'; + +cytoscape.use(coseBilkent); + +let options = { + container: document.getElementById('graph'), +}; + +Object.assign(options, data); + +let cy = cytoscape(options); + +cy.on('tap', 'node', function() { + try { + // your browser may block popups + window.open(this.data('id')); + } catch (e) { + // fall back on url change + window.location.href = this.data('id'); + } +}); + +cy.on('cxttap', 'node', function() { + try { + // your browser may block popups + window.open(this.data('edit')); + } catch (e) { + // fall back on url change + window.location.href = this.data('edit'); + } +}); |