forked from siddii/angular-timer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.html
300 lines (272 loc) · 11.5 KB
/
examples.html
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Angular Timer, a simple, inter-operable AngularJS directive</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<link href="bower_components/bootstrap/docs/assets/css/bootstrap.css" rel="stylesheet"/>
<link href="bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css" rel="stylesheet"/>
<link href="docs/css/docs.css" rel="stylesheet"/>
<link href="docs/css/prettify.css" rel="stylesheet"/>
<script src="bower_components/jquery/jquery.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/bootstrap/docs/assets/js/bootstrap.min.js"></script>
<script src="dist/angular-timer.min.js"></script>
<script src="docs/docs.js"></script>
</head>
<body ng-app="timer-demo" ng-controller="TimerDemoController">
<ng-include src="'navbar.html'" onload='linkAnchors();'></ng-include>
<div class="container page-content">
<section id="angularjs-single-timer">
<h3>AngularJS - Single Timer</h3>
<ul class="nav nav-tabs" id="angularjs-single-timer-tab">
<li class="active"><a data-toggle="tab" href="#angularjs-single-timer-source">index.html</a></li>
<li><a data-toggle="tab" href="#angularjs-single-timer-demo">Demo</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="angularjs-single-timer-source">
<pre class="prettyprint linenums">
<!DOCTYPE html>
<html>
<head>
<title>AngularJS Example - Single Timer Example</title>
<script src="../angular/angular.min.js"></script>
<script src="../app/js/timer.js"></script>
<script>
angular.module('MyApp', ['timer']);
function MyAppController($scope) {
$scope.timerRunning = true;
$scope.startTimer = function (){
$scope.$broadcast('timer-start');
$scope.timerRunning = true;
};
$scope.stopTimer = function (){
$scope.$broadcast('timer-stop');
$scope.timerRunning = false;
};
$scope.$on('timer-stopped', function (event, data){
console.log('Timer Stopped - data = ', data);
});
}
MyAppController.$inject = ['$scope'];
</script>
</head>
<body ng-app="MyApp">
<div ng-controller="MyAppController">
<h1>AngularJS - Single Timer Example</h1>
<h3><timer/></h3>
<button ng-click="startTimer()" ng-disabled="timerRunning">Start Timer</button>
<button ng-click="stopTimer()" ng-disabled="!timerRunning">Stop Timer</button>
</div>
<br/>
</body>
</html></pre>
</div>
<div class="tab-pane" id="angularjs-single-timer-demo">
<iframe src="examples/angularjs-single-timer.html" width="100%" height="350px"></iframe>
</div>
</div>
</section>
<section id="angularjs-multiple-timer">
<h3>AngularJS - Multiple Timer</h3>
<ul class="nav nav-tabs" id="angularjs-multiple-timer-tab">
<li class="active"><a data-toggle="tab" href="#angularjs-multiple-timer-source">index.html</a></li>
<li><a data-toggle="tab" href="#angularjs-multiple-timer-demo">Demo</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="angularjs-multiple-timer-source">
<pre class="prettyprint linenums">
<!DOCTYPE html>
<html>
<head>
<title>AngularJS Example - Multiple Timers Example</title>
<script src="../angular/angular.min.js"></script>
<script src="../app/js/timer.js"></script>
<script>
angular.module('MyApp', ['timer']);
function MyAppController($scope) {
$scope.timerRunning = true;
$scope.startTimer = function (){
$scope.$broadcast('timer-start');
$scope.timerRunning = true;
};
$scope.stopTimer = function (){
$scope.$broadcast('timer-stop');
$scope.timerRunning = false;
};
}
MyAppController.$inject = ['$scope'];
</script>
</head>
<body ng-app="MyApp">
<div ng-controller="MyAppController">
<h2>AngularJS - Multiple Timers Example</h2>
<h3>Timer 1: <timer/></h3>
<h3>Timer 2: <timer interval="2000"/></h3>
<h3>Timer 3: <timer>{{minutes}} minutes, {{seconds}} seconds.</timer></h3>
<button ng-click="startTimer()" ng-disabled="timerRunning">Start Timers</button>
<button ng-click="stopTimer()" ng-disabled="!timerRunning">Stop Timers</button>
</div>
</body>
</html></pre>
</div>
<div class="tab-pane" id="angularjs-multiple-timer-demo">
<iframe src="examples/angularjs-multiple-timers.html" width="100%" height="350px"></iframe>
</div>
</div>
</section>
<section id="angularjs-polling-timer">
<h3>AngularJS - Polling Timers</h3>
<ul class="nav nav-tabs" id="angularjs-polling-timer-tab">
<li class="active"><a data-toggle="tab" href="#angularjs-polling-timer-source">index.html</a></li>
<li><a data-toggle="tab" href="#angularjs-polling-timer-demo">Demo</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="angularjs-polling-timer-source">
<pre class="prettyprint linenums">
<!DOCTYPE html>
<html>
<head>
<title>AngularJS Example - Polling Timer Example</title>
<script src="../angular/angular.min.js"></script>
<script src="../app/js/timer.js"></script>
<script>
angular.module('MyApp', ['timer']);
function PollingController($scope) {
$scope.timerRunning = true;
$scope.timerConsole = '';
$scope.timerType = '';
$scope.startTimer = function (){
$scope.$broadcast('timer-start');
$scope.timerRunning = true;
};
$scope.stopTimer = function (){
$scope.$broadcast('timer-stop');
$scope.timerRunning = false;
};
$scope.$on('timer-tick', function (event, args) {
$scope.timerConsole += $scope.timerType + ' - event.name = '+ event.name + ', timeoutId = ' + args.timeoutId + ', millis = ' + args.millis +'\n';
});
}
PollingController.$inject = ['$scope'];
</script>
</head>
<body ng-app="MyApp">
<div>
<h1>AngularJS - Polling Timer Example using <code>timer-tick</code> event</h1>
<div ng-init="timerType = 'Polling Server'" ng-controller="PollingController" style="border: 1px darkgray dashed; padding: 15px;margin:15px">
<h2>Polling Server every 5 seconds</h2>
<h3><timer interval="5000"/></h3>
<textarea style="height: 100px;" row=20 cols="200">{{timerConsole}}</textarea>
<br/>
<button ng-click="startTimer('poll-server')" ng-disabled="timerRunning">Start Timer</button>
<button ng-click="stopTimer('poll-server')" ng-disabled="!timerRunning">Stop Timer</button>
</div>
<br/>
<div ng-init="timerType = 'Saving Documents'" ng-controller="PollingController" style="border: 1px darkgray dashed; padding: 15px">
<h2>Saving Document every 3 seconds</h2>
<h3><timer interval="3000"/></h3>
<textarea style="height: 100px;" row=20 cols="200">{{timerConsole}}</textarea>
<br/>
<button ng-click="startTimer('poll-server')" ng-disabled="timerRunning">Start Timer</button>
<button ng-click="stopTimer('poll-server')" ng-disabled="!timerRunning">Stop Timer</button>
</div>
</div>
<br/>
</body>
</html></pre>
</div>
<div class="tab-pane" id="angularjs-polling-timer-demo">
<iframe src="examples/angularjs-polling-timer.html" width="100%" height="350px"></iframe>
</div>
</div>
</section>
<section id="jquery-timer">
<h3>JQuery Timer</h3>
<ul class="nav nav-tabs" id="jquery-timer-tab">
<li class="active"><a data-toggle="tab" href="#jquery-timer-source">index.html</a></li>
<li><a data-toggle="tab" href="#jquery-timer-demo">Demo</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="jquery-timer-source">
<pre class="prettyprint linenums">
<!DOCTYPE html>
<html>
<head>
<title>JQuery Timer Example</title>
<script src="../jquery/jquery-1.9.1.min.js"></script>
<script src="../angular/angular.min.js"></script>
<script src="../app/js/timer.js"></script>
<script>
function startTimer() {
$('timer')[0].start();
}
function stopTimer() {
$('timer')[0].stop();
}
</script>
</head>
<body>
<div ng-controller="MyAppController">
<h2>JQuery - Timer Example</h2>
<h3 ng-app="timer"><timer/></h3>
<button onclick="startTimer()">Start Timer</button>
<button onclick="stopTimer()">Stop Timer</button>
</div>
<br/>
</body>
</html></pre>
</div>
<div class="tab-pane" id="jquery-timer-demo">
<iframe src="examples/jquery-timer.html" width="100%" height="350px"></iframe>
</div>
</div>
</section>
<section id="plain-javascript">
<h3>Plain JavaScript</h3>
<ul class="nav nav-tabs" id="plain-javascript-tab">
<li class="active"><a data-toggle="tab" href="#plain-javascript-source">index.html</a></li>
<li><a data-toggle="tab" href="#plain-javascript-demo">Demo</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="plain-javascript-source">
<pre class="prettyprint linenums">
<!DOCTYPE html>
<html>
<head>
<title>Plain Javascript Timer Example</title>
<script src="../angular/angular.min.js"></script>
<script src="../app/js/timer.js"></script>
<script>
function startTimer() {
document.getElementsByTagName('timer')[0].start();
}
function stopTimer() {
document.getElementsByTagName('timer')[0].stop();
}
</script>
</head>
<body>
<div>
<h2>Plain JavaScript - Timer Example</h2>
<h3><timer ng-app="timer"/></h3>
<button onclick="startTimer()">Start Timer</button>
<button onclick="stopTimer()">Stop Timer</button>
</div>
<br/>
</body>
</html></pre>
</div>
<div class="tab-pane" id="plain-javascript-demo">
<iframe src="examples/plain-javascript.html" width="100%" height="350px"></iframe>
</div>
</div>
</section>
<footer>
<p>© Siddique Hameed 2013</p>
</footer>
</div>
<script src="docs/prettify.js"></script>
<script src="docs/application.js"></script>
</body>
</html>