Skip to content

Commit 7871369

Browse files
committed
Merge branch 'dy-sprae'
2 parents 6e463d3 + 638e009 commit 7871369

File tree

5 files changed

+206
-0
lines changed

5 files changed

+206
-0
lines changed

frameworks/non-keyed/sprae/index.html

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>sprae</title>
7+
<link href="/css/currentStyle.css" rel="stylesheet">
8+
</head>
9+
10+
<body>
11+
<div id="main">
12+
<div class="container">
13+
<div class="jumbotron">
14+
<div class="row">
15+
<div class="col-md-6">
16+
<h1>sprae</h1>
17+
</div>
18+
<div class="col-md-6">
19+
<div class="row">
20+
<div class="col-sm-6 smallpad">
21+
<button @click="run()" type="button" class="btn btn-primary btn-block" id="run">Create 1,000
22+
rows</button>
23+
</div>
24+
<div class="col-sm-6 smallpad">
25+
<button @click="runLots()" type="button" class="btn btn-primary btn-block" id="runlots">Create 10,000
26+
rows</button>
27+
</div>
28+
<div class="col-sm-6 smallpad">
29+
<button @click="add()" type="button" class="btn btn-primary btn-block" id="add">Append 1,000
30+
rows</button>
31+
</div>
32+
<div class="col-sm-6 smallpad">
33+
<button @click="update()" type="button" class="btn btn-primary btn-block" id="update">Update every 10th
34+
row</button>
35+
</div>
36+
<div class="col-sm-6 smallpad">
37+
<button @click="clear()" type="button" class="btn btn-primary btn-block" id="clear">Clear</button>
38+
</div>
39+
<div class="col-sm-6 smallpad">
40+
<button @click="swap()" type="button" class="btn btn-primary btn-block" id="swaprows">Swap Rows</button>
41+
</div>
42+
</div>
43+
</div>
44+
</div>
45+
</div>
46+
<table class="table table-hover table-striped test-data">
47+
<tr :each="item in rows" :class="selected && item.id == selected.id ? 'danger' : ''">
48+
<td class="col-md-1" :text="item.id"></td>
49+
<td class="col-md-4">
50+
<a role="select" @click="select(item)" :text="item.label"></a>
51+
</td>
52+
<td class="col-md-1">
53+
<a>
54+
<span role="delete" @click="remove(item)" class="glyphicon glyphicon-remove" aria-hidden="true"></span>
55+
</a>
56+
</td>
57+
<td class="col-md-6"></td>
58+
</tr>
59+
</table>
60+
</div>
61+
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
62+
</div>
63+
<script type="module" src="src/main.js"></script>
64+
</body>
65+
66+
</html>

frameworks/non-keyed/sprae/package-lock.json

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "js-framework-benchmark-non-keyed-sprae",
3+
"version": "1.0.0",
4+
"description": "Benchmark for sprae",
5+
"js-framework-benchmark": {
6+
"frameworkVersionFromPackage": "sprae",
7+
"frameworkHomeURL": "https://github.com/dy/sprae"
8+
},
9+
"keywords": [
10+
"vue"
11+
],
12+
"scripts": {
13+
"build-dev": "cp ./node_modules/sprae/sprae.js ./src/sprae.js",
14+
"build-prod": "cp ./node_modules/sprae/sprae.min.js ./src/sprae.js"
15+
},
16+
"type": "module",
17+
"dependencies": {
18+
"sprae": "8.0.1"
19+
}
20+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import sprae from './sprae.js'
2+
3+
const adjectives = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome', 'plain', 'quaint', 'clean', 'elegant', 'easy', 'angry', 'crazy', 'helpful', 'mushy', 'odd', 'unsightly', 'adorable', 'important', 'inexpensive', 'cheap', 'expensive', 'fancy']
4+
const colours = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown', 'white', 'black', 'orange']
5+
const nouns = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie', 'sandwich', 'burger', 'pizza', 'mouse', 'keyboard']
6+
7+
let nextId = 1
8+
function buildData(count) {
9+
const data = []
10+
11+
for (let i = 0; i < count; i++) {
12+
data.push({
13+
id: nextId++,
14+
label: `${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`,
15+
})
16+
}
17+
18+
return data
19+
}
20+
21+
function _random(max) {
22+
return Math.round(Math.random() * 1000) % max
23+
}
24+
25+
sprae(document.getElementById('main'), {
26+
rows: [],
27+
selected: null,
28+
29+
remove(item) {
30+
const index = this.rows.findIndex(x => x.id == item.id)
31+
this.rows.splice(index, 1)
32+
},
33+
34+
select(item) {
35+
this.selected = item
36+
},
37+
38+
run() {
39+
this.rows = buildData(1000)
40+
this.selected = null
41+
},
42+
43+
add() {
44+
this.rows = this.rows.concat(buildData(1000))
45+
this.selected = null
46+
},
47+
48+
update() {
49+
for (let i = 0; i < this.rows.length; i += 10) {
50+
this.rows[i].label += ' !!!'
51+
}
52+
this.selected = null
53+
},
54+
55+
runLots() {
56+
this.rows = buildData(10000)
57+
this.selected = null
58+
},
59+
60+
clear() {
61+
this.rows = []
62+
this.selected = null
63+
},
64+
65+
swap() {
66+
if (this.rows.length > 998) {
67+
const a = this.rows[1]
68+
this.rows[1] = this.rows[998]
69+
this.rows[998] = a
70+
}
71+
}
72+
})

frameworks/non-keyed/sprae/src/sprae.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)