in-the-zone 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5f0bc1e993ba1a6a150126b62ac0332fc80c233
4
- data.tar.gz: 9d773b67e41839149792df270584d3075a29af9e
3
+ metadata.gz: 45a46caa46971175205becd39c8a61a922d11e70
4
+ data.tar.gz: 9c3b65ab914fc6ef6aa3af625d2a3b55c36870e3
5
5
  SHA512:
6
- metadata.gz: b76bc52908d42e65e98de2c0646850b503f6f367e05785c1aa49c11834afcd54e9123588d9b9550070df71dfb8a0905851a40ddd06ad77b7155b97691c426458
7
- data.tar.gz: 472d35dbe0dcc7bdfb00eaf41b267a3bf7c1f0c1ee6f4b45fd7367c869b562c36c4469649795722a6d2dd143bab314001aa0bb0b0b5dbf916dd3e4874d081a73
6
+ metadata.gz: 20e778fc2af793598a2843ba843d3f8d87e01ad9ef90941fac9b2cb48b3e9ee0edd65f6b8675f053744bcd8f83a518f76c5ae6811e3eb080232c6e3bab20f59e
7
+ data.tar.gz: a0807b3c124a13527d1022a7795789c4a09d1e03e317f13f23499534339c15eed4f43c3851b236694fff519f102cf7c242d045ecb94a74f9e7979078f948ff07
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- K�����")]���pݱVލ�+�g��3MU��LIw�Q6}b�?]p`j}0;گF��[\^����]S4��0��u��3�a��Eqf���]!k��SEfU��(�;P O��l���q����h��3�̟���{n 0DA�"� q����n�/�>+&/j���0Q�#��}Dq䊂ĉ��(�-�wӛ����i(c���no&ܸFO2���D(Ehe��� �$�N̎���!R
1
+ 4���i3�Ŏ�0����QF?c��|���2*�>����Tq��zX}(Ao?���D�.'_`���G H�� JFI����]�<'[�t��J;� $��[ū���a���zZ���YN��D1SSX���ڨ� ���7X7��H$52�A;��/y�d��c���ҁAI���Q$˦_��6E�$�=?U�DI3�7���e۸a)@�C�i�1hT��.�����&��e�ϙ�ѠrB��r�$w3�;1�
data/lib/in_the_zone.rb CHANGED
@@ -55,6 +55,9 @@ module InTheZone
55
55
  if opts[ :from_now ]
56
56
  data[ :options ][ :from_now ] = true
57
57
  end
58
+ if opts[ :format_method ]
59
+ data[ :options ][ :format_method ] = opts[ :format_method ].to_s
60
+ end
58
61
  if opts[ :live_update ]
59
62
  data[ :options ][ :live_update ] = true
60
63
  end
@@ -1,3 +1,3 @@
1
1
  module InTheZone
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,12 +2,17 @@ define('inthezone',
2
2
  ['ko', 'moment'],
3
3
  function(ko, moment) {
4
4
 
5
+ var options = {
6
+ format_methods: {}
7
+ };
8
+
5
9
  var InTheZone = function(element, opts) {
6
10
  this.element = element;
7
11
  this.format = ko.observable(opts.format);
8
12
  this.current_time = ko.observable(moment.unix(opts.timestamp));
9
13
  this.from_now = ko.observable(opts.from_now);
10
14
  this.live_update = ko.observable(opts.live_update);
15
+ this.format_method = ko.observable(opts.format_method);
11
16
  if(this.from_now() && this.live_update()) {
12
17
  this.start_interval();
13
18
  };
@@ -33,25 +38,14 @@ define('inthezone',
33
38
  return(60*60*24*interval_base);
34
39
  };
35
40
 
36
- // A Cozy-style time_from_now function...
37
- // InTheZone.prototype.time_from_now = function(time) {
38
- // if(time.diff(moment(),'days')==0) {
39
- // return(time.format('LT'));
40
- // } else if(time.diff(moment(),'days')==-1){
41
- // return('Yesterday');
42
- // } else {
43
- // return(time.format('l'));
44
- // };
45
- // };
46
-
47
- InTheZone.prototype.time_from_now = function(time) {
48
- return(time.fromNow());
49
- };
50
-
51
41
  InTheZone.prototype.update_time = function(new_time) {
52
42
  if(new_time) this.current_time(moment(new_time));
53
- if(this.from_now()) {
54
- this.element.innerHTML = this.time_from_now(this.current_time());
43
+ var meth;
44
+ if(this.format_method() && (meth = options.format_methods[ this.format_method() ])) {
45
+ this.element.innerHTML = meth(this.current_time());
46
+ }
47
+ else if(this.from_now()) {
48
+ this.element.innerHTML = this.current_time().fromNow();
55
49
  } else {
56
50
  this.element.innerHTML = this.current_time().format(this.format());
57
51
  };
@@ -72,4 +66,6 @@ define('inthezone',
72
66
  element.timeHandler.update_time();
73
67
  }
74
68
  }
69
+
70
+ return(options)
75
71
  });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: in-the-zone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Bragg
@@ -30,7 +30,7 @@ cert_chain:
30
30
  TlaAvFdgPdUIydKBhAeUZA4ACyA9QT6EKa2WlkZoV/nVD6N3UfTzj/2Em2EP1lfm
31
31
  dSlv1HCMhSbE8y64mkOubGxyu9V3eM99rqEGwSNo7zMu/cb1
32
32
  -----END CERTIFICATE-----
33
- date: 2014-05-24 00:00:00.000000000 Z
33
+ date: 2014-05-27 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: bundler
metadata.gz.sig CHANGED
Binary file