forked from x/volcanos
add volcanos.js
This commit is contained in:
parent
f412a44aea
commit
16dc9edff3
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.swp
|
37
README.md
37
README.md
@ -1,2 +1,35 @@
|
||||
# volcanos
|
||||
frontage framework
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>:volcano.md</title>
|
||||
<link rel="shortcut icon" type="image/ico" href="/static/librarys/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="/static/librarys/share.css">
|
||||
<script src="/static/volcanos/volcanos.js"></script>
|
||||
<script src="/static/librarys/share.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Volcanos.js</h1>
|
||||
|
||||
<p>volcanos是一个前端框架。
|
||||
模块化
|
||||
通过建立脚本的依赖关系,按需加载相关文件,从而更加高效的组织项目文件。
|
||||
<svg vertion="1.1" xmlns="http://www.w3.org/2000/svg" width="393", height="88" style="">
|
||||
<rect x="4" y="26" width="123" height="36" fill="red" />
|
||||
<text x="65" y="44" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Volcanos</text>
|
||||
<rect x="135" y="26" width="123" height="36" fill="red" />
|
||||
<text x="196" y="44" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Volcanos</text>
|
||||
<rect x="266" y="4" width="123" height="36" fill="red" />
|
||||
<text x="327" y="22" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Volcanos</text>
|
||||
<rect x="266" y="48" width="123" height="36" fill="red" />
|
||||
<text x="327" y="66" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Volcanos</text>
|
||||
</svg></p>
|
||||
|
||||
<h2>0.1 type模块</h2>
|
||||
|
||||
<h2>0.2 core模块</h2>
|
||||
|
||||
<h2>0.3 node模块</h2>
|
||||
|
||||
<h2>0.4 misc模块</h2>
|
||||
|
||||
<h2>0.5 device模块</h2>
|
||||
|
73
volcanos.js
Normal file
73
volcanos.js
Normal file
@ -0,0 +1,73 @@
|
||||
function Volcanos(name, can, libs, cb) {var list = arguments.callee.list || [], meta = arguments.callee.meta || {
|
||||
// 全局属性
|
||||
path: "/static/volcanos/", index: 1,
|
||||
};
|
||||
can[name] || list.push({name: name, can: can, create_time: new Date()}) && (can.__proto__ = {
|
||||
// 通用属性
|
||||
create_time: new Date(),
|
||||
name: name, help: "静态模块", load: function() {
|
||||
for (var i = meta.index; i < list.length; i++) {var item = list[i];
|
||||
can[item.name] = item.can, item.can.name != can.name && (item.can.name = can.name + "." + item.name);
|
||||
}
|
||||
meta.index = i
|
||||
},
|
||||
}), arguments.callee.meta = meta, arguments.callee.list = list;
|
||||
|
||||
if (libs && libs.length > 0) {
|
||||
if (can[libs[0]]) {
|
||||
// 重复加载
|
||||
libs.length > 1? Volcanos(name, can, libs.slice(1), cb): cb(can);
|
||||
} else {
|
||||
// 加载脚本
|
||||
var script = document.createElement("script");
|
||||
script.src = (can.path||meta.path)+libs[0]+".js";
|
||||
script.type = "text/javascript";
|
||||
script.onload = function() {
|
||||
can.load(), libs.length > 1? Volcanos(name, can, libs.slice(1), cb): cb(can);
|
||||
}
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
} else {
|
||||
typeof cb == "function" && cb(can);
|
||||
}
|
||||
return can
|
||||
}
|
||||
|
||||
Volcanos("type", {help: "类型模块",
|
||||
Format: function(obj) {return JSON.stringify(obj)},
|
||||
|
||||
List: function(obj, cb, interval, cbs) {obj = typeof obj == "string"? [obj]: (obj || [])
|
||||
if (interval > 0) {
|
||||
function loop(i) {if (i >= obj.length) {return kit._call(cbs)}
|
||||
kit._call(cb, [obj[i], i, obj]), setTimeout(function() {loop(i+1)}, interval)
|
||||
}
|
||||
obj.length > 0 && setTimeout(function() {loop(0)}, interval/4)
|
||||
return obj
|
||||
}
|
||||
|
||||
var list = []
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
kit.Push(list, kit._call(cb, [obj[i], i, obj]))
|
||||
}
|
||||
return list
|
||||
},
|
||||
})
|
||||
Volcanos("core", {help: "核心模块",
|
||||
Log: function() {
|
||||
},
|
||||
})
|
||||
Volcanos("node", {help: "节点模块",
|
||||
Log: function() {
|
||||
},
|
||||
Split: function() {},
|
||||
})
|
||||
Volcanos("misc", {help: "其它模块",
|
||||
|
||||
})
|
||||
Volcanos("device", {help: "设备模块",
|
||||
isWeiXin: navigator.userAgent.indexOf("MicroMessenger") > -1,
|
||||
isMobile: navigator.userAgent.indexOf("Mobile") > -1,
|
||||
isIPhone: navigator.userAgent.indexOf("iPhone") > -1,
|
||||
isMacOSX: navigator.userAgent.indexOf("Mac OS X") > -1,
|
||||
isWindows: navigator.userAgent.indexOf("Windows") > -1,
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user