This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CustomPromise = function(callback) { | |
const res = (fn, ...args) => fn && callOnce(fn, args); | |
const rej = (fn, ...args) => fn && callOnce(fn, args); | |
let callOnce = (fn, args) => { | |
fn.apply(null, args); | |
callOnce = () => { }; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.fData = function(_data) { | |
var $form = this; | |
if (!_data) { | |
return $form.serializeArray().reduce(function(obj, field) { | |
obj[field.name] = field.value; | |
return obj; | |
}, {}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form enctype="multipart/form-data"> | |
<input type="file" name="files" id="files" multiple onchange="File.set(this)"> | |
</form> | |
var File = (function(){ | |
var files = [], | |
set = function(obj){ | |
for(var i in obj.files) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Router js</title> | |
</head> | |
<body> | |
<h1 id="title"><?=!empty($_GET['page']) ? strip_tags($_GET['page']) : 'Home';?></h1> | |
<ul> | |
<li><a onclick="Router.go('/'); return false;" href="/">Home</a></li> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isMobile = function(){ | |
return /Mobi|Mini|Symbian|SAMSUNG|Nokia|BlackBerry|Series|Bada|SymbOS|PLAYSTATION/g | |
.test(navigator.userAgent.toString()); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var player = { | |
play: function(music){ | |
console.info('player plaing: ', music); | |
} | |
}; | |
var search = { | |
items: { | |
a: 'ABBA', | |
b: 'Boney M', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.remove = function(id){ | |
return this.splice(id, 1); | |
} | |
var a = ["a","b","c","d"]; | |
a.remove(2); | |
console.log(a); | |
// ["a", "b", "d"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $scope = (function($){ | |
var _this = { | |
name: 'Alex' | |
}; | |
return { | |
get: function(prop){ | |
return _this[prop]; | |
}, | |
set: function(prop, val){ | |
return _this[prop] = val; |