-
Notifications
You must be signed in to change notification settings - Fork 4
/
Demo.js
111 lines (108 loc) · 3.24 KB
/
Demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var demo = new Vue({
el: '#app',
mixins: [vueinterval],
data: {
createTime: Date.now(),
tenMinuteCnt: new Date(Date.now() + 6e5),
nextNewYear: new Date((new Date().getFullYear() + 1 + '')),
explodeLimit: 0,
explode: 0,
livingSecounds: 0,
binaryRun: true,
tasks: [{ ttl: 5e5, iid: null }],
endMessage: 'Goodbye',
endMessages: [],
t2interval: 1000,
t2time: 5000
},
computed: {
nonreactive: function () {
this.ticker
return document.getElementById('actMe').value
}
},
methods: {
calcExplode: function () {
this.explode = this.explodeLimit - Date.now()
},
INTERVAL__1e3$update: function (a) {
this.livingSecounds += 1 + (a || 0)
},
addTask: function () {
var item = { ttl: 1e4, iid: null }
this.tasks.push(item)
},
addTask2: function () {
var item = { ttl: 15e3, iid: null }
var self = this
var message = this.endMessage
this.setVueInterval(function () {
self.endMessages.push('Tick ' + self.ticker + ': My message is ' + message)
}, this.t2interval, function () { self.endMessages.push('<b>Callback: ' + message + '</b>') }, this.t2time)
},
startTask: function (t) {
var fnDel = this.deleteTask
t.iid = this.setVueInterval(function () {
t.ttl -= 1000
if (t.ttl <= 0) { fnDel(t) }
if (t.ttl === 0) t.ttl = 'Goodbye!'
}, 1e3)
},
suspendTask: function (t) {
if (t.iid && !isNaN(t.iid)) t.iid = this.suspendVueInterval(t.iid)
},
resumeTask: function (t) {
if (!t.iid.indexOf('suspended')) {
t.iid = this.resumeVueInterval(t.iid)
}
},
deleteTask: function (t) {
this.removeVueInterval(t.iid)
this.tasks.splice(this.tasks.indexOf(t), 1)
}
},
filters: {
hhmmssFilter: function (val) {
if (!val) return ''
if (typeof val === 'number') { val = new Date(val) }
var dateArray = val.toISOString().split(/[T:.]/g)
return dateArray[1] + ':' + dateArray[2] + ':' + dateArray[3]
},
inYear: function (val) {
var month = new Date(val)
val = new Date(val)
var dateArray = val.toISOString().split(/[T:.]/g)
return month.getMonth() + '.' + month.getDate() + '. ' + dateArray[1] + ':' + dateArray[2] + ':' + dateArray[3]
},
iso: function (val) {
if (typeof val === 'number') { val = new Date(val) }
return val.toISOString()
}
},
directives: {
turning: function (el, binding) {
if (!binding.value) return
var cur = el.style.transform.length ? el.style.transform : 'rotate(0deg)'
cur = Number(cur.replace(/[rotate()deg]/g, ''))
var turning = 'rotate(' + ((cur + 16 * binding.value) % 360) + 'deg)'
el.style.transform = turning// "rotate(" + turning + "deg);";
}
}
})
new Vue({
el: '#app2',
mixins: [vueinterval],
methods: {
changeTicker: function () {
var newTickerInterval = this.$refs.tickTime.value
this.adjustVueTickerInterval(newTickerInterval)
}
},
computed: {
tickerIntervalTime: function () {
for (var i = 0; i < this.interval_Array.length; i++) {
if (this.interval_Array[i].iType === 'tickerInterval') { return this.interval_Array[i].time }
}
}
}
})