- commit
- 3a640f26fce73a9a3168586b74c88c0b8412e6cc
- parent
- ba4975295ea835c0cc2065946ad83adc432720bc
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-10-18 07:09
change URL structure
Diffstat
| M | static/src/utils.js | 10 | ---------- |
| M | static/src/voterunner.js | 15 | +++++++-------- |
| M | static/test/test.js | 13 | +++++++------ |
3 files changed, 14 insertions, 24 deletions
diff --git a/static/src/utils.js b/static/src/utils.js
@@ -51,19 +51,9 @@ var randomString = function() {
51 51 return Math.floor(a).toString(36);
52 52 };
53 53
54 -1 var setCookie = function(key, value, days) {
55 -1 localStorage[key] = value;
56 -1 };
57 -1
58 -1 var getCookie = function(key) {
59 -1 return localStorage[key];
60 -1 };
61 -1
62 54 module.exports = {
63 55 throttle: throttle,
64 56 on: on,
65 57 initVDom: initVDom,
66 58 randomString: randomString,
67 -1 setCookie: setCookie,
68 -1 getCookie: getCookie,
69 59 };
diff --git a/static/src/voterunner.js b/static/src/voterunner.js
@@ -2,17 +2,16 @@ var template = require('./template');
2 2 var utils = require('./utils');
3 3
4 4 document.addEventListener('DOMContentLoaded', function() {
5 -1 var TOPIC = document.URL.split('/')[3];
6 -1 var ID = document.URL.split('/')[4];
7 -1 if (!ID) ID = utils.getCookie('id');
8 -1 if (!ID) ID = utils.randomString();
9 -1 utils.setCookie('id', ID, 100);
10 -1
11 -1 var url = 'https://via.ce9e.org/hmsg/voterunner/' + TOPIC;
-1 5 if (!location.hash) {
-1 6 location.hash = utils.randomString();
-1 7 }
-1 8 var topic = location.hash.substr(1);
-1 9 var url = 'https://via.ce9e.org/hmsg/voterunner/' + topic;
-1 10 document.title += ' - ' + topic;
12 11
13 12 var state = {
14 13 nodes: [],
15 -1 id: ID,
-1 14 id: null,
16 15 dirty: false,
17 16 };
18 17
diff --git a/static/test/test.js b/static/test/test.js
@@ -14,10 +14,10 @@ var setUpUser = function(browser, id) {
14 14 trigger(userName, 'input');
15 15 };
16 16
17 -1 var setUp = function(url, fn) {
-1 17 var setUp = function(topic, fn) {
18 18 var iframe = document.createElement('iframe');
19 -1 iframe.url = url;
20 -1 iframe.src = url;
-1 19 iframe.url = '/#test' + topic;
-1 20
21 21 iframe.onload = function() {
22 22 setUpUser(this, ID);
23 23 fn(iframe);
@@ -42,6 +42,7 @@ var setUp = function(url, fn) {
42 42 };
43 43
44 44 document.getElementById('testarea').appendChild(iframe);
-1 45 iframe.src = iframe.url;
45 46 };
46 47
47 48 describe('load', function() {
@@ -49,7 +50,7 @@ describe('load', function() {
49 50 var browser;
50 51
51 52 before(function(done) {
52 -1 setUp('/test' + test + '/', function(b) {
-1 53 setUp(test, function(b) {
53 54 browser = b;
54 55 done();
55 56 });
@@ -75,7 +76,7 @@ describe('setComment', function() {
75 76 var d, userComment, node, nodeComment, nodeExpand;
76 77
77 78 before(function(done) {
78 -1 setUp('/test' + test + '/' + ID, function(b) {
-1 79 setUp(test, function(b) {
79 80 browser = b;
80 81 d = browser.contentDocument;
81 82
@@ -139,7 +140,7 @@ describe('remove', function() {
139 140 var d, userComment, userRemove;
140 141
141 142 before(function(done) {
142 -1 setUp('/test' + test + '/' + ID, function(b) {
-1 143 setUp(test, function(b) {
143 144 browser = b;
144 145 d = browser.contentDocument;
145 146 browser.contentWindow.confirm = () => true;