当前位置:   article > 正文

http://zc.qq.com/en/index.html,index.html

丫p6666。c0m
Std Source Repository

//-----当前仓库版本号

Std.source.latestVersion = "0.2";

//-----当前仓库名称

Std.source.repositoryName = "StdJS";

//-----当前仓库git地址

Std.source.gitAddress = "https://github.com/stdjs/SourceRepository";

//-----当前仓库最新版本代码源地址,以下地址是根据当前路径和上面的版本号判断的

Std.source.latestVersionAddress = (location + "").between(0,(location + "").lastIndexOf("/") + 1) + Std.source.latestVersion;

//-----

Std.source("StdJS",Std.source.latestVersionAddress);

body{

font-family: Lato,"Open Sans",Arial,"Hiragino Sans GB","Microsoft YaHei",STHeiti,"WenQuanYi Micro Hei",SimSun,sans-serif;

font-size: 13px;

margin: 0;

color: #474442;

background: #4C89AE;

}

h1{

display: inline-block;*display: inline;*zoom: 1;

font-size: 36px;

margin: 0;

padding: 20px 0 20px 60px;

text-shadow: 2px 4px 0 #396884;

text-align: center;

color: white;

background-image: url("favicon.png");

background-repeat: no-repeat;

background-position: 0 24px;

}

h2{

font-size: 21px;

margin: 0;

padding: 10px 0 30px 0;

text-align: center;

text-shadow: 1px 2px 0 #30576F;

}

h3{

font-size: 32px;

margin: 10px 0 20px;

padding: 10px 0 10px 0;

text-align: center;

letter-spacing: 2px;

color: #28A0DA;

}

/*

* header

*/

.header{

font-size: 16px;

height: 56px;

text-align: center;

text-shadow: 1px 2px 0 #3B6C89;

border-bottom: 1px solid #3D6E8C;

background-color: #4A87AB;

}

.header > ._location{

display: inline-block;*display: inline;*zoom: 1;

text-decoration: none;

margin: 0 20px 0 20px;

height: 53px;

line-height: 50px;

border-top: 3px solid transparent;

color: #E8E8E8;

outline: none;

cursor: pointer;

transition: color 0.2s,border-color 0.2s;

}

.header > ._location:hover{

color: white;

}

.header > ._location.selected{

color: #96DBFF;

border-color: #96DBFF;

}

.header.__gray__{

background-color: #D9D5D3;

border-bottom-color: #B5B0AD;

text-shadow: 0 1px 0 #E1DAD6;

}

.header.__gray__ > ._location{

color: #474442;

}

.header.__gray__ > ._location.selected{

color: #238EC1;

border-color: #28A0DA;

}

/*

* main

*/

.main{

background: #4C89AE;

padding: 15px 0 50px 0;

text-align: center;

}

.main > ._description{

font-size: 16px;

width: 900px;

margin: 0 auto;

color: white;

}

.main > ._description > p{

line-height: 2em;

margin-bottom: 30px;

}

/*

* addresses

*/

.addresses{

background: #427797;

color: white;

padding: 25px 0 50px 0;

}

.addresses input{

font-family: Lato,"Open Sans",Arial,"Hiragino Sans GB","Microsoft YaHei",STHeiti,"WenQuanYi Micro Hei",SimSun,sans-serif;

font-size: 13px;

height: 40px;

width: 590px;

margin: 8px 0 8px 0;

padding: 0 5px 0 5px;

border: 2px solid #5FABD9;

color: white;

background: #427797;

transition: background 0.2s,border-color 0.2s;

}

.addresses input:focus{

border-color: #86D5FF;

background: #4781A4;

}

.addresses > ._row{

width: 600px;

margin: 8px auto 25px auto;

}

.addresses > ._row > ._title a{

font-style: italic;

font-size: 14px;

margin-bottom: 4px;

text-decoration: none;

color: white;

text-shadow: 0 1px 0 #134F6C;

}

.addresses > ._row > ._title a:hover{

text-decoration: underline;

}

/*

* example

*/

.example{

background: #EEF6FC;

position: relative;

padding: 20px 10px 20px 10px;

}

.example pre{

font-family: "Source Code Pro";

font-size: 14px;

margin: 0 auto;

padding:20px;

width: 860px;

}

/*

* footer

*/

.footer{

padding: 20px 0 20px 0;

background: #4C89AE;

}

.footer > ._links{

width: 900px;

margin: 0 auto;

}

.footer > ._links > a{

display: inline-block;*display: inline;*zoom: 1;

font-size: 14px;

padding: 20px 0 20px 0;

width: 24%;

color: #C2E9FF;

text-decoration: none;

text-align: center;

transition: all 0.2s;

}

.footer > ._links > a:hover{

color: white;

text-decoration: underline;

}

/*

* resources

*/

.resources{

width: 80%;

margin: 10px auto 50px auto;

border-collapse:collapse;

background: white;

border: 1px solid #3D6E8C;

}

.resources td{

padding: 3px 5px 3px 5px;

}

.resources thead > tr{

font-size: 14px;

height: 35px;

text-align: center;

font-style: italic;

margin-bottom: 4px;

text-decoration: none;

background: #4A87AB;

color: white;

}

.resources thead > tr > td{

border: 1px solid #3D6E8C;

}

.resources tbody > tr{

border-right: 1px solid #C1C1C1;

}

.resources tbody > tr > td{

font-size: 13px;

height: 30px;

border-right: 1px solid #C1C1C1;

border-bottom: 1px solid #C1C1C1;

}

/*

* packages

*/

.packages{

margin: 0 auto;

background: #D9D5D3;

border-top: 1px solid #E1DAD6;

}

/********* screen ***********/

@media only screen and (max-width: 1024px){

.resources{

width: 98%

}

}

Std Source Repository

Std Source Repository (Std代码仓库) 是StdJS用于管理代码而提供的一个代码存储仓库,仓库中可以有

任意数量以及任意类型的代码包,每个包都有独立的唯一名称,仓库中包含的包仅仅只会在需要的时候才会被载入.

这解决了js开发过程中的代码部署,以及代码复用,和其他的一系列繁琐的维护过程.

其中仓库中的包是可以任意定制的(添加,删除,修改) ,并且该页面上提供了一个在线版的包维护和构建工具(见顶部包管理),

你可以通过git将该仓库克隆到本地,放置到你自己的项目当中,或者创建一个完全属于自己的仓库地址,无论怎么样,

在项目中使用时候,只需要使用Std.source方法引入正确的地址即可,非常简单.

如果你已经将该仓库克隆到了你自己的服务器中,以及完成了自己代码仓库的包配置,并且打算公开这个代码仓库,那么请将上面的git地址修改为你自己的地址,

同时请尽量不要删除当前页面.

LATEST VERSION :

当前代码仓库的Git地址:

当前的代码仓库代码源地址:

常见的用法

 
   

/*

* 引入代码仓库,注意仓库名称StdJS,区分大小写

* 仓库中的包可以为任意数量,只有在代码引入包的时候,该包才会被真正载入

*/

Std.source("Std.source.repositoryName","Std.source.latestVersionAddress");

/*

* 使用仓库中的包,例如 ui.MessageBox

* 包含多个包的情况下可以使用数组,例如["ui.MessageBox","ui.Window"]

* 只有在Std.use的包载入完毕之后Std.main托管的函数才会被执行.

*/

Std.use("ui.MessageBox",function(){

Std.ui("MessageBox").information("test");

});

Std.main(function(){

Std.ui("MessageBox").information("MessageBox package loaded");

});

/*

* 如果要单独执行一个函数,但是需要使用某个包,可以这样创建函数

* 被引入的包将会被自动缓存起来,第二次执行函数时候将会跳过加载包的步骤

*/

var func1 = Std.func(function(){

// code...

},{

packages:["ui.Window"]

});

/*

* 在 Std.main 主函数触发之前载入某个包,还可以这样写

*/

Std.main(Std.func(function(){

Std.ui("Notify").success("Std.main");

},{

packages:["ui.Notify"]

}));

(function(){

var exampleElem = Std.dom("#home_example");

var exampleText = exampleElem.html().replace(/\"([^\"]*)\"/g, function(word){

return "" + word + "";

}).replace(/function/g, function(word){

return "" + word + "";

}).replace(/\/\*([\s\S]*?)\*\//g, function(word){

return "" + word + "";

}).replace("Std.source.repositoryName",Std.source.repositoryName).replace(

"Std.source.latestVersionAddress",Std.source.latestVersionAddress

);

exampleElem.html(exampleText);

})();

=packageName?>=version?>=basics?>=description?>

包名称版本依赖包文档地址包描述

  • 包名称
  • 版本
  • 依赖包
  • 文档地址
  • 描述

文件列表:

#each files?>

$value?>

/each?>

 
 

//-------全局只需要设置一次仓库源地址

Std.source("=repositoryName?>","=latestVersionAddress?>");

//-------用Std.use等方法载入包

Std.use("=packageName?>",function(){

//.......代码

})

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAJcEhZcwABEJAAARCQAYms0rgAAAN+SURBVEjHldR9aNVlFAfwz733t1d1m5N8me1qW1mZm8Z1uqlURJQvVCAYhEHYP2VjSBJCJERBb1AKoRloEYoQRKZWDsNEpJmQc+HIqWUm2Ta3OZuuqXu5tz+6XXdd8+X73zkP3+95nu855wlJIkbEBNPdq8Q4ExVKOOusM05r1KhDvN5QhJLkfA9ZaJ5Jcv/NDULcRSftU6vOpWtFQjEiHvayB2W5Prp9bY1DEoNFIkWB5dabJnAjZJpmvtOairSkkmGLvaHwhuT/UGytisGJsGVG3zQdohalC9waHUakC2zXd0v0bnsHh5GiBO4f0rrh0GedP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ZGF0ZTpjcmVhdGUAMjAxNS0wNy0yNVQyMTo1MDoyMyswODowMC596vAAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTItMDctMjdUMjM6MDA6MDIrMDg6MDBIAFyvAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDA5LTEwLTI3VDE4OjQwOjM0KzAxOjAwiuDM0gAAAE50RVh0c29mdHdhcmUASW1hZ2VNYWdpY2sgNi44LjgtMTAgUTE2IHg4Nl82NCAyMDE1LTA3LTE5IGh0dHA6Ly93d3cuaW1hZ2VtYWdpY2sub3JnBQycNQAAABh0RVh0VGh1bWI6OkRvY3VtZW50OjpQYWdlcwAxp/+7LwAAABh0RVh0VGh1bWI6OkltYWdlOjpIZWlnaHQAMTI4Q3xBgAAAABd0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAAxMjjQjRHdAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADEzNDM0MDEyMDIznb56AAAAE3RFWHRUaHVtYjo6U2l6ZQAxOC41S0JCSeC45gAAAFp0RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC93d3cuZWFzeWljb24ubmV0L2Nkbi1pbWcuZWFzeWljb24uY24vc3JjLzEwNzc1LzEwNzc1NzMucG5nhXuVWgAAAABJRU5ErkJggg==

Std.main(function(){

var dom_header = Std.dom(".header");

var packages = {};

var lastPassword = "";

var skipPassword = false;

var messager = Std.module({

static:{

/*

* text window

*/

textWindow:Std.func(function(title,text){

Std.ui("Window",{

width:800,

height:600,

modal:true,

minimizable:false,

title:title,

layout:{

ui:"VBoxLayout",

items:[{

ui:"CodeMirror",

mode:"javascript",

lineNumbers:true,

value:text

}]

}

})

},{

packages:["ui.Window","code.CodeMirror[mode='javascript']"]

}),

/*

* example

*/

example:Std.func(function(packageName,repositoryName,address){

Std.ui("MessageBox").information(Std.template("grid_example").render({

packageName:packageName,

repositoryName:repositoryName,

latestVersionAddress:address

}))

},{

packages:["ui.MessageBox"]

}),

/*

* delete package

*/

deletePackage:Std.func(function(callback){

Std.ui("MessageBox").confirm("确定要删除选中的包吗?对应的文件也将会被删除,该操作不可恢复.","提示",callback)

},{

packages:["ui.MessageBox"]

}),

/*

* connect error

*/

connectError:Std.func(function(){

Std.ui("Notify").error({

text:"无法连接到12444端口失败,可能是server.js 未运行.
请尝试到服务器中以 node ./server.js 方式启动服务端.
" +

"如果已经启动服务端还是出现这个错误
则当前浏览器不支持ajax Access-Control-Allow-Origin 跨域请求",

title:"发生错误",

timeout:"8s"

});

},{

packages:["ui.MessageBox"]

}),

/*

* save success

*/

saveSuccess:Std.func(function(){

Std.ui("Notify").success({

title:"成功",

text:"packages.json 和 index.js 文件保存成功",

timeout:"2s"

});

},{

packages:["ui.MessageBox"]

}),

/*

* save error

*/

saveError:Std.func(function(text){

Std.ui("Notify").error({

text:"保存失败,服务器返回信息:
" + text,

title:"发生错误",

timeout:"8s"

});

},{

packages:["ui.MessageBox"]

}),

/*

* package duplicate

*/

packageDuplicate:Std.func(function(packageName){

Std.ui("MessageBox").information("包: [" + packageName + "] 已经存在,不能重复添加.")

},{

packages:["ui.MessageBox"]

})

}

});

var mainModule = Std.module({

static:{

/*

* stringify

*/

stringify:function(jsonObject){

Std.each(jsonObject,function(name,data){

if(isObject(data.attr)){

Std.each(data.attr,function(name,data){

data.files = data.files + "";

data.parallel = !!data.parallel;

});

}

});

return JSON.stringify(jsonObject,null,4);

},

/*

* save

*/

save:function(password,code){

Std.ajax({

url:"http://" + Std.url.location().hostName + ":12444/save",

type:"post",

data:{

version:Std.source.latestVersion,

password:lastPassword = password,

index:code,

packages:mainModule.stringify(packages)

},

error:messager.connectError,

success:function(text){

if(text == "0"){

messager.saveSuccess();

skipPassword = true;

}else{

messager.saveError(text);

}

}

});

}

},

private:{

/*

* loading

*/

loading:false,

/*

* packages loaded

*/

packagesLoaded:false,

/*

* packages grid

*/

packagesGrid:null,

/*

* packages page loaded

*/

packagesPageLoaded:false,

/*

* current page

*/

currentPage:"page_home"

},

initialize:{

/*

* init document state

*/

initDocumentState:function(){

Std.source.repository.on({

append:function(){

Std.css.cursor("wait");

},

complete:function(){

Std.css.cursor(null);

}

});

},

/*

* init router

*/

initRouter:function(){

var that = this;

//------ ie fix

if(!("onhashchange" in window)){

var currentHash = location.hash;

setInterval(function(){

if(location.hash !== currentHash){

currentHash = location.hash;

Std.dom(window).emit("hashchange");

}

},100);

}

/*

* add hash change event listener

*/

Std.dom(window).on("hashchange",function(){

var hash = location.hash;

var changeTheme = false;

if(hash === "#page_resource"){

that.showResourcePage();

}else if(hash === "#page_packages"){

changeTheme = true;

that.showPackagesPage();

}else if(hash !== "#page_home"){

return;

}

dom_header.toggleClass("__gray__",changeTheme);

Std.dom("#"+that._currentPage).hide();

Std.dom("#"+(that._currentPage = location.hash.substr(1))).show();

Std.dom(">._location.selected",dom_header).removeClass("selected");

Std.dom(">._location[href='#"+that._currentPage+"']",dom_header).addClass("selected");

});

/*

* check current url hash

*/

if(location.hash !== ""){

Std.dom(window).emit("hashchange")

}

}

},

protected:{

/*

* load packages

*/

loadPackages:function(callback){

var that = this;

if(that._loading){

return;

}

if(that._packagesLoaded){

return callback(packages);

}

(that._loading = true) && Std.ajax.json(Std.source.latestVersionAddress + "/packages.json",function(data){

that._loading = false;

that._packagesLoaded = true;

callback(that.formatPackages(packages = data));

});

},

/*

* show resource page

*/

showResourcePage:function(){

this.loadPackages(function(data){

var tbody = Std.dom("#resources > tbody").clear();

Std.each(data,function(packageName,packageValue){

tbody.append(newDom("tr").append([

newDom("td").html(packageName),

newDom("td").html(packageValue.version),

newDom("td").html(isArray(packageValue.basics) ? packageValue.basics.join(' ') : packageValue.basics),

newDom("td").append(

newDom("a").html(packageValue.documentation).attr({

href:packageValue.documentation,

target:"_blank"

})

),

newDom("td").html(packageValue.description)

]));

});

});

},

/*

* show packages page

*/

showPackagesPage:Std.func(function(){

var that = this;

var dom = Std.dom("#packages");

var resize = function(){

dom.height(Std.dom(window).height() - dom_header.outerHeight() - 1);

};

if(that._packagesPageLoaded){

resize();

dom.layout().update();

return;

}

var layout = resize() || dom.layout("VBoxLayout",{

paddingTop:3

});

Std.dom(window).on("resize",function(){

if(that._currentPage === "page_packages"){

resize() || layout.update()

}

});

that._packagesGrid = layout.find("Grid")[0];

that._packagesGrid.rowContextMenu({

items:[

Std.action("addPackage"),

Std.action("editPackage"),

Std.action("deletePackage"),

{ui:"sep"},

Std.action("reload"),

Std.action("showExample")

]

});

that._packagesGrid.on("rowEvent",function(type){

if(type === "dblclick"){

Std.action("editPackage").call();

}

});

that.loadPackages(function(packages){

Std.each(packages,function(name,data){

that.addPackageRow(name,data);

});

});

that._packagesPageLoaded = true;

},{

delay:1,

packages:["ui.ToolBar","ui.Grid","ui.ComboBox","ui.Menu"]

})

},

public:{

/*

* update default values

*/

updateDefaultValue:function(){

Std.dom("#git_address").value(Std.source.gitAddress).prevSibling().get(0).attr("href",Std.source.gitAddress);

Std.dom("#source_address").value(Std.source.latestVersionAddress).prevSibling().get(0).attr("href",Std.source.latestVersionAddress);

Std.dom(".addresses").on("click","input",function(){

this.select()

});

},

/*

* build index code

*/

buildIndexCode:function(){

var code = 'Std.source.response("'+Std.source.repositoryName+'",function(){';

var codeMap = {at:3,func:{},variable:{}};

var analysis = {paths:{}, basics:{}};

var formatUrl = function(file){

var url = Std.url(file);

var text = file;

if(url.suffix === "css"){

url.file = url.basename;

text = '"' + escape(url.toUrl()) + '"+C';

}else if(url.suffix === "js"){

url.file = url.basename;

text = '"' + escape(url.toUrl()) + '"+B';

}else{

return '"' + escape(text) + '"';

}

return text;

};

code += "var B='.js',C='.css';function A(f,b,a){return {files:f,basics:b,attr:a}}";

Std.each(packages,function(name,config){

for(var i=config.files.length-1;i>=0;i--){

var fileAddress = config.files[i].trim();

if(isEmpty(fileAddress)){

config.files.remove(i);

continue;

}

var url = Std.url(fileAddress);

url.file = "";

url = url.toUrl();

if(isEmpty(url.path) === ""){

continue;

}

if(!(url in analysis.paths)){

analysis.paths[url] = 0;

}else{

analysis.paths[url]++;

}

}

for(i=config.basics.length-1;i>=0;i--){

var packageName = config.basics[i].trim();

if(isEmpty(packageName)){

config.basics.remove(i);

continue;

}

if(!(packageName in analysis.basics)){

analysis.basics[packageName] = 0;

}else{

analysis.basics[packageName]++;

}

}

});

Std.each(analysis.paths,function(path,pathNumber){

if(pathNumber > 1){

var name = Std.convert.ntol(codeMap.at++);

codeMap.func[path] = name;

code += "function " + name + "(s){return '"+path+"'+s}";

}

});

Std.each(analysis.basics,function(packageName,basicsNumber){

if(basicsNumber > 1){

var name = Std.convert.ntol(codeMap.at++);

codeMap.variable[packageName] = name;

code += "var " + name + "='" + packageName + "';";

}

});

code += "return{";

Std.each(packages,function(packageName,config){

var basics = config.basics;

var attrs = config.attr;

var files = config.files;

var readPath = function(fileAddress){

var url = Std.url(fileAddress);

url.file = "";

return url.toUrl();

};

var filePath = function(file){

var url = Std.url(file);

var path = readPath(file);

var text = "";

if(analysis.paths[path] > 1){

text = codeMap.func[path] + '(' + formatUrl(url.file) + ')';

}else{

text = formatUrl(file);

}

return text;

};

var basicPath = function(packageName){

var text = "";

if(analysis.basics[packageName] > 1){

text = codeMap.variable[packageName];

}else{

text = '"'+escape(packageName)+'"';

}

return text;

};

var filesPath = function(files){

if(files.length === 1){

return filePath(files[0]);

}

var fileTextArray = [];

Std.each(files,function(i,path){

fileTextArray.push(filePath(path))

});

return "[" + fileTextArray.join(",") + "]";

};

var basicsPath = function(basics){

if(basics.length === 1){

return basicPath(basics[0]);

}

var basicsTextArray = [];

Std.each(basics,function(i,packageName){

basicsTextArray.push(basicPath(packageName))

});

return "[" + basicsTextArray.join(",") + "]";

};

code += '"'+packageName+'":';

if(isEmpty(basics) && isEmpty(attrs)){

if(files.length > 0){

code += filesPath(files);

}else{

code += "null"

}

}else{

var args = [filesPath(files),basicsPath(basics)];

if(!isEmpty(attrs)){

var attrsCode = [];

Std.each(attrs,function(name,data){

if(isString(data) || isFunction(data)){

data = (data + "").trim();

}

if(isObject(data)){

if(data.parallel === true){

attrsCode.push(name + ":"+ data.files);

}else{

attrsCode.push(name + ":{parallel:false,files:"+ data.files +"}");

}

}else if(isString(data) && !isEmpty(data)){

attrsCode.push(name + ":"+ data)

}

});

if(!isEmpty(attrsCode)){

attrsCode = attrsCode.join(",")

}

args.push("{"+ attrsCode + "}");

}

code += "A(" +args.join(",")+")";

}

code += ","

});

if(code[code.length - 1] === ","){

code = code.substr(0,code.length - 1)

}

return code + "}});";

},

/*

* format package

*/

formatPackage:function(name,data){

var config = {

basics:[],

files:[],

attr:data.attr || null,

packageName:name,

version:data.version || "",

documentation:data.documentation || "",

description:data.description || ""

};

if(isString(data) && !isEmpty(data)){

config.files.push(data);

}

if(isArray(data)){

Std.each(data,function(i,fileAddress){

!isEmpty(fileAddress) && config.files.push(fileAddress);

});

}

if(isString(data.basics) && !isEmpty(data.basics)){

config.basics.push(data.basics);

}

if(isArray(data.basics)){

Std.each(data.basics,function(i,packageName){

!isEmpty(packageName) && config.basics.push(packageName);

});

}

if(isString(data.files) && !isEmpty(data.files)){

config.files.push(data.files);

}

if(isArray(data.files)){

Std.each(data.files,function(i,fileAddress){

!isEmpty(fileAddress) && config.files.push(fileAddress);

});

}

if(isObject(data.attr)){

for(var name in data.attr){

if(isFunction(data.attr[name])){

data.attr[name] = {parallel:true,files:data.attr[name] + ""}

}

}

}

return config;

},

/*

* format packages

*/

formatPackages:function(){

var that = this;

Std.each(packages,function(name,data){

packages[name] = that.formatPackage(name,data);

});

return packages;

},

/*

* add package row

*/

addPackageRow:function(name,data,type,index){

this._packagesGrid[type || "appendRow"]({

value:data,

cells:{

packageName:name,

version:data.version || "",

basics:data.basics.join(" "),

documentation:data.documentation || "",

description:data.description

},

content:Std.template("grid_rowContent").render(data)

},index);

},

/*

* edit package

*/

editPackage:function(defaultValue,callback){

Std.stl.cache = false;

Std.stl.fileCache = false;

Std.stl.load("editPackage.stl",function(error,stl,exports){

if(!error){

exports(defaultValue,callback);

}

})

}

},

main:function(){

this.initRouter();

this.initDocumentState();

this.updateDefaultValue();

}

});

var mainInstance = new mainModule();

/**

* actions

*/

Std.action({

addPackage:{

icon:"add",

text:"添加包",

hotKey:"Ctrl+N",

main:function(){

mainInstance.editPackage(null,function(values,window){

if(values.packageName in packages){

return messager.packageDuplicate(values.packageName);

}

var packageData = packages[values.packageName] = mainInstance.formatPackage(values.packageName,values);

mainInstance.addPackageRow(values.packageName, packageData, "insertRow", 0);

mainInstance._packagesGrid.selectRow(0);

window.close();

});

}

},

editPackage:{

icon:"edit",

text:"编辑选中包",

main:function(){

var selectedRow = mainInstance._packagesGrid.selectedRow(true);

selectedRow && mainInstance.editPackage(Std.extend({},selectedRow.value,3),function(values,window){

Std.extend(selectedRow.value,values);

selectedRow.cells.basics = values["basics"].join(' ');

selectedRow.cells.version = values["version"] || "";

selectedRow.cells.documentation = values["documentation"] || "";

selectedRow.cells.description = values["description"];

selectedRow.content = Std.template("grid_rowContent").render(values);

mainInstance._packagesGrid.refresh();

window.close();

});

}

},

deletePackage:{

icon:"delete",

text:"删除包",

hotKey:"delete",

main:function(){

var rows = mainInstance._packagesGrid.selectedRows(true);

var names = [];

var indexes = [];

if(!isEmpty(rows)){

messager.deletePackage(function(){

Std.each(rows,function(i,row){

indexes.push(mainInstance._packagesGrid.indexOf(row));

delete packages[names[i] = row.value.packageName];

},true);

mainInstance._packagesGrid.removeRow(indexes);

});

}

}

},

reload:{

icon:"reload",

text:"重新载入",

main:function(){

mainInstance._packagesGrid.clearRows();

mainInstance._packagesLoaded = false;

mainInstance.loadPackages(function(packages){

Std.each(packages,function(name,data){

mainInstance.addPackageRow(name,data);

});

});

}

},

save:{

icon:"save",

text:"保存配置",

main:Std.func(function(){

var code = mainInstance.buildIndexCode();

try{

new Function(code);

}catch(e){

return Std.ui("MessageBox").error("生成的js代码验证不通过,请检查是配置中否有特殊字符.");

}

if(typeof JSON === "undefined"){

return Std.ui("Notify").error("浏览器版本过低");

}

if(skipPassword){

mainModule.save(lastPassword,code)

}else{

Std.ui("MessageBox").prompt("请输入密码:",null,"密码验证",function(password){

mainModule.save(lastPassword = password,code)

});

}

},{

packages:["ui.Notify","ui.MessageBox","ui.Edit"]

})

},

showExample:{

text:"使用例子",

main:function(){

var rowIndex = mainInstance._packagesGrid.selectedRow();

if(rowIndex !== -1){

messager.example(

mainInstance._packagesGrid.cell(rowIndex,0),

Std.source.repositoryName,

Std.source.latestVersionAddress

)

}

}

},

buildPackagesText:{

icon:"build",

text:"packages.json",

main:function(){

messager.textWindow("packages.json",function(){

if(typeof JSON === "object"){

return mainModule.stringify(packages)

}

return "";

}())

}

},

buildIndexText:{

icon:"build",

text:"index.js",

main:function(){

messager.textWindow("index.js",mainInstance.buildIndexCode())

}

}

});

})

一键复制

编辑

Web IDE

原始数据

按行查看

历史

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/155768
推荐阅读
相关标签
  

闽ICP备14008679号