From dcf5a87de927e683d4bbfad3978c3d608c06e48c Mon Sep 17 00:00:00 2001
From: LH_Jzs <jiazeshi_zpp@163.com>
Date: 星期一, 26 四月 2021 14:21:53 +0800
Subject: [PATCH] init
---
在线文档index.htm | 109 ++++++++++++++++++
fileupload.htm | 58 +++++++++
index.htm | 104 +++++++++++++++++
websocket.htm | 57 +++++++++
4 files changed, 328 insertions(+), 0 deletions(-)
diff --git a/fileupload.htm b/fileupload.htm
new file mode 100644
index 0000000..bdcd0c8
--- /dev/null
+++ b/fileupload.htm
@@ -0,0 +1,58 @@
+<!doctype html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <title>Document</title>
+
+</head>
+
+<body>
+ <div>
+ <input type="file" id="files" style="display: none" onchange="fileImport();">
+ <input type="button" id="fileImport" value="瀵煎叆">
+ </div>
+ <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
+ <!-- <script src="../js/jQuery/jquery-1.11.1.js"></script> -->
+ <script>
+ //鐐瑰嚮瀵煎叆鎸夐挳,浣縡iles瑙﹀彂鐐瑰嚮浜嬩欢,鐒跺悗瀹屾垚璇诲彇鏂囦欢鐨勬搷浣�
+ $("#fileImport").click(function () {
+ $("#files").click();
+ })
+
+ function fileImport() {
+ //鑾峰彇璇诲彇鎴戞枃浠剁殑File瀵硅薄
+ var selectedFile = document.getElementById('files').files[0];
+ var name = selectedFile.name; //璇诲彇閫変腑鏂囦欢鐨勬枃浠跺悕
+ var size = selectedFile.size; //璇诲彇閫変腑鏂囦欢鐨勫ぇ灏�
+ console.log("鏂囦欢鍚�:" + name + "澶у皬:" + size);
+ var reader = new FileReader(); //杩欐槸鏍稿績,璇诲彇鎿嶄綔灏辨槸鐢卞畠瀹屾垚.
+ reader.readAsText(selectedFile, "utf-8"); //璇诲彇鏂囦欢鐨勫唴瀹�,涔熷彲浠ヨ鍙栨枃浠剁殑URL
+ reader.onload = function () {
+ //褰撹鍙栧畬鎴愬悗鍥炶皟杩欎釜鍑芥暟,鐒跺悗姝ゆ椂鏂囦欢鐨勫唴瀹瑰瓨鍌ㄥ埌浜唕esult涓�,鐩存帴鎿嶄綔鍗冲彲
+ console.log(this.result);
+ var data = {
+ name: name,
+ da: this.result
+ }
+ console.log(data);
+ // data.da
+
+ const base64String = window.btoa('asdasd');
+ console.log(base64String);
+ }
+ }
+ function arrayBufferToBase64(buffer) {
+ var binary = '';
+ var bytes = new Uint8Array(buffer);
+ var len = bytes.byteLength;
+ console.log(len);
+ for (var i = 0; i < len; i++) {
+ binary += String.fromCharCode(bytes[i]);
+ }
+ return window.btoa(binary);
+ }
+ </script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/index.htm b/index.htm
new file mode 100644
index 0000000..4749df7
--- /dev/null
+++ b/index.htm
@@ -0,0 +1,104 @@
+<!doctype html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <title>Document</title>
+
+</head>
+
+<body>
+ <div>
+ <input type="file" id="files" style="display: none" onchange="fileImport();">
+ <input type="button" id="fileImport" value="瀵煎叆">
+ <input type="button" id="c" value="娴嬭瘯" onclick="ccccc()">
+ </div>
+ <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
+ <!-- <script src="../js/jQuery/jquery-1.11.1.js"></script> -->
+ <script>
+ //鐐瑰嚮瀵煎叆鎸夐挳,浣縡iles瑙﹀彂鐐瑰嚮浜嬩欢,鐒跺悗瀹屾垚璇诲彇鏂囦欢鐨勬搷浣�
+ $("#fileImport").click(function () {
+ $("#files").click();
+ })
+
+ function fileImport() {
+ //鑾峰彇璇诲彇鎴戞枃浠剁殑File瀵硅薄
+ var selectedFile = document.getElementById('files').files[0];
+ console.log(selectedFile);
+ var reqData = {
+ name: selectedFile.name,
+ size: selectedFile.size,
+ lastModified: selectedFile.lastModified,
+ type: selectedFile.type,
+ data: null
+ }
+ var name = selectedFile.name; //璇诲彇閫変腑鏂囦欢鐨勬枃浠跺悕
+ var size = selectedFile.size; //璇诲彇閫変腑鏂囦欢鐨勫ぇ灏�
+ var lastModified = selectedFile.lastModified; //鏂囦欢鏃堕棿鎴�
+ var type = selectedFile.type; //鏂囦欢绫诲瀷
+ console.log("鏂囦欢鍚�:" + name + "澶у皬:" + size);
+ var reader = new FileReader(); //杩欐槸鏍稿績,璇诲彇鎿嶄綔灏辨槸鐢卞畠瀹屾垚.
+ reader.readAsDataURL(selectedFile);
+ // reader.readAsText(selectedFile, "utf-8"); //璇诲彇鏂囦欢鐨勫唴瀹�,涔熷彲浠ヨ鍙栨枃浠剁殑URL
+ reader.onload = function () {
+ //褰撹鍙栧畬鎴愬悗鍥炶皟杩欎釜鍑芥暟,鐒跺悗姝ゆ椂鏂囦欢鐨勫唴瀹瑰瓨鍌ㄥ埌浜唕esult涓�,鐩存帴鎿嶄綔鍗冲彲
+ console.log(this.result);
+ // console.log(typeof (this.result));
+ // console.log(JSON.stringify(this.result));
+ reqData.data = this.result;
+
+ $.ajax({
+ type: "POST",
+ url: "http://localhost:10000/SerialPortService/Test",
+ data: JSON.stringify(reqData),
+ success: function (d) {
+ console.log(d);
+ },
+ error: function (jqXHR) {
+ console.error(jqXHR);
+ }
+ });
+
+ //var base64String = window.btoa(this.result);
+ //console.log(base64String);
+ // var temp = window.atob(reqData);
+ // console.log(temp);
+ }
+ }
+ function ccccc() {
+ $.ajax({
+ type: "POST",
+ url: "http://139.129.89.252:8080/StatisticsService.asmx/ToDaySales",
+ dataType: "json",
+ success: function (d) {
+ console.log(d);
+ },
+ error: function (jqXHR) {
+ console.log(jqXHR);
+ }
+ });
+ }
+ function arrayBufferToBase64(buffer) {
+ var binary = '';
+ var bytes = new Uint8Array(buffer);
+ var len = bytes.byteLength;
+ console.log(len);
+ for (var i = 0; i < len; i++) {
+ binary += String.fromCharCode(bytes[i]);
+ }
+ return window.btoa(binary);
+ }
+
+ let str = "娴嬭瘯", escapeStr = "";
+ escapeStr = escape(str)
+ console.log(escapeStr);
+ console.log(unescape(escapeStr));
+
+ str = "ceshi";
+ escapeStr = escape(str)
+ console.log(escapeStr);
+ console.log(unescape(escapeStr));
+ </script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/websocket.htm b/websocket.htm
new file mode 100644
index 0000000..d177b0a
--- /dev/null
+++ b/websocket.htm
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+
+</head>
+
+<body>
+ <div>
+ <input style="width: max-content;" id="input_init" type="text">
+ <input type="button" value="鍒濆鍖�" onclick="Init()">
+ </div>
+ <div>
+ <input id="input_text" type="text">
+ <input type="button" value="鍙戦��" onclick="Send()">
+ </div>
+ <script type="text/javascript">
+ //楂樻媿浠富鏈嶅姟鎸囦护鎺у埗鍦板潃
+ var url = "ws://192.168.1.2:25014/";
+ var ws_test;
+ if ('WebSocket' in window) {
+ ws_test = new WebSocket(url);
+ }
+ else if ('MozWebSocket' in window) {
+ ws_test = new MozWebSocket(url);
+ }
+ else {
+ alert("娴忚鍣ㄤ笉鏀寔WebSocket");
+ }
+ ws_test.onopen = function (evt) {
+ console.log("Connection open ...");
+ //ws.send("Hello WebSockets!");
+ };
+
+ ws_test.onmessage = function (evt) {
+ console.log(evt.data);
+ //ws.close();
+ };
+
+ ws_test.onclose = function (evt) {
+ console.log("Connection closed.");
+ };
+ function Init() {
+ var str = document.getElementById('input_init');
+ console.log(str.value);
+ ws_test.send(str.value);
+ }
+ function Send() {
+ var str = document.getElementById('input_text');
+ console.log(str.value);
+ ws_test.send(str.value);
+ }
+ </script>
+</body>
+
+</html>
\ No newline at end of file
diff --git "a/\345\234\250\347\272\277\346\226\207\346\241\243index.htm" "b/\345\234\250\347\272\277\346\226\207\346\241\243index.htm"
new file mode 100644
index 0000000..be87953
--- /dev/null
+++ "b/\345\234\250\347\272\277\346\226\207\346\241\243index.htm"
@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
+ <title>demo</title>
+ <script id="scriptApi" type="text/javascript" src="https://www.51jianxie.com/ds-vpath/web-apps/apps/api/documents/api.js"></script>
+</head>
+
+<body>
+ <div id="placeholder"></div>
+ <script type="text/javascript">
+ window.onload=function(){
+ initEditor("","http://sdk.51changxie.com/demo/TravelList.xlsx",true,true,true,true,"a8a62dd9-dbef-4840-b610-791d666bb92f","edit","",{"comment":false,"download":true,"edit":true,"print":true,"review":false})
+ }
+ function initEditor(username,docUrl, titlebarFlag, rightPanelFlag, leftPanelFlag, toobarFlag, docKey, mode, type, permission) {
+ //mode for editor
+
+ window.mode = window.mode || mode || "view";
+ mode = window.mode;
+
+ //mode for editor
+ window.type = window.type || type || "desktop";
+ type = window.type;
+
+ //url for document
+ // window.docUrl = document.getElementById("documentUrl").value;
+ window.docUrl = docUrl;
+ //key for chaching and collaborate editing
+ window.docKey = docKey;
+
+ //type for document
+ var docType = docUrl.substring(docUrl.lastIndexOf(".") + 1).trim().toLowerCase();
+ //type for editor
+ var documentType = getDocumentType(docType);
+
+
+ window.permission = permission;
+ window.user = username;
+
+ window.user = window.user || "娴嬭瘯"
+ var id = window.user + "-4"
+ //CXO_API.CXEditor
+ //creating object editing
+ var onDocumentReady = function() {
+ //editor.destroyEditor();
+
+ }
+ var onAppReady = function() {
+
+ }
+
+ var editor = new CXO_API.CXEditor("placeholder", {
+ type: type,
+ width: (type == "desktop" ? "100%" : undefined),
+ height: (type == "desktop" ? "900px" : undefined),
+ documentType: documentType,
+ token: "eyJ0eXBlIjoiMSIsImFsZyI6IkhTNTEyIn0.e30.RgxbmTaMyvL4cYnOg2DH03JghyUeIlLTiFDZrxqM4Ai_8XGv0K1qw0DB2r9EDRmiLb9ROxzzg36J62V-2IvaXA",
+ document: {
+ title: docUrl,
+ url: docUrl,
+ fileType: docType,
+ key: docKey + 2,
+ permissions: window.permission
+ },
+ editorConfig: {
+ mode: mode,
+ user: {
+ "id": id,
+ "name": window.user
+ },
+ customization: {
+ about: true,
+ chat: false,
+ comments: true,
+ zoom: 50,
+ leftMenu: leftPanelFlag,
+ rightMenu: rightPanelFlag,
+ toolbar: toobarFlag,
+ displayTitle:titlebarFlag,
+ header: true,
+ statusBar: true,
+ autosave: false,
+ forcesave: false
+ },
+ },
+ events: {
+ 'onDocumentReady': onDocumentReady,
+ 'onAppReady': onAppReady
+ }
+ });
+ }
+
+ function key(k) {
+ // var result = k.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_") + (new Date()).getTime();
+ var result = k.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_");
+ return result.substring(result.length - Math.min(result.length, 20));
+ };
+ var getDocumentType = function(ext) {
+ if (".doc.docx.docm.dot.dotx.dotm.odt.fodt.ott.rtf.txt.html.htm.mht.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
+ if (".xls.xlsx.xlsm.xlt.xltx.xltm.ods.fods.ots.csv".indexOf(ext) != -1) return "spreadsheet";
+ if (".pps.ppsx.ppsm.ppt.pptx.pptm.pot.potx.potm.odp.fodp.otp".indexOf(ext) != -1) return "presentation";
+ return null;
+ };
+ </script>
+</body>
+
+</html>
\ No newline at end of file
--
Gitblit v1.9.1