merge: merge old web-client
This commit is contained in:
parent
0ede1c3919
commit
1ead2613a9
@ -3,27 +3,27 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="Cache-Control" content="no-cache"/>
|
||||
<title>数瑞客户端</title>
|
||||
|
||||
<script src="./js/createWS.js"></script>
|
||||
<script src="./js/cryptico.js"></script>
|
||||
<script src="./js/jquery-2.1.4.js"></script>
|
||||
<script src="./js/bootstrap.min.js"></script>
|
||||
<script src="./js/commonutil.js"></script>
|
||||
|
||||
<link href="./css/common.css" rel="stylesheet">
|
||||
<link href="./css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="./js/vue.js"></script>
|
||||
<script src="./js/bdwareclient.js"></script>
|
||||
<script src="./js/sm2.js"></script>
|
||||
<link href="./css/common.css" rel="stylesheet">
|
||||
<link href="./css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header
|
||||
class="headerFooter navbar navbar-default navbar-fixed-top navColor ">
|
||||
<header class="headerFooter navbar navbar-default navbar-fixed-top navColor ">
|
||||
<div class="col-10">
|
||||
<div class="input-group">
|
||||
<a class="navbar-brand" href="#"> <img alt="Brand"
|
||||
<a class="navbar-brand" href="#">
|
||||
<img alt="Brand"
|
||||
src="./img/logo-1.png" style="height: 30px">
|
||||
</a><a class="navbar-brand">数瑞浏览器 </a>
|
||||
</a>
|
||||
<a class="navbar-brand">数瑞浏览器 </a>
|
||||
<div class="input-group-prepend">
|
||||
<input id="urlInput" style="border-top-left-radius: 5px; border-bottom-left-radius: 5px"
|
||||
type="text" placeholder="输入地址">
|
||||
@ -34,12 +34,13 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-secondary" style="border-top-right-radius: 5px; border-bottom-right-radius: 5px" id="switchRenderBtn" type="button"
|
||||
<button class="btn btn-outline-secondary"
|
||||
style="border-top-right-radius: 5px; border-bottom-right-radius: 5px" id="switchRenderBtn"
|
||||
type="button"
|
||||
onclick="changeRender()">不加载界面
|
||||
</button>
|
||||
</div>
|
||||
<span> </span>
|
||||
|
||||
<div class="input-group-append">
|
||||
<select id="selectContract" class="custom-select"
|
||||
style="-webkit-appearance: none" onchange="changeApp()">
|
||||
@ -71,12 +72,10 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row" style="padding-left: 16px; padding-right: 16px">
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<label class="input-group-text" for="localKeyList">本地公钥</label>
|
||||
</div>
|
||||
|
||||
<select class="custom-select"
|
||||
aria-label="Example select with button addon"
|
||||
style="appearance: none" v-model="selectedSM2Key"
|
||||
@ -98,7 +97,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="padding-left: 16px; padding-right: 16px">
|
||||
|
||||
<div class="input-group mb-1">
|
||||
<div class="input-group-prepend">
|
||||
<label class="input-group-text" for="localKeyList">当前SM2密钥</label>
|
||||
@ -124,7 +122,6 @@
|
||||
style="width: 100%; min-height: 150px" rows="" cols="">
|
||||
</textarea>
|
||||
<div class="row" style="padding-left: 16px; padding-right: 16px;">
|
||||
|
||||
</div>
|
||||
<div class="row" style="padding-left: 16px; padding-right: 16px">
|
||||
<span>我的权限:{{myRole}}</span>
|
||||
@ -143,16 +140,10 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="modal fade" id="dialog" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
@ -176,16 +167,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var h = document.body.clientHeight
|
||||
- $("header").css("height").replace("px", "")
|
||||
|
||||
<script>
|
||||
const h = document.body.clientHeight
|
||||
- $("header").css("height").replace("px", "")
|
||||
$("#main").css("height", h + "px");
|
||||
init();
|
||||
|
||||
//initWSocket();
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
@ -243,6 +243,11 @@ function onExecuteResult(obj) {
|
||||
onExecuteResultInternal(obj);
|
||||
}
|
||||
|
||||
function onExecuteContractTrustfully(obj) {
|
||||
console.log(obj);
|
||||
$("#consistencyResult").html(global.executeResult.size + "个结果一致");
|
||||
}
|
||||
|
||||
function showContractResult(requestID) {
|
||||
var data = global.responseCollector[requestID][0];
|
||||
result = data;
|
||||
|
@ -2,7 +2,7 @@ var createWssocket = function(wsurl, onopen, handler) {
|
||||
console.log("[createWS.js] createWssocket : " + wsurl);
|
||||
var retsocket = {};
|
||||
retsocket.handlerList = [];
|
||||
if (handler != undefined)
|
||||
if (handler)
|
||||
retsocket.handlerList.push(handler);
|
||||
var wssocket = new WebSocket(wsurl);
|
||||
wssocket.onerror = function (error) {
|
||||
@ -39,11 +39,11 @@ var createWssocket = function(wsurl, onopen, handler) {
|
||||
wssocket.onclose = reconnect;
|
||||
|
||||
retsocket.receiveSeg = function (obj) {
|
||||
if (obj.cid == 'start') {
|
||||
if (obj.cid === 'start') {
|
||||
retsocket.toReceive = "";
|
||||
}
|
||||
retsocket.toReceive += obj.data;
|
||||
if (obj.cid == 'done') {
|
||||
if (obj.cid === 'done') {
|
||||
console.log("[receiveSeg] Received AllData:" + retsocket.toReceive);
|
||||
var event = {};
|
||||
event.data = retsocket.toReceive;
|
||||
@ -82,15 +82,14 @@ var createWssocket = function(wsurl, onopen, handler) {
|
||||
};
|
||||
retsocket.sendNextSegment = function () {
|
||||
var str = retsocket.toSend;
|
||||
const obj = {};
|
||||
if (str.length > 1024) {
|
||||
retsocket.toSend = str.substr(1024);
|
||||
var obj = {};
|
||||
obj.isSegment = true;
|
||||
obj.data = str.substr(0, 1024);
|
||||
wssocket.send(JSON.stringify(obj));
|
||||
} else {
|
||||
retsocket.toSend = "";
|
||||
var obj = {};
|
||||
obj.isSegment = false;
|
||||
obj.data = str;
|
||||
wssocket.send(JSON.stringify(obj));
|
||||
@ -119,8 +118,7 @@ var aesDecrypt = function(data) {
|
||||
|
||||
};
|
||||
var aesEncrypt = function (data, aesKey) {
|
||||
var key = aesKey;
|
||||
var exkey = key.slice(0);
|
||||
var exkey = aesKey.slice(0);
|
||||
aes.ExpandKey(exkey);
|
||||
var blocks = my.string2bytes(data);
|
||||
blocks = my.pad16(blocks);
|
||||
@ -132,8 +130,7 @@ var aesEncrypt = function(data, aesKey) {
|
||||
var rsaEncrypt = function (data, rsaKey) {
|
||||
var rsa = new RSAKey();
|
||||
rsa.setPublic(rsaKey.n, rsaKey.e1);
|
||||
var result = rsa.encrypt(data);
|
||||
return result;
|
||||
return rsa.encrypt(data);
|
||||
};
|
||||
var loadRSAKey = function (rsaKey) {
|
||||
var str = cryptico.b64to256(rsaKey);
|
||||
@ -178,7 +175,7 @@ var onExecuteResultInternal = function(data) {
|
||||
global.executeResult = data;
|
||||
var reqId = data.responseID;
|
||||
var callback = global.cbs[data.responseID];
|
||||
if (callback != undefined) {
|
||||
if (callback) {
|
||||
callback(global.executeResult, data);
|
||||
}
|
||||
};
|
||||
@ -194,7 +191,7 @@ window.executeContract = function(contractID, method, strarg, cb) {
|
||||
request.operation = method;
|
||||
request.arg = strarg;
|
||||
|
||||
if (sm2Key != undefined) {
|
||||
if (sm2Key) {
|
||||
request.pubkey = sm2Key.publicKey;
|
||||
request.signature = sm2.doSignature(request.contractID + "|"
|
||||
+ method + "|" + strarg + "|" + sm2Key.publicKey,
|
||||
@ -212,17 +209,17 @@ window.executeCurrentContract = function(method, strarg, cb) {
|
||||
|
||||
|
||||
window.loadBDWareWebSDK = function (url, onopen, handler) {
|
||||
if (window.global == undefined) {
|
||||
if (!window.global) {
|
||||
window.global = {};
|
||||
}
|
||||
if (global.sm2Key == undefined) {
|
||||
if (sm2 != undefined)
|
||||
if (!global.sm2Key) {
|
||||
if (sm2)
|
||||
global.sm2Key = sm2.generateKeyPairHex();
|
||||
}
|
||||
if (global.cbs == undefined) {
|
||||
if (!global.cbs) {
|
||||
global.cbs = {};
|
||||
}
|
||||
if (global.wssocket == undefined) {
|
||||
if (!global.wssocket) {
|
||||
global.wssocket = createWssocket(url, onopen, function (event, wss) {
|
||||
var data = event.data;
|
||||
var obj = JSON.parse(data);
|
||||
@ -230,11 +227,12 @@ window.loadBDWareWebSDK = function(url, onopen, handler) {
|
||||
case 'onExecuteResult':
|
||||
onExecuteResultInternal(obj);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
handler(event, global.wssocket);
|
||||
});
|
||||
} else {
|
||||
if (onopen != undefined)
|
||||
if (onopen)
|
||||
onopen();
|
||||
global.wssocket.addHandler(handler);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user