Skip to content

Commit e027ca3

Browse files
Paul LeclercqPaul Leclercq
authored andcommitted
use dist/angular-timer.js instead of app/js/_timer.js and app/js/i18nService.js in the index.html file, rename timer.js to _timer.js
1 parent 02537ed commit e027ca3

File tree

4 files changed

+57
-58
lines changed

4 files changed

+57
-58
lines changed
File renamed without changes.

dist/angular-timer.js

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,10 @@
11
/**
2-
* angular-timer - v1.3.0 - 2015-03-03 5:32 PM
2+
* angular-timer - v1.3.0 - 2015-03-05 1:08 PM
33
* https://github.com/siddii/angular-timer
44
*
55
* Copyright (c) 2015 Siddique Hameed
66
* Licensed MIT <https://github.com/siddii/angular-timer/blob/master/LICENSE.txt>
77
*/
8-
var app = angular.module('timer');
9-
10-
app.factory('I18nService', function() {
11-
12-
var I18nService = function() {};
13-
14-
I18nService.prototype.language = 'en';
15-
I18nService.prototype.timeHumanizer = {};
16-
17-
I18nService.prototype.init = function init(lang){
18-
this.language = lang;
19-
//moment init
20-
moment.locale(this.language); //@TODO maybe to remove, it should be handle by the user's application itself, and not inside the directive
21-
22-
//human duration init, using it because momentjs does not allow accurate time (
23-
// momentJS: a few moment ago, human duration : 4 seconds ago
24-
this.timeHumanizer = humanizeDuration.humanizer({
25-
language: this.language,
26-
halfUnit:false
27-
});
28-
};
29-
30-
/**
31-
* get time with units from momentJS i18n
32-
* @param {int} millis
33-
* @returns {{millis: string, seconds: string, minutes: string, hours: string, days: string, months: string, years: string}}
34-
*/
35-
I18nService.prototype.getTimeUnits = function getTimeUnits(millis) {
36-
var diffFromAlarm = Math.round(millis/1000) * 1000; //time in milliseconds, get rid of the last 3 ms value to avoid 2.12 seconds display
37-
38-
var time = {};
39-
40-
if (typeof this.timeHumanizer != 'undefined'){
41-
time = {
42-
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
43-
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
44-
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
45-
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
46-
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
47-
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
48-
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
49-
};
50-
}
51-
else {
52-
console.error('i18nService has not been initialized. You must call i18nService.init("en") for example');
53-
}
54-
55-
return time;
56-
};
57-
58-
return I18nService;
59-
});
60-
618
var timerModule = angular.module('timer', [])
629
.directive('timer', ['$compile', function ($compile) {
6310
return {
@@ -366,3 +313,56 @@ var timerModule = angular.module('timer', [])
366313
if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){
367314
module.exports = timerModule;
368315
}
316+
317+
var app = angular.module('timer');
318+
319+
app.factory('I18nService', function() {
320+
321+
var I18nService = function() {};
322+
323+
I18nService.prototype.language = 'en';
324+
I18nService.prototype.timeHumanizer = {};
325+
326+
I18nService.prototype.init = function init(lang){
327+
this.language = lang;
328+
//moment init
329+
moment.locale(this.language); //@TODO maybe to remove, it should be handle by the user's application itself, and not inside the directive
330+
331+
//human duration init, using it because momentjs does not allow accurate time (
332+
// momentJS: a few moment ago, human duration : 4 seconds ago
333+
this.timeHumanizer = humanizeDuration.humanizer({
334+
language: this.language,
335+
halfUnit:false
336+
});
337+
};
338+
339+
/**
340+
* get time with units from momentJS i18n
341+
* @param {int} millis
342+
* @returns {{millis: string, seconds: string, minutes: string, hours: string, days: string, months: string, years: string}}
343+
*/
344+
I18nService.prototype.getTimeUnits = function getTimeUnits(millis) {
345+
var diffFromAlarm = Math.round(millis/1000) * 1000; //time in milliseconds, get rid of the last 3 ms value to avoid 2.12 seconds display
346+
347+
var time = {};
348+
349+
if (typeof this.timeHumanizer != 'undefined'){
350+
time = {
351+
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
352+
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
353+
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
354+
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
355+
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
356+
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
357+
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
358+
};
359+
}
360+
else {
361+
console.error('i18nService has not been initialized. You must call i18nService.init("en") for example');
362+
}
363+
364+
return time;
365+
};
366+
367+
return I18nService;
368+
});

dist/angular-timer.min.js

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

index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
<script src="bower_components/momentjs/min/moment.min.js"></script>
1515
<script src="bower_components/momentjs/min/locales.min.js"></script>
1616
<script src="bower_components/humanize-duration/humanize-duration.js"></script>
17-
<script src="app/js/timer.js"></script>
18-
<script src="app/js/i18nService.js"></script>
17+
<script src="dist/angular-timer.js"></script>
1918
<script src="docs/docs.js"></script>
2019
</head>
2120
<body ng-app="timer-demo" ng-controller="TimerDemoController">

0 commit comments

Comments
 (0)