Advertisement
Guest User

Gangnan Style Overflow Counter

a guest
Nov 29th, 2014
2,369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // JSNice results from https://s.ytimg.com/yts/jsbin/www-en_US-vflBNYrhc/watch_gangnam_overflow.js
  2.  
  3. (function(self) {
  4.   var window = this;
  5.   /**
  6.    * @param {(Object|number|string)} r
  7.    * @param {number} dataType
  8.    * @return {undefined}
  9.    */
  10.   var run = function(r, dataType) {
  11.     self.Sa.call(this);
  12.     /** @type {(Object|number|string)} */
  13.     this.R = r;
  14.     /** @type {number} */
  15.     this.J = 0;
  16.     /** @type {number} */
  17.     this.H = 17 * r.length;
  18.     /** @type {number} */
  19.     this.K = 0;
  20.     this.k = dataType || 5;
  21.     /** @type {number} */
  22.     this.j = this.g = 17 * this.J;
  23.     /** @type {null} */
  24.     this.C = this.F = this.D = this.da = null;
  25.     var info = window.document.createElement("div");
  26.     self.B(info, "go-numberwheel-container");
  27.     var d = window.document.createElement("div");
  28.     self.B(d, "go-numberwheel");
  29.     var html = this.R.join(" ") + " " + this.R[0];
  30.     d.innerHTML = html;
  31.     info.appendChild(d);
  32.     this.D = d;
  33.     this.da = info;
  34.     join(this);
  35.   };
  36.   /**
  37.    * @param {?} msg
  38.    * @param {number} key
  39.    * @return {undefined}
  40.    */
  41.   var callback = function(msg, key) {
  42.     /** @type {number} */
  43.     msg.J = key;
  44.     /** @type {number} */
  45.     msg.j = 17 * key;
  46.   };
  47.   /**
  48.    * @param {Object} arg
  49.    * @return {?}
  50.    */
  51.   var fn = function(arg) {
  52.     return new self.be(function(cb) {
  53.       if (this.g == this.j) {
  54.         cb();
  55.       } else {
  56.         /** @type {boolean} */
  57.         this.F = cb;
  58.       }
  59.     }, arg);
  60.   };
  61.   /**
  62.    * @param {Object} options
  63.    * @return {undefined}
  64.    */
  65.   var move = function(options) {
  66.     /** @type {boolean} */
  67.     var b = 2 == options.K;
  68.     if (b || options.j != options.g) {
  69.       if (1 == options.K) {
  70.         options.g = options.j;
  71.       } else {
  72.         options.g += options.k;
  73.         /** @type {number} */
  74.         var value = Math.abs(options.k / 2);
  75.         var tval = options.j + value;
  76.         /** @type {number} */
  77.         value = options.j - value;
  78.         if (!b && (tval >= options.g && value <= options.g)) {
  79.           options.g = options.j;
  80.         } else {
  81.           if (0 > options.k) {
  82.             if (0 > options.g - 0.1) {
  83.               options.g = options.H + options.g;
  84.               if (options.C) {
  85.                 options.C();
  86.               }
  87.             }
  88.           } else {
  89.             if (0 < options.k) {
  90.               if (options.g + 0.1 >= options.H) {
  91.                 options.g = 0 == options.j ? options.j : options.g - options.H;
  92.                 if (options.C) {
  93.                   options.C();
  94.                 }
  95.               }
  96.             }
  97.           }
  98.         }
  99.       }
  100.       join(options);
  101.       if (!b) {
  102.         if (options.F) {
  103.           if (options.j == options.g) {
  104.             options.F();
  105.             /** @type {null} */
  106.             options.F = null;
  107.           }
  108.         }
  109.       }
  110.     }
  111.   };
  112.   /**
  113.    * @param {Object} obj
  114.    * @return {undefined}
  115.    */
  116.   var join = function(obj) {
  117.     /** @type {string} */
  118.     obj.D.style[vendorProp] = "translate3d(0, -" + obj.g + "px, 0)";
  119.   };
  120.   /**
  121.    * @param {number} n
  122.    * @param {number} r
  123.    * @return {undefined}
  124.    */
  125.   var e = function(n, r) {
  126.     self.Sa.call(this);
  127.     /** @type {number} */
  128.     this.k = n;
  129.     this.C = self.Tk("div");
  130.     self.B(this.C, "go-odometer");
  131.     /** @type {number} */
  132.     this.K = r;
  133.     /** @type {number} */
  134.     this.R = -1;
  135.     this.D = new self.Hz(this.Bf, window, this);
  136.     self.Ta(this, this.D);
  137.     /** @type {boolean} */
  138.     this.F = true;
  139.     /** @type {number} */
  140.     this.J = 0;
  141.     /** @type {string} */
  142.     this.H = "";
  143.     /** @type {Array.<string>} */
  144.     var pattern = "0123456789".split("");
  145.     /** @type {Array} */
  146.     this.g = Array(10);
  147.     /** @type {number} */
  148.     var pix1 = 10;
  149.     for (;pix1--;) {
  150.       var g = new run(pattern);
  151.       this.g[pix1] = g;
  152.       self.Ta(this, g);
  153.     }
  154.     this.j = new run(["&nbsp;", "-"]);
  155.     self.Ta(this, this.j);
  156.     /** @type {Array} */
  157.     this.O = [this.wq, test(this, 500), this.sq, test(this, 1500), this.vq, test(this, 2E3), this.uq, this.tq];
  158.   };
  159.   /**
  160.    * @param {?} bind
  161.    * @param {Function} scope
  162.    * @param {number} opt_attributes
  163.    * @return {undefined}
  164.    */
  165.   var forEach = function(bind, scope, opt_attributes) {
  166.     bind.J = self.v((0, self.p)(scope, bind), opt_attributes);
  167.   };
  168.   /**
  169.    * @param {number} offset
  170.    * @return {?}
  171.    */
  172.   var extractStacktrace = function(offset) {
  173.     /** @type {number} */
  174.     offset = Math.abs(offset);
  175.     /** @type {Array} */
  176.     var eventPath = [];
  177.     for (;offset;) {
  178.       /** @type {number} */
  179.       var cur = offset % 10;
  180.       /** @type {number} */
  181.       offset = (offset - cur) / 10 | 0;
  182.       eventPath.push(cur);
  183.     }
  184.     return eventPath;
  185.   };
  186.   /**
  187.    * @param {Object} args
  188.    * @param {number} recurring
  189.    * @return {undefined}
  190.    */
  191.   var each = function(args, recurring) {
  192.     args.j.hc(recurring);
  193.     /** @type {number} */
  194.     var i = 0;
  195.     var valuesLen = args.g.length;
  196.     for (;i < valuesLen;++i) {
  197.       args.g[i].hc(recurring);
  198.     }
  199.   };
  200.   /**
  201.    * @param {Object} options
  202.    * @param {number} y
  203.    * @return {?}
  204.    */
  205.   var build = function(options, y) {
  206.     /** @type {number} */
  207.     var a = Math.abs(y);
  208.     /** @type {Array} */
  209.     var r = [];
  210.     /** @type {number} */
  211.     var i = 0;
  212.     var valuesLen = options.g.length;
  213.     for (;i < valuesLen;++i) {
  214.       /** @type {number} */
  215.       var b = a % 10;
  216.       /** @type {number} */
  217.       a = (a - b) / 10 | 0;
  218.       var e = options.g[i];
  219.       callback(e, b);
  220.       r.push(fn(e));
  221.     }
  222.     callback(options.j, 0 > y ? 1 : 0);
  223.     r.push(fn(options.j));
  224.     return self.ak(r);
  225.   };
  226.   /**
  227.    * @param {?} cond
  228.    * @param {number} opt_attributes
  229.    * @return {?}
  230.    */
  231.   var test = function(cond, opt_attributes) {
  232.     return(0, self.p)(function() {
  233.       return new self.be(function($sanitize) {
  234.         forEach(this, function() {
  235.           this.De();
  236.           $sanitize();
  237.         }, opt_attributes);
  238.       }, this);
  239.     }, cond, opt_attributes);
  240.   };
  241.   /**
  242.    * @return {undefined}
  243.    */
  244.   var y = function() {
  245.     match();
  246.     var interval = self.G("watch-view-count");
  247.     var timer = self.G("real-view-count", interval);
  248.     if (interval) {
  249.       if (timer) {
  250.         timer = (0, window.parseInt)(timer.innerHTML, 0);
  251.         if (!(2147483947 > timer)) {
  252.           self.D(interval, "go-done");
  253.           self.B(interval, "go-ready");
  254.           tester = new e(interval, timer);
  255.           self.Ua(tester, match);
  256.           tester.run();
  257.         }
  258.       }
  259.     }
  260.   };
  261.   /**
  262.    * @return {undefined}
  263.    */
  264.   var i = function() {
  265.     match();
  266.   };
  267.   /**
  268.    * @return {undefined}
  269.    */
  270.   var match = function() {
  271.     self.Va(tester);
  272.     /** @type {null} */
  273.     tester = null;
  274.     var onComplete = self.G("watch-view-count");
  275.     if (onComplete) {
  276.       self.B(onComplete, "go-done");
  277.     }
  278.   };
  279.   self.t(run, self.Sa);
  280.   var transformProperty;
  281.   t: {
  282.     var elem = self.Tk("div");
  283.     /** @type {Array} */
  284.     var props = ["transform", "webkitTransform", "mozTransform", "msTransform", "oTransform"];
  285.     /** @type {number} */
  286.     var idx = props.length;
  287.     for (;idx--;) {
  288.       var prop = props[idx];
  289.       if (void 0 !== elem.style[prop]) {
  290.         transformProperty = prop;
  291.         break t;
  292.       }
  293.     }
  294.     /** @type {string} */
  295.     transformProperty = "transform";
  296.   }
  297.   var vendorProp = transformProperty;
  298.   /**
  299.    * @return {undefined}
  300.    */
  301.   run.prototype.N = function() {
  302.     self.Lh(this.D);
  303.     self.Lh(this.da);
  304.     /** @type {null} */
  305.     this.C = this.D = this.da = null;
  306.     run.L.N.call(this);
  307.   };
  308.   /**
  309.    * @param {number} outstandingDataSize
  310.    * @return {undefined}
  311.    */
  312.   run.prototype.hc = function(outstandingDataSize) {
  313.     /** @type {number} */
  314.     this.K = outstandingDataSize;
  315.   };
  316.   self.t(e, self.Sa);
  317.   self.g = e.prototype;
  318.   /**
  319.    * @return {undefined}
  320.    */
  321.   self.g.N = function() {
  322.     e.L.N.call(this);
  323.     this.D.stop();
  324.     self.bb(this.J);
  325.     self.Lh(this.C);
  326.     self.D(this.k, "go-activate");
  327.     self.N(this.H);
  328.   };
  329.   /**
  330.    * @return {undefined}
  331.    */
  332.   self.g.Bf = function() {
  333.     if (!this.ha()) {
  334.       if (this.F) {
  335.         /** @type {boolean} */
  336.         this.F = false;
  337.         ++this.R;
  338.         var i = this.O[this.R];
  339.         if (i) {
  340.           i.call(this);
  341.         } else {
  342.           this.end();
  343.         }
  344.       }
  345.       move(this.j);
  346.       /** @type {number} */
  347.       i = 0;
  348.       var valuesLen = this.g.length;
  349.       for (;i < valuesLen;++i) {
  350.         move(this.g[i]);
  351.       }
  352.       this.D.start();
  353.     }
  354.   };
  355.   /**
  356.    * @return {undefined}
  357.    */
  358.   self.g.run = function() {
  359.     this.Bf();
  360.   };
  361.   /**
  362.    * @return {undefined}
  363.    */
  364.   self.g.pause = function() {
  365.     this.D.stop();
  366.   };
  367.   /**
  368.    * @return {undefined}
  369.    */
  370.   self.g.end = function() {
  371.     this.pause();
  372.     this.dispose();
  373.   };
  374.   /**
  375.    * @return {undefined}
  376.    */
  377.   self.g.De = function() {
  378.     /** @type {boolean} */
  379.     this.F = true;
  380.   };
  381.   /**
  382.    * @return {undefined}
  383.    */
  384.   self.g.wq = function() {
  385.     self.rc("/gen_204?go_init");
  386.     each(this, 1);
  387.     this.k.appendChild(this.C);
  388.     this.C.appendChild(this.j.da);
  389.     var spaces = this.g.length;
  390.     for (;spaces--;) {
  391.       this.C.appendChild(this.g[spaces].da);
  392.     }
  393.     build(this, this.K).then(function() {
  394.       each(this, 0);
  395.       return new self.be(function(millis) {
  396.         this.H = self.mk(this.k, self.Wp, millis);
  397.         self.B(this.k, "go-activate");
  398.       }, this);
  399.     }, null, this).then(this.De, null, this);
  400.   };
  401.   /**
  402.    * @return {undefined}
  403.    */
  404.   self.g.sq = function() {
  405.     /** @type {number} */
  406.     this.j.k = 0.9;
  407.     this.j.hc(2);
  408.     /** @type {number} */
  409.     var a1 = 1;
  410.     var line = this.g.length;
  411.     for (;line--;) {
  412.       var value = this.g[line];
  413.       /** @type {number} */
  414.       var b4 = 0.5 > Math.random() ? 1 : -1;
  415.       value.hc(2);
  416.       /** @type {number} */
  417.       value.k = a1 * b4;
  418.       ++a1;
  419.     }
  420.     this.De();
  421.   };
  422.   /**
  423.    * @return {undefined}
  424.    */
  425.   self.g.vq = function() {
  426.     var uri = build(this, -4294967294 + this.K);
  427.     this.j.hc(0);
  428.     var result = self.de();
  429.     var f = this.g.length;
  430.     for (;f--;) {
  431.       result = result.then(self.q(function(e) {
  432.         return new self.be(function(next_scope) {
  433.           e.hc(0);
  434.           forEach(this, next_scope, 100);
  435.         }, this);
  436.       }, this.g[f]), null, this);
  437.     }
  438.     self.ak([uri, result]).then(this.De, null, this);
  439.   };
  440.   /**
  441.    * @return {undefined}
  442.    */
  443.   self.g.uq = function() {
  444.     var iteratee = extractStacktrace(this.K);
  445.     /** @type {number} */
  446.     var requestId = 2;
  447.     var jQuery = (0, self.p)(function(index) {
  448.       var id = requestId += 0.3;
  449.       for (;index--;) {
  450.         var e = this.g[index];
  451.         e.hc(2);
  452.         e.k = id;
  453.         callback(e, iteratee[index]);
  454.         if (50 < id) {
  455.           /** @type {number} */
  456.           id = 50;
  457.         }
  458.       }
  459.     }, this);
  460.     var sel = this.g.length;
  461.     jQuery(sel);
  462.     /** @type {number} */
  463.     this.j.k = 2;
  464.     callback(this.j, 0);
  465.     this.j.hc(0);
  466.     var outcome = fn(this.j);
  467.     for (;sel--;) {
  468.       outcome = outcome.then((0, self.p)(function(e, option) {
  469.         jQuery(option);
  470.         e.hc(0);
  471.         return fn(e);
  472.       }, this, this.g[sel], sel));
  473.     }
  474.     outcome.then(this.De, null, this);
  475.   };
  476.   /**
  477.    * @return {undefined}
  478.    */
  479.   self.g.tq = function() {
  480.     self.rc("/gen_204?go_cleanup");
  481.     this.H = self.mk(this.k, self.Wp, (0, self.p)(this.De, this));
  482.     self.D(this.k, "go-activate");
  483.   };
  484.   /** @type {null} */
  485.   var tester = null;
  486.   /** @type {Array} */
  487.   var out = [];
  488.   self.Wc(self.Ck({
  489.     name : "www/gangnam_overflow",
  490.     deps : ["www/watch"],
  491.     page : "watch",
  492.     /**
  493.      * @return {undefined}
  494.      */
  495.     init : function() {
  496.       var statements = self.G("watch-view-count");
  497.       if (statements) {
  498.         out.push(self.J(statements, "mouseenter", y));
  499.         out.push(self.J(statements, "mouseleave", i));
  500.       }
  501.     },
  502.     /**
  503.      * @return {undefined}
  504.      */
  505.     dispose : function() {
  506.       match();
  507.       self.N(out);
  508.       /** @type {number} */
  509.       out.length = 0;
  510.     }
  511.   }));
  512. })(_yt_www);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement