Skip to content
This repository was archived by the owner on Mar 29, 2021. It is now read-only.

Commit 4eae24a

Browse files
authored
Merge pull request #331 from IDotD/simplify
Simplify+Tests
2 parents abc79d5 + e569b1d commit 4eae24a

28 files changed

Lines changed: 1138 additions & 931 deletions

.travis.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
language: node_js
2-
node_js:
3-
- "7"
4-
cache:
5-
directories:
6-
- "node_modules"
2+
node_js: "node"
3+
git:
4+
depth: 3
5+
addons:
6+
apt:
7+
sources:
8+
- ubuntu-toolchain-r-test
9+
packages:
10+
- libstdc++-4.9-dev
11+
before_script:
12+
- npm install
13+
- npm install codeclimate-test-reporter codacy-coverage istanbul -g
14+
script:
15+
- istanbul cover "./node_modules/mocha/bin/_mocha" --report lcovonly --print detail -- --recursive --reporter spec
16+
after_success:
17+
- codeclimate-test-reporter < ./coverage/lcov.info
18+
- codacy-coverage < ./coverage/lcov.info

karma.conf.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

package.json

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,35 @@
44
"description": "A script for dawn of the dragons, that works based on data provided to https://dotd.idrinth.de via UgUp",
55
"main": "src/stable.js",
66
"directories": {
7-
"test": "test"
7+
"lib": "./src",
8+
"test": "./test"
89
},
910
"scripts": {
10-
"test": "./node_modules/karma/bin/karma start karma.conf.js",
11-
"test-watch": "./node_modules/karma/bin/karma start karma.conf.js --auto-watch"
11+
"test": "./node_modules/mocha/bin/mocha -R test/**/*.js"
1212
},
1313
"repository": {
1414
"type": "git",
15-
"url": "git+https://github.com/Idrinth/IDotD.git"
15+
"url": "git+https://github.com/IDotD/Userscript.git"
1616
},
1717
"keywords": [
1818
"dotd",
1919
"idrinth",
2020
"script",
2121
"userscript",
22-
"dotd"
22+
"dawn of the dragons"
2323
],
24-
"author": "Björn Büttner",
24+
"author": {
25+
"name": "Björn Büttner",
26+
"url": "https://github.com/Idrinth"
27+
},
2528
"license": "MIT",
2629
"bugs": {
27-
"url": "https://github.com/Idrinth/IDotD/issues"
30+
"url": "https://github.com/IDotD/Userscript/issues"
2831
},
29-
"homepage": "https://github.com/Idrinth/IDotD#idotd",
32+
"homepage": "https://idotd.github.io",
3033
"devDependencies": {
31-
"jasmine": "^2.5.3",
32-
"jasmine-core": "^2.5.2",
33-
"karma": "^1.3.0",
34-
"karma-coverage": "^1.1.1",
35-
"karma-jasmine": "^1.1.0",
36-
"karma-phantomjs-launcher": "^1.0.2",
37-
"karma-spec-reporter": "0.0.26"
34+
"mocha": "^5",
35+
"chai": "^4.1",
36+
"rewire": "^4"
3837
}
3938
}

src/loader.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@
3434
window.location.host === "web1.dawnofthedragons.com" ||
3535
window.location.host === "dotd-web1.5thplanetgames.com"
3636
) {
37-
var f = function() {
38-
console.log("s");
39-
window.idrinth = {};
40-
window.idrinth.add= function(data) {
41-
var s = document.createElement("script");
42-
s.appendChild(document.createTextNode(data));
43-
document.getElementsByTagName("head")[0].appendChild(s);
44-
};
37+
let f = function() {
38+
window.idrinth = {
39+
add: function(data) {
40+
let s = document.createElement("script");
41+
s.appendChild(document.createTextNode(data));
42+
document.getElementsByTagName("head")[0].appendChild(s);
43+
}
44+
};
4545
window.addEventListener(
4646
"message",
4747
function(event) {
4848
try {
49-
var data = JSON.parse(event.data);
49+
let data = JSON.parse(event.data);
5050
if (
5151
!data ||
5252
data.to !== "idotd" ||
@@ -63,13 +63,13 @@
6363
false
6464
);
6565
};
66-
var sc = document.createElement("script");
66+
let sc = document.createElement("script");
6767
sc.setAttribute("id", "idotd-loader");
6868
sc.appendChild(document.createTextNode('('+f.toString()+'());'));
6969
document.getElementsByTagName("head")[0].appendChild(sc);
7070
return;
7171
}
72-
var sc = document.createElement("script");
72+
let sc = document.createElement("script");
7373
sc.setAttribute(
7474
"src",
7575
"https://dotd.idrinth.de/static/userscript/" + GM_info.script.version + "/"
@@ -78,9 +78,9 @@
7878
sc.setAttribute("async", "async");
7979
sc.errorCounter = 0;
8080
sc.errorFunction = function() {
81-
var self = document.getElementById("idotd-loader");
81+
let self = document.getElementById("idotd-loader");
8282
self.parentNode.removeChild(self);
83-
var sc = document.createElement("script");
83+
let sc = document.createElement("script");
8484
sc.onerror = self.onerror;
8585
sc.errorCounter = self.errorCounter + 1;
8686
sc.errorFunction = self.errorFunction;

0 commit comments

Comments
 (0)