📄 doc.js
字号:
_printResults: function(results){ dojo.debug("_printResults(): called"); // summary: Call this function to send the /doc/results topic }, _onDocSelectFunction: function(/*Object*/ input){ // summary: Get doc, meta, and src var name = input.name; var selectKey = selectKey; dojo.debug("_onDocSelectFunction(" + name + ")"); if(!name){ return false; } if(!selectKey){ selectKey = ++dojo.doc._count; } dojo.doc._keys[selectKey] = {size: 0}; dojo.doc._myKeys[++dojo.doc._count] = {selectKey: selectKey, type: "meta"} dojo.doc.getMeta(dojo.doc._count, dojo.doc._onDocSelectResults, name); dojo.doc._myKeys[++dojo.doc._count] = {selectKey: selectKey, type: "src"} dojo.doc.getSrc(dojo.doc._count, dojo.doc._onDocSelectResults, name); dojo.doc._myKeys[++dojo.doc._count] = {selectKey: selectKey, type: "doc"} dojo.doc.getDoc(dojo.doc._count, dojo.doc._onDocSelectResults, name); }, _onDocSelectResults: function(/*String*/ type, /*Object*/ data, /*Object*/ evt){ dojo.debug("dojo.doc._onDocSelectResults(" + evt.type + ", " + evt.name + ")"); var myKey = dojo.doc._myKeys[evt.selectKey]; dojo.doc._keys[myKey.selectKey][myKey.type] = data; dojo.doc._keys[myKey.selectKey].size; if(++dojo.doc._keys[myKey.selectKey].size == 3){ var key = dojo.lang.mixin(evt, dojo.doc._keys[myKey.selectKey]); delete key.size; dojo.debug("Publishing docFunctionDetail"); dojo.doc._printFunctionDetail(key); delete dojo.doc._keys[myKey.selectKey]; delete dojo.doc._myKeys[evt.selectKey]; } }, _printFunctionDetail: function(results) { // summary: Call this function to send the /doc/functionDetail topic event }, _buildCache: function(/*Object*/ input){ var type = input.type; var pkg = input.pkg; var callbacks = input.callbacks; var id = input.id; if(!id){ id = "_"; } var name = input.name; dojo.debug("_buildCache() type: " + type); if(type == "function_names"){ if(!dojo.doc._cache["function_names"]){ dojo.debug("_buildCache() new cache"); if(callbacks && callbacks.length){ dojo.doc._callbacks.function_names.push([input, callbacks.shift()]); } dojo.doc._cache["function_names"] = {loading: true}; dojo.io.bind({ url: "json/function_names", mimetype: "text/json", error: function(type, data, evt){ dojo.debug("Unable to load function names"); for(var i = 0, callback; callback = dojo.doc._callbacks.function_names[i]; i++){ callback[1].call(null, "error", {}, callback[0]); } }, load: function(type, data, evt){ dojo.doc._cache['function_names'] = data; for(var i = 0, callback; callback = dojo.doc._callbacks.function_names[i]; i++){ callback[1].call(null, "load", data, callback[0]); } } }); }else if(dojo.doc._cache["function_names"].loading){ dojo.debug("_buildCache() loading cache"); if(callbacks && callbacks.length){ dojo.doc._callbacks.function_names.push([input, callbacks.shift()]); } }else{ dojo.debug("_buildCache() from cache"); if(callbacks && callbacks.length){ var callback = callbacks.shift(); callback.call(null, "load", dojo.doc._cache["function_names"], input); } } }else if(type == "meta" || type == "src"){ if(!pkg){ if(type == "meta"){ dojo.doc.functionPackage(dojo.doc._getMeta, input); }else{ dojo.doc.functionPackage(dojo.doc._getSrc, input); } }else{ try{ var cached = dojo.doc._cache[pkg][name][id][type]; }catch(e){} if(cached){ if(callbacks && callbacks.length){ var callback = callbacks.shift(); callback.call(null, "load", cached, input); return; } } dojo.debug("Finding " + type + " for: " + pkg + ", function: " + name + ", id: " + id); var mimetype = "text/json"; if(type == "src"){ mimetype = "text/plain" } var url = "json/" + pkg + "/" + name + "/" + id + "/" + type; dojo.io.bind({ url: url, input: input, mimetype: mimetype, error: function(type, data, evt, args){ var input = args.input; var pkg = input.pkg; var type = input.type; var callbacks = input.callbacks; var id = input.id; var name = input.name; if(callbacks && callbacks.length){ if(!data){ data = {}; } if(!dojo.doc._cache[pkg]){ dojo.doc._cache[pkg] = {}; } if(!dojo.doc._cache[pkg][name]){ dojo.doc._cache[pkg][name] = {}; } if(type == "meta"){ data.sig = dojo.doc._cache[pkg][name][id].sig; data.params = dojo.doc._cache[pkg][name][id].params; } var callback = callbacks.shift(); callback.call(null, "error", data, args.input); } }, load: function(type, data, evt, args){ var input = args.input; var pkg = input.pkg; var type = input.type; var id = input.id; var name = input.name; var cache = dojo.doc._cache; dojo.debug("_buildCache() loaded " + type); if(!data){ data = {}; } if(!cache[pkg]){ dojo.doc._cache[pkg] = {}; } if(!cache[pkg][name]){ dojo.doc._cache[pkg][name] = {}; } if(!cache[pkg][name][id]){ dojo.doc._cache[pkg][name][id] = {}; } if(!cache[pkg][name][id].meta){ dojo.doc._cache[pkg][name][id].meta = {}; } dojo.doc._cache[pkg][name][id][type] = data; if(callbacks && callbacks.length){ var callback = callbacks.shift(); callback.call(null, "load", data, args.input); } } }); } }else if(type == "pkgmeta"){ try{ var cached = dojo.doc._cache[name]["meta"]; }catch(e){} if(cached){ if(callbacks && callbacks.length){ var callback = callbacks.shift(); callback.call(null, "load", cached, input); return; } } dojo.debug("Finding package meta for: " + name); dojo.io.bind({ url: "json/" + name + "/meta", input: input, mimetype: "text/json", error: function(type, data, evt, args){ var callbacks = args.input.callbacks; if(callbacks && callbacks.length){ var callback = callbacks.shift(); callback.call(null, "error", {}, args.input); } }, load: function(type, data, evt, args){ var pkg = args.input.name; var cache = dojo.doc._cache; dojo.debug("_buildCache() loaded for: " + pkg); if(!cache[pkg]){ dojo.doc._cache[pkg] = {}; } if(!cache[pkg]["meta"]){ dojo.doc._cache[pkg]["meta"] = {}; } var methods = data.methods; if(methods){ for(var method in methods){ if (method == "is") { continue; } for(var pId in methods[method]){ if(!cache[pkg]["meta"][method]){ dojo.doc._cache[pkg]["meta"][method] = {}; } if(!cache[pkg]["meta"][method][pId]){ dojo.doc._cache[pkg]["meta"][method][pId] = {}; } dojo.doc._cache[pkg]["meta"][method][pId].summary = methods[method][pId]; } } } dojo.doc._cache[pkg]["meta"].methods = methods; var requires = data.requires; if(requires){ dojo.doc._cache[pkg]["meta"].requires = requires; } if(callbacks && callbacks.length){ var callback = callbacks.shift(); callback.call(null, "load", methods, input); } } }); } }, selectFunction: function(/*String*/ name, /*String?*/ id){ // summary: The combined information }, savePackage: function(/*String*/ name, /*String*/ description){ dojo.doc._rpc.callRemote( "saveForm", { form: "DocPkgForm", path: "/WikiHome/DojoDotDoc/id", pname1: "main/text", pvalue1: "Test" } ).addCallbacks(dojo.doc._results, dojo.doc._results); }, functionPackage: function(/*Function*/ callback, /*Object*/ input){ dojo.debug("functionPackage() name: " + input.name + " for type: " + input.type); input.type = "function_names"; input.callbacks.unshift(callback); input.callbacks.unshift(dojo.doc._functionPackage); dojo.doc._buildCache(input); }, _functionPackage: function(/*String*/ type, /*Array*/ data, /*Object*/ evt){ dojo.debug("_functionPackage() name: " + evt.name + " for: " + evt.type + " with: " + type); evt.pkg = ''; var data = dojo.doc._cache['function_names']; for(var key in data){ if(dojo.lang.inArray(data[key], evt.name)){ evt.pkg = key; break; } } if(evt.callbacks && evt.callbacks.length){ var callback = evt.callbacks.shift(); callback.call(null, type, data[key], evt); } }, _sort: function(a, b){ if(a[0] < b[0]){ return -1; } if(a[0] > b[0]){ return 1; } return 0; }});dojo.event.topic.subscribe("/doc/search", dojo.doc, "_onDocSearch");dojo.event.topic.subscribe("/doc/selectFunction", dojo.doc, "_onDocSelectFunction");dojo.event.topic.registerPublisher("/doc/results", dojo.doc, "_printResults");dojo.event.topic.registerPublisher("/doc/functionDetail", dojo.doc, "_printFunctionDetail");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -