Skip to content

Instantly share code, notes, and snippets.

@luokebi
luokebi / gist:450d65dce7cb5b2e6a85
Created April 3, 2015 05:53
Jquery ajax post with payload
$.ajax({
rul: url,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({a: b})
})
@luokebi
luokebi / expanding-text-area2
Last active August 29, 2015 14:01
expanding-text-area2
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<textarea id="test"></textarea>
<script type="text/javascript">
function autoExpand(textarea) {
@luokebi
luokebi / promise
Last active August 29, 2015 14:00
promise test
function log (str) {
document.body.innerHTML += str + '<br/>';
}
function Promise (func) {
var z = this;
this._thens = [];
function resolve () {
var args = Array.prototype.slice.call(arguments);
@luokebi
luokebi / float-title-input
Created April 16, 2014 02:31
float title input demo
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset=utf-8>
<title>niceInput</title>
<style>
body {
font-family: "ff-tisa-web-pro-1","ff-tisa-web-pro-2","Lucida Grande","Helvetica Neue",Helvetica,Arial,"Hiragino Sans GB","Hiragino Sans GB W3","WenQuanYi Micro Hei",sans-serif;
}
@luokebi
luokebi / expanding-text-area
Created April 16, 2014 01:47
auto expanding textaea implement
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
textarea,
pre {
margin: 0;
padding: 0;
@luokebi
luokebi / jquery-dataBind-demo
Last active January 1, 2016 08:39
jquery two-way data bind demo
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
</head>
<body>
<input type="text" data-bind-123="name">
<script type="text/javascript">
@luokebi
luokebi / gist:7315666
Created November 5, 2013 08:34
download a image using javascript from the image url
var a = document.createElement('a');
var e = document.createEvent("MouseEvents");
e.initMouseEvent("click", !0, !0, window, 1, 0, 0, 0, 0, !1, !1, !1, !1, 0, null);
a.setAttribute("href", 'http://www.baidu.com/img/bdlogo.gif'); //the image url
a.setAttribute("download", "kkk.png"); // the file name
a.dispatchEvent(e);
@luokebi
luokebi / gist:6985679
Created October 15, 2013 02:36
social network share button
Facebook
--------
<a title="send to Facebook"
href="http://www.facebook.com/sharer.php?s=100&p[title]=YOUR_TITLE&p[summary]=YOUR_SUMMARY&p[url]=YOUR_URL&p[images][0]=YOUR_IMAGE_TO_SHARE_OBJECT"
target="_blank">
<span>
<img width="14" height="14" src="'icons/fb.gif" alt="Facebook" /> Facebook
</span>
</a>
var stage = new createjs.Stage("testCanvas");
var shape, hit;
var oldX,oldY;
stage.addEventListener('stagemousedown',mouseDown,false);
function mouseDown(e){
console.log(stage.getObjectUnderPoint(e.stageX,e.stageY));
@luokebi
luokebi / gist:6603755
Last active December 23, 2015 07:49
HTML to Dom
function Html2Dom(str) {
var tempDiv = document.createElement('div');
tempDiv.innerHTML = str;
var dom = tempDiv.childNodes[0];
return dom;
}