This file contains 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
.c-wrap { display: table; *writing-mode: tb-rl; } | |
.c-inner { display: table-cell; vertical-align: middle; *width:100%; *margin:auto 0; *writing-mode:lr-tb;} |
This file contains 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
define(function(require, exports, module) { | |
var ua = navigator.userAgent, | |
android = ua.match(/(Android);?[\s\/]+([\d.]+)?/), | |
ipad = ua.match(/(iPad).*OS\s([\d_]+)/), | |
ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/), | |
iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/), | |
os = {}; | |
if (android) os.android = true, os.version = android[2]; |
This file contains 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
/** | |
* module:tree | |
* | |
* example: | |
var join = require('path').join | |
var Tree = require('./tree') | |
var cwd = process.cwd() | |
new Tree(cwd, 'root').writeTo(join(cwd, 'tree.json')).then(function() { | |
console.log('done') |
This file contains 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
class Store { | |
constructor(props = {}, initialState = {}) { | |
this.state = initialState | |
this.actions = {} | |
this.listeners = [] | |
Object.assign(this, props) | |
for (let key in this) { | |
if (typeof this[key] === 'function') { | |
this.actions[key] = (...args) => { | |
this[key](...args) |
This file contains 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
function walkDom(node, callback) { | |
if (node === null) { | |
return | |
} | |
var stack = [node] //存入数组 | |
var target | |
while (stack.length) { //数组长度不为0,继续循环 | |
target = stack.shift() //取出元素 | |
callback(target) //传入callback | |
Array.prototype.push.apply(stack, target.childNodes) //将其子元素一股脑推入stack,增加长度 |
This file contains 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
!function(t, e) { | |
"object" == typeof exports && "object" == typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports ? exports.POWERMODE = e() : t.POWERMODE = e() | |
}(window, function() { | |
return function(t) { | |
function e(n) { | |
if (o[n]) | |
return o[n].exports; | |
var r = o[n] = { | |
exports: {}, |
This file contains 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
(function() { | |
window.React = { | |
createElement: createElement, | |
render: render, | |
} | |
function render(vnode, container, callback) { | |
var node = initVnode(vnode) | |
container.innerHTML = '' |
This file contains 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
import React from 'react' | |
import ReactDOM from 'react-dom' | |
function createStore(actions, initialState={}) { | |
let currentState = initialState | |
let getState = () => currentState | |
let listeners = [] | |
let subscribe = listener => !listeners.includes(listener) && listeners.push(listener) | |
let publish = () => listeners.forEach(listener => listener()) | |
let dispatch = (type, payload) => { |
This file contains 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
class App { | |
constructor() { | |
this.middlewares = [] | |
} | |
use(...middlewares) { | |
this.middlewares.push(...middlewares) | |
} | |
next(index = 0) { | |
let middleware = this.middlewares[index] | |
return middleware ? middleware(() => this.next(index + 1)) : null |
OlderNewer