-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
635 lines (569 loc) · 29.2 KB
/
index.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
<!doctype html>
<html ng-app="demo">
<head>
<meta charset="utf-8">
<title>ngPromiseStatus by Barak Chamo</title>
<!-- TODO: Include Angular from Bower components -->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-sanitize.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">
<link rel="stylesheet" href="bower_components/google-code-prettify/bin/prettify.min.css"></script>
<link rel="stylesheet" href="dist/directive.css">
<link rel="stylesheet" href="demo/demo.css">
</head>
<body ng-controller="demoController">
<a href="https://github.com/BarakChamo/ng-promise-status"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<div class="jumbotron">
<div class="container">
<h1>ngPromiseStatus <small>promise-aware UI elements.</small></h1>
<br>
<h4>A collection of Angular.js promise-aware directives and UI elements for your project </h4>
<h4 class="text-muted">by Barak Chamo</h4>
<div>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://barakchamo.github.io/ng-promise-status" data-text="ngPromiseStatus - promise-aware Angular components" data-via="BarakChamo">Tweet</a>
<div class="g-plusone" data-size="medium" data-href="http://barakchamo.github.io/ng-promise-status"></div>
</div>
</div>
</div>
<div class="container">
<div class="container-fluid">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<p class="lead">ngPromiseStatus is a collection (starting with statusButton) of promise-aware Angular directives that make it easy to bind UI elements to the progress and eventual outcome of a promise.</p>
<!-- Examples -->
<h1 class>Examples</h1>
<h3 class="page-header" id="statusButtonExamples">statusButton <small class="text-muted"><a href="#statusButtonDocs">read the docs</a></small></h3>
<h4>Simple usage</h4>
<p>This is a simplest use of the directive with only a promise (or array of) passed (and some default styles). <small><a href="#values">See valid values for promises</a></small></p>
<br>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 text-center">
<status-button ng-click="setSuccessPromise()" promise="successPromise">
<span>Success</span>
</status-button>
</div>
<div class="col-sm-4 text-center">
<status-button ng-click="setErrorPromise()" promise="errorPromise">
<span>Error</span>
</status-button>
</div>
<div class="col-sm-4 text-center">
<status-button ng-click="setValuePromise()" promise="valuePromise">
<span>Value (immediate)</span>
</status-button>
</div>
</div>
</div>
<br><br>
<h4>Custom Status Classes</h4>
<p>You can pass custom classes to be applied for each stage of the promise (progress, succcess and error). It plays nicely with Bootstrap btn classes</p>
<br>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 text-center">
<status-button ng-click="setSuccessPromise()" promise="successPromise" options="bootstrapConfig"class="btn">
<span>Success</span>
</status-button>
</div>
<div class="col-sm-4 text-center">
<status-button ng-click="setErrorPromise()" promise="errorPromise" options="bootstrapConfig"class="btn">
<span>Error</span>
</status-button>
</div>
<div class="col-sm-4 text-center">
<status-button ng-click="setErrorPromise()" promise="errorPromise" options="bootstrapDelayConfig"class="btn">
<span>Error + Delay</span>
</status-button>
</div>
</div>
</div>
<br><br>
<h4>Promise Values</h4>
<p>The directive exposes several scope properties to the button's content (see docs). You can use them to give extra info on the promise's status.</p>
<br>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 text-center">
<status-button ng-click="setSuccessPromise()" promise="successPromise" options="bootstrapConfig"class="btn">
<span>Success {{$value}}</span>
</status-button>
<p><small class="text-muted">Resolved with value 'Done!'</small></p>
</div>
<div class="col-sm-4 text-center">
<status-button ng-click="setErrorPromise()" promise="errorPromise" options="bootstrapConfig"class="btn">
<span>Error {{$value}}</span>
</status-button>
<p><small class="text-muted">Rejected with error 'Error!'</small></p>
</div>
<div class="col-sm-4 text-center">
<status-button ng-click="setErrorPromise()" promise="errorPromise" options="bootstrapDelayConfig"class="btn">
<span>Error + Delay {{$value}}</span>
</status-button>
<p><small class="text-muted">Rejected with error 'error!'</small></p>
</div>
</div>
</div>
<br><br>
<!-- Status bar examples -->
<h3 class="page-header" id="statusBarExamples">statusBar <small class="text-muted"><a href="#statusBarDocs">read the docs</a></small></h3>
<h4>Example with custom classes and promise values</h4>
<p>status-bar makes it really easy to create an alert container that reacts to promises.</p>
<p>This is an example with Bootstrap alert styles and the promise value exposed. It works just like the button, pass a promise or array of promises. Click on the buttons above to show the promises.</p>
<br>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 text-center">
<status-button ng-click="setAlertSuccessPromise()" promise="alertSuccessPromise" options="bootstrapDelayConfig" class="btn">
<span>Success {{$value}}</span>
</status-button>
<p><small>I'm here, trigger the success button above.</small></p>
<status-bar promise="alertSuccessPromise" class="alert" options="alertConfig">
<span ng-switch="$status">
<strong ng-switch-when="inprogress">Wait for it...</strong>
<strong ng-switch-when="success">Woohoo!</strong>
<strong ng-switch-when="error">Bummer...</strong>
{{$value}}
</span>
</status-bar>
</div>
<div class="col-sm-4 text-center">
<status-button ng-click="setAlertErrorPromise()" promise="alertErrorPromise" options="bootstrapDelayConfig" class="btn">
<span>Error {{$value}}</span>
</status-button>
<p><small>Me too, trigger the error button above.</small></p>
<status-bar promise="alertErrorPromise" class="alert" options="alertConfig">
<span ng-switch="$status">
<strong ng-switch-when="inprogress">Wait for it...</strong>
<strong ng-switch-when="success">Woohoo!</strong>
<strong ng-switch-when="error">Bummer...</strong>
{{$value}}
</span>
</status-bar>
</div>
<div class="col-sm-4 text-center">
<status-button ng-click="setAlertValuePromise()" promise="alertValuePromise" options="bootstrapDelayConfig" class="btn">
<span>Value {{$value}}</span>
</status-button>
<p><small>This one is for a value promise, try the button in the first row.</small></p>
<status-bar promise="alertValuePromise" class="alert" options="alertConfig">
<span ng-switch="$status">
<strong ng-switch-when="inprogress">Wait for it...</strong>
<strong ng-switch-when="success">Woohoo!</strong>
<strong ng-switch-when="error">Bummer...</strong>
{{$value}}
</span>
</status-bar>
</div>
</div>
</div>
<!-- Start Documentation -->
<br><br>
<h1 class>Documentation</h1>
<!-- Installation -->
<h3 class="page-header">Installation</h3>
<p>You can install through bower:</p>
<pre class="prettyprint">bower install ng-promise-status</pre>
<p>or through npm:</p>
<pre class="prettyprint">npm install ng-promise-status</pre>
<p>or <a href="https://github.com/BarakChamo/ng-promise-status">download the latest version from GitHub</a></p>
<!-- Setup -->
<h3 class="page-header">Setup</h3>
<p>To get started include ngPromiseStatus as a dependency in your angular app:</p>
<pre class="prettyprint">var app = angular.module('myApp', ['ngPromiseStatus']);</pre>
<p>and you're good to go!</p>
<br>
<h3 class="page-header">Common configuration</h3>
<!-- Multiple Promises -->
<h4 id="values">Multiple Promises (and other valid inputs)</h4>
<p>The directives are built to work with multiple type of inputs:</p>
<dl class="dl-horizontal">
<dt>promises</dt>
<dd>The <code>promise</code> from a <code>$q.defer()</code> or similar interfaces.</dd>
<dt>deffers</dt>
<dd>The <code>deffered</code> itself, saves the need of saving multiple references on scope.</dd>
<dt>promise arrays</dt>
<dd>An array of promises or deffereds.</dd>
<dt>other values</dt>
<dd>Any other value will not break but rather resolve immediately (implements <code>$q.when</code>).</dd>
</dl>
<!-- End Multiple Promises -->
<br>
<!-- Custom Configuration -->
<h4 id="classes">CSS Classes</h4>
<p>By default, the directives apply 4 classes to the elements depending on the state of the promise:</p>
<dl class="dl-horizontal">
<dt><code>idle</code></dt>
<dd>There is no current promise in progress.</dd>
<br>
<dt><code>inprogress</code></dt>
<dd>There promise is still in progress, <code>inprogress</code> is used instead of <code>progress</code> so that it doesn't clash with Bootstrap progress bars.</dd>
<br>
<dt><code>success</code></dt>
<dd>The promise was resolved.</dd>
<br>
<dt><code>error</code></dt>
<dd>The promise was rejected.</dd>
</dl>
<p>ngPromiseStatus intentionally doesn't rely on any additional CSS files or required styling. It provides an easy interface in the form of class management that allows you to easy interact with promises using your existing styles and with no additional bloat to your project.</p>
<br>
<h4 id="scope">Scope Properties</h4>
<p>The directive exposes special scope properties to the button's content that allow you to customize the button's content and interact with the promise's values and state.</p>
<table class="table">
<thead>
<tr>
<th>name</th>
<th>type</th>
<th>details</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>$status</code></td>
<td><span class="label label-primary">string</span></td>
<td>The status of the promise, same as the default class names: <code>idle</code>, <code>inprogress</code>, <code>success</code> and <code>error</code></td>
</tr>
<tr>
<td><code>$value</code></td>
<td><span class="label label-warning">any</span></td>
<td>Whatever value is passed upon resolution or rejection of the promise. If an array of promises is used, <code>$value</code> will be an ordered array of said whatevers.</td>
</tr>
<tr>
<td><code>$done</code></td>
<td><span class="label label-default">boolean</span></td>
<td>A convenience boolean that indicates if a promise is in progress.</td>
</tr>
<tr>
<td><code>$class</code></td>
<td><span class="label label-primary">string</span></td>
<td>The class that is currently applied, overwritten with your custom configuration if provided.</td>
</tr>
</tbody>
</table>
<br>
<!-- statusButton Usage -->
<h3 class="page-header" id="statusButtonDocs">statusButton <small class="text-muted"><a href="#statusButtonExamples">see some examples</a></small></h3>
<h4>Basic Use <small><a href="#classes">See default classes</a></small></h4>
<p>The <code>statusButton</code> directive can be used by simply using the directive as a tag or attribute and passing a promise (or array of). <small><a href="#values">See valid values for promises</a></small></p>
<p>When the button is clicked an internal handler is fired and assigns a promise handler to the assigned promise. Note that for that reason
new promises are only detected on click.</p>
<p>Any <code>ng-click</code> handler assigned to the element will be called before the internal handler so you can easily use the same <code>'click'</code> event to both assign a promise in your controller and for it to be detected by the button.</p>
<!-- Code example -->
<p><strong>Here's an example:</strong></p>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
<p>Result:</p>
<div class="usage text-center">
<status-button ng-click="setSuccessPromise()" promise="successPromise">
<span>Success</span>
</status-button>
</div>
</div>
<div class="col-sm-8">
<p>Template:</p>
<pre class="prettyprint">
<status-button
ng-click="setSuccessPromise()"
promise="successPromise">
<span>Success</span>
</status-button>
</pre>
<p>Controller:</p>
<pre class="prettyprint">
// Create a new promise that will succeed in 3 seconds
$scope.setSuccessPromise = function(){
// Set $scope.promise with a new promise
$scope.successPromise = $q.defer();
// React to promise in controller
$scope.successPromise
.promise
.then(function(){
console.log('Done from controller');
});
// Set a timeout for 3 seconds and resolve
$timeout(function(){
$scope.successPromise.resolve('Done!');
}, 3000);
};
</pre>
</div>
</div>
</div>
<!-- /- end code samle -->
<br>
<!-- Custom Configuration -->
<h4>Custom Configuration</h4>
<p>You can configure a few key features of statusButton - classes applied on promise stages, delay and disable:</p>
<table class="table">
<thead>
<tr>
<th>name</th>
<th>type</th>
<th>default</th>
<th>details</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>idle_class</code></td>
<td><span class="label label-primary">string</span></td>
<td><code>idle</code></td>
<td>The initial class applied to the button and will applied after completion if a delay is specified.</td>
</tr>
<tr>
<td><code>progress_class</code></td>
<td><span class="label label-primary">string</span></td>
<td><code>inprogress</code></td>
<td>The class that will be applied to the button whenever a promise is in progress.</td>
</tr>
<tr>
<td><code>success_class</code></td>
<td><span class="label label-primary">string</span></td>
<td><code>success</code></td>
<td>The class that will be applied to the button when a promise is resolved (completed successfully).</td>
</tr>
<tr>
<td><code>error_class</code></td>
<td><span class="label label-primary">string</span></td>
<td><code>error</code></td>
<td>The class that will be applied to the button when a promise is rejected (resulted in an error).</td>
</tr>
<tr>
<td><code>progress_disable</code></td>
<td><span class="label label-default">boolean</span></td>
<td><code>true</code></td>
<td>A toggle that determines if the button will be disabled when a promise is in progress.</td>
</tr>
<tr>
<td><code>delay</code></td>
<td><span class="label label-info">number</span></td>
<td><code>0</code></td>
<td>The time (in milliseconds) it takes for the button to return to idle state upon promise completion (either success or error). 0 will not return to idle.</td>
</tr>
</tbody>
</table>
<!-- custom configuration example example -->
<p><strong>Here's an example for custom configuration using Bootstrap classes and a 2s delay:</strong></p>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
<p>Result:</p>
<div class="usage text-center">
<status-button ng-click="setErrorPromise()" promise="errorPromise" options="bootstrapDelayConfig"class="btn">
<span>Custom + Delay</span>
</status-button>
</div>
</div>
<div class="col-sm-8">
<p>Template:</p>
<pre class="prettyprint">
<status-button
ng-click="setButtonPromise()"
promise="buttonPromise">
options="buttonConfig">
<span>Success</span>
</status-button>
</pre>
<p>Controller:</p>
<pre class="prettyprint">
// Define your custom configuration
$scope.buttonConfig = {
success_class: 'btn-success',
error_class: 'btn-danger',
progress_class: 'btn-warning',
idle_class: 'btn-default',
delay: 2000
};
// Create a new promise that will succeed in 3 seconds
$scope.setButtonPromise = function(){
// Set $scope.promise with a new promise
$scope.buttonPromise = $q.defer();
// React to promise in controller
$scope.buttonPromise
.promise
.then(function(){
console.log('Done from controller');
});
// Set a timeout for 3 seconds and reject
$timeout(function(){
$scope.buttonPromise.reject();
}, 3000);
};
</pre>
</div>
</div>
</div>
<!-- /- end code sample -->
<br>
<!-- Scope Properties -->
<h4>Scope Properties <small><a href="#scope">Available scope properties</a></small></h4>
<!-- scope properties example -->
<p><strong>Here's an example of using scope properties inside the button (promise is rejected with 'Error!'):</strong></p>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
<p>Result:</p>
<div class="usage text-center">
<status-button ng-click="setErrorPromise()" promise="errorPromise" options="bootstrapDelayConfig"class="btn">
<span>What's up? {{$value}}</span>
</status-button>
</div>
</div>
<div class="col-sm-8">
<p>Template:</p>
<pre class="prettyprint" ng-non-bindable>
<status-button
ng-click="setButtonPromise()"
promise="buttonPromise"
options="bootstrapConfig">
<span>Success {{$value}}</span>
</status-button>
</pre>
</div>
</div>
</div>
<!-- /- end code sample -->
<!-- End Scope Properties -->
<!-- statusBar Usage -->
<br>
<h3 class="page-header" id="statusBarDocs">statusBar <small class="text-muted"><a href="#statusBarExamples">see some examples</a></small></h3>
<p>Just like the <code>statusButton</code>, the <code>statusBar</code> directive can be easily put to work as a tag or attribute and passing a promise (or array of). <small><a href="#values">See valid values for promises</a></small></p>
<p>When a promise is set and re-set a promise handler is assigned. This is managed by watching the promise passed but other hooks will soon be implemented.</p>
<br>
<!-- Custom Configuration -->
<h4>Custom Configuration</h4>
<p>You can configure some parameters of statusBar - classes applied on promise stages, delay and watch:</p>
<table class="table">
<thead>
<tr>
<th>name</th>
<th>type</th>
<th>default</th>
<th>details</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>idle_class</code></td>
<td><span class="label label-primary">string</span></td>
<td><code>idle</code></td>
<td>The initial class applied to the bar and will applied after completion if a delay is specified.</td>
</tr>
<tr>
<td><code>progress_class</code></td>
<td><span class="label label-primary">string</span></td>
<td><code>inprogress</code></td>
<td>The class that will be applied to the bar whenever a promise is in progress.</td>
</tr>
<tr>
<td><code>success_class</code></td>
<td><span class="label label-primary">string</span></td>
<td><code>success</code></td>
<td>The class that will be applied to the bar when a promise is resolved (completed successfully).</td>
</tr>
<tr>
<td><code>error_class</code></td>
<td><span class="label label-primary">string</span></td>
<td><code>error</code></td>
<td>The class that will be applied to the bar when a promise is rejected (resulted in an error).</td>
</tr>
<tr>
<td><code>watch</code></td>
<td><span class="label label-default">boolean</span></td>
<td><code>true</code></td>
<td>A toggle that determines if the promise is watched. <small class="text-muted">This should be left <code>true</code> for now until additional hooks are implemented.</small></td>
</tr>
<tr>
<td><code>delay</code></td>
<td><span class="label label-info">number</span></td>
<td><code>0</code></td>
<td>The time (in milliseconds) it takes for the bar to return to idle state upon promise completion (either success or error). 0 will not return to idle.</td>
</tr>
</tbody>
</table>
<h4>Usage <small>with Bootstrap classes and conditional content.</small></h4>
<p>The <code>statusBar</code> directive assigns status classes to a container, it works well with Bootstrap <code><alert></code>s and other CSS framework components.</p>
<br>
<!-- Code example -->
<p><strong>Here's an example with custom configuration and conditional content based on exposed scope properties.</strong></p>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
<p>Result:</p>
<div class="usage text-center">
<status-button ng-click="setExamplePromise()" promise="examplePromise">
<span>Give it a go!</span>
</status-button>
<br><br>
<small>
<p class="text-muted">The bar will show up here</p>
</small>
<status-bar promise="examplePromise" class="alert" options="alertConfig">
<span ng-switch="$status">
<strong ng-switch-when="inprogress">Wait for it...</strong>
<strong ng-switch-when="success">Woohoo!</strong>
<strong ng-switch-when="error">Bummer...</strong>
{{$value}}
</span>
</status-bar>
</div>
</div>
<div class="col-sm-8">
<p>Bar Template:</p>
<pre class="prettyprint" ng-non-bindable>
<status-bar class="alert"
promise="examplePromise"
options="alertConfig">
<span ng-switch="$status">
<strong ng-switch-when="inprogress">
Wait for it...
</strong>
<strong ng-switch-when="success">
Woohoo!
</strong>
<strong ng-switch-when="error">
Bummer...
</strong>
{{$value}}
</span>
</status-bar>
</pre>
<p>Button Template:</p>
<pre class="prettyprint">
<status-button
ng-click="setExamplePromise()"
promise="examplePromise">
<span>Give it a go!</span>
</status-button>
</pre>
</div>
</div>
</div>
<!-- /- end code samle -->
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p>Built by <a href="http://github.com/barakchamo" target="_blank">Barak Chamo.</a>
<!-- and <a href="https://github.com/angular-ui/bootstrap/graphs/contributors" target="_blank">contributors</a>.</p> -->
<p>Code licensed under <a href="https://github.com/BarakChamo/ng-promise-status/blob/master/LICENSE.md">MIT License</a>.</p>
<p><a href="https://github.com/BarakChamo/ng-promise-status/issues">Issues</a></p>
</div>
</footer>
<script src="dist/directive.js"></script>
<script src="demo/demo.js"></script>
<script src="bower_components/google-code-prettify/bin/prettify.min.js"></script>
<script>
(function(){
prettyPrint();
})();
</script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<!-- Place this tag in your head or just before your close body tag. -->
<script src="https://apis.google.com/js/platform.js" async defer></script>
</body>
</html>