SHARE
TWEET

Untitled

a guest Feb 7th, 2016 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function Timer() {
  3.     this.node = document.createElement('span');
  4. }
  5.  
  6. Timer.prototype = {
  7.     set time (v) {
  8.         var d = new Date(v * 1000);
  9.         this._time = v;
  10.         this.node.textContent = d.toISOString().match(/\d+:\d+:\d+/)[0];
  11.     },
  12.     get time () {
  13.         return this._time;
  14.     }
  15. }
  16.  
  17. var t_t = new Timer();
  18. t_t.time = 70;
  19. document.body.appendChild(t_t.node);
  20.  
  21.  
  22. // Без прототипа //////////////////////////////////////////////////////////////////////////////////
  23. ///////////////////////////////////////////////////////////////////////////////////////////////////
  24.  
  25. function Timer() {
  26.     var node = document.createElement('span');
  27.     var time = 0;
  28.  
  29.     this.node = node;
  30.  
  31.     Object.defineProperty(this, 'time', {
  32.         set: function (v) {
  33.             var d = new Date(v * 1000);
  34.             time = v;
  35.             node.textContent = d.toISOString().match(/\d+:\d+:\d+/)[0];
  36.         },
  37.         get: function () {
  38.             return time;
  39.         }
  40.     });
  41. }
  42.  
  43. var t_t = new Timer();
  44. t_t.time = 70;
  45. document.body.appendChild(t_t.node);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top