/* * 调用管理 */ // 终止本地合约 var stopContractAtSlave = function() { var temp = global.contractInstance; if (temp == undefined || temp == "选择...") { myToast("提示","请选择合约进程!"); return; } var request = {}; request.action = "killContractProcess"; request.requestID = new Date().getTime() + ""; request.id = temp; global.wssocket.send(JSON.stringify(request)); }; var onStopContract = function(obj) { if(obj.data == "success"){ myToast("提示","停止该合约成功,用时" + obj.executeTime + "ms!") }else{ myToast("提示","停止该合约失败,用时" + obj.executeTime + "ms!") } listContractProcess(); }; // 终止本地全部合约 var killAllContractLocal = function() { var request = {}; request.action = "killAllContract"; global.wssocket.send(JSON.stringify(request)); }; var onKillAllContract = function(obj) { customAlert(obj.data); listContractProcess(); }; var stopContractP2PTrustfully = function() { var request = {}; request.action = "killContractProcess"; request.requestID = new Date().getTime() + ""; request.name = $("#contractProcess")[0].value; global.wssocket.send(JSON.stringify(request)); }; /* * 权限管理 */ var showPermissionList = function(data) { var liHtml = ""; var result = {}; result.name = data; var x = global.permissionNameMap[data]; if (x == undefined) { console.log("undefined x" + undefined); liHtml = "
  • 没有智能合约进程,请先选择合约进程
  • "; $("#ulPermission").html(liHtml); $('[data-toggle="toggle"]').bootstrapToggle(); } else { x = JSON.parse(x); var xlen = 0; for ( var key in x) { xlen++; liHtml += "
  • "; var permission = key; liHtml += permission; if (x[key] == "open") { liHtml += "
  • "; } else { liHtml += ""; } } if (xlen == 0) { liHtml = "
  • 没有IO权限
  • "; } $("#ulPermission").html(liHtml); $('[data-toggle="toggle"]').bootstrapToggle(); var Uarry = $("#ulPermission li"); var Tresult = ""; $("#ulPermission li").click(function() { var count = $(this).index(); Tresult = Uarry.eq(count).text().trim(); }); $('[data-toggle="toggle"]').off("change", ":input").on( "change", ":input", function() { var isChosen = $(this).prop('checked'); if (isChosen == false) { var word = "智能合约IO权限中" + Tresult + "将被取消,可能会导致智能合约无法正常执行,继续取消点击“确定按钮”"; $("#dialogBodyDiv").text(word); showDialog("权限操作警告", function() { result.permission = Tresult; result.isOpen = "close"; myToast("取消权限", "success"); setPermission(result); }); } else { var word = "智能合约IO权限中" + Tresult + "将被启用,继续取消点击“确定按钮”"; $("#dialogBodyDiv").text(word); showDialog("权限操作警告", function() { result.permission = Tresult; result.isOpen = "open"; myToast("启用权限", "success"); setPermission(result); }); } }); } }; /* * 状态管理 */ var showChangeDumpPeriod = function() { var contractName = global.contractInstance; if (contractName == undefined || contractName == "选择...") { myToast("提示","请选择合约进程!"); return; } getDumpPeriod(contractName); }; var getDumpPeriod = function(contractName){ var request = {}; request.action = "getDumpPeriod"; request.contractName = contractName; global.wssocket.send(JSON.stringify(request)); }; var onGetDumpPeriod = function(obj){ var period = obj.data; var contractName = obj.contractName; var html = "
    "; html += "
    "; html += ""; html += "状态保存策略:" + "
    "; html += "
    "; html += ""; html += "
    "; $("#dialogBodyDiv").html(html); showDialog("更改合约实例"+ contractName +"的自动状态保存周期", function() { changeDumpPeriod(contractName); }); }; var changeDumpPeriod = function(contractName) { var period = $("#selectDumpPeriod2")[0].value; var dumpPeriod = switchPeriod(period); var request = {}; request.action = "changeDumpPeriod"; request.dumpPeriod = dumpPeriod; // request.owner = global.sm2Key.publicKey; request.contractName = contractName; global.wssocket.send(JSON.stringify(request)); }; var onChangeDumpPeriod = function(obj) { updateResultDisplay(obj); };