From c8efe0e7064ec6398942012f65089e693fc68634 Mon Sep 17 00:00:00 2001 From: yangjian Date: Mon, 16 Dec 2019 21:29:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=BC=96=E8=BE=91=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8F=AF=E6=8F=92=E5=85=A5=E6=9C=AC=E5=9C=B0=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=96=87=E4=BB=B6=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/app_doc/create_base.html | 4 +-- template/app_doc/create_doc.html | 53 ++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/template/app_doc/create_base.html b/template/app_doc/create_base.html index 549c3cf..fa4ea89 100644 --- a/template/app_doc/create_base.html +++ b/template/app_doc/create_base.html @@ -15,13 +15,13 @@ {% block custom_style %}{% endblock %} - + {% include 'app_doc/head_base.html' %} -
+
{% block content %} {% endblock %}
diff --git a/template/app_doc/create_doc.html b/template/app_doc/create_doc.html index 58009c3..af02913 100644 --- a/template/app_doc/create_doc.html +++ b/template/app_doc/create_doc.html @@ -16,7 +16,7 @@
-
+
@@ -38,16 +38,23 @@
-
+
-
+
@@ -211,6 +218,44 @@ }, }); }; + //插入本地文本文件 + function insertLocalFile(input) { + var file = input.files[0]; + //filename = file.name.split(".")[0]; // 文件名 + //支持chrome IE10 + if (window.FileReader) { + var reader = new FileReader(); + reader.onload = function() { + console.log(this.result); + editor.insertValue(this.result); + } + reader.readAsText(file); + } + //支持IE 7 8 9 10 + else if (typeof window.ActiveXObject != 'undefined'){ + var xmlDoc; + xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); + xmlDoc.async = false; + xmlDoc.load(input.value); + console.log(xmlDoc.xml); + editor.insertValue(xmlDoc.xml); + } + //支持FF + else if (document.implementation && document.implementation.createDocument) { + var xmlDoc; + xmlDoc = document.implementation.createDocument("", "", null); + xmlDoc.async = false; + xmlDoc.load(input.value); + console.log(xmlDoc.xml); + editor.insertValue(xmlDoc.xml); + } else { + alert('error'); + } + }; + //选择本地文本文件 + function selectLocalFile(){ + $("#insert-local-file").trigger("click"); + }; {% endblock %}