Skip to content

Instantly share code, notes, and snippets.

View zhang6464's full-sized avatar

zhang meng zhang6464

  • ByteDance
  • Chengdu, China
View GitHub Profile
@zhang6464
zhang6464 / a.html
Created May 5, 2015 06:33
open new window after click but determined by ajax result
<button class="btn">123</button>
// event-wrapper.js
(function(angular, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define([
'angular'
], function(angular) {
@zhang6464
zhang6464 / number_format.js
Last active August 29, 2015 14:11
number_format for javascript
function number_format(num, precision, glue){
num = parseFloat(num);
if(isNaN(num))
num = 0;
precision = (!precision || isNaN(precision = parseInt(precision))) ? 2 : precision;
num = num.toFixed(precision);
glue = glue ? glue : ",";
@zhang6464
zhang6464 / Array.prototype.map.js
Created October 11, 2014 11:12
javascript Array.prototype.map implement.
!function(){
if( typeof Array.prototype.map == 'function')
return;
Array.prototype.map = function(callback){
var i = 0,
length = this.length,
res = [];
if( callback && typeof callback == 'function' ){
for(;i<length;i++)
@zhang6464
zhang6464 / queueable-event.js
Created October 11, 2014 10:59
javascript queueable event handler.
var handler = new Handler();
function Handler(){
var queues = [];
this.addQueue = function( method ){
queues.push(method);
}
this.removeQueue = function( method ){
queues.splice(queues.indexOf(method)-1, 1);
}