";
body += "
";
@@ -213,33 +214,33 @@ function onStartContract(data) {
}
}
-function onStartContractAsDebug(data) {
- // console.log(data);
- const result = JSON.parse(data.data);
- /* if (result.isInsnLimit) {
- global.withEvaluatesAnalysis = true;
- $("#dialogBodyDiv").text("此合约在执行时会消耗gas,请在执行前进行预估,根据预估值给出相应的值,建议给出的值大于预估值");
- showDialog("部署合约成功", function() {
- });
- }*/
- startResult.innerText = result.status + "(" + data.executeTime + "ms" + ")";
- if (result.status !== "Success") {
- let body = "
";
- body += " ";
- body += "
";
- $("#dialogBodyDiv").html(body);
- $("#onStartContractFailedContent")[0].value = result.result
- showDialog("部署合约失败", function () {
- });
- }
-}
+// function onStartContractAsDebug(data) {
+// // console.log(data);
+// const result = JSON.parse(data.data);
+// /* if (result.isInsnLimit) {
+// global.withEvaluatesAnalysis = true;
+// $("#dialogBodyDiv").text("此合约在执行时会消耗gas,请在执行前进行预估,根据预估值给出相应的值,建议给出的值大于预估值");
+// showDialog("部署合约成功", function() {
+// });
+// }*/
+// startResult.innerText = `${result.status}(${data['executeTime']}ms)`;
+// if (result.status !== "Success") {
+// let body = "
";
+// body += " ";
+// body += "
";
+// $("#dialogBodyDiv").html(body);
+// $("#onStartContractFailedContent")[0].value = result.result
+// showDialog("部署合约失败", function () {
+// });
+// }
+// }
function onKillContractProcess(data) {
// console.log(data);
if (data.data === "success") {
listContracts();
}
- stopResult.innerText = data.data + "(" + data.executeTime + "ms" + ")";
+ stopResult.innerText = `${data.data}(${data['executeTime']}ms)`;
}
function onKillAllContract(data) {
@@ -275,7 +276,7 @@ function onQueryContractInstanceInfoByDOI(data) {
initContractInstanceInfoArea();
// console.log(data);
$("#contractInstanceInfoTitle")
- .html(" (" + data.executeTime + "ms)");
+ .html(` (${data['executeTime']}ms)`);
global.contractInstanceInfoEditor.setValue(data.data);
let totalLines = global.contractInstanceInfoEditor.lineCount();
@@ -292,7 +293,7 @@ function onImportContractInstanceCodeByDOI(data) {
initContractInstanceInfoArea();
// console.log(data);
$("#contractInstanceInfoTitle")
- .html(" (" + data.executeTime + "ms)");
+ .html(` (${data['executeTime']}ms)`);
global.contractInstanceInfoEditor.setValue(data.data);
let totalLines = global.contractInstanceInfoEditor.lineCount();
@@ -307,14 +308,12 @@ function onImportContractInstanceCodeByDOI(data) {
global.wssocket.send("{\"action\":\"listProjects\",\"isPrivate\":true}");
}
-
function onListContractProcess(data) {
// console.log(data);
-
mainVue.contracts = [];
- var list = JSON.parse(data.data);
- for (var i = 0; i < list.length; i++) {
- if (list[i].contractStatus != "KILLED") {
+ const list = JSON.parse(data.data);
+ for (let i = 0; i < list.length; i++) {
+ if (list[i].contractStatus !== "KILLED") {
mainVue.contracts.push(list[i]);
}
}
@@ -359,25 +358,25 @@ function initResponseAndOutputArea() {
}
function onExecuteResult(obj) {
-
+ const executeResultTitleEl = $("#executeResultTitle")
const data = obj;
- $("#executeResultTitle")
- .html(data.status + " (" + obj.executeTime + "ms) 未知格式");
+ executeResultTitleEl
+ .html(`${data.status} (${obj['executeTime']}ms) 未知格式`);
if (data.result instanceof Object) {
- $("#executeResultTitle")
- .html(data.status + " (" + obj.executeTime + "ms) JSON格式");
+ executeResultTitleEl
+ .html(`${data.status} (${obj['executeTime']}ms) JSON格式`);
global.responseEditor.setValue(JSON.stringify(data.result));
} else if (typeof data.result == 'string') {
- $("#executeResultTitle")
- .html(data.status + " (" + obj.executeTime + "ms) 字符串格式");
+ executeResultTitleEl
+ .html(`${data.status} (${obj['executeTime']}ms) 字符串格式`);
global.responseEditor.setValue(data.result);
} else {
if (typeof data.result == 'number') {
- $("#executeResultTitle")
- .html(data.status + " (" + obj.executeTime + "ms) 数值格式");
+ executeResultTitleEl
+ .html(`${data.status} (${obj['executeTime']}ms) 数值格式`);
} else if (typeof data.result == 'boolean') {
- $("#executeResultTitle")
- .html(data.status + " (" + obj.executeTime + "ms) 布尔型格式");
+ executeResultTitleEl
+ .html(`${data.status} (${obj['executeTime']}ms) 布尔型格式`);
}
global.responseEditor.setValue(data.result.toString());
}
@@ -391,9 +390,9 @@ function onExecuteResult(obj) {
}, {
line: totalLines
});
- if (data.analysis && data.analysis.length > 0) {
- // displayOutputStr(data.analysis);
- }
+ // if (data['analysis'] && data['analysis'].length > 0) {
+ // displayOutputStr(data.analysis);
+ // }
}
function onGenerateReadme(obj) {
diff --git a/js/cm.js b/js/cm.js
index 8d04778..20c2f1a 100644
--- a/js/cm.js
+++ b/js/cm.js
@@ -1,527 +1,528 @@
-var WSHandler = function(event) {
- // console.log(event);
- data = event.data;
- // console.log(" -->" + data);
- try {
- var obj = JSON.parse(data);
- switch (obj.action) {
- case 'ping':
- case 'poing':
- break;
- case 'onExecuteResult':
- onExecuteResult(obj);
- break;
- case 'onListContractProcess':
- onListContractProcess(obj);
- break;
- case 'onStartContract':
- onStartContract(obj);
- break;
- case 'onKillContractProcess':
- logComm(obj);
- break;
- case 'onKillAllContract':
- onKillAllContract(obj);
- break;
- case 'onOutputStream':
- displayOutput(obj);
- break;
- case 'onSaveFile':
- onSaveFile(obj);
- break;
- case 'uploadNext':
- onUploadNext(obj);
- break;
- case 'sendNextSegment':
- global.wssocket.sendNextSegment();
- break;
- case 'sendSeg':
- receiveSeg(obj);
- break;
- case 'onException':
- logException(obj);
- break;
- case 'onHashResult':
- onHashResult(obj);
- break;
- case 'onDumpContract':
- onDumpContract(obj);
- break;
- default:
- displayOutput(obj);
- break;
- }
- } catch (err) {
- console.log(err);
- }
+var WSHandler = function (event) {
+ // console.log(event);
+ data = event.data;
+ // console.log(" -->" + data);
+ try {
+ var obj = JSON.parse(data);
+ switch (obj.action) {
+ case 'ping':
+ case 'poing':
+ break;
+ case 'onExecuteResult':
+ onExecuteResult(obj);
+ break;
+ case 'onListContractProcess':
+ onListContractProcess(obj);
+ break;
+ case 'onStartContract':
+ onStartContract(obj);
+ break;
+ case 'onKillContractProcess':
+ logComm(obj);
+ break;
+ case 'onKillAllContract':
+ onKillAllContract(obj);
+ break;
+ case 'onOutputStream':
+ displayOutput(obj);
+ break;
+ case 'onSaveFile':
+ onSaveFile(obj);
+ break;
+ case 'uploadNext':
+ onUploadNext(obj);
+ break;
+ case 'sendNextSegment':
+ global.wssocket.sendNextSegment();
+ break;
+ case 'sendSeg':
+ receiveSeg(obj);
+ break;
+ case 'onException':
+ logException(obj);
+ break;
+ case 'onHashResult':
+ onHashResult(obj);
+ break;
+ case 'onDumpContract':
+ onDumpContract(obj);
+ break;
+ default:
+ displayOutput(obj);
+ break;
+ }
+ } catch (err) {
+ console.log(err);
+ }
};
-var logException = function(obj) {
- global.tempobj = obj;
- $("#responseStatus").html("Exception (" + obj.executeTime + "ms)");
- displayOutput(obj);
+var logException = function (obj) {
+ global.tempobj = obj;
+ $("#responseStatus").html("Exception (" + obj.executeTime + "ms)");
+ displayOutput(obj);
};
-var logComm = function(obj) {
- console.log(obj);
+var logComm = function (obj) {
+ console.log(obj);
};
-var displayOutput = function(obj) {
- displayOutputStr(obj.data);
+var displayOutput = function (obj) {
+ displayOutputStr(obj.data);
};
-var displayOutputStr = function(str) {
- console.log("[cm.js] displayOutput:" + str);
+var displayOutputStr = function (str) {
+ console.log("[cm.js] displayOutput:" + str);
};
-var getControlWsUrl = function(host) {
- var prefix = "ws://";
- if (document.location.href.startsWith("https"))
- prefix = "wss://";
- var path = document.location.pathname.lastIndexOf("/");
- path = document.location.pathname.substr(0, path + 1);
- path += "SCExecutor";
- return prefix + host + path;
+var getControlWsUrl = function (host) {
+ var prefix = "ws://";
+ if (document.location.href.startsWith("https"))
+ prefix = "wss://";
+ var path = document.location.pathname.lastIndexOf("/");
+ path = document.location.pathname.substr(0, path + 1);
+ path += "SCExecutor";
+ return prefix + host + path;
};
-var initWSocket = function() {
- var host = getHost();
- var url = getControlWsUrl(host);
- global.wssocket = createWssocket(url, function() {
- listContractProcess();
- }, WSHandler);
+var initWSocket = function () {
+ var host = getHost();
+ var url = getControlWsUrl(host);
+ global.wssocket = createWssocket(url, function () {
+ listContractProcess();
+ }, WSHandler);
};
// ====== wsHandler
-var onStartContract = function(obj) {
- // console.log(obj);
- var result = JSON.parse(obj.data);
+var onStartContract = function (obj) {
+ // console.log(obj);
+ var result = JSON.parse(obj.data);
- $("#responseStatus").html(result.status + " (" + obj.executeTime + "ms)");
- global.responseEditor.setValue(result.result);
- // $("#tabdiv").editableSelect('add', obj.cid);
- // $("#tabdiv").editableSelect()[0].value = obj.cid;
+ $("#responseStatus").html(result.status + " (" + obj.executeTime + "ms)");
+ global.responseEditor.setValue(result.result);
+ // $("#tabdiv").editableSelect('add', obj.cid);
+ // $("#tabdiv").editableSelect()[0].value = obj.cid;
};
-var onExecuteResult = function(obj) {
- // console.log(obj);
- var data = JSON.parse(obj.data);
- $("#responseStatus").html(data.status + " (" + obj.executeTime + "ms)");
- global.responseEditor.setValue(data.result);
- // console.log(data);
- var totalLines = global.responseEditor.lineCount();
- global.responseEditor.autoFormatRange({
- line : 0,
- ch : 0
- }, {
- line : totalLines
- });
- if (data.analysis != undefined && data.analysis.length > 0) {
- // displayOutputStr(data.analysis);
- }
+var onExecuteResult = function (obj) {
+ // console.log(obj);
+ var data = JSON.parse(obj.data);
+ $("#responseStatus").html(data.status + " (" + obj.executeTime + "ms)");
+ global.responseEditor.setValue(data.result);
+ // console.log(data);
+ var totalLines = global.responseEditor.lineCount();
+ global.responseEditor.autoFormatRange({
+ line: 0,
+ ch: 0
+ }, {
+ line: totalLines
+ });
+ if (data.analysis != undefined && data.analysis.length > 0) {
+ // displayOutputStr(data.analysis);
+ }
};
-var onListContractProcess = function(obj) {
- var data = JSON.parse(obj.data);
- global.contracts = data;
- var html = "";
+var onListContractProcess = function (obj) {
+ var data = JSON.parse(obj.data);
+ global.contracts = data;
+ var html = "";
- // $("#tabdiv").html("");
- global.contractName2ID = {};
- for (var i = 0; i < data.length; i++) {
- global.contractName2ID[data[i].name] = data[i].id;
- html += "
" + data[i].name + " ";
- // $("#tabdiv").append(
- // $("
").attr("value", data[i].id).text(
- // data[i].id));
- }
- $("#contractList").html(html);
- $("#contractList").selectable(
- {
- stop : function() {
- var result = "";
- global.selectedContracts = [];
- global.selectedContractIndexs = [];
+ // $("#tabdiv").html("");
+ global.contractName2ID = {};
+ for (var i = 0; i < data.length; i++) {
+ global.contractName2ID[data[i].name] = data[i].id;
+ html += "
" + data[i].name + " ";
+ // $("#tabdiv").append(
+ // $("
").attr("value", data[i].id).text(
+ // data[i].id));
+ }
+ $("#contractList").html(html);
+ $("#contractList").selectable(
+ {
+ stop: function () {
+ var result = "";
+ global.selectedContracts = [];
+ global.selectedContractIndexs = [];
- $(".ui-selected", this).each(function() {
- var index = $("#contractList li").index(this);
- global.selectedContracts.push(this.innerText);
- global.selectedContractIndexs.push(index);
- });
- // console.log("[cm.js] selectContractResult:"
- // + global.selectedContracts);
- }
- });
- // $("#tabdiv").selectmenu("refresh");
- // $("#tabdiv").html(html);
- // $("yourid/class here").append($("
").attr("value",
- // youroption-value).text(youroption-text));
+ $(".ui-selected", this).each(function () {
+ var index = $("#contractList li").index(this);
+ global.selectedContracts.push(this.innerText);
+ global.selectedContractIndexs.push(index);
+ });
+ // console.log("[cm.js] selectContractResult:"
+ // + global.selectedContracts);
+ }
+ });
+ // $("#tabdiv").selectmenu("refresh");
+ // $("#tabdiv").html(html);
+ // $("yourid/class here").append($("
").attr("value",
+ // youroption-value).text(youroption-text));
};
-var onSaveFile = function(obj) {
- alert("Save file:" + obj.data);
+var onSaveFile = function (obj) {
+ alert("Save file:" + obj.data);
};
-var onKillAllContract = function(obj) {
- customAlert(obj.data);
+var onKillAllContract = function (obj) {
+ customAlert(obj.data);
};
-var onHashResult = function(obj) {
- $("#hashResult").html("刚刚操作的数链指纹:" + obj.data);
+var onHashResult = function (obj) {
+ $("#hashResult").html("刚刚操作的数链指纹:" + obj.data);
};
-var onDumpContract = function(obj) {
- // console.log("DumpResult:" + obj.data);
- if (obj.data == "success") {
- listDumpMemoryDir();
- }
+var onDumpContract = function (obj) {
+ // console.log("DumpResult:" + obj.data);
+ if (obj.data == "success") {
+ listDumpMemoryDir();
+ }
};
// ====== wsHandler done!
-var switchContract = function(off) {
- // var contract = global.contracts[off];
- // global.scriptEditor.setValue(contract.script);
- // $("#tabdiv")[0].value = contract.id;
- var pingObj = {};
- pingObj.action = "connectTo";
+var switchContract = function (off) {
+ // var contract = global.contracts[off];
+ // global.scriptEditor.setValue(contract.script);
+ // $("#tabdiv")[0].value = contract.id;
+ var pingObj = {};
+ pingObj.action = "connectTo";
- pingObj.name = $("#tabdiv")[0].value;
- pingObj.id = global.contractName2ID[pingObj.name];
- global.wssocket.send(JSON.stringify(pingObj));
+ pingObj.name = $("#tabdiv")[0].value;
+ pingObj.id = global.contractName2ID[pingObj.name];
+ global.wssocket.send(JSON.stringify(pingObj));
}
-var countChar = function(str, c) {
- var ret = 0;
- for (var i = 0; i < str.length; i++) {
- if (str.charAt(i) == c)
- ret++;
- }
- return ret;
+var countChar = function (str, c) {
+ var ret = 0;
+ for (var i = 0; i < str.length; i++) {
+ if (str.charAt(i) == c)
+ ret++;
+ }
+ return ret;
}
-var generate = function() {
- $.ajax({
- url : "./SCManager?action=generatePrivateKey",
- dataType : "json"
- }).done(function(result) {
- if (result.status) {
- localStorage.setItem("PrivKey", result.data);
- alert("Key successfully generated!");
- initRest();
- }
- });
+var generate = function () {
+ $.ajax({
+ url: "./SCManager?action=generatePrivateKey",
+ dataType: "json"
+ }).done(function (result) {
+ if (result.status) {
+ localStorage.setItem("PrivKey", result.data);
+ alert("Key successfully generated!");
+ initRest();
+ }
+ });
}
-var initGlobal = function() {
- window.global = {};
- global.privKey = localStorage.getItem("PrivKey");
- if (global.privKey == undefined || global.privKey == null
- || global.privKey.length < 100) {
- generate();
- } else
- initRest();
+var initGlobal = function () {
+ window.global = {};
+ global.privKey = localStorage.getItem("PrivKey");
+ if (global.privKey == undefined || global.privKey == null
+ || global.privKey.length < 100) {
+ generate();
+ } else
+ initRest();
}
-var setMainHost = function() {
- var mainHost = $("#targetHost")[0].value;
- localStorage.setItem("mainHost", mainHost);
+var setMainHost = function () {
+ var mainHost = $("#targetHost")[0].value;
+ localStorage.setItem("mainHost", mainHost);
}
-var initRest = function() {
- var mainHost = localStorage.getItem("mainHost");
- if (mainHost == undefined) {
- localStorage.setItem("mainHost", "39.106.6.6:8080");
- mainHost = localStorage.getItem("mainHost");
- }
- $("#targetHost")[0].value = mainHost;
+var initRest = function () {
+ var mainHost = localStorage.getItem("mainHost");
+ if (mainHost == undefined) {
+ localStorage.setItem("mainHost", "39.106.6.6:8080");
+ mainHost = localStorage.getItem("mainHost");
+ }
+ $("#targetHost")[0].value = mainHost;
};
-var onUploadNext = function() {
- var request = {};
- request.action = "startContract";
- request.owner = global.privKey;
- request.isPartial = false;
- request.script = global.toSend;
- if (request.script.length > 1024) {
- global.toSend = request.script.substr(1024);
- request.script = request.script.substr(0, 1024);
- request.isPartial = true;
- } else {
- global.toSend = "";
- }
- // console.log("Upload nextPart:");
- // console.log(JSON.stringify(request));
- global.wssocket.send(JSON.stringify(request));
+var onUploadNext = function () {
+ var request = {};
+ request.action = "startContract";
+ request.owner = global.privKey;
+ request.isPartial = false;
+ request.script = global.toSend;
+ if (request.script.length > 1024) {
+ global.toSend = request.script.substr(1024);
+ request.script = request.script.substr(0, 1024);
+ request.isPartial = true;
+ } else {
+ global.toSend = "";
+ }
+ // console.log("Upload nextPart:");
+ // console.log(JSON.stringify(request));
+ global.wssocket.send(JSON.stringify(request));
};
-var disposeContract = function(request, host, contractIndex) {
- // fileWs.send(JSON.stringify(request));
- // console.log("[cm.js] disposeContract:" + host + "-->"
- // + JSON.stringify(request));
- var wsUrl = getFileWsUrl(host);
- var fileWs = new WebSocket(wsUrl);
- fileWs.onerror = function(error) {
- console.log(error);
- };
- fileWs.contractIndex = contractIndex;
- fileWs.onopen = function(error) {
- fileWs.send(JSON.stringify(request));
- };
- fileWs.currHost = host;
- fileWs.zipInfo = request;
- fileWs.onmessage = downloadHandler;
+var disposeContract = function (request, host, contractIndex) {
+ // fileWs.send(JSON.stringify(request));
+ // console.log("[cm.js] disposeContract:" + host + "-->"
+ // + JSON.stringify(request));
+ var wsUrl = getFileWsUrl(host);
+ var fileWs = new WebSocket(wsUrl);
+ fileWs.onerror = function (error) {
+ console.log(error);
+ };
+ fileWs.contractIndex = contractIndex;
+ fileWs.onopen = function (error) {
+ fileWs.send(JSON.stringify(request));
+ };
+ fileWs.currHost = host;
+ fileWs.zipInfo = request;
+ fileWs.onmessage = downloadHandler;
}
-var updateProgress = function(progressIndex, host, progress) {
- if (isNaN(progress)) {
- console.log("StopHere");
- }
- var hostMap = global.progressStat.get(progressIndex);
- hostMap.set(host, progress);
- var total = 0;
- for (var j = 0; j < global.hosts.length; j++) {
- total += hostMap.get(global.hosts[j]);
- }
- // console.log("[cm.js] updateProgress:" + total);
- $($("#progressBars .progressDiv")[progressIndex]).progressbar({
- value : Math.floor(total / global.hosts.length)
- });
+var updateProgress = function (progressIndex, host, progress) {
+ if (isNaN(progress)) {
+ console.log("StopHere");
+ }
+ var hostMap = global.progressStat.get(progressIndex);
+ hostMap.set(host, progress);
+ var total = 0;
+ for (var j = 0; j < global.hosts.length; j++) {
+ total += hostMap.get(global.hosts[j]);
+ }
+ // console.log("[cm.js] updateProgress:" + total);
+ $($("#progressBars .progressDiv")[progressIndex]).progressbar({
+ value: Math.floor(total / global.hosts.length)
+ });
};
-var downloadHandler = function(obj, wssocket) {
- data = event.data;
- // console.log(" -->" + data);
- try {
- var obj = JSON.parse(data);
- switch (obj.action) {
- case "onDownloadContract":
- // console.log(JSON.stringify(obj));
- updateProgress(this.contractIndex, this.currHost,
- obj.executeTime * 0.95);
- //console.log("[cm.js] obj.executeTime = " + obj.executeTime * 0.95 + " ; " + obj.executeTime);
- if (obj.data == "success") {
- console.log("[cm.js] downloadHandler successs");
- startContractWithHost(this.currHost, this.zipInfo.fileName,
- this.contractIndex);
- this.close();
- }
- break;
- case "onStartContract":
- updateProgress(wssocket.contractIndex, wssocket.currHost, 100);
- wssocket.close();
- break;
- default:
- }
- } catch (err) {
- console.log(err);
- }
+var downloadHandler = function (obj, wssocket) {
+ data = event.data;
+ // console.log(" -->" + data);
+ try {
+ var obj = JSON.parse(data);
+ switch (obj.action) {
+ case "onDownloadContract":
+ // console.log(JSON.stringify(obj));
+ updateProgress(this.contractIndex, this.currHost,
+ obj.executeTime * 0.95);
+ //console.log("[cm.js] obj.executeTime = " + obj.executeTime * 0.95 + " ; " + obj.executeTime);
+ if (obj.data == "success") {
+ console.log("[cm.js] downloadHandler successs");
+ startContractWithHost(this.currHost, this.zipInfo.fileName,
+ this.contractIndex);
+ this.close();
+ }
+ break;
+ case "onStartContract":
+ updateProgress(wssocket.contractIndex, wssocket.currHost, 100);
+ wssocket.close();
+ break;
+ default:
+ }
+ } catch (err) {
+ console.log(err);
+ }
}
-var getControlWsUrl = function(host) {
- var prefix = "ws://";
- if (document.location.href.startsWith("https"))
- prefix = "wss://";
- var path = document.location.pathname.lastIndexOf("/");
- path = document.location.pathname.substr(0, path + 1);
- path += "SCExecutor";
- return prefix + host + path;
+var getControlWsUrl = function (host) {
+ var prefix = "ws://";
+ if (document.location.href.startsWith("https"))
+ prefix = "wss://";
+ var path = document.location.pathname.lastIndexOf("/");
+ path = document.location.pathname.substr(0, path + 1);
+ path += "SCExecutor";
+ return prefix + host + path;
};
-var startContractWithHost = function(host, fileName, contractIndex) {
-
- //console.log("[cm.js] host = " + host + " ; fileName" + fileName + " ; contractIndex = " + contractIndex);
- var wsUrl = getControlWsUrl(host);
- //console.log("[cm.js] this = " + this);
- var controller = createWssocket(wsUrl, function() {
- // onopen;
- var request = {};
- request.action = "startContractInTempZips";
- request.owner = global.privKey;
- request.path = fileName;
- request.script = "empty";
- controller.send(JSON.stringify(request));
- this.contractIndex = contractIndex;
- this.currHost = host;
- }, downloadHandler);
+var startContractWithHost = function (host, fileName, contractIndex) {
+
+ //console.log("[cm.js] host = " + host + " ; fileName" + fileName + " ; contractIndex = " + contractIndex);
+ var wsUrl = getControlWsUrl(host);
+ //console.log("[cm.js] this = " + this);
+ var controller = createWssocket(wsUrl, function () {
+ // onopen;
+ var request = {};
+ request.action = "startContractInTempZips";
+ request.owner = global.privKey;
+ request.path = fileName;
+ request.script = "empty";
+ controller.send(JSON.stringify(request));
+ this.contractIndex = contractIndex;
+ this.currHost = host;
+ }, downloadHandler);
};
-var startContract = function() {
-
- global.progressStat = new Map();
- for (var i = 0; i < global.selectedProjects.length; i++) {
- var map = new Map();
- for (var j = 0; j < global.hosts.length; j++) {
- map.set(global.hosts[j], 0);
- }
- global.progressStat.set(global.selectedProjectIndexs[i], map);
- }
+var startContract = function () {
- for (var i = 0; i < global.selectedProjects.length; i++)
- for (var j = 0; j < global.hosts.length; j++) {
- var request = {};
- request.action = "downloadContract";
- request.mainHost = $("#targetHost")[0].value;
- request.projectName = global.selectedProjects[i].replace(" ", "");
- request.fileName = request.projectName + "_" + new Date().getTime()
- + ".ypk";
-
- disposeContract(request, global.hosts[j],
- global.selectedProjectIndexs[i]);
- }
+ global.progressStat = new Map();
+ for (var i = 0; i < global.selectedProjects.length; i++) {
+ var map = new Map();
+ for (var j = 0; j < global.hosts.length; j++) {
+ map.set(global.hosts[j], 0);
+ }
+ global.progressStat.set(global.selectedProjectIndexs[i], map);
+ }
+
+ for (var i = 0; i < global.selectedProjects.length; i++)
+ for (var j = 0; j < global.hosts.length; j++) {
+ var request = {};
+ request.action = "downloadContract";
+ request.mainHost = $("#targetHost")[0].value;
+ request.projectName = global.selectedProjects[i].replace(" ", "");
+ request.fileName = request.projectName + "_" + new Date().getTime()
+ + ".ypk";
+
+ disposeContract(request, global.hosts[j],
+ global.selectedProjectIndexs[i]);
+ }
};
-var dumpContract = function() {
- var pingObj = {};
- for (var i = 0; i < global.selectedContracts.length; i++) {
- pingObj.action = "dumpContract";
- pingObj.target = "/memoryDumps/" + global.selectedContracts[i] + "_"
- + new Date().getTime() + ".dyjs";
- pingObj.contractID = global.selectedContracts[i];
- //console.log("[cm.js] pingObj.target = " + pingObj.target);
- //console.log("[cm.js] pingObj.contractID = " + pingObj.contractID);
-
- global.wssocket.send(JSON.stringify(pingObj));
- }
+var dumpContract = function () {
+ var pingObj = {};
+ for (var i = 0; i < global.selectedContracts.length; i++) {
+ pingObj.action = "dumpContract";
+ pingObj.target = "/memoryDumps/" + global.selectedContracts[i] + "_"
+ + new Date().getTime() + ".dyjs";
+ pingObj.contractID = global.selectedContracts[i];
+ //console.log("[cm.js] pingObj.target = " + pingObj.target);
+ //console.log("[cm.js] pingObj.contractID = " + pingObj.contractID);
+
+ global.wssocket.send(JSON.stringify(pingObj));
+ }
};
-var loadMemory = function() {
- var pingObj = {};
- for (var i = 0; i < global.selectedContracts.length; i++) {
- pingObj.action = "loadMemory";
- pingObj.target = "/memoryDumps/" + global.selectedDumps[0];
- pingObj.contractID = global.selectedContracts[i];
- global.wssocket.send(JSON.stringify(pingObj));
- }
+var loadMemory = function () {
+ var pingObj = {};
+ for (var i = 0; i < global.selectedContracts.length; i++) {
+ pingObj.action = "loadMemory";
+ pingObj.target = "/memoryDumps/" + global.selectedDumps[0];
+ pingObj.contractID = global.selectedContracts[i];
+ global.wssocket.send(JSON.stringify(pingObj));
+ }
};
-var executeContractWithDynamicResult = function() {
- var request = {};
- request.action = "executeContract";
- request.requestID = new Date().getTime() + "";
- request.contractID = $("#tabdiv")[0].value;
- request.arg = global.argEditor.getValue();
- request.privKey = global.privKey;
- request.withDyanmicAnalysis = true;
- localStorage.setItem("persisArg", JSON.stringify(request));
- global.wssocket.send(JSON.stringify(request));
+var executeContractWithDynamicResult = function () {
+ var request = {};
+ request.action = "executeContract";
+ request.requestID = new Date().getTime() + "";
+ request.contractID = $("#tabdiv")[0].value;
+ request.arg = global.argEditor.getValue();
+ request.privKey = global.privKey;
+ request.withDyanmicAnalysis = true;
+ localStorage.setItem("persisArg", JSON.stringify(request));
+ global.wssocket.send(JSON.stringify(request));
};
-var executeContract = function() {
- var request = {};
- request.action = "executeContract";
- request.requestID = new Date().getTime() + "";
- request.contractID = $("#tabdiv")[0].value;
- request.arg = global.argEditor.getValue();
- request.privKey = global.privKey;
- localStorage.setItem("persisArg", JSON.stringify(request));
- global.wssocket.send(JSON.stringify(request));
+var executeContract = function () {
+ var request = {};
+ request.action = "executeContract";
+ request.requestID = new Date().getTime() + "";
+ request.contractID = $("#tabdiv")[0].value;
+ request.arg = global.argEditor.getValue();
+ request.privKey = global.privKey;
+ localStorage.setItem("persisArg", JSON.stringify(request));
+ global.wssocket.send(JSON.stringify(request));
};
-var listContractProcess = function() {
- var request = {};
- request.action = "listContractProcess";
- global.wssocket.send(JSON.stringify(request));
+var listContractProcess = function () {
+ global.wssocket.send(JSON.stringify({
+ action: 'listContractProcess',
+ filters: 2
+ }));
};
-var killContractProcess = function() {
- var request = {};
- request.action = "killContractProcess";
- request.requestID = new Date().getTime() + "";
- request.name = $("#tabdiv")[0].value;
- request.id = global.contractName2ID[request.name];
- global.wssocket.send(JSON.stringify(request));
+var killContractProcess = function () {
+ var request = {};
+ request.action = "killContractProcess";
+ request.requestID = new Date().getTime() + "";
+ request.name = $("#tabdiv")[0].value;
+ request.id = global.contractName2ID[request.name];
+ global.wssocket.send(JSON.stringify(request));
};
-var staticVerify = function() {
- var request = {};
- request.action = "staticVerifyContract";
- // TODO should be pubkey
- request.owner = global.privKey;
- request.isPartial = false;
- // TODO ignore contractid
- request.contractid = $("#tabdiv")[0].value;
- request.script = global.scriptEditor.getValue();
- request.path = $(".ui-tabs-active").find("a").html();
- localStorage.setItem("persisStatus", JSON.stringify(request));
- if (request.path.startsWith("/"))
- request.script = "empty";
- /*
- * if (request.script.length > 1024) { global.toSend =
- * request.script.substr(1024); request.script = request.script.substr(0,
- * 1024); request.isPartial = true; }
- */
- global.wssocket.send(JSON.stringify(request));
+var staticVerify = function () {
+ var request = {};
+ request.action = "staticVerifyContract";
+ // TODO should be pubkey
+ request.owner = global.privKey;
+ request.isPartial = false;
+ // TODO ignore contractid
+ request.contractid = $("#tabdiv")[0].value;
+ request.script = global.scriptEditor.getValue();
+ request.path = $(".ui-tabs-active").find("a").html();
+ localStorage.setItem("persisStatus", JSON.stringify(request));
+ if (request.path.startsWith("/"))
+ request.script = "empty";
+ /*
+ * if (request.script.length > 1024) { global.toSend =
+ * request.script.substr(1024); request.script = request.script.substr(0,
+ * 1024); request.isPartial = true; }
+ */
+ global.wssocket.send(JSON.stringify(request));
};
-var downloadContract = function() {
- if (global.lastClickedProjectId == undefined)
- global.lastClickedProjectId = 0;
- var projectName = global.projects[global.lastClickedProjectId];
- var url = window.location.href.replace("/scide.html",
- "/downLoadServlet?projectName=");
- url += projectName;
- window.open(url);
+var downloadContract = function () {
+ if (global.lastClickedProjectId == undefined)
+ global.lastClickedProjectId = 0;
+ var projectName = global.projects[global.lastClickedProjectId];
+ var url = window.location.href.replace("/scide.html",
+ "/downLoadServlet?projectName=");
+ url += projectName;
+ window.open(url);
};
-var killAllContract = function() {
- var request = {};
- request.action = "killAllContract";
- global.wssocket.send(JSON.stringify(request));
+var killAllContract = function () {
+ var request = {};
+ request.action = "killAllContract";
+ global.wssocket.send(JSON.stringify(request));
};
-var customAlert = function(message, title) {
- if (!title)
- title = 'Alert';
+var customAlert = function (message, title) {
+ if (!title)
+ title = 'Alert';
- if (!message)
- message = 'No Message to Display.';
+ if (!message)
+ message = 'No Message to Display.';
- $('
').html(message).dialog({
- title : title,
- resizable : false,
- modal : true,
- buttons : {
- 'Ok' : function() {
- $(this).dialog('close');
- }
- }
- });
+ $('
').html(message).dialog({
+ title: title,
+ resizable: false,
+ modal: true,
+ buttons: {
+ 'Ok': function () {
+ $(this).dialog('close');
+ }
+ }
+ });
}
-var init = function() {
- initGlobal();
- initWSocket();
- global.hosts = [];
- $("#serverList").selectable({
- stop : function() {
- var result = "";
- global.hosts = [];
- $(".ui-selected", this).each(function() {
- var index = $("#serverList li").index(this);
- global.hosts.push(this.innerText);
- });
- // console.log("[cm.js] selectResult:" + global.hosts);
- }
- });
+var init = function () {
+ initGlobal();
+ initWSocket();
+ global.hosts = [];
+ $("#serverList").selectable({
+ stop: function () {
+ var result = "";
+ global.hosts = [];
+ $(".ui-selected", this).each(function () {
+ var index = $("#serverList li").index(this);
+ global.hosts.push(this.innerText);
+ });
+ // console.log("[cm.js] selectResult:" + global.hosts);
+ }
+ });
};
-var getRequestParameters = function() {
- var arr = (location.search || "").replace(/^\?/, '').split("&");
- var params = {};
- for (var i = 0; i < arr.length; i++) {
- var data = arr[i].split("=");
- if (data.length == 2) {
- params[data[0]] = data[1];
- }
- }
- return params;
+var getRequestParameters = function () {
+ var arr = (location.search || "").replace(/^\?/, '').split("&");
+ var params = {};
+ for (var i = 0; i < arr.length; i++) {
+ var data = arr[i].split("=");
+ if (data.length == 2) {
+ params[data[0]] = data[1];
+ }
+ }
+ return params;
};
-var initHello = function() {
- var param = getRequestParameters();
- var type = parseInt(param["type"]);
- var template;
- switch (type) {
- case 1:
- template = getTemplate1(param["name"], decodeURI(param["list"]),
- param["expiredDate"]);
- break;
- case 2:
- template = getTemplate2(param["name"], decodeURI(param["list"]),
- param["expiredDate"]);
- break;
- case 3:
- var contractID = param["contractID"];
- $.ajax({
- url : "./SCManager?action=getCodeByID&contractID=" + contractID,
- dataType : "json"
- }).done(function(result) {
- global.fileContentMap.set(contractID, result.data);
- addTab({
- "title" : contractID
- });
+var initHello = function () {
+ var param = getRequestParameters();
+ var type = parseInt(param["type"]);
+ var template;
+ switch (type) {
+ case 1:
+ template = getTemplate1(param["name"], decodeURI(param["list"]),
+ param["expiredDate"]);
+ break;
+ case 2:
+ template = getTemplate2(param["name"], decodeURI(param["list"]),
+ param["expiredDate"]);
+ break;
+ case 3:
+ var contractID = param["contractID"];
+ $.ajax({
+ url: "./SCManager?action=getCodeByID&contractID=" + contractID,
+ dataType: "json"
+ }).done(function (result) {
+ global.fileContentMap.set(contractID, result.data);
+ addTab({
+ "title": contractID
+ });
- });
- return;
- default:
- return;
- }
- global.scriptEditor.setValue(template);
+ });
+ return;
+ default:
+ return;
+ }
+ global.scriptEditor.setValue(template);
};
\ No newline at end of file
diff --git a/js/codeManage/recoverFrame.js b/js/codeManage/recoverFrame.js
index 44a9958..d7a1c5c 100644
--- a/js/codeManage/recoverFrame.js
+++ b/js/codeManage/recoverFrame.js
@@ -50,7 +50,7 @@ var onListMemoryFiles = function(obj){
console.log(htm);
$("#selectMemeryFiles").html(htm);
- changeMemeryFiles($("#selectMemeryFiles")[0].value);
+ changeMemoryFiles($("#selectMemeryFiles")[0].value);
};
var transferTo = function(){
diff --git a/js/codeManage/selectManage.js b/js/codeManage/selectManage.js
index b533e68..0ff54e9 100644
--- a/js/codeManage/selectManage.js
+++ b/js/codeManage/selectManage.js
@@ -1,151 +1,153 @@
-var listContractProcess = function() {
- console.log("listContractProcess : ");
- var request = {};
- request.action = "listContractProcess";
- global.wssocket.send(JSON.stringify(request));
-
-};
-
-var onListContractProcess = function(obj) {
- var userManTab = $("#v-pills-contractInstance-tab")[0];
- var isActive = (userManTab.getAttribute("aria-selected") == "true");
- if (isActive) {
- onListContractProcess1(obj);
- } else {
- onListContractProcess2(obj);
- }
-};
-
-var changeContractProcess = function(obj) {
- global.contractProcess = obj; // 代码管理菜单选中的合约
- console.log("oooooooooooo" + global.contractProcess);
- //showPermissionList(global.contractProcess);
-};
-
-var onListContractProcess2 = function(obj) {
- var data = JSON.parse(obj.data);
-
- global.contracts = data;
- // $("#contractProcess").editableSelect('clear');
- // $("#tabdiv").html("");
-
- global.contractName2ID = {};
- //global.permissionNameMap = {};
- var name = "";
- var htm = "
选择合约进程 ";
- for (var i = 0; i < data.length; i++) {
- // htm += "
" + data[i].name + " ";
- htm += "
" + data[i].name + " ";
- global.contractName2ID[data[i].name] = data[i].id;
- //global.permissionNameMap[data[i].name] = data[i].contractPermission;
- console.log(htm);
- name = data[i].name;
- }
- //showPermissionList(name);
- console.log(htm);
- $("#contractProcess").html(htm);
-
- /*
- * $("#contractProcess").editableSelect({ effects: 'slide',
- * //可选参数default、fade filter: true //false 不过滤,否则选中后其它选项消失 });
- */
-
- /*
- * if(data.length > 0){ for (var i = 0; i < data.length; i++) {
- * console.log(i); $("#contractProcess").editableSelect('add',
- * data[i].name); global.contractName2ID[data[i].name] = data[i].id; //
- * $("#tabdiv").append( // $("
").attr("value",
- * data[i].id).text( // data[i].id)); } } if (data.length > 0)
- * $("#contractProcess").editableSelect()[0].value = data[0].name;
- */
-};
-
-var addTcpNodeUnits = function(data) {
- if (data.length > 0) {
- for (var i = 0; i < data.length; i++) {
- var unitID = data[i].key;
- var nodes = JSON.parse(data[i].value);
- var json = {};
- json.type = "TCP";
- json.key = unitID;
- json.value = nodes;
- addNodeUnit(json);
- }
- }
-};
-
-var listSelectUnits = function(data) {
- console.log(data);
- global.units = {};
- var htm = "";
- if (data.length > 0) {
- // data的key是创建人公钥_时间戳,value是nodes的ID
- for (var i = 0; i < data.length; i++) {
- var unitID = data[i].key;
- var nodes = JSON.parse(data[i].value);
- var at_ = data[i].key.indexOf("_");
- console.log(nodes);
- htm += "
集群:" + unitID.substring(at_ + 1)
- + " ";
- global.units[unitID.substring(at_ + 1)] = nodes;
- }
- }
- htm += "
选择节点集群 ";
- htm += "
无 ";
- console.log(htm);
-
- $("#selectUnits").html(htm);
+function listContractProcess() {
+ console.log("listContractProcess : ");
+ global.wssocket.send(JSON.stringify({
+ action: 'listContractProcess',
+ filters: 2
+ }));
}
-var onCancelAuth = function(obj) {
- myToast("取消权限", obj.data);
- if (obj.data == "success") {
- }
-};
-var setPermission = function(data) {
- var request = {};
- request.resetContractProcess = data.name;
- console.log(request.resetContractName);
- request.closePer = data.permission;
- request.oldPer = data.oldPermission;
- request.isOpen = data.isOpen;
- request.action = "setPermission";
- global.wssocket.send(JSON.stringify(request));
-};
-var onSetPermission = function(obj) {
- console.log(obj);
+function onListContractProcess(obj) {
+ const userManTab = $("#v-pills-contractInstance-tab")[0];
+ const isActive = (userManTab.getAttribute("aria-selected") === "true");
+ if (isActive) {
+ onListContractProcess1(obj);
+ } else {
+ onListContractProcess2(obj);
+ }
+}
- var html = "