Skip to content

Commit c6efd60

Browse files
committed
riot 2.5
1 parent b6b8791 commit c6efd60

File tree

8 files changed

+166
-67
lines changed

8 files changed

+166
-67
lines changed

cleanup.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
rm -r angular/node_modules
2+
rm -r angular2/node_modules
3+
rm -r aurelia/node_modules
4+
rm -r aurelia/jspm_packages
5+
rm -r ember/node_modules
6+
rm -r ember/bower_components
7+
rm -r mithril/node_modules
8+
rm -r ractive/node_modules
9+
rm -r react/node_modules
10+
rm -r tests/node_modules
11+
rm -r node_modules
12+
13+
rm -r angular/dist
14+
rm angular2/app/app.js*
15+
rm -r aurelia/dist/*
16+
rm -r ember/dist
17+
rm -r mithril/dist
18+
rm -r ractive/dist
19+
rm -r react/dist
20+
rm -r vidom/dist
21+
rm -r vue/dist
22+
23+
rm -r webdriver-java/node_modules
24+
rm -r webdriver-java/target

riot-v2.4.0/src/entry/app.html

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

riot-v2.4.0/index.html renamed to riot-v2.5.0/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>riot v2.4.0</title>
5+
<title>riot v2.5.0</title>
66
<link href="../css/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
77
<link href="../css/main.css" rel="stylesheet"/>
88
</head>
99
<body>
1010
<app></app>
11-
<script src="src/entry/app.html" type="riot/tag"></script>
11+
<script src="src/app.html" type="riot/tag"></script>
1212
<script src="node_modules/riot/riot+compiler.min.js"></script>
1313
<script src='dist/main.js'></script>
1414
</body>

riot-v2.4.0/package.json renamed to riot-v2.5.0/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"webpack": "^1.13.1"
1515
},
1616
"dependencies": {
17-
"riot": "2.4.1"
17+
"riot": "2.5.0"
1818
}
1919
}

riot-v2.5.0/src/app.html

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*global riot */
2+
<app>
3+
<div class="container">
4+
<div class="jumbotron">
5+
<div class="row">
6+
<div class="col-md-6">
7+
<h1>riot v2.5.0</h1>
8+
</div>
9+
<div class="col-md-6">
10+
<div class="row">
11+
<div class="col-sm-6 smallpad">
12+
<button type="button" class="btn btn-primary btn-block" id="run" onclick={run} >Create 1,000 rows</button>
13+
</div>
14+
<div class="col-sm-6 smallpad">
15+
<button type="button" class="btn btn-primary btn-block" id="runlots" onclick={runLots} >Create 10,000 rows</button>
16+
</div>
17+
<div class="col-sm-6 smallpad">
18+
<button type="button" class="btn btn-primary btn-block" id="add" onclick={add} >Append 1,000 rows</button>
19+
</div>
20+
<div class="col-sm-6 smallpad" id="addUpdateHere">
21+
<!-- <button type="button" class="btn btn-primary btn-block" id="_update" onclick={change} >Update every 10th row</button> -->
22+
</div>
23+
<div class="col-sm-6 smallpad">
24+
<button type="button" class="btn btn-primary btn-block" id="clear" onclick={clear} >Clear</button>
25+
</div>
26+
<div class="col-sm-6 smallpad">
27+
<button type="button" class="btn btn-primary btn-block" id="swaprows" onclick={swapRows} >Swap Rows</button>
28+
</div>
29+
</div>
30+
</div>
31+
</div>
32+
</div>
33+
<table class="table table-hover table-striped test-data">
34+
<tbody>
35+
<tr each={ item in this.opts.data } class="{item.id == parent.opts.selected ? class='danger' : ''}">
36+
<td class="col-md-1">{ item.id }</td>
37+
<td class="col-md-4">
38+
<a onclick={parent.select}>{ item.label }</a>
39+
</td>
40+
<td class="col-md-1">
41+
<a onclick={parent.remove}><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
42+
</td>
43+
<td class="col-md-6"></td>
44+
</tr>
45+
</tbody>
46+
</table>
47+
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
48+
</div>
49+
<script>
50+
'use strict';
51+
this.on('mount', function(){
52+
let elem = document.getElementById("addUpdateHere");
53+
let button = document.createElement("button");
54+
button.setAttribute("id","update");
55+
button.setAttribute("class", "btn btn-primary btn-block");
56+
button.innerText = "Update every 10th row";
57+
let that = this;
58+
button.addEventListener("click", function() {
59+
that._update();
60+
});
61+
elem.appendChild(button);
62+
})
63+
this.on('updated', function() {
64+
this.opts.updated();
65+
})
66+
run() {
67+
this.opts.run();
68+
this.update();
69+
};
70+
runLots() {
71+
this.opts.runLots();
72+
this.update();
73+
};
74+
add() {
75+
this.opts.add();
76+
this.update();
77+
};
78+
_update() {
79+
this.opts.update();
80+
this.update();
81+
};
82+
clear() {
83+
this.opts.clear();
84+
this.update();
85+
};
86+
swapRows() {
87+
this.opts.swapRows();
88+
this.update();
89+
};
90+
select(evt) {
91+
this.opts.select(evt.item.item.id);
92+
this.update();
93+
};
94+
remove(evt) {
95+
this.opts.delete(evt.item.item.id);
96+
this.update();
97+
};
98+
</script>
99+
</app>
File renamed without changes.

riot-v2.4.0/src/entry/store.es6.js renamed to riot-v2.5.0/src/store.es6.js

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ function _random(max) {
44
return Math.round(Math.random()*1000)%max;
55
}
66

7+
var startTime;
8+
var lastMeasure;
9+
var startMeasure = function(name) {
10+
startTime = performance.now();
11+
lastMeasure = name;
12+
}
13+
var stopMeasure = function() {
14+
var last = lastMeasure;
15+
if (lastMeasure) {
16+
window.setTimeout(function () {
17+
lastMeasure = null;
18+
var stop = performance.now();
19+
var duration = 0;
20+
console.log(last+" took "+(stop-startTime));
21+
}, 0);
22+
}
23+
}
24+
725
export class Store {
826
constructor() {
927
this.data = [];
@@ -25,46 +43,49 @@ export class Store {
2543
}
2644
}
2745
delete(id) {
46+
startMeasure("delete");
2847
const idx = this.data.findIndex(d => d.id==id);
29-
this.data = this.data.filter((e,i) => i!=idx);
48+
this.data.splice(idx, 1);
3049
return this;
3150
}
3251
run() {
52+
startMeasure("run");
3353
this.data = this.buildData();
3454
this.selected = undefined;
3555
}
3656
add() {
57+
startMeasure("add");
3758
this.data = this.data.concat(this.buildData(1000));
3859
this.selected = undefined;
3960
}
4061
update() {
62+
startMeasure("update");
4163
this.updateData();
4264
this.selected = undefined;
4365
}
4466
select(id) {
45-
console.log("select",e,id);
67+
startMeasure("select");
4668
this.selected = id;
4769
}
48-
hideAll(e) {
49-
e.preventDefault();
50-
this.backup = this.data;
51-
this.data = [];
52-
this.selected = undefined;
53-
}
54-
showAll(e) {
55-
e.preventDefault();
56-
this.data = this.backup;
57-
this.backup = null;
58-
this.selected = undefined;
59-
}
60-
runLots(e) {
61-
e.preventDefault();
70+
runLots() {
71+
startMeasure("runLots");
6272
this.data = this.buildData(10000);
6373
this.selected = undefined;
6474
}
65-
clear(e) {
66-
e.preventDefault();
75+
clear() {
76+
startMeasure("clear");
6777
this.data = [];
6878
this.selected = undefined;
6979
}
80+
swapRows() {
81+
startMeasure("swapRows");
82+
if(this.data.length > 10) {
83+
var a = this.data[4];
84+
this.data[4] = this.data[9];
85+
this.data[9] = a;
86+
}
87+
}
88+
updated() {
89+
stopMeasure();
90+
}
7091
}

riot-v2.4.0/webpack.config.js renamed to riot-v2.5.0/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = [{
2525
loaders: loaders
2626
},
2727
entry: {
28-
main: './src/entry/main',
28+
main: './src/main',
2929
},
3030
output: {
3131
path: './dist',

0 commit comments

Comments
 (0)