diff --git a/src/main/java/com/nis/web/controller/SystemController.java b/src/main/java/com/nis/web/controller/SystemController.java index f817edf6e..025fea435 100644 --- a/src/main/java/com/nis/web/controller/SystemController.java +++ b/src/main/java/com/nis/web/controller/SystemController.java @@ -1,14 +1,22 @@ package com.nis.web.controller; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; import com.nis.domain.SysMenu; import com.nis.util.StringUtil; @@ -100,6 +108,29 @@ public class SystemController extends BaseController{ model.addAttribute("menuList",newList); return "/help"; } - + @RequestMapping("saveHelp") + @ResponseBody + public boolean saveHelp(HttpServletRequest request, HttpServletResponse response,ModelMap model,@RequestParam(required=true,value="editedHelpInfo")String editedHelpInfo,@RequestParam(required=true,value="helpHrefVal")String helpHrefVal){ + + try { + StringBuffer helpInfo=new StringBuffer(); + helpInfo.append(URLDecoder.decode(editedHelpInfo,"utf-8")); + String htmlName=URLDecoder.decode(helpHrefVal,"utf-8"); + String htmlPath=request.getServletContext().getRealPath("/")+htmlName; + + File file=new File(htmlPath); + OutputStream out=new FileOutputStream(file); + out.write(helpInfo.toString().getBytes()); + out.flush(); + out.close(); + } catch (Exception e) { + + e.printStackTrace(); + return false; + } + + + return true; + } } diff --git a/src/main/resources/jdbc.properties b/src/main/resources/jdbc.properties index 291639453..58a3c8584 100644 --- a/src/main/resources/jdbc.properties +++ b/src/main/resources/jdbc.properties @@ -1,120 +1,120 @@ -#jdbc for oracle -#jdbc.driver=oracle.jdbc.driver.OracleDriver -jdbc.devlop.driver=com.mysql.jdbc.Driver -jdbc.devlop.url=jdbc:mysql://10.0.4.221:3306/ntc_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true -jdbc.devlop.username=root -jdbc.devlop.key=pR3JFt5dsGCW0nZO3TLF7Q== -jdbc.devlop.password=JgW5tsiGBNAtcqCgSQIP0g== - -jdbc.product.driver=com.mysql.jdbc.Driver -jdbc.product.url=jdbc:mysql://10.0.4.221:3306/ntc_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true -jdbc.product.username=root -jdbc.product.key=pR3JFt5dsGCW0nZO3TLF7Q== -jdbc.product.password=JgW5tsiGBNAtcqCgSQIP0g== - -#jdbc.log.driver=oracle.jdbc.driver.OracleDriver -#jdbc.log.url=jdbc:oracle:thin:@10.0.6.212:1523:app -##jdbc.log.url=jdbc:oracle:thin:@10.174.196.22:1521:orcl -#jdbc.log.username=gk_log -##jdbc.log.username=z2_5x9logb -#jdbc.log.key=pHl+0udycGQWNZcN68Sv9A== -#jdbc.log.password=Z/pVMDXcWNxzVGAX0yRp3Q== -# -#jdbc.logA.driver=oracle.jdbc.driver.OracleDriver -##jdbc.logA.url=jdbc:oracle:thin:@10.0.6.212:1523:app -#jdbc.logA.url=jdbc:oracle:thin:@10.174.196.21:1521:orcl -##jdbc.logA.username=gk_log_a -#jdbc.logA.username=z2_5x9loga -#jdbc.logA.key=SXHfLUwzPw0cQEc1wzwM4w== -#jdbc.logA.password=auvtDoVZpGP6P4OqfBrWAg== -# -#jdbc.logC.driver=oracle.jdbc.driver.OracleDriver -#jdbc.logC.url=jdbc:oracle:thin:@10.0.6.212:1523:app -#jdbc.logC.username=gk_log_c -#jdbc.logC.key=MvwfUIYP0nLyiQeprHB/5A== -#jdbc.logC.password=3HXvsqpbOoNBIkHDS5c9Aw== -# -#jdbc.jk.driver=oracle.jdbc.driver.OracleDriver -#jdbc.jk.url=jdbc:oracle:thin:@10.0.6.212:1523:app -##jdbc.jk.url=jdbc:oracle:thin:@10.174.196.20:1521:orcl -#jdbc.jk.username=gk_jk -##jdbc.jk.username=z2_5x9jk -#jdbc.jk.key=+FaavsHgQ0qBSebsAoochw== -#jdbc.jk.password=wBrNar7gX/iQR7IyCSHuSg== - - - -bonecp.idleMaxAgeInMinutes=60 -bonecp.idleConnectionTestPeriodInMinutes=240 -bonecp.maxConnectionsPerPartition=50 -bonecp.minConnectionsPerPartition=10 -bonecp.partitionCount=3 -bonecp.acquireIncrement=5 -bonecp.statementsCacheSize=100 - -############################################################################################################################################ -#数据中心神通数据库接口配置 -############################################################################################################################################ -#bonecp.cluster.idleMaxAgeInMinutes=60 -#bonecp.cluster.idleConnectionTestPeriodInMinutes=240 -#bonecp.cluster.maxConnectionsPerPartition=10 -#bonecp.cluster.minConnectionsPerPartition=5 -#bonecp.cluster.partitionCount=3 -#bonecp.cluster.acquireIncrement=5 -#bonecp.cluster.statementsCacheSize=100 -# -#jdbc.log.cluster.driver=com.oscar.cluster.BulkDriver -#jdbc.log.cluster.url=jdbc:oscarclusterbulk://10.3.129.125:2010/logdb -#jdbc.log.cluster.username=xa_z2_iie -#jdbc.log.cluster.key=2fa3hQn28+4AOdJXL4Ud2w== -#jdbc.log.cluster.password=uut+weC9of5ocPheagBJ4A== -############################################################################################################################################ -#数据中心hive接口配置 -############################################################################################################################################ - -#A版日志库 -#jdbc.hiveA.driver=org.apache.hive.jdbc.HiveDriver -#jdbc.hiveA.url=jdbc:hive2://10.3.130.24:10000/default -#jdbc.hiveA.username=xa_z2_mesa -#jdbc.hiveA.key=aC/8fTC9vfPVhCk+CDzbAQ== -##加密后密码 -##jdbc.hiveA.password=V3GyFlG8Mg01bTt8ykFVaA== -##实际密码 -#jdbc.hiveA.password=123!@#qwe -# -# -# -# -# -##B版日志库 -#jdbc.hiveB.driver=org.apache.hive.jdbc.HiveDriver -#jdbc.hiveB.url=jdbc:hive2://10.3.130.25:10000/default -#jdbc.hiveB.username=xa_z2_mesa -#jdbc.hiveB.key=aC/8fTC9vfPVhCk+CDzbAQ== -##加密后密码 -##jdbc.hiveB.password=V3GyFlG8Mg01bTt8ykFVaA== -##实际密码 -#jdbc.hiveB.password=123!@#qwe -# -# -#bonecp.hive.idleMaxAgeInMinutes=60 -#bonecp.hive.idleConnectionTestPeriodInMinutes=240 -#bonecp.hive.maxConnectionsPerPartition=20 -#bonecp.hive.minConnectionsPerPartition=10 -#bonecp.hive.partitionCount=3 -#bonecp.hive.acquireIncrement=5 -#bonecp.hive.statementsCacheSize=100 -# -# -# -############################################################################################################################################# -##下面的库为测试库,测试完成后会删除 -############################################################################################################################################# -# -#jdbc.test.driver=oracle.jdbc.driver.OracleDriver -#jdbc.test.url=jdbc:oracle:thin:@10.0.6.212:1523:app -#jdbc.test.username=gk_pztest -#jdbc.test.key=cV9126WUYdojQjvuKNjidw== -#jdbc.test.password=OrTu/cLwlduYPW/tmxqNgQ== - - +#jdbc for oracle +#jdbc.driver=oracle.jdbc.driver.OracleDriver +jdbc.devlop.driver=com.mysql.jdbc.Driver +jdbc.devlop.url=jdbc:mysql://192.168.10.204:3306/gwall_dev?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true +jdbc.devlop.username=root +jdbc.devlop.key=pR3JFt5dsGCW0nZO3TLF7Q== +jdbc.devlop.password=JgW5tsiGBNAtcqCgSQIP0g== + +jdbc.product.driver=com.mysql.jdbc.Driver +jdbc.product.url=jdbc:mysql://192.168.10.204:3306/gwall_dev?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true +jdbc.product.username=root +jdbc.product.key=pR3JFt5dsGCW0nZO3TLF7Q== +jdbc.product.password=JgW5tsiGBNAtcqCgSQIP0g== + +#jdbc.log.driver=oracle.jdbc.driver.OracleDriver +#jdbc.log.url=jdbc:oracle:thin:@10.0.6.212:1523:app +##jdbc.log.url=jdbc:oracle:thin:@10.174.196.22:1521:orcl +#jdbc.log.username=gk_log +##jdbc.log.username=z2_5x9logb +#jdbc.log.key=pHl+0udycGQWNZcN68Sv9A== +#jdbc.log.password=Z/pVMDXcWNxzVGAX0yRp3Q== +# +#jdbc.logA.driver=oracle.jdbc.driver.OracleDriver +##jdbc.logA.url=jdbc:oracle:thin:@10.0.6.212:1523:app +#jdbc.logA.url=jdbc:oracle:thin:@10.174.196.21:1521:orcl +##jdbc.logA.username=gk_log_a +#jdbc.logA.username=z2_5x9loga +#jdbc.logA.key=SXHfLUwzPw0cQEc1wzwM4w== +#jdbc.logA.password=auvtDoVZpGP6P4OqfBrWAg== +# +#jdbc.logC.driver=oracle.jdbc.driver.OracleDriver +#jdbc.logC.url=jdbc:oracle:thin:@10.0.6.212:1523:app +#jdbc.logC.username=gk_log_c +#jdbc.logC.key=MvwfUIYP0nLyiQeprHB/5A== +#jdbc.logC.password=3HXvsqpbOoNBIkHDS5c9Aw== +# +#jdbc.jk.driver=oracle.jdbc.driver.OracleDriver +#jdbc.jk.url=jdbc:oracle:thin:@10.0.6.212:1523:app +##jdbc.jk.url=jdbc:oracle:thin:@10.174.196.20:1521:orcl +#jdbc.jk.username=gk_jk +##jdbc.jk.username=z2_5x9jk +#jdbc.jk.key=+FaavsHgQ0qBSebsAoochw== +#jdbc.jk.password=wBrNar7gX/iQR7IyCSHuSg== + + + +bonecp.idleMaxAgeInMinutes=60 +bonecp.idleConnectionTestPeriodInMinutes=240 +bonecp.maxConnectionsPerPartition=50 +bonecp.minConnectionsPerPartition=10 +bonecp.partitionCount=3 +bonecp.acquireIncrement=5 +bonecp.statementsCacheSize=100 + +############################################################################################################################################ +#数据中心神通数据库接口配置 +############################################################################################################################################ +#bonecp.cluster.idleMaxAgeInMinutes=60 +#bonecp.cluster.idleConnectionTestPeriodInMinutes=240 +#bonecp.cluster.maxConnectionsPerPartition=10 +#bonecp.cluster.minConnectionsPerPartition=5 +#bonecp.cluster.partitionCount=3 +#bonecp.cluster.acquireIncrement=5 +#bonecp.cluster.statementsCacheSize=100 +# +#jdbc.log.cluster.driver=com.oscar.cluster.BulkDriver +#jdbc.log.cluster.url=jdbc:oscarclusterbulk://10.3.129.125:2010/logdb +#jdbc.log.cluster.username=xa_z2_iie +#jdbc.log.cluster.key=2fa3hQn28+4AOdJXL4Ud2w== +#jdbc.log.cluster.password=uut+weC9of5ocPheagBJ4A== +############################################################################################################################################ +#数据中心hive接口配置 +############################################################################################################################################ + +#A版日志库 +#jdbc.hiveA.driver=org.apache.hive.jdbc.HiveDriver +#jdbc.hiveA.url=jdbc:hive2://10.3.130.24:10000/default +#jdbc.hiveA.username=xa_z2_mesa +#jdbc.hiveA.key=aC/8fTC9vfPVhCk+CDzbAQ== +##加密后密码 +##jdbc.hiveA.password=V3GyFlG8Mg01bTt8ykFVaA== +##实际密码 +#jdbc.hiveA.password=123!@#qwe +# +# +# +# +# +##B版日志库 +#jdbc.hiveB.driver=org.apache.hive.jdbc.HiveDriver +#jdbc.hiveB.url=jdbc:hive2://10.3.130.25:10000/default +#jdbc.hiveB.username=xa_z2_mesa +#jdbc.hiveB.key=aC/8fTC9vfPVhCk+CDzbAQ== +##加密后密码 +##jdbc.hiveB.password=V3GyFlG8Mg01bTt8ykFVaA== +##实际密码 +#jdbc.hiveB.password=123!@#qwe +# +# +#bonecp.hive.idleMaxAgeInMinutes=60 +#bonecp.hive.idleConnectionTestPeriodInMinutes=240 +#bonecp.hive.maxConnectionsPerPartition=20 +#bonecp.hive.minConnectionsPerPartition=10 +#bonecp.hive.partitionCount=3 +#bonecp.hive.acquireIncrement=5 +#bonecp.hive.statementsCacheSize=100 +# +# +# +############################################################################################################################################# +##下面的库为测试库,测试完成后会删除 +############################################################################################################################################# +# +#jdbc.test.driver=oracle.jdbc.driver.OracleDriver +#jdbc.test.url=jdbc:oracle:thin:@10.0.6.212:1523:app +#jdbc.test.username=gk_pztest +#jdbc.test.key=cV9126WUYdojQjvuKNjidw== +#jdbc.test.password=OrTu/cLwlduYPW/tmxqNgQ== + + diff --git a/src/main/resources/nis.properties b/src/main/resources/nis.properties index c6723011f..0b472b46f 100644 --- a/src/main/resources/nis.properties +++ b/src/main/resources/nis.properties @@ -1,626 +1,623 @@ -#\u7ba1\u7406\u57fa\u7840\u8def\u5f84, \u9700\u540c\u6b65\u4fee\u6539\uff1aweb.xml -adminPath=/nis - -#Restful\u670d\u52a1\u9ed8\u8ba4\u8def\u5f84\ufffd -servicePath=/service - -#\u5206\u9875\u914d\u7f6e -page.pageSize=20 -#\u5206\u9875\u914d\u7f6e -page.count=0 - -#\u7d22\u5f15\u9875\u8def\u5f84 -web.view.index=/nis/index - -#\u7f13\u5b58\u8bbe\u7f6e -ehcache.configFile=cache/ehcache-local.xml -#ehcache.configFile=cache/ehcache-rmi.xml - -#\u4f1a\u8bdd\u8d85\u65f6\uff0c \u5355\u4f4d\uff1a\u6beb\u79d2\uff0c 20m=1200000ms, 30m=1800000ms, 60m=3600000ms -session.sessionTimeout=1800000 -#\u4f1a\u8bdd\u6e05\u7406\u95f4\u9694\u65f6\u95f4\uff0c \u5355\u4f4d\uff1a\u6beb\u79d2\uff0c2m=120000ms\u3002 -session.sessionTimeoutClean=120000 - -#\u9759\u6001\u6587\u4ef6\u540e\u7f00 -web.staticFile=.css,.js,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.htm,.html,.crx,.xpi,.exe,.ipa,.apk - -#\u7f51\u7ad9URL\u540e\u7f00 -urlSuffix=.jsp - -#\u89c6\u56fe\u6587\u4ef6\u5b58\u653e\u8def\u5f84 -web.view.prefix=/WEB-INF/views/ -web.view.suffix=.jsp - -#\u662f\u5426\u4e0d\u5141\u8bb8\u5237\u65b0\u4e3b\u9875\uff0c\u4e0d\u5141\u8bb8\u60c5\u51b5\u4e0b\uff0c\u5237\u65b0\u4e3b\u9875\u4f1a\u5bfc\u81f4\u91cd\u65b0\u767b\u5f55 -notAllowRefreshIndex=false - -#\u524d\u7aef\u57fa\u7840\u8def\u5f84 -frontPath=/f - -#\u662f\u5426\u8fd0\u884c\u591a\u8d26\u6237\u540c\u65f6\u767b\u5f55? -user.multiAccountLogin=true - -#\u7855\u6b63\u7ec4\u4ef6\u662f\u5426\u4f7f\u7528\u7f13\u5b58 -supcan.useCache=false - -#\u901a\u77e5\u95f4\u9694\u65f6\u95f4\u8bbe\u7f6e, \u5355\u4f4d\uff1a\u6beb\u79d2, 30s=30000ms, 60s=60000ms -work.notify.remind.interval=60000 - - -#============================# -#===== System settings ======# -#============================# - -#\u4ea7\u54c1\u4fe1\u606f\u8bbe\u7f6e -productName=National Traffic Control System -copyrightYear=2015 -version=V1.0.0 - - -#\u4e0a\u4f20\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84, \u8def\u5f84\u4e2d\u4e0d\u5141\u8bb8\u5305\u542b\u201cuserfiles\u201d -userfiles.basedir=upload - - -#============================# -#===== webservice settings ======# -#============================# - -#ESB\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u1e69\ufffd\ufffd\u0373\u04bb\ufffd\ufffd\u05b7 -webservice.esb.endpoint=http://10.55.0.197:7879/TongServiceProxy_doprocess/services/WebService1/ -#webservice RID -webservice.rid=XFBL - -#webservice user SID -webservice.yh.sid=s_2016_x2000 - -#webservice office SID -webservice.jg.sid=s_2015_x2000 - -#webservice data dict SID -webservice.data.dict.sid=s_2031_x2000 - -#webservice data dict bm SID -webservice.data.dict.bm.sid=s_2032_x2000 - -#webservice data dict code SID -webservice.data.dict.code.sid=s_2042_0660BD17-35E4-4482-AA3A-556F2C024902 - -#webservice request timeout for seconds -webservice.request.timeout=30 - -#\ufffd\ufffd\ufffd\ufffd\ufffdURL -webservice.jg.service.url=http://10.55.0.155:8080/jgService - -#\ufffd\u00fb\ufffd\ufffd\ufffd\ufffd\ufffdURL -webservice.yh.service.url=http://10.55.0.155:8080/ryService - -#\ufffd\ufffd\ufffd\ufffd\u05b5\ufffdURL -webservice.data.dict.service.url=http://10.55.0.155:8080/sjzdService - -#\ufffd\ufffd\ufffd\ufffd\u05b5\ufffd\ufffd\ufffd\ufffdURL -webservice.data.dict.bm.url=http://10.55.0.155:8080/sjzdbmService - -#\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdURL -webservice.data.code.url=http://10.55.0.155:8080/sjmbService - -#webservice\ufffd\u04ff\ufffd\ufffd\ufffd\ufffd\u00ff\u04b3\ufffd\ufffd\ufffd\ufffd -webservice.data.pagesize = 2000 -#webservice\ufffd\ufffd\u01f0\u012c\ufffd\ufffd\u04b3 -webservice.data.currentpage = 1 - -#webservice \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd -webservice.jgmb.name=CK_T_JC_RY -#webservice \ufffd\u00fb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd -webservice.yhmb.name=CK_T_YH_RY -#webservice\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \u022b\ufffd\ufffd -webservice.method.name.ql=getData -# webservice\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd -webservice.method.name.zl=getDataZL - -# redis\u914d\u7f6e\u6587\u4ef6 -#redis \u5404\u4e2a\u5206\u7247\u7684 IP\u7aef\u53e3 -redis.cluster.host_port=10.0.6.32:6379,10.0.6.32:6380,10.0.6.32:6381,10.0.6.33:6379,10.0.6.33:6380,10.0.6.33:6381 - - -#\u4e2d\u5fc3\u73b0\u573aredis\u5730\u5740\u548c\u7aef\u53e3 -#redis.cluster.host_port=10.174.196.33:6379,10.174.196.33:6380,10.174.196.33:6381,10.174.196.34:6379,10.174.196.34:6380,10.174.196.34:6381,10.174.196.35:6379,10.174.196.35:6380,10.174.196.35:6381,10.174.196.36:6379,10.174.196.36:6380,10.174.196.36:6381,10.174.196.37:6379,10.174.196.37:6380,10.174.196.37:6381,10.174.196.38:6379,10.174.196.38:6380,10.174.196.38:6381,10.174.196.39:6379,10.174.196.39:6380,10.174.196.39:6381 - -redis.cluster.connectiontimeout=5000 -redis.cluster.sotimeout=5000 -redis.cluster.maxattempts=3 -#redis\u8fde\u63a5\u6c60\u76f8\u5173\u914d\u7f6e - -redis.pool.maxtotal=500 - -redis.pool.maxidle=500 -redis.pool.maxwaitmillis=-1 -redis.pool.blockwhenexhausted=true -redis.pool.numtestsperevictionrun=60000 -redis.pool.testonborrow=true -redis.pool.testonreturn=false -redis.pool.testwhileidle=true -redis.pool.timebetweenevictionrunsmillis=60000 -redis.pool.minevictableidletimemillis=60000 -#oracle\u6570\u636eredis\u5b58\u50a8\u65f6\u95f4(\u79d2\u4e3a\u5355\u4f4d \u9ed8\u8ba43\u5206\u949f\u5373180s) -oracleExpire=180 -#hive\u6570\u636e\u4e2d\u5fc3\u6570\u636eredis\u5b58\u50a8\u65f6\u95f4(\u79d2\u4e3a\u5355\u4f4d \u9ed8\u8ba420\u5206\u949f\u53731200s) -hiveExpire=300 -#redis\u5f00\u5173 -isOpenRedis=false -#\u662f\u5426\u5c06\u6570\u636e\u4e2d\u5fc3\u7684\u65e5\u5fd7\u52a0\u5165\u5230redis\u4e2d -dataCenterOpenRedis=true -#\u8de8\u57df\u95ee\u9898\u5141\u8bb8 \u7684url Access-Control-Allow-Origin *\u5141\u8bb8\u6240\u6709\uff0c\u8bbe\u7f6e\u6210\u5176\u4ed6url\u53ea\u5141\u8bb8\u8be5url.\u4e0d\u80fd\u8bbe\u7f6e\u591a\u4e2aurl -target_url=* -#\u8de8\u57df\u95ee\u9898 3600\uff1a\u8868\u660e\u57283600\u79d2\u5185\uff0c\u4e0d\u9700\u8981\u518d\u53d1\u9001\u9884\u8bf7\u6c42\uff0c\u53ef\u4ee5\u7f13\u5b58\u8be5\u7ed3\u679c -ACCESS_CONTROL_MAX_AGE=3600 -##########HTTPCLIENT POOL START################### -#\u4ece\u8fde\u63a5\u6c60\u4e2d\u83b7\u53d6\u5230\u8fde\u63a5\u7684\u6700\u957f\u65f6\u95f4 -http.request.connectionRequestTimeout=500 -#5000 -http.request.connectTimeout=5000 -#\u6570\u636e\u4f20\u8f93\u7684\u6700\u957f\u65f6\u95f4 -http.request.socketTimeout=30000 -#\u63d0\u4ea4\u8bf7\u6c42\u524d\u6d4b\u8bd5\u8fde\u63a5\u662f\u5426\u53ef\u7528 -http.request.staleConnectionCheckEnabled=true - -#\u8bbe\u7f6e\u8fde\u63a5\u603b\u6570 -http.pool.maxTotal=200 -#\u8bbe\u7f6e\u6bcf\u4e2a\u5730\u5740\u7684\u5e76\u53d1\u6570 -http.pool.defaultMaxPerRoute=100 -##########HTTPCLIENT POOL END################### -search.dateformat=yyyy-MM-dd HH:mm:ss -search.eshostandport_A=10.0.6.115:9200 -search.eshostandport_B=10.0.6.115:9200 -search.eshostandport_C=10.0.6.115:9200 - -#search.eshostandport=10.174.196.135:9200 - - -#\u65e5\u5fd7\u662f\u5426\u4ecehive\u4e2d\u67e5\u8be2 -selFromHive=false - -#\u662f\u5426\u83b7\u53d6\u6570\u636e\u4e2d\u5fc3\u67e5\u8be2\u8bb0\u5f55\u7684\u603b\u6761\u6570 -isGetHiveCount=false - -#\u6bcf\u6b21\u83b7\u53d6\u6570\u636e\u4e2d\u5fc3\u591a\u5c11\u6761\u6570\u636e,\u54b1\u4eec\u5728\u5bf9\u83b7\u53d6\u7684\u6570\u636e\u8fdb\u884c\u5206\u9875\u5904\u7406 -everyGetHiveDataNum=10000 - -#oracle\u6570\u636e\u5e93\u6709\u95ee\u9898\u4e0d\u4eceoracle\u67e5\u8be2\u6570\u636e,\u6240\u6709\u65e5\u5fd7\u6570\u636e\u5747\u4ece\u6570\u636e\u4e2d\u5fc3\u67e5\u8be2 -onlySelFromHive=false - -#\u662f\u5426\u67e5\u8be2\u795e\u901a\u6570\u636e\u5e93 -isSelectCluster=true - -#\u7528\u6237\u67e5\u8be2\u65e5\u5fd7\u8d85\u8fc7\u591a\u5c11\u5c0f\u65f6\u53bb\u6570\u636e\u4e2d\u5fc3\u67e5\u8be2 -dataCenterTime=48 - -#\u662f\u5426\u5f00\u542f\u57fa\u7840\u9a8c\u8bc1 -baseValidate=true - -#\u662f\u5426\u5f00\u542f\u4e1a\u52a1\u9a8c\u8bc1 -serviceValidate=true - - - -#\u65e5\u5fd7\u5b58\u50a8\u672c\u5730\u65f6\u95f4(\u5355\u4f4d\u5c0f\u65f6) -logLocalTime=48 -#\u5b9e\u65f6\u7edf\u8ba1\u9ed8\u8ba4\u67e5\u8be2\u672c\u5730\u4e00\u4e2a\u5c0f\u65f6\u7684\u6570\u636e(\u5355\u4f4d\uff1a\u5c0f\u65f6) -reportLocalTime=1 - -#\u795e\u901a\u6570\u636e\u5e93\u6700\u65e9\u65e5\u5fd7\u65f6\u95f4(A\u7248\u6beb\u79d2) -#2017-08-13 10:07:25 -clusterAStartTime=1503504000725 -#\u795e\u901a\u6570\u636e\u5e93\u6700\u65e9\u7ed3\u675f\u65f6\u95f4(B\u7248\u6beb\u79d2) -#2017-08-13 10:07:25 -clusterBStartTime=1503504000725 -############################################################################################################################################ -#\u8bbe\u7f6e\u914d\u7f6e\u662f\u5426\u5165\u5e93 -############################################################################################################################################ -isCommit=true -############################################################################################################################################ -############################################################################################################################################ -httpUrl=http://10.0.7.14:9999/galaxy-service/service/cfg/ -maatCfg=v1/configSources -fileUploadCfg=v1/fileUploadSources -callbackCfg=v1/commonSources -fileDigestCfg=v1/fileDigestSources -configIdSources=v1/configPzIdSources -#logBaseUrl=http://10.0.6.242:8080/galaxy-service/service/log/v1/ -logBaseUrl=http://10.0.7.14:9999/galaxy-service/service/log/ -ntcPzReport=v1/ntcPzReport -ntcServiceReport=v1/ntcServiceReport -ntcTagReport=v1/ntcTagReport -ntcAttrTypeReport=v1/ntcAttrTypeReport -ntcLwhhReport=v1/ntcLwhhReport -ntcSrcipDomesticReport=v1/ntcSrcipDomesticReport -ntcDestipCountryReport=v1/ntcDestipCountryReport -ntcEntranceReport=v1/ntcEntranceReport -ntcIpLog=v1/ntcIpLogs -ntcBgpLog=v1/ntcBgpLogs -ntcP2pLog=v1/ntcP2pLogs -ntcHttpLog=v1/ntcHttpLogs -ntcDnsLog=v1/ntcDnsLogs -ntcSslLog=v1/ntcSslLogs -ntcPptpLog=v1/ntcPptpLogs -ntcL2tpLog=v1/ntcL2tpLogs -ntcOpenvpnLog=v1/ntcOpenvpnLogs -ntcIpsecLog=v1/ntcIpsecLogs -ntcSshLog=v1/ntcSshLogs -ntcMailLog=v1/ntcMailLogs -ntcFtpLog=v1/ntcFtpLogs -ntcAppLog=v1/ntcAppLogs -ntcDdosLog=v1/ntcDdosLogs -dkBehaviorLog=v1/ntcAppLogs -mmVoipLog=v1/ntcVoipLogs -mmAvIpLog=v1/mmAvIpLogs -mmAvUrlLog=v1/mmAvUrlLogs -mmPicIpLog=v1/mmPicIpLogs -mmPicUrlLog=v1/mmPicUrlLogs -mmVoipIpLog=v1/ntcVoipLogs -mmVoipAccountLog=v1/mmVoipAccountLogs -mmSampleAudioLog=v1/mmSampleAudioLogs -mmSampleVideoLog=v1/mmSampleVideoLogs -mmPornAudioLevelLog=v1/mmPornAudioLevelLogs -mmPornVideoLevelLog=v1/mmPornVideoLevelLogs -mmSamplePicLog=v1/mmSamplePicLogs -mmSampleVoipLog=v1/mmSampleVoipLogs -pxyHttpLog=v1/pxyHttpLogs -mmSpeakerRecognizationLog=v1/mmSpeakerRecognizationLogs -mmLogoDetectionLog=v1/mmLogoDetectionLogs -mmFaceRecognizationLog=v1/mmFaceRecognizationLogs -######################################## -#\u5927\u5c4f\u56fe\u8868\u5c55\u793a\u670d\u52a1\u63a5\u53e3 -dashboardUrl=http://10.0.7.14:9999/galaxy-service/service/log/ -trafficIpActive=v1/trafficIpActive -trafficProtocol=v1/trafficProtocol -trafficApp=v1/trafficApp -trafficOsList=v1/trafficOsList -trafficBrowserChart=v1/trafficBrowserChart -trafficBsList=v1/trafficBsList -trafficSystemChart=v1/trafficSystemChart -trafficWebsiteList=v1/trafficWebsiteList -trafficWebTypeChart=v1/trafficWebTypeChart -trafficPortActive=v1/trafficPortActive -trafficTopicAndDomainChart=v1/trafficTopicAndDomainChart -ntcTotalReport=v1/ntcTotalReport -trafficIpActiveFiveMinute=v1/trafficIpActiveFiveMinute -trafficIpActiveOneHour=v1/trafficIpActiveOneHour - -client_connect_timeout=300000 -client_read_timeout=300000 -log_time_interval=300000 -logsearch_menu_id=152 -#use elasticsearch or not# -isUseES=false - -#httpclient \u5de5\u5177\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4 -http_socket_timeout=300000 -http_connect_timeout=10000 -http_connect_request_timeout=50000 -http_connect_retry_times=3 - - -#\u6570\u636e\u4e2d\u5fc3A\u7248\u6570\u636e\u5e93\u540d\u79f0,\u7a0b\u5e8f\u4e2d\u6bcf\u6b21\u67e5\u8be2\u65f6\u4f7f\u7528\u7684\u6570\u636e\u5e93\u540d\u79f0 use dbA -jdbc.hive.AName=xa_dfbhit_hive -#\u6570\u636e\u4e2d\u5fc3B\u7248\u6570\u636e\u5e93\u540d\u79f0 -jdbc.hive.BName=xa_z2_mesalog_hive - -maxPageSize=100000 -#\u5bfc\u51fa\u6700\u5927\u6761\u6570 -maxExportSize=5000 -#\u5141\u8bb8\u914d\u7f6e\u6700\u5927\u5c42\u7ea7 -maxLevelNo=4 -#\u4e0a\u4e0b\u7ea7\u663e\u793a\u95f4\u9694\u6807\u8bc6\u7b26 -childrenMark=. -#\u4e1a\u52a1\u5b57\u5178\u5728\u8bcd\u5178\u4e2d\u7684\u6807\u8bc6 -SERVICE_DICT_ITM_TYPE=SERVICE_DICT_ITM_TYPE -#\u7cfb\u7edf\u5b57\u5178\u5728\u8bcd\u5178\u4e2d\u7684\u6807\u8bc6 -SYS_DICT_ITM_TYPE=SYS_DICT_ITM_TYPE -area_region=NTC_IP_RANGE -protocol_num_region=NTC_UNIVERSAL_PROTO_TYPE -http_ip_region=NTC_UNIVERSAL_IP -http_req_hdr_region=NTC_HTTP_REQ_HDR -http_req_body_region=NTC_HTTP_REQ_BODY -http_res_hdr_region=NTC_HTTP_RES_HDR -http_res_body_region=NTC_HTTP_RES_BODY -ntc_subscribe_id=NTC_SUBSCRIBE_ID -http_url_region=NTC_HTTP_URL -http_redirect_url_region=PXY_CTRL_HTTP_URL -http_redirect_req_hdr_region=PXY_CTRL_HTTP_REQ_HDR -http_redirect_res_hdr_region=PXY_CTRL_HTTP_RES_HDR -http_redirect_req_body_region=PXY_CTRL_HTTP_REQ_BODY -http_redirect_res_body_region=PXY_CTRL_HTTP_RES_BODY -http_redirect_ip_region=PXY_CTRL_IP -p2p_hash_bin_region=NTC_P2P_HASH_BIN -p2p_keywords_region=NTC_P2P_KEYWORDS -voip_ip=av_voip_ip -voip_account=av_voip_account -ssl_sni_region=ssl_sni -ssl_san_region=ssl_san -ssl_ca_region=ssl_ca -ssl_ip_region=ssl_ip -bgp_ip_region=bgp_ip -behav_id_region=BEHAV_ID -rate_limit_region=Droprate -#\u5b58\u5728\u4e0e\u8868\u8fbe\u5f0f\u7684\u5173\u952e\u5b57\u7279\u6b8a\u5206\u9694\u7b26 -keyword_expr=***and*** -#\u65f6\u533a -time_zone=8 -#\u9700\u8981\u7279\u6b8a\u5904\u7406\u7684\u4e1a\u52a1\u7c7b\u578b -service_pxy_domain_intercept=513 -service_ip_mulitiplex=768 -service_ip_ratelimit=1057 -service_domain_ratelimit=1058 -#\u7528\u6237\u81ea\u5b9a\u4e49\u57df -userregion_rate_limit=Droprate -userregion_ir_strategy=IR_STRATEGY -userregion_ir_type=IR_TYPE -userregion_domain_id=DOMAIN_ID -userregion_domain_str=DOMAIN_STR -userregion_replace_type_key=zone -userregion_replace_req_key_value=http_req_body -userregion_replace_res_key_value=http_res_body -userregion_replace_regex_key=regex -#\u7528\u6237\u81ea\u5b9a\u4e49\u57df\u5360\u4f4d\u7b26 -user_region_placeholder=0 -#\u7528\u6237\u81ea\u5b9a\u4e49\u57df\u5206\u9694\u7b26 -user_region_split=; -#IP\u76f8\u5173\u9a8c\u8bc1\u6b63\u5219 -ipv4_ip_subnet_regexp=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)/(3[0-2]|1[6-9]|2[0-9])$ -ipv6_ip_subnet_regexp=^((::)|(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))/([2-9]|[1-9][0-9]|1[0-2][0-8])$ -ipv4_ip_range_regexp=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)-(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$ -ipv6_ip_range_regexp=^((::)|(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))-((::)|(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))$ -ipv4_ip_regexp=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$ -ipv6_ip_regexp=^((::)|(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))$ -#\u91cd\u5b9a\u5411\u4e1a\u52a1\u81ea\u5b9a\u4e49\u57df\u76f8\u5173\u53c2\u6570 -redirect_response_code_key=code -redirect_url_key=url -redirect_content_key=content -redirect_response_code_startwith=30 -replace_zone_key=zone -replace_substitute_key=substitute -#\u6837\u4f8b\u6587\u4ef6\u4e0a\u4f20\u7684uri\u5173\u952e\u8bcd -sample_upload_url_keyword=/av -digest_upload_url_keyword=/filetransfer -cert_upload_url_keyword=/intercept/strateagy - -#sample File Size 100M -sample_total_file_max_size=104857600 -#audio File Types -audio_file_type=,mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm,wav,mp3, -#audio File Size 100M 10485760\uff08single\uff09 -audio_single_file_max_size=0 -#speaker File Types \u8bf4\u8bdd\u4eba\u8bc6\u522b\u6587\u4ef6\u7c7b\u578b -speaker_file_type= -#audio File Size 100M 10485760\uff08single\uff09 -speaker_single_file_max_size=0 -#video File Types -video_file_type=,mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm,ogv, -#video File Size 10M 10485760\uff08single\uff09 -video_single_file_max_size=0 -#face File Types \u4eba\u8138\u8bc6\u522b -face_file_type= -#face File Size 10M 10485760\uff08single\uff09 -face_single_file_max_size=0 -#picture File Types -picture_file_type= -#picture File Size 100M 10485760\uff08single\uff09 -picture_single_file_max_size=104857600 -#logo File Types \u53f0\u6807\u8bc6\u522b -logo_file_type= -#logo File Size 100M 10485760\uff08single\uff09 -logo_single_file_max_size=104857600 -#voip File Types -voip_file_type=,mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm,ogv,wav,mp3, -#voip File Size 10M 10485760\uff08single\uff09 -voip_single_file_max_size=0 - -#digest File Types -digest_file_type= -#digest File Size 100M 10485760\uff08single\uff09 -digest_single_file_max_size=104857600 -#digest File Size 100M 12582912\uff08total\uff09 -digest_total_file_max_size=104857600 -#cert File Size 100M 12582912\uff08total\uff09 -cert_total_file_max_size=104857600 -#public File Types -public_file_type= -#public File Size 100M 10485760\uff08single\uff09 -public_single_file_max_size=104857600 -#private File Types -private_file_type= -#private File Size 100M 10485760\uff08single\uff09 -private_single_file_max_size=104857600 -#YSP\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84 -av_file_path=/home/ysp/ -#av_file_path=D\:\\ysp\\ -#YSP\u6587\u4ef6\u7279\u5f81\u7c7b\u578b -av_sample_audio_region=av_sample_audio -av_sample_video_region=av_sample_video -av_sample_picture_region=av_sample_picture -av_sample_voip_region=av_sample_voip -mm_speaker_recognization_region=MM_SPEAKER_RECOGNIZATION -mm_logo_detection_region=MM_LOGO_DETECTION -mm_face_recognization_region=MM_FACE_RECOGNIZATION - -#\u6837\u4f8b\u6587\u4ef6\u751f\u6210\u7a0b\u5e8f -audio_sample_create_proc=/home/ceiec/av_feature_gen/audio_convert_proc -video_sample_create_proc=/home/ceiec/av_feature_gen/extract_frame_feature -picture_sample_create_proc=/home/ceiec/av_feature_gen/picture_convert_proc -speaker_sample_create_proc=java -jar /home/sampleTest.jar -logo_sample_create_proc=/home/ceiec/av_feature_gen/logo_convert_proc -face_sample_create_proc=/home/ceiec/av_feature_gen/face_convert_proc -audio_sample_proc_param_is_quotation=true -video_sample_proc_param_is_quotation=true -picture_sample_proc_param_is_quotation=true -speaker_sample_proc_param_is_quotation=true -logo_sample_proc_param_is_quotation=true -face_sample_proc_param_is_quotation=true -audio_sample_proc_param_is_translation=false -video_sample_proc_param_is_translation=false -picture_sample_proc_param_is_translation=false -speaker_sample_proc_param_is_translation=false -logo_sample_proc_param_is_translation=false -face_sample_proc_param_is_translation=false -#\u672c\u5730\u6d4b\u8bd5 -#audio_sample_create_proc=java -jar D\:\\sampleTest.jar -#video_sample_create_proc=java -jar D\:\\sampleTest.jar -#picture_sample_create_proc=java -jar D\:\\sampleTest.jar -#speaker_sample_create_proc=java -jar D\:\\sampleTest.jar -#logo_sample_create_proc=java -jar D\:\\sampleTest.jar -#face_sample_create_proc=java -jar D\:\\sampleTest.jar -#audio_sample_proc_param_is_quotation=false -#video_sample_proc_param_is_quotation=false -#picture_sample_proc_param_is_quotation=false -#speaker_sample_proc_param_is_quotation=false -#logo_sample_proc_param_is_quotation=false -#face_sample_proc_param_is_quotation=false -#audio_sample_proc_param_is_translation=true -#video_sample_proc_param_is_translation=true -#picture_sample_proc_param_is_translation=true -#speaker_sample_proc_param_is_translation=true -#logo_sample_proc_param_is_translation=true -#face_sample_proc_param_is_translation=true -#http\u81ea\u5b9a\u4e49\u57df\u76f8\u5173\u53c2\u6570 -http_header_user_region_key=HTTP_HEADER -http_header_dict_module=HTTP_HEADER_DISTRICT -#dns\u81ea\u5b9a\u4e49\u57df\u53c2\u6570key -dns_strategy_user_region_key=DNS_STRATEGY -#p2p\u81ea\u5b9a\u4e49\u57dfkey -p2p_ip_type_user_region_key=P2P_IP_TYPE -p2p_hash_type_user_region_key=P2P_HASH_TYPE -#\u7279\u5b9a\u670d\u52a1\u7c7b\u522b -specific_service_cfg_type_app=social_app -specific_service_cfg_type_encrypted_tunnel_behavior=encrypted_tunnel_behavior -specific_service_cfg_type_basic_protocol=basic_protocol -#\u57fa\u7840\u534f\u8bae\u81ea\u5b9a\u4e49\u57df -proto_id_region=PROTO_ID -#\u62e6\u622aIP\u81ea\u5b9a\u4e49\u57dfkey -keyring_id=keyring_id -droprate=Droprate -bandwidth=Bandwidth -intercept_domain_intensity=DOMAIN_INTENSITY -#IP\u9ed8\u8ba4\u503c -ipv4_default_ip_value=0.0.0.0 -ipv6_default_ip_value=\:\: -ipv4_default_ip_subnet_value=0.0.0.0/16 -ipv6_default_ip_subnet_value=::/128 -ipv4_default_ip_range_value=0.0.0.0-1 -ipv6_default_ip_range_value=::-:: -#\u7aef\u53e3\u9ed8\u8ba4\u503c -port_default=0 -port_mask_default=0/65535 -#MAAT CFG \u4e00\u4e9b\u9ed8\u8ba4\u503c -maat_cfg_dolog_default=2 -maat_cfg_dolog_doblacklist_default=1 -maat_cfg_dolog_configpercent_default=100 -maat_cfg_dolog_configoption_default=1 -#app\uff0c\u57fa\u7840\u534f\u8bae\uff0c\u7279\u5b9a\u670d\u52a1\u7684userregion\u5206\u9694\u7b26 -app_cfg_userregion_splitor=& -app_id_region=APP_ID -#application spec service code scope -app_spec_service_code_max_val=310000 -app_spec_service_code_min_val=300001 -groupReuseSources=v1/groupReuseSources -log_time_range=300000 -log_time_start=2018-08-01 00:00:00 -log_time_end=2018-10-01 00:00:00 -area_tag=location -isp_tag=isp -mmFileDigestLog=v1/mmFileDigestLogs -ntcStreamMediaLog=v1/ntcStreamMediaLogs -#\u97f3\u89c6\u9891\u6837\u4f8b\u9650\u5236\u65f6\u957f\uff0c\u5355\u4f4d\u79d2 -av_duration_limit=120 -video_to_picture_proc=/home/ceiec/av_feature_gen/save_video_frame -#\u8bc1\u4e66\u6587\u4ef6\u8def\u5f84 -cert_file_path=/home/cert/ -#\u8bc1\u4e66\u6821\u9a8c\u5de5\u5177\u540d\u79f0 -cert_validate_file=x509 -#\u8bc1\u4e66\u6821\u9a8c\u6210\u529f\u7684\u5173\u952e\u4fe1\u606f -cert_validate_success_info=Successful -#ipv4 range\u65b0\u683c\u5f0f0.0.0.1-2 -ipv4_ip_range_regexp_new=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)-(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$ -ipv4_ip_subnet_regexp_original=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)/(3[0-2]|1[0-9]|2[0-9]|[0-9])$ -#\u57df\u540d\u9a8c\u8bc1\u6b63\u5219 -domain_regexp=^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$ -#IP\u590d\u7528maat json\u4e2d\u7684ip region\u5355\u6b21send \u6700\u5927\u4e2a\u6570 -maat_json_send_size=20000 -#\u5bfc\u5165\u9a8c\u8bc1\u7684\u7ebf\u7a0b\u6570\u91cf -mulity_thread_size=5 -ntcRadiusReport=v2/ntcRadiusReport -ntcCollectVoipLog=v1/ntcCollectVoipLogs -ntcKeywordsUrlLog=v1/ntcKeywordsUrlLogs -save_and_del_thread_size=20 -#mysql \u5355\u4e2asql\u5927\u5c0f\u9650\u5236,\u6839\u636emariadb\u76f8\u5173\u53c2\u6570\u914d\u7f6e -max_allowed_packet=1048576 -#http client\u8fde\u63a5\u6c60\u76f8\u5173\u53c2\u6570\uff0chttp_max_connection:\u6700\u5927\u8fde\u63a5\u6570\uff0cdefault_max_perroute:\u6bcf\u4e2a\u4e3b\u673a\u5730\u5740\u7684\u5e76\u53d1\u6570\uff0cpoolcm_socket_timeout:socket\u8d85\u65f6\u65f6\u95f4 -http_max_connection=1000 -default_max_perroute=100 -poolcm_socket_timeout=3000 -app_vignore_user_region_key=DKC -#policies\u83dc\u5355\u7684\u83dc\u5355ID -policies_menu_id=86 -userCreate=UserCreate -userPasswordSet=UserPasswordSet -userDelete=UserDelete -userGet=UserGet -userList=UserList -ip_reuse_call_cgi_url=http://10.4.10.32:8090/command -ipNumGet=IpNumGet -allIpGet=AllIpGet -#\u6d41\u91cf\u7edf\u8ba1\u5e26\u5bbd\u8be6\u60c5 -trafficBandwidthTrans=v1/trafficBandwidthTrans -trafficProtocolList=v1/trafficProtocolList -irSnatLog=v1/irSnatLogs -irDnatLog=v1/irDnatLogs -trafficBandwidthTrans=v1/trafficBandwidthTrans -trafficProtocolList=v1/trafficProtocolList -trafficAppList=v1/trafficAppList -ntcActionEntranceReport=v1/ntcActionEntranceReport -redis.host=10.0.4.2:6379 -redis.expire=1800 -redis.timeout=10000 -dns_spoofing_ip_desc=Default Spoofing IP -dns_spoofing_ip_ip=1.1.1.1 -trafficBandwidthTransTwo=v1/trafficBandwidthTransTwo -trafficBandwidthTransThree=v1/trafficBandwidthTransThree -trafficBandwidthTransFour=v1/trafficBandwidthTransFour -ntcCollectRadiusLog=v1/ntcCollectRadiusLogs -ntcConnRecordLog=v1/ntcConnRecordLogs -ntcConnRecordPercent=v1/ntcConnRecordPercent -#\u5bfc\u51fa\u6700\u5927\u6761\u6570 -maxLogExportSize=2000 -pxy_crtl_subscribe_id_region=PXY_CTRL_SUBSCRIBE_ID -ntc_subscribe_id_region=NTC_SUBSCRIBE_ID -ntcAsnRecord=v1/ntcAsnRecord -ntcURLReport=v1/ntcURLReport -ntcIpRangeReport=v1/ntcIpRangeReport -trafficWebsiteListNoTime=v1/trafficWebsiteListNoTime -trafficTopicList=v1/trafficTopicList -trafficDomainTrans=v1/trafficDomainTrans -#maximum number to import -import_limit=10000 -trafficPortActiveFiveMinute=v1/trafficPortActiveFiveMinute -trendTotalReport=v1/trendTotalReport -#\u4e8b\u4ef6\u76d1\u6d4b/\u5c01\u5835 -ntcEventsMonitorOrBlock=v1/ntcEventsMonitorOrBlock -#\u91cd\u70b9\u4fdd\u969c\u4e8b\u4ef6 -ntcEventKeyProtection=v1/ntcEventKeyProtection -dashboardUrlV2=http://10.0.7.14:9999/galaxy-service/service/log/v2/ -trafficAreaStat=v1/trafficAreaStat -logServiceTopn=v1/logServiceTopn -blockAndDropStat=v1/blockAndDropStat -#\u914d\u7f6e\u542f\u505c\u63a5\u53e3 -configStartStop=v2/configStartStop -trafficAppTrend=v1/trafficAppTrend -appConnRecordTop100=v1/appConnRecordTop100 -#SSL\u6cdb\u6536 -ntcSslRecordLog=v1/ntcSslRecordLogs -ntc_asn_number=NTC_ASN_NUMBER -addRegionToCommonGroup=v1/addRegionToCommonGroup -updateRegionToCommonGroup=v1/updateCommonGroupRegion -deleteRegionToCommonGroup=v1/delCommonGroupRegion -asn_key=AS -#Http\u6cdb\u6536 -ntcHttpRecordLog=v1/ntcHttpRecordLogs -asn_region_key=ASN_ID \ No newline at end of file +#\u7ba1\u7406\u57fa\u7840\u8def\u5f84, \u9700\u540c\u6b65\u4fee\u6539\uff1aweb.xml +adminPath=/nis + +#Restful\u670d\u52a1\u9ed8\u8ba4\u8def\u5f84\ufffd +servicePath=/service + +#\u5206\u9875\u914d\u7f6e +page.pageSize=20 +#\u5206\u9875\u914d\u7f6e +page.count=0 + +#\u7d22\u5f15\u9875\u8def\u5f84 +web.view.index=/nis/index + +#\u7f13\u5b58\u8bbe\u7f6e +ehcache.configFile=cache/ehcache-local.xml +#ehcache.configFile=cache/ehcache-rmi.xml + +#\u4f1a\u8bdd\u8d85\u65f6\uff0c \u5355\u4f4d\uff1a\u6beb\u79d2\uff0c 20m=1200000ms, 30m=1800000ms, 60m=3600000ms +session.sessionTimeout=1800000 +#\u4f1a\u8bdd\u6e05\u7406\u95f4\u9694\u65f6\u95f4\uff0c \u5355\u4f4d\uff1a\u6beb\u79d2\uff0c2m=120000ms\u3002 +session.sessionTimeoutClean=120000 + +#\u9759\u6001\u6587\u4ef6\u540e\u7f00 +web.staticFile=.css,.js,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.htm,.html,.crx,.xpi,.exe,.ipa,.apk + +#\u7f51\u7ad9URL\u540e\u7f00 +urlSuffix=.jsp + +#\u89c6\u56fe\u6587\u4ef6\u5b58\u653e\u8def\u5f84 +web.view.prefix=/WEB-INF/views/ +web.view.suffix=.jsp + +#\u662f\u5426\u4e0d\u5141\u8bb8\u5237\u65b0\u4e3b\u9875\uff0c\u4e0d\u5141\u8bb8\u60c5\u51b5\u4e0b\uff0c\u5237\u65b0\u4e3b\u9875\u4f1a\u5bfc\u81f4\u91cd\u65b0\u767b\u5f55 +notAllowRefreshIndex=false + +#\u524d\u7aef\u57fa\u7840\u8def\u5f84 +frontPath=/f + +#\u662f\u5426\u8fd0\u884c\u591a\u8d26\u6237\u540c\u65f6\u767b\u5f55? +user.multiAccountLogin=true + +#\u7855\u6b63\u7ec4\u4ef6\u662f\u5426\u4f7f\u7528\u7f13\u5b58 +supcan.useCache=false + +#\u901a\u77e5\u95f4\u9694\u65f6\u95f4\u8bbe\u7f6e, \u5355\u4f4d\uff1a\u6beb\u79d2, 30s=30000ms, 60s=60000ms +work.notify.remind.interval=60000 + + +#============================# +#===== System settings ======# +#============================# + +#\u4ea7\u54c1\u4fe1\u606f\u8bbe\u7f6e +productName=National Traffic Control System +copyrightYear=2015 +version=V1.0.0 + + +#\u4e0a\u4f20\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84, \u8def\u5f84\u4e2d\u4e0d\u5141\u8bb8\u5305\u542b\u201cuserfiles\u201d +userfiles.basedir=upload + + +#============================# +#===== webservice settings ======# +#============================# + +#ESB\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u1e69\ufffd\ufffd\u0373\u04bb\ufffd\ufffd\u05b7 +webservice.esb.endpoint=http://10.55.0.197:7879/TongServiceProxy_doprocess/services/WebService1/ +#webservice RID +webservice.rid=XFBL + +#webservice user SID +webservice.yh.sid=s_2016_x2000 + +#webservice office SID +webservice.jg.sid=s_2015_x2000 + +#webservice data dict SID +webservice.data.dict.sid=s_2031_x2000 + +#webservice data dict bm SID +webservice.data.dict.bm.sid=s_2032_x2000 + +#webservice data dict code SID +webservice.data.dict.code.sid=s_2042_0660BD17-35E4-4482-AA3A-556F2C024902 + +#webservice request timeout for seconds +webservice.request.timeout=30 + +#\ufffd\ufffd\ufffd\ufffd\ufffdURL +webservice.jg.service.url=http://10.55.0.155:8080/jgService + +#\ufffd\u00fb\ufffd\ufffd\ufffd\ufffd\ufffdURL +webservice.yh.service.url=http://10.55.0.155:8080/ryService + +#\ufffd\ufffd\ufffd\ufffd\u05b5\ufffdURL +webservice.data.dict.service.url=http://10.55.0.155:8080/sjzdService + +#\ufffd\ufffd\ufffd\ufffd\u05b5\ufffd\ufffd\ufffd\ufffdURL +webservice.data.dict.bm.url=http://10.55.0.155:8080/sjzdbmService + +#\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdURL +webservice.data.code.url=http://10.55.0.155:8080/sjmbService + +#webservice\ufffd\u04ff\ufffd\ufffd\ufffd\ufffd\u00ff\u04b3\ufffd\ufffd\ufffd\ufffd +webservice.data.pagesize = 2000 +#webservice\ufffd\ufffd\u01f0\u012c\ufffd\ufffd\u04b3 +webservice.data.currentpage = 1 + +#webservice \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd +webservice.jgmb.name=CK_T_JC_RY +#webservice \ufffd\u00fb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd +webservice.yhmb.name=CK_T_YH_RY +#webservice\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \u022b\ufffd\ufffd +webservice.method.name.ql=getData +# webservice\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd +webservice.method.name.zl=getDataZL + +# redis\u914d\u7f6e\u6587\u4ef6 +#redis \u5404\u4e2a\u5206\u7247\u7684 IP\u7aef\u53e3 +redis.cluster.host_port=10.0.6.32:6379,10.0.6.32:6380,10.0.6.32:6381,10.0.6.33:6379,10.0.6.33:6380,10.0.6.33:6381 + + +#\u4e2d\u5fc3\u73b0\u573aredis\u5730\u5740\u548c\u7aef\u53e3 +#redis.cluster.host_port=10.174.196.33:6379,10.174.196.33:6380,10.174.196.33:6381,10.174.196.34:6379,10.174.196.34:6380,10.174.196.34:6381,10.174.196.35:6379,10.174.196.35:6380,10.174.196.35:6381,10.174.196.36:6379,10.174.196.36:6380,10.174.196.36:6381,10.174.196.37:6379,10.174.196.37:6380,10.174.196.37:6381,10.174.196.38:6379,10.174.196.38:6380,10.174.196.38:6381,10.174.196.39:6379,10.174.196.39:6380,10.174.196.39:6381 + +redis.cluster.connectiontimeout=5000 +redis.cluster.sotimeout=5000 +redis.cluster.maxattempts=3 +#redis\u8fde\u63a5\u6c60\u76f8\u5173\u914d\u7f6e + +redis.pool.maxtotal=500 + +redis.pool.maxidle=500 +redis.pool.maxwaitmillis=-1 +redis.pool.blockwhenexhausted=true +redis.pool.numtestsperevictionrun=60000 +redis.pool.testonborrow=true +redis.pool.testonreturn=false +redis.pool.testwhileidle=true +redis.pool.timebetweenevictionrunsmillis=60000 +redis.pool.minevictableidletimemillis=60000 +#oracle\u6570\u636eredis\u5b58\u50a8\u65f6\u95f4(\u79d2\u4e3a\u5355\u4f4d \u9ed8\u8ba43\u5206\u949f\u5373180s) +oracleExpire=180 +#hive\u6570\u636e\u4e2d\u5fc3\u6570\u636eredis\u5b58\u50a8\u65f6\u95f4(\u79d2\u4e3a\u5355\u4f4d \u9ed8\u8ba420\u5206\u949f\u53731200s) +hiveExpire=300 +#redis\u5f00\u5173 +isOpenRedis=false +#\u662f\u5426\u5c06\u6570\u636e\u4e2d\u5fc3\u7684\u65e5\u5fd7\u52a0\u5165\u5230redis\u4e2d +dataCenterOpenRedis=true +#\u8de8\u57df\u95ee\u9898\u5141\u8bb8 \u7684url Access-Control-Allow-Origin *\u5141\u8bb8\u6240\u6709\uff0c\u8bbe\u7f6e\u6210\u5176\u4ed6url\u53ea\u5141\u8bb8\u8be5url.\u4e0d\u80fd\u8bbe\u7f6e\u591a\u4e2aurl +target_url=* +#\u8de8\u57df\u95ee\u9898 3600\uff1a\u8868\u660e\u57283600\u79d2\u5185\uff0c\u4e0d\u9700\u8981\u518d\u53d1\u9001\u9884\u8bf7\u6c42\uff0c\u53ef\u4ee5\u7f13\u5b58\u8be5\u7ed3\u679c +ACCESS_CONTROL_MAX_AGE=3600 +##########HTTPCLIENT POOL START################### +#\u4ece\u8fde\u63a5\u6c60\u4e2d\u83b7\u53d6\u5230\u8fde\u63a5\u7684\u6700\u957f\u65f6\u95f4 +http.request.connectionRequestTimeout=500 +#5000 +http.request.connectTimeout=5000 +#\u6570\u636e\u4f20\u8f93\u7684\u6700\u957f\u65f6\u95f4 +http.request.socketTimeout=30000 +#\u63d0\u4ea4\u8bf7\u6c42\u524d\u6d4b\u8bd5\u8fde\u63a5\u662f\u5426\u53ef\u7528 +http.request.staleConnectionCheckEnabled=true + +#\u8bbe\u7f6e\u8fde\u63a5\u603b\u6570 +http.pool.maxTotal=200 +#\u8bbe\u7f6e\u6bcf\u4e2a\u5730\u5740\u7684\u5e76\u53d1\u6570 +http.pool.defaultMaxPerRoute=100 +##########HTTPCLIENT POOL END################### +search.dateformat=yyyy-MM-dd HH:mm:ss +search.eshostandport_A=10.0.6.115:9200 +search.eshostandport_B=10.0.6.115:9200 +search.eshostandport_C=10.0.6.115:9200 + +#search.eshostandport=10.174.196.135:9200 + + +#\u65e5\u5fd7\u662f\u5426\u4ecehive\u4e2d\u67e5\u8be2 +selFromHive=false + +#\u662f\u5426\u83b7\u53d6\u6570\u636e\u4e2d\u5fc3\u67e5\u8be2\u8bb0\u5f55\u7684\u603b\u6761\u6570 +isGetHiveCount=false + +#\u6bcf\u6b21\u83b7\u53d6\u6570\u636e\u4e2d\u5fc3\u591a\u5c11\u6761\u6570\u636e,\u54b1\u4eec\u5728\u5bf9\u83b7\u53d6\u7684\u6570\u636e\u8fdb\u884c\u5206\u9875\u5904\u7406 +everyGetHiveDataNum=10000 + +#oracle\u6570\u636e\u5e93\u6709\u95ee\u9898\u4e0d\u4eceoracle\u67e5\u8be2\u6570\u636e,\u6240\u6709\u65e5\u5fd7\u6570\u636e\u5747\u4ece\u6570\u636e\u4e2d\u5fc3\u67e5\u8be2 +onlySelFromHive=false + +#\u662f\u5426\u67e5\u8be2\u795e\u901a\u6570\u636e\u5e93 +isSelectCluster=true + +#\u7528\u6237\u67e5\u8be2\u65e5\u5fd7\u8d85\u8fc7\u591a\u5c11\u5c0f\u65f6\u53bb\u6570\u636e\u4e2d\u5fc3\u67e5\u8be2 +dataCenterTime=48 + +#\u662f\u5426\u5f00\u542f\u57fa\u7840\u9a8c\u8bc1 +baseValidate=true + +#\u662f\u5426\u5f00\u542f\u4e1a\u52a1\u9a8c\u8bc1 +serviceValidate=true + + + +#\u65e5\u5fd7\u5b58\u50a8\u672c\u5730\u65f6\u95f4(\u5355\u4f4d\u5c0f\u65f6) +logLocalTime=48 +#\u5b9e\u65f6\u7edf\u8ba1\u9ed8\u8ba4\u67e5\u8be2\u672c\u5730\u4e00\u4e2a\u5c0f\u65f6\u7684\u6570\u636e(\u5355\u4f4d\uff1a\u5c0f\u65f6) +reportLocalTime=1 + +#\u795e\u901a\u6570\u636e\u5e93\u6700\u65e9\u65e5\u5fd7\u65f6\u95f4(A\u7248\u6beb\u79d2) +#2017-08-13 10:07:25 +clusterAStartTime=1503504000725 +#\u795e\u901a\u6570\u636e\u5e93\u6700\u65e9\u7ed3\u675f\u65f6\u95f4(B\u7248\u6beb\u79d2) +#2017-08-13 10:07:25 +clusterBStartTime=1503504000725 +############################################################################################################################################ +#\u8bbe\u7f6e\u914d\u7f6e\u662f\u5426\u5165\u5e93 +############################################################################################################################################ +isCommit=true +############################################################################################################################################ +############################################################################################################################################ +httpUrl=http://192.168.10.204:9999/galaxy-service/service/cfg/ +maatCfg=v1/configSources +fileUploadCfg=v1/fileUploadSources +callbackCfg=v1/commonSources +fileDigestCfg=v1/fileDigestSources +configIdSources=v1/configPzIdSources +#logBaseUrl=http://10.0.6.242:8080/galaxy-service/service/log/v1/ +logBaseUrl=http://192.168.10.204:9999/galaxy-service/service/log/ +ntcPzReport=v1/ntcPzReport +ntcServiceReport=v1/ntcServiceReport +ntcTagReport=v1/ntcTagReport +ntcAttrTypeReport=v1/ntcAttrTypeReport +ntcLwhhReport=v1/ntcLwhhReport +ntcSrcipDomesticReport=v1/ntcSrcipDomesticReport +ntcDestipCountryReport=v1/ntcDestipCountryReport +ntcEntranceReport=v1/ntcEntranceReport +ntcIpLog=v1/ntcIpLogs +ntcBgpLog=v1/ntcBgpLogs +ntcP2pLog=v1/ntcP2pLogs +ntcHttpLog=v1/ntcHttpLogs +ntcDnsLog=v1/ntcDnsLogs +ntcSslLog=v1/ntcSslLogs +ntcPptpLog=v1/ntcPptpLogs +ntcL2tpLog=v1/ntcL2tpLogs +ntcOpenvpnLog=v1/ntcOpenvpnLogs +ntcIpsecLog=v1/ntcIpsecLogs +ntcSshLog=v1/ntcSshLogs +ntcMailLog=v1/ntcMailLogs +ntcFtpLog=v1/ntcFtpLogs +ntcAppLog=v1/ntcAppLogs +ntcDdosLog=v1/ntcDdosLogs +dkBehaviorLog=v1/ntcAppLogs +mmVoipLog=v1/ntcVoipLogs +mmAvIpLog=v1/mmAvIpLogs +mmAvUrlLog=v1/mmAvUrlLogs +mmPicIpLog=v1/mmPicIpLogs +mmPicUrlLog=v1/mmPicUrlLogs +mmVoipIpLog=v1/ntcVoipLogs +mmVoipAccountLog=v1/mmVoipAccountLogs +mmSampleAudioLog=v1/mmSampleAudioLogs +mmSampleVideoLog=v1/mmSampleVideoLogs +mmPornAudioLevelLog=v1/mmPornAudioLevelLogs +mmPornVideoLevelLog=v1/mmPornVideoLevelLogs +mmSamplePicLog=v1/mmSamplePicLogs +mmSampleVoipLog=v1/mmSampleVoipLogs +pxyHttpLog=v1/pxyHttpLogs +mmSpeakerRecognizationLog=v1/mmSpeakerRecognizationLogs +mmLogoDetectionLog=v1/mmLogoDetectionLogs +mmFaceRecognizationLog=v1/mmFaceRecognizationLogs +######################################## +#\u5927\u5c4f\u56fe\u8868\u5c55\u793a\u670d\u52a1\u63a5\u53e3 +dashboardUrl=http://192.168.10.204:9999/galaxy-service/service/log/ +trafficIpActive=v1/trafficIpActive +trafficProtocol=v1/trafficProtocol +trafficApp=v1/trafficApp +trafficOsList=v1/trafficOsList +trafficBrowserChart=v1/trafficBrowserChart +trafficBsList=v1/trafficBsList +trafficSystemChart=v1/trafficSystemChart +trafficWebsiteList=v1/trafficWebsiteList +trafficWebTypeChart=v1/trafficWebTypeChart +trafficPortActive=v1/trafficPortActive +trafficTopicAndDomainChart=v1/trafficTopicAndDomainChart +ntcTotalReport=v1/ntcTotalReport +trafficIpActiveFiveMinute=v1/trafficIpActiveFiveMinute +trafficIpActiveOneHour=v1/trafficIpActiveOneHour + +client_connect_timeout=300000 +client_read_timeout=300000 +log_time_interval=300000 +logsearch_menu_id=152 +#use elasticsearch or not# +isUseES=false + +#httpclient \u5de5\u5177\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4 +http_socket_timeout=300000 +http_connect_timeout=10000 +http_connect_request_timeout=50000 +http_connect_retry_times=3 + + +#\u6570\u636e\u4e2d\u5fc3A\u7248\u6570\u636e\u5e93\u540d\u79f0,\u7a0b\u5e8f\u4e2d\u6bcf\u6b21\u67e5\u8be2\u65f6\u4f7f\u7528\u7684\u6570\u636e\u5e93\u540d\u79f0 use dbA +jdbc.hive.AName=xa_dfbhit_hive +#\u6570\u636e\u4e2d\u5fc3B\u7248\u6570\u636e\u5e93\u540d\u79f0 +jdbc.hive.BName=xa_z2_mesalog_hive + +maxPageSize=100000 +#\u5bfc\u51fa\u6700\u5927\u6761\u6570 +maxExportSize=5000 +#\u5141\u8bb8\u914d\u7f6e\u6700\u5927\u5c42\u7ea7 +maxLevelNo=4 +#\u4e0a\u4e0b\u7ea7\u663e\u793a\u95f4\u9694\u6807\u8bc6\u7b26 +childrenMark=. +#\u4e1a\u52a1\u5b57\u5178\u5728\u8bcd\u5178\u4e2d\u7684\u6807\u8bc6 +SERVICE_DICT_ITM_TYPE=SERVICE_DICT_ITM_TYPE +#\u7cfb\u7edf\u5b57\u5178\u5728\u8bcd\u5178\u4e2d\u7684\u6807\u8bc6 +SYS_DICT_ITM_TYPE=SYS_DICT_ITM_TYPE +area_region=NTC_IP_RANGE +protocol_num_region=NTC_UNIVERSAL_PROTO_TYPE +http_ip_region=NTC_UNIVERSAL_IP +http_req_hdr_region=NTC_HTTP_REQ_HDR +http_req_body_region=NTC_HTTP_REQ_BODY +http_res_hdr_region=NTC_HTTP_RES_HDR +http_res_body_region=NTC_HTTP_RES_BODY +ntc_subscribe_id=NTC_SUBSCRIBE_ID +http_url_region=NTC_HTTP_URL +http_redirect_url_region=PXY_CTRL_HTTP_URL +http_redirect_req_hdr_region=PXY_CTRL_HTTP_REQ_HDR +http_redirect_res_hdr_region=PXY_CTRL_HTTP_RES_HDR +http_redirect_req_body_region=PXY_CTRL_HTTP_REQ_BODY +http_redirect_res_body_region=PXY_CTRL_HTTP_RES_BODY +http_redirect_ip_region=PXY_CTRL_IP +p2p_hash_bin_region=NTC_P2P_HASH_BIN +p2p_keywords_region=NTC_P2P_KEYWORDS +voip_ip=av_voip_ip +voip_account=av_voip_account +ssl_sni_region=ssl_sni +ssl_san_region=ssl_san +ssl_ca_region=ssl_ca +ssl_ip_region=ssl_ip +bgp_ip_region=bgp_ip +behav_id_region=BEHAV_ID +rate_limit_region=Droprate +#\u5b58\u5728\u4e0e\u8868\u8fbe\u5f0f\u7684\u5173\u952e\u5b57\u7279\u6b8a\u5206\u9694\u7b26 +keyword_expr=***and*** +#\u65f6\u533a +time_zone=8 +#\u9700\u8981\u7279\u6b8a\u5904\u7406\u7684\u4e1a\u52a1\u7c7b\u578b +service_pxy_domain_intercept=513 +service_ip_mulitiplex=768 +service_ip_ratelimit=1057 +service_domain_ratelimit=1058 +#\u7528\u6237\u81ea\u5b9a\u4e49\u57df +userregion_rate_limit=Droprate +userregion_ir_strategy=IR_STRATEGY +userregion_ir_type=IR_TYPE +userregion_domain_id=DOMAIN_ID +userregion_domain_str=DOMAIN_STR +userregion_replace_type_key=zone +userregion_replace_req_key_value=http_req_body +userregion_replace_res_key_value=http_res_body +userregion_replace_regex_key=regex +#\u7528\u6237\u81ea\u5b9a\u4e49\u57df\u5360\u4f4d\u7b26 +user_region_placeholder=0 +#\u7528\u6237\u81ea\u5b9a\u4e49\u57df\u5206\u9694\u7b26 +user_region_split=; +#IP\u76f8\u5173\u9a8c\u8bc1\u6b63\u5219 +ipv4_ip_subnet_regexp=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)/(3[0-2]|1[6-9]|2[0-9])$ +ipv6_ip_subnet_regexp=^((::)|(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))/([2-9]|[1-9][0-9]|1[0-2][0-8])$ +ipv4_ip_range_regexp=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)-(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$ +ipv6_ip_range_regexp=^((::)|(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))-((::)|(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))$ +ipv4_ip_regexp=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$ +ipv6_ip_regexp=^((::)|(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))$ +#\u91cd\u5b9a\u5411\u4e1a\u52a1\u81ea\u5b9a\u4e49\u57df\u76f8\u5173\u53c2\u6570 +redirect_response_code_key=code +redirect_url_key=url +redirect_content_key=content +redirect_response_code_startwith=30 +replace_zone_key=zone +replace_substitute_key=substitute +#\u6837\u4f8b\u6587\u4ef6\u4e0a\u4f20\u7684uri\u5173\u952e\u8bcd +sample_upload_url_keyword=/av +digest_upload_url_keyword=/filetransfer +cert_upload_url_keyword=/intercept/strateagy + +#sample File Size 100M +sample_total_file_max_size=104857600 +#audio File Types +audio_file_type=,mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm,wav,mp3, +#audio File Size 100M 10485760\uff08single\uff09 +audio_single_file_max_size=0 +#speaker File Types \u8bf4\u8bdd\u4eba\u8bc6\u522b\u6587\u4ef6\u7c7b\u578b +speaker_file_type= +#audio File Size 100M 10485760\uff08single\uff09 +speaker_single_file_max_size=0 +#video File Types +video_file_type=,mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm,ogv, +#video File Size 10M 10485760\uff08single\uff09 +video_single_file_max_size=0 +#face File Types \u4eba\u8138\u8bc6\u522b +face_file_type= +#face File Size 10M 10485760\uff08single\uff09 +face_single_file_max_size=0 +#picture File Types +picture_file_type= +#picture File Size 100M 10485760\uff08single\uff09 +picture_single_file_max_size=104857600 +#logo File Types \u53f0\u6807\u8bc6\u522b +logo_file_type= +#logo File Size 100M 10485760\uff08single\uff09 +logo_single_file_max_size=104857600 +#voip File Types +voip_file_type=,mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm,ogv,wav,mp3, +#voip File Size 10M 10485760\uff08single\uff09 +voip_single_file_max_size=0 + +#digest File Types +digest_file_type= +#digest File Size 100M 10485760\uff08single\uff09 +digest_single_file_max_size=104857600 +#digest File Size 100M 12582912\uff08total\uff09 +digest_total_file_max_size=104857600 +#cert File Size 100M 12582912\uff08total\uff09 +cert_total_file_max_size=104857600 +#public File Types +public_file_type= +#public File Size 100M 10485760\uff08single\uff09 +public_single_file_max_size=104857600 +#private File Types +private_file_type= +#private File Size 100M 10485760\uff08single\uff09 +private_single_file_max_size=104857600 +#YSP\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84 +av_file_path=/home/ysp/ +#av_file_path=D\:\\ysp\\ +#YSP\u6587\u4ef6\u7279\u5f81\u7c7b\u578b +av_sample_audio_region=av_sample_audio +av_sample_video_region=av_sample_video +av_sample_picture_region=av_sample_picture +av_sample_voip_region=av_sample_voip +mm_speaker_recognization_region=MM_SPEAKER_RECOGNIZATION +mm_logo_detection_region=MM_LOGO_DETECTION +mm_face_recognization_region=MM_FACE_RECOGNIZATION + +#\u6837\u4f8b\u6587\u4ef6\u751f\u6210\u7a0b\u5e8f +audio_sample_create_proc=/home/ceiec/av_feature_gen/audio_convert_proc +video_sample_create_proc=/home/ceiec/av_feature_gen/extract_frame_feature +picture_sample_create_proc=/home/ceiec/av_feature_gen/picture_convert_proc +speaker_sample_create_proc=java -jar /home/sampleTest.jar +logo_sample_create_proc=/home/ceiec/av_feature_gen/logo_convert_proc +face_sample_create_proc=/home/ceiec/av_feature_gen/face_convert_proc +audio_sample_proc_param_is_quotation=true +video_sample_proc_param_is_quotation=true +picture_sample_proc_param_is_quotation=true +speaker_sample_proc_param_is_quotation=true +logo_sample_proc_param_is_quotation=true +face_sample_proc_param_is_quotation=true +audio_sample_proc_param_is_translation=false +video_sample_proc_param_is_translation=false +picture_sample_proc_param_is_translation=false +speaker_sample_proc_param_is_translation=false +logo_sample_proc_param_is_translation=false +face_sample_proc_param_is_translation=false +#\u672c\u5730\u6d4b\u8bd5 +#audio_sample_create_proc=java -jar D\:\\sampleTest.jar +#video_sample_create_proc=java -jar D\:\\sampleTest.jar +#picture_sample_create_proc=java -jar D\:\\sampleTest.jar +#speaker_sample_create_proc=java -jar D\:\\sampleTest.jar +#logo_sample_create_proc=java -jar D\:\\sampleTest.jar +#face_sample_create_proc=java -jar D\:\\sampleTest.jar +#audio_sample_proc_param_is_quotation=false +#video_sample_proc_param_is_quotation=false +#picture_sample_proc_param_is_quotation=false +#speaker_sample_proc_param_is_quotation=false +#logo_sample_proc_param_is_quotation=false +#face_sample_proc_param_is_quotation=false +#audio_sample_proc_param_is_translation=true +#video_sample_proc_param_is_translation=true +#picture_sample_proc_param_is_translation=true +#speaker_sample_proc_param_is_translation=true +#logo_sample_proc_param_is_translation=true +#face_sample_proc_param_is_translation=true +#http\u81ea\u5b9a\u4e49\u57df\u76f8\u5173\u53c2\u6570 +http_header_user_region_key=HTTP_HEADER +http_header_dict_module=HTTP_HEADER_DISTRICT +#dns\u81ea\u5b9a\u4e49\u57df\u53c2\u6570key +dns_strategy_user_region_key=DNS_STRATEGY +#p2p\u81ea\u5b9a\u4e49\u57dfkey +p2p_ip_type_user_region_key=P2P_IP_TYPE +p2p_hash_type_user_region_key=P2P_HASH_TYPE +#\u7279\u5b9a\u670d\u52a1\u7c7b\u522b +specific_service_cfg_type_app=social_app +specific_service_cfg_type_encrypted_tunnel_behavior=encrypted_tunnel_behavior +specific_service_cfg_type_basic_protocol=basic_protocol +#\u57fa\u7840\u534f\u8bae\u81ea\u5b9a\u4e49\u57df +proto_id_region=PROTO_ID +#\u62e6\u622aIP\u81ea\u5b9a\u4e49\u57dfkey +keyring_id=keyring_id +droprate=Droprate +bandwidth=Bandwidth +intercept_domain_intensity=DOMAIN_INTENSITY +#IP\u9ed8\u8ba4\u503c +ipv4_default_ip_value=0.0.0.0 +ipv6_default_ip_value=\:\: +ipv4_default_ip_subnet_value=0.0.0.0/16 +ipv6_default_ip_subnet_value=::/128 +ipv4_default_ip_range_value=0.0.0.0-1 +ipv6_default_ip_range_value=::-:: +#\u7aef\u53e3\u9ed8\u8ba4\u503c +port_default=0 +port_mask_default=0/65535 +#MAAT CFG \u4e00\u4e9b\u9ed8\u8ba4\u503c +maat_cfg_dolog_default=2 +maat_cfg_dolog_doblacklist_default=1 +maat_cfg_dolog_configpercent_default=100 +maat_cfg_dolog_configoption_default=1 +#app\uff0c\u57fa\u7840\u534f\u8bae\uff0c\u7279\u5b9a\u670d\u52a1\u7684userregion\u5206\u9694\u7b26 +app_cfg_userregion_splitor=& +app_id_region=APP_ID +#application spec service code scope +app_spec_service_code_max_val=310000 +app_spec_service_code_min_val=300001 +groupReuseSources=v1/groupReuseSources +log_time_range=300000 +log_time_start=2018-08-01 00:00:00 +log_time_end=2018-10-01 00:00:00 +area_tag=location +isp_tag=isp +mmFileDigestLog=v1/mmFileDigestLogs +ntcStreamMediaLog=v1/ntcStreamMediaLogs +#\u97f3\u89c6\u9891\u6837\u4f8b\u9650\u5236\u65f6\u957f\uff0c\u5355\u4f4d\u79d2 +av_duration_limit=120 +video_to_picture_proc=/home/ceiec/av_feature_gen/save_video_frame +#\u8bc1\u4e66\u6587\u4ef6\u8def\u5f84 +cert_file_path=/home/cert/ +#\u8bc1\u4e66\u6821\u9a8c\u5de5\u5177\u540d\u79f0 +cert_validate_file=x509 +#\u8bc1\u4e66\u6821\u9a8c\u6210\u529f\u7684\u5173\u952e\u4fe1\u606f +cert_validate_success_info=Successful +#ipv4 range\u65b0\u683c\u5f0f0.0.0.1-2 +ipv4_ip_range_regexp_new=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)-(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$ +ipv4_ip_subnet_regexp_original=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)/(3[0-2]|1[0-9]|2[0-9]|[0-9])$ +#\u57df\u540d\u9a8c\u8bc1\u6b63\u5219 +domain_regexp=^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$ +#IP\u590d\u7528maat json\u4e2d\u7684ip region\u5355\u6b21send \u6700\u5927\u4e2a\u6570 +maat_json_send_size=20000 +#\u5bfc\u5165\u9a8c\u8bc1\u7684\u7ebf\u7a0b\u6570\u91cf +mulity_thread_size=5 +ntcRadiusReport=v2/ntcRadiusReport +ntcCollectVoipLog=v1/ntcCollectVoipLogs +ntcKeywordsUrlLog=v1/ntcKeywordsUrlLogs +save_and_del_thread_size=20 +#mysql \u5355\u4e2asql\u5927\u5c0f\u9650\u5236,\u6839\u636emariadb\u76f8\u5173\u53c2\u6570\u914d\u7f6e +max_allowed_packet=1048576 +#http client\u8fde\u63a5\u6c60\u76f8\u5173\u53c2\u6570\uff0chttp_max_connection:\u6700\u5927\u8fde\u63a5\u6570\uff0cdefault_max_perroute:\u6bcf\u4e2a\u4e3b\u673a\u5730\u5740\u7684\u5e76\u53d1\u6570\uff0cpoolcm_socket_timeout:socket\u8d85\u65f6\u65f6\u95f4 +http_max_connection=1000 +default_max_perroute=100 +poolcm_socket_timeout=3000 +app_vignore_user_region_key=DKC +#policies\u83dc\u5355\u7684\u83dc\u5355ID +policies_menu_id=86 +userCreate=UserCreate +userPasswordSet=UserPasswordSet +userDelete=UserDelete +userGet=UserGet +userList=UserList +ip_reuse_call_cgi_url=http://10.4.10.32:8090/command +ipNumGet=IpNumGet +allIpGet=AllIpGet +#\u6d41\u91cf\u7edf\u8ba1\u5e26\u5bbd\u8be6\u60c5 +trafficBandwidthTrans=v1/trafficBandwidthTrans +trafficProtocolList=v1/trafficProtocolList +irSnatLog=v1/irSnatLogs +irDnatLog=v1/irDnatLogs +trafficBandwidthTrans=v1/trafficBandwidthTrans +trafficProtocolList=v1/trafficProtocolList +trafficAppList=v1/trafficAppList +ntcActionEntranceReport=v1/ntcActionEntranceReport +redis.host=192.168.10.192:6379 +redis.expire=1800 +redis.timeout=10000 +dns_spoofing_ip_desc=Default Spoofing IP +dns_spoofing_ip_ip=1.1.1.1 +trafficBandwidthTransTwo=v1/trafficBandwidthTransTwo +trafficBandwidthTransThree=v1/trafficBandwidthTransThree +trafficBandwidthTransFour=v1/trafficBandwidthTransFour +ntcCollectRadiusLog=v1/ntcCollectRadiusLogs +ntcConnRecordLog=v1/ntcConnRecordLogs +ntcConnRecordPercent=v1/ntcConnRecordPercent +#\u5bfc\u51fa\u6700\u5927\u6761\u6570 +maxLogExportSize=2000 +pxy_crtl_subscribe_id_region=PXY_CTRL_SUBSCRIBE_ID +ntc_subscribe_id_region=NTC_SUBSCRIBE_ID +ntcAsnRecord=v1/ntcAsnRecord +ntcURLReport=v1/ntcURLReport +ntcIpRangeReport=v1/ntcIpRangeReport +trafficWebsiteListNoTime=v1/trafficWebsiteListNoTime +trafficTopicList=v1/trafficTopicList +trafficDomainTrans=v1/trafficDomainTrans +#maximum number to import +import_limit=10000 +trafficPortActiveFiveMinute=v1/trafficPortActiveFiveMinute +trendTotalReport=v1/trendTotalReport +#\u4e8b\u4ef6\u76d1\u6d4b/\u5c01\u5835 +ntcEventsMonitorOrBlock=v1/ntcEventsMonitorOrBlock +#\u91cd\u70b9\u4fdd\u969c\u4e8b\u4ef6 +ntcEventKeyProtection=v1/ntcEventKeyProtection +dashboardUrlV2=http://192.168.10.204:9999/galaxy-service/service/log/v2/ +trafficAreaStat=v1/trafficAreaStat +logServiceTopn=v1/logServiceTopn +blockAndDropStat=v1/blockAndDropStat +#\u914d\u7f6e\u542f\u505c\u63a5\u53e3 +configStartStop=v2/configStartStop +trafficAppTrend=v1/trafficAppTrend +appConnRecordTop100=v1/appConnRecordTop100 +#SSL\u6cdb\u6536 +ntcSslRecordLog=v1/ntcSslRecordLogs +ntc_asn_number=NTC_ASN_NUMBER +addRegionToCommonGroup=v1/addRegionToCommonGroup +updateRegionToCommonGroup=v1/updateCommonGroupRegion +deleteRegionToCommonGroup=v1/delCommonGroupRegion + diff --git a/src/main/webapp/WEB-INF/views/help.jsp b/src/main/webapp/WEB-INF/views/help.jsp index cd35fa574..a1669ef8f 100644 --- a/src/main/webapp/WEB-INF/views/help.jsp +++ b/src/main/webapp/WEB-INF/views/help.jsp @@ -4,9 +4,10 @@ + - + @@ -63,9 +110,10 @@ function showHelp(helpHref) {
-
- +
+
+
diff --git a/src/main/webapp/online-help/app/DNS_feature_advance.md b/src/main/webapp/online-help/app/DNS_feature_advance.md new file mode 100644 index 000000000..82863a14f --- /dev/null +++ b/src/main/webapp/online-help/app/DNS_feature_advance.md @@ -0,0 +1,22 @@ +#### [1.功能简介](#accordion1_1) + +用户自定义DNS协议特征,为特定应用添加DNS协议的特征。 + +#### [2.基础配置信息](#accordion1_2) + +* 社交应用:用户选择APP。 +* 配置描述:用户自定义该条配置的描述信息。 + +#### [3.配置约束条件](#accordion1_3) + +* 匹配区域:只支持DNS_NAME。 +* 关键字:添加1个DNS请求域名(只能添加1个),最长1024个字符。 +* 匹配方式:包含子串匹配、左匹配、有匹配和完全匹配。 +* 是否十六进制:若关键字填写十六进制格式的DNS请求域名,选择十六进制,否则为非十六进制。 +* 表达式类型:分为“无表达式”和“与表达式”,“无表达式”可以和任意一种匹配方式组合使用,“与表达式”只能和子串匹配组合使用。 + +#### [4.预期效果](#accordion1_4) + +将该DNS特征添加给了指定的APP,如用户产生具有该特征的数据,会有如下效果。* 若用户下发该APP阻断配置,该DNS被阻断,若用户选择生成日志,会有该APP的阻断日志。 +* 若用户下发该APP监视配置,DNS请求正常工作,若用户选择生成日志,会有该APP的监视日志。 +* 若用户下发该APP限速配置,户会感知DNS响应变差,若用户选择生成日志,会有该APP的限速日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/app/HTTP_feature_advance.md b/src/main/webapp/online-help/app/HTTP_feature_advance.md new file mode 100644 index 000000000..87c7f08c5 --- /dev/null +++ b/src/main/webapp/online-help/app/HTTP_feature_advance.md @@ -0,0 +1,33 @@ +#### [1.功能简介](#accordion1_1) + +用户自定义HTTP协议特征,为特定应用添加HTTP协议的特征。 + +#### [2.基础配置信息](#accordion1_2) + +* 社交应用:用户选择APP。 +* 配置描述:用户自定义该条配置的描述信息。 + +#### [3.配置约束条件](#accordion1_3) + +APP HTTP特征限制条件: + +* 匹配区域:选择具体的HTTP特征,包括请求包的特征和应答包的特征。 +* 关键字:可填多个关键字,最长1024个字符,用回车键分割。 +* 匹配方式:包含子串匹配、左匹配、有匹配和完全匹配。 +* 表达式类型:分为“无表达式”和“与表达式”,“无表达式”可以和任意一种匹配方式组合使用,“与表达式”只能和子串匹配组合使用。 +* 是否十六进制:若关键字填写十六进制格式的特征,选择十六进制,否则为非十六进制。 + +IP范围特征限制条件: + +* IP类型:可选IPV4或IPV6。 +* IP格式:可选IP、IP范围和IP/子网掩码。 +* 目的IP:IP格式选择“IP”,该文本框填合法的单个IP;IP格式选择“IP范围”,IP段只能配置x.x.x.0-x.x.x.255;IP/子网掩码中子网掩码值限制为16-32。 +* 目的端口:端口与端口掩码范围是0-65535。 +* 协议:可选TCP、UDP、全部。全部表示TCP或UDP。 +* 可为一个应用添加最多3个APP HTTP特征和1个IP范围特征。当同时满足APP HTTP特征和IP范围特征时,该配置才生效。 + +#### [4.预期效果](#accordion1_4) + +将该HTTP特征添加给了指定的APP,如用户产生具有该特征的数据,会有如下效果。* 若用户下发该APP阻断配置,请求该HTTP请求被阻断,若用户选择生成日志,会有该APP的阻断日志。 +* 若用户下发该APP监视配置,HTTP请求正常工作,若用户选择生成日志,会有该APP的监视日志。 +* 若用户下发该APP限速配置,户会感知HTTP响应变差,若用户选择生成日志,会有该APP的限速日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/app/IP_feature_advance.md b/src/main/webapp/online-help/app/IP_feature_advance.md new file mode 100644 index 000000000..1477bfdc0 --- /dev/null +++ b/src/main/webapp/online-help/app/IP_feature_advance.md @@ -0,0 +1,22 @@ +#### [1.功能简介](#accordion1_1) + +用户自定义IP特征,为特定应用添加IP的特征。 + +#### [2.基础配置信息](#accordion1_2) + +* 社交应用:用户选择APP。 +* 配置描述:用户自定义该条配置的描述信息。 + +#### [3.配置约束条件](#accordion1_3) + +* IP类型:可选IPV4或IPV6。 +* IP格式:可选IP、IP范围和IP/子网掩码。 +* 目的IP:IP格式选择“IP”,该文本框填合法的单个IP;IP格式选择“IP范围”,IP段只能配置x.x.x.0-x.x.x.255;IP/子网掩码中子网掩码值限制为16-32。 +* 目的端口:端口与端口掩码范围是0-65535。 +* 协议:可选TCP、UDP、全部。全部表示TCP或UDP。 + +#### [4.预期效果](#accordion1_4) + +将该IP特征添加给了指定的APP,并产生了该特征的数据流量,有如下效果。* 若用户下发该APP阻断配置,无法连接到该IP地址; +* 若用户下发该APP监视配置,IP请求正常工作,若用户选择生成日志,会有该APP的监视日志。 +* 若用户下发该APP限速配置,户会感知响应变差,若用户选择生成日志,会有该APP的限速日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/app/app.md b/src/main/webapp/online-help/app/app.md new file mode 100644 index 000000000..dd8a43bac --- /dev/null +++ b/src/main/webapp/online-help/app/app.md @@ -0,0 +1,43 @@ +#### [1.功能简介](#accordion1_1) + +APP的识别和管控,配置指定APP的封堵、监视、限速功能界面。 + +#### [2.基础配置信息](#accordion1_2) + +* 配置描述:用户自定义该条配置的描述信息。 +* 是否记录日志:是否生成日志信息。 +* 社交应用:选择管控的应用。 +* 行为类型:选择管控具体行为类型。可选项,不选则对该应用的所有行为进行管控。 +* 执行动作:APP有3种管控动作:阻断、监视和限速。若选择监视,用户需指定客户端IP。若选择限速,用户需指定限速比例。 + +#### [3.配置约束条件](#accordion1_3) + +IP类配置,当执行动作选择“监视”,必须填写对应的IP配置。 + +* IP类型:IPV4或IPV6。 +* 协议:可选TCP、UDP和全部。 +* IP格式:可选IP、IP范围和IP/子网掩码。 +* 源IP:IP格式选择“IP”,该文本框填合法的单IP;IP格式选择“IP范围”,IP段只能配置x.x.x.0-x.x.x.255;IP/子网掩码中子网掩码值限制为16-32。 +* 源端口:端口与端口掩码范围是0-65535。 +* 目的IP:限制同源IP。 +* 目的端口:端口与端口掩码范围是0-65535。 +* 另:源IP与目的IP不能相同 + +#### [4.配置生效范围](#accordion1_4) + +配置生效范围,分为“全部”和“选择区域”。“全部”指所有地区;“选择区域”需选择区域和运营商,并且可以同时选择多个区域和多个运营商,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:选择来函文件类型,必选项; +* 类型:指明该配置的类型,可同时选多个,比如信息内容安全、网络攻击等,非必选项; +* 性质:指明该配置的性质,可同时选多个,比如政治事务、暴力恐怖等,非必选项; +* 用户标签:用户自定义标签,可同时选多个,非必选项; + +#### [6.预期效果](#accordion1_7) + +* 执行动作选择“阻断”,未选择行为类型,该APP全部功能无法正常使用;如果选择了行为类型,该APP的对应行为无法正常使用; +* 执行动作选择“监视”,该APP被正常使用。 +* 执行动作选择“限速”,户会感知网速变差,当限速比例高达**时,APP出现无法使用的情况。 +* 若指定了客户端IP,该配置只对该用户生效,其他用户不受影响。 +* 若选择了记录日志,日志界面出现该配置的日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/app/basic_protocol.md b/src/main/webapp/online-help/app/basic_protocol.md new file mode 100644 index 000000000..82785de11 --- /dev/null +++ b/src/main/webapp/online-help/app/basic_protocol.md @@ -0,0 +1,41 @@ +#### [1.功能简介](#accordion1_1) + +基础协议的识别和管控,配置指定协议的封堵、监视界面。 + +#### [2.基础配置信息](#accordion1_2) + +* 配置描述:用户自定义该条配置的描述信息。 +* 是否记录日志:是否生成日志信息。 +* 基础协议:选择管控的协议。 +* 执行动作:基础协议有两种管控动作:阻断、监视。若选择监视,用户需指定客户端IP相关信息。 + +#### [3.配置约束条件](#accordion1_3) + +IP类配置,当执行动作选择“监视”,必须填写对应的IP配置。 + +* IP类型:IPV4或IPV6。 +* 协议:可选TCP、UDP和全部。 +* IP格式:可选IP、IP范围和IP/子网掩码。 +* 源IP:IP格式选择“IP”,该文本框填合法的单IP;IP格式选择“IP范围”,IP段只能配置x.x.x.0-x.x.x.255;IP/子网掩码中子网掩码值限制为16-32。 +* 源端口:端口与端口掩码范围是0-65535。 +* 目的IP:限制同源IP。 +* 目的端口:端口与端口掩码范围是0-65535。 +* 另:源IP与目的IP不能相同 + +#### [4.配置生效范围](#accordion1_4) + +配置生效范围,分为“全部”和“选择区域”。“全部”指所有地区;“选择区域”需选择区域和运营商,并且可以同时选择多个区域和多个运营商,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:选择来函文件类型,必选项; +* 类型:指明该配置的类型,可同时选多个,比如信息内容安全、网络攻击等,非必选项; +* 性质:指明该配置的性质,可同时选多个,比如政治事务、暴力恐怖等,非必选项; +* 用户标签:用户自定义标签,可同时选多个,非必选项; + +#### [6.预期效果](#accordion1_7) + +* 执行动作选择“阻断”,使用该协议的应用全部无法正常使用; +* 执行动作选择“监视”,使用该协议的应用不受影响。 +* 若指定了客户端IP,该配置只对该用户生效,其他用户不受影响。 +* 若选择了记录日志,日志界面出现该配置的日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/app/domain_feature_advance.md b/src/main/webapp/online-help/app/domain_feature_advance.md new file mode 100644 index 000000000..c578da685 --- /dev/null +++ b/src/main/webapp/online-help/app/domain_feature_advance.md @@ -0,0 +1,20 @@ +#### [1.功能简介](#accordion1_1) + +用户自定义域名特征,为特定应用添加域名的特征。 + +#### [2.基础配置信息](#accordion1_2) + +* 社交应用:用户选择APP。 +* 配置描述:用户自定义该条配置的描述信息。 + +#### [3.配置约束条件](#accordion1_3) + +* 域名:填写正确的域名,最长1024字符。 +* 匹配方式:包含子串匹配、左匹配、有匹配和完全匹配。 +* 是否十六进制:若关键字填写十六进制格式的特征,选择十六进制,否则为非十六进制。 + +#### [4.预期效果](#accordion1_4) + +将该域名特征添加给了指定的APP,如用户产生具有该特征的数据,会有如下效果。* 若用户下发该APP阻断配置,请求该域名被阻断,若用户选择生成日志,会有该APP的阻断日志。 +* 若用户下发该APP监视配置,域名请求正常工作,若用户选择生成日志,会有该APP的监视日志。 +* 若用户下发该APP限速配置,户会感知域名响应变差,若用户选择生成日志,会有该APP的限速日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/app/payload_feature_advance.md b/src/main/webapp/online-help/app/payload_feature_advance.md new file mode 100644 index 000000000..071860909 --- /dev/null +++ b/src/main/webapp/online-help/app/payload_feature_advance.md @@ -0,0 +1,34 @@ +#### [1.功能简介](#accordion1_1) + +用户自定义数据包载荷特征,为特定应用添加载荷的特征。 + +#### [2.基础配置信息](#accordion1_2) + +* 社交应用:用户选择APP。 +* 配置描述:用户自定义该条配置的描述信息。 + +#### [3.配置约束条件](#accordion1_3) + +APP载荷类约束条件: + +* 匹配区域:共7类APP载荷特征,分别是:载荷、C2S载荷、S2C载荷,C2S方向包序列,S2C方向包序列,二层头,三层头。 +* 关键字:可填多个关键字,最长1024字符,用回车键分割。 +* 匹配方式:包含子串匹配、左匹配、有匹配和完全匹配。 +* 表达式类型:分为“无表达式”和“与表达式”,“无表达式”可以和任意一种匹配方式组合使用,“与表达式”只能和子串匹配组合使用。 +* 是否十六进制:十六进制的 + +IP类约束条件: + +* IP类型:可选IPV4或IPV6。 +* IP格式:可选IP、IP范围和IP/子网掩码。 +* 目的IP:IP格式选择“IP”,该文本框填合法的单个IP;IP格式选择“IP范围”,IP段只能配置x.x.x.0-x.x.x.255;IP/子网掩码中子网掩码值限制为16-32。 +* 目的端口:端口与端口掩码范围是0-65535。 +* 协议:可选TCP、UDP、全部。全部表示TCP或UDP。 + +可为一个应用添加最多3个APP载荷特征和1个IP范围特征。当同时满足APP载荷特征和IP范围特征时,该配置才生效。 + +#### [4.预期效果](#accordion1_4) + +将该载荷特征添加给了指定的APP,如用户产生具有该载荷特征的数据,会有如下效果。* 若用户下发该APP阻断配置,具有该载荷特征的数据流被阻断,若用户选择生成日志,会有该APP的阻断日志。; +* 若用户下发该APP监视配置,具有该载荷特征的数据正常工作,若用户选择生成日志,会有该APP的监视日志。 +* 若用户下发该APP限速配置,户会感知响应变差,若用户选择生成日志,会有该APP的限速日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/app/ssl_feature_advance.md b/src/main/webapp/online-help/app/ssl_feature_advance.md new file mode 100644 index 000000000..ae59d7ea4 --- /dev/null +++ b/src/main/webapp/online-help/app/ssl_feature_advance.md @@ -0,0 +1,33 @@ +#### [1.功能简介](#accordion1_1) + +用户自定义SSL协议特征,为特定应用添加SSL协议的特征。 + +#### [2.基础配置信息](#accordion1_2) + +* 社交应用:用户选择APP。 +* 配置描述:用户自定义该条配置的描述信息。 + +#### [3.配置约束条件](#accordion1_3) + +APP SSL类约束条件: + +* 匹配区域:选择具体的SSL特征。 +* 关键字:可填多个关键字,最长1024字符,用回车键分割。比如匹配区域选择SSL_SNI,关键字填完整的域名,用户需按实际情况填写,可参考抓包工具的数据包解析结果。 +* 匹配方式:包含子串匹配、左匹配、有匹配和完全匹配。 +* 是否十六进制:若关键字填写十六进制格式的特征,选择十六进制,否则为非十六进制。 + +IP类约束条件: + +* IP类型:可选IPV4或IPV6。 +* IP格式:可选IP、IP范围和IP/子网掩码。 +* 目的IP:IP格式选择“IP”,该文本框填合法的单个IP;IP格式选择“IP范围”,IP段只能配置x.x.x.0-x.x.x.255;IP/子网掩码中子网掩码值限制为16-32。 +* 目的端口:端口与端口掩码范围是0-65535。 +* 协议:可选TCP、UDP、全部。全部表示TCP或UDP。 + +可为一个应用添加最多3个APP SSL特征和1个IP范围特征。当同时满足APP SSL特征和IP范围特征时,该配置才生效。 + +#### [4.预期效果](#accordion1_4) + +将该SLL特征添加给了指定的APP,如用户产生具有该特征的数据,会有如下效果。* 若用户下发该APP阻断配置,具有该特征的数据流被阻断,若用户选择生成日志,会有该APP的阻断日志。 +* 若用户下发该APP监视配置,具有该特征的数据正常工作,若用户选择生成日志,会有该APP的监视日志。 +* 若用户下发该APP限速配置,户会感知响应变差,若用户选择生成日志,会有该APP的限速日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/app/tunnel_behavior.md b/src/main/webapp/online-help/app/tunnel_behavior.md new file mode 100644 index 000000000..897c345c3 --- /dev/null +++ b/src/main/webapp/online-help/app/tunnel_behavior.md @@ -0,0 +1,42 @@ +#### [1.功能简介](#accordion1_1) + +对用户使用加密隧道的行为进行识别和管控,比如识别用户使用加密隧道进行视频通话的行为。 + +#### [2.基础配置信息](#accordion1_2) + +* 配置描述:用户自定义该条配置的描述信息。 +* 是否记录日志:是否生成日志信息。 +* 加密隧道协议:选择一种加密隧道协议。 +* 行为类型:包括“视频”和“其他”,视频指实时视频通话,注意,使用youtube播放视频属于“其他”。 +* 执行动作:加密隧道行为有两种管控动作:阻断、监视。若选择监视,用户需指定客户端相关信息。 + +#### [3.配置约束条件](#accordion1_3) + +IP类配置,当执行动作选择“监视”,必须填写对应的IP配置。 + +* IP类型:IPV4或IPV6。 +* 协议:可选TCP、UDP和全部。 +* IP格式:可选IP、IP范围和IP/子网掩码。 +* 源IP:IP格式选择“IP”,该文本框填合法的单IP;IP格式选择“IP范围”,IP段只能配置x.x.x.0-x.x.x.255;IP/子网掩码中子网掩码值限制为16-32。 +* 源端口:端口与端口掩码范围是0-65535。 +* 目的IP:限制同源IP。 +* 目的端口:端口与端口掩码范围是0-65535。 +* 另:源IP与目的IP不能相同 + +#### [4.配置生效范围](#accordion1_4) + +配置生效范围,分为“全部”和“选择区域”。“全部”指所有地区;“选择区域”需选择区域和运营商,并且可以同时选择多个区域和多个运营商,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:选择来函文件类型,必选项; +* 类型:指明该配置的类型,可同时选多个,比如信息内容安全、网络攻击等,非必选项; +* 性质:指明该配置的性质,可同时选多个,比如政治事务、暴力恐怖等,非必选项; +* 用户标签:用户自定义标签,可同时选多个,非必选项; + +#### [6.预期效果](#accordion1_7) + +* 执行动作选择“阻断”,使用该协议的应用全部无法正常使用;若指定了行为,只有该行为无法正常使用。 +* 执行动作选择“监视”,使用该协议的应用不受影响。 +* 若指定了客户端IP,该配置只对该用户生效,其他用户不受影响。 +* 若选择了记录日志,日志界面出现该配置的日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/editHelp.html b/src/main/webapp/online-help/editHelp.html new file mode 100644 index 000000000..23c8ec2c7 --- /dev/null +++ b/src/main/webapp/online-help/editHelp.html @@ -0,0 +1,102 @@ + + + + markdown test + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/BGP.md b/src/main/webapp/online-help/ntc/BGP.md new file mode 100644 index 000000000..8a2c7d6a5 --- /dev/null +++ b/src/main/webapp/online-help/ntc/BGP.md @@ -0,0 +1,44 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对BGP流量的配置,从而对包含特定IP或AS特征的BGP流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中BGP协议配置的流量信息,包括发现时间、IP、AS等。 + +#### [2.业务配置属性](#accordion1_2) + +BGP协议管控的流量属性信息: + +* AS:配置自治系统的关键词,精确匹配,非二进制,大小写不敏感。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 + +#### [3.配置约束条件](#accordion1_3) + +BGP协议管控配置的属性信息: + +* 源IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 源端口:端口与端口掩码范围是0-65535。 +* 目的IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 目的端口:端口与端口掩码范围是0-65535。 +* 另:源IP与目的IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的BGP流量监测日志。 +* 阻断预期效果:阻断符合配置条件的BGP流量,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/DNS.md b/src/main/webapp/online-help/ntc/DNS.md new file mode 100644 index 000000000..59aec983b --- /dev/null +++ b/src/main/webapp/online-help/ntc/DNS.md @@ -0,0 +1,45 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对DNS流量的配置,从而对包含特定IP或DNS关键词特征的DNS流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中DNS协议配置的流量信息,包括发现时间、IP、请求内容等。 + +#### [2.业务配置属性](#accordion1_2) + +DNS协议管控的流量属性信息: + +* keyword:DNS关键词。匹配字段选择,例如QNAME;关键字填写;表达式类型选择,支持选择与表达式;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字,子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +DNS协议管控配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的DNS流量监测日志。 +* 阻断预期效果:阻断符合配置条件的DNS请求或对符合配置条件的DNS请求抢答欺骗包,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/FTP.md b/src/main/webapp/online-help/ntc/FTP.md new file mode 100644 index 000000000..5dbb68854 --- /dev/null +++ b/src/main/webapp/online-help/ntc/FTP.md @@ -0,0 +1,46 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对FTP流量的配置,从而对包含特定IP、URL或内容特征的FTP流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中FTP协议配置的流量信息,包括发现时间、IP、URL等。 + +#### [2.业务配置属性](#accordion1_2) + +FTP协议扩展管控的流量属性信息: + +* URL:FTP的URL。关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;非二进制;大小写不敏感。 +* FTP内容:关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字,子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +FTP协议管控配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的FTP流量监测日志。 +* 阻断预期效果:阻断符合配置条件的FTP访问,即无法获取到该FTP内容,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/HTTP_URL.md b/src/main/webapp/online-help/ntc/HTTP_URL.md new file mode 100644 index 000000000..05b10093c --- /dev/null +++ b/src/main/webapp/online-help/ntc/HTTP_URL.md @@ -0,0 +1,34 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对HTTP流量的配置,从而对包含特定URL特征的HTTP流量进行加入白名单、监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为白名单、阻断、监测三选一。 + +#### [2.业务配置属性](#accordion1_2) + +HTTP协议管控的流量属性信息: + +* URL:HTTP统一资源定位符关键词。关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;非二进制;大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的HTTP流量监测日志。 +* 阻断预期效果:阻断符合配置条件的HTTP访问,即访问页面无响应,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/HTTP_advanced.md b/src/main/webapp/online-help/ntc/HTTP_advanced.md new file mode 100644 index 000000000..38ec60a4a --- /dev/null +++ b/src/main/webapp/online-help/ntc/HTTP_advanced.md @@ -0,0 +1,54 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对HTTP流量的扩展配置,从而对包含特定IP、URL、字段或内容特征的HTTP流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中HTTP扩展配置的流量信息,包括发现时间、IP、URL、请求头、请求体、响应头、响应体等。 + +#### [2.业务配置属性](#accordion1_2) + +HTTP协议扩展管控的流量属性信息,分为请求侧与响应侧。 请求侧: + +* URL:关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* 字段:匹配字段选择,例如User Agent、Cookie等;关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* 请求消息体:关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字,子串匹配,非二进制,大小写不敏感。 + +响应侧: + +* 响应头域字段:匹配字段选择,例如set-cookie、Content-Type等;关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* 响应消息体:关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字,子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +HTTP协议扩展管控配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的HTTP流量监测日志。 +* 阻断预期效果:阻断符合配置条件的HTTP访问,即访问页面无响应,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/HTTP_website.md b/src/main/webapp/online-help/ntc/HTTP_website.md new file mode 100644 index 000000000..cc9d6357b --- /dev/null +++ b/src/main/webapp/online-help/ntc/HTTP_website.md @@ -0,0 +1,36 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对HTTP流量的配置,从而对包含特定网站关键词特征的HTTP流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中配置的HTTP流量信息,包括发现时间、IP、URL、请求头、请求体、响应头、响应体等。 + +#### [2.业务配置属性](#accordion1_2) + +HTTP协议网站管控的流量属性信息,分为请求侧与响应侧: + +* 请求侧消息体关键词:关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* 响应侧消息体关键词:关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 + +#### [3.配置约束条件](#accordion1_3) + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的HTTP流量监测日志。 +* 阻断预期效果:阻断符合配置条件的HTTP访问,即访问页面无响应,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/Mail.md b/src/main/webapp/online-help/ntc/Mail.md new file mode 100644 index 000000000..833bb13d6 --- /dev/null +++ b/src/main/webapp/online-help/ntc/Mail.md @@ -0,0 +1,45 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对Mail流量的配置,从而对包含特定IP、收发件人特征的Mail流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中Mail协议配置的流量信息,包括发现时间、IP、收发件人等。 + +#### [2.业务配置属性](#accordion1_2) + +MAIL协议管控的流量属性信息: + +* Mail头部关键词:匹配字段选择,例如发件人From与收件人To;关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字,子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +MAIL协议管控配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的Mail流量监测日志。 +* 阻断预期效果:阻断符合配置条件的Mail邮件,即该邮件无法正常发送或接收,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/Mail_advanced.md b/src/main/webapp/online-help/ntc/Mail_advanced.md new file mode 100644 index 000000000..472316f96 --- /dev/null +++ b/src/main/webapp/online-help/ntc/Mail_advanced.md @@ -0,0 +1,46 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对Mail流量的扩展配置,从而对包含特定IP、收发件人、主题或邮件正文特征的Mail流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中Mail协议扩展配置的流量信息,包括发现时间、IP、收发件人等。 + +#### [2.业务配置属性](#accordion1_2) + +MAIL协议扩展管控的流量属性信息: + +* Mail头部关键词:匹配字段选择,例如发件人From、收件人To、主题;关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* Mail正文关键词:匹配字段选择,例如正文内容、附件名称、附件内容;关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字,子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +MAIL协议管控配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的Mail流量监测日志。 +* 阻断预期效果:阻断符合配置条件的Mail邮件,即该邮件无法正常发送或接收,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/SSL.md b/src/main/webapp/online-help/ntc/SSL.md new file mode 100644 index 000000000..b921b9c5d --- /dev/null +++ b/src/main/webapp/online-help/ntc/SSL.md @@ -0,0 +1,47 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对SSL流量的配置,从而对包含特定IP、SNI、SAN或CN特征的SSL流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中SSL协议配置的流量信息,包括发现时间、IP、SNI、SAN、CN等。 + +#### [2.业务配置属性](#accordion1_2) + +SSL协议管控的流量属性信息: + +* SNI:SSL请求服务器名称指示关键词。关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* SAN:SSL域名主体替代名称关键词。关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* CN:SSL域名通用名关键词。关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流);是否大小写敏感选择。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字,子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +SSL协议管控配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的SSL流量监测日志。 +* 阻断预期效果:阻断符合配置条件的SSL网络流量,例如阻止某次特定HTTPS访问,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/ip_address.md b/src/main/webapp/online-help/ntc/ip_address.md new file mode 100644 index 000000000..a041520d1 --- /dev/null +++ b/src/main/webapp/online-help/ntc/ip_address.md @@ -0,0 +1,46 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成对网络流量IP特征的配置,对包含特定IP特征的流量进行阻断、监测、丢弃或限速。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测、丢弃、限速四选一。 +* 是否记录日志:对网络流量施加执行动作时,是否命中IP配置的网络流量信息,包括发现时间、IP、端口等。 + +#### [2.业务配置属性](#accordion1_2) + +IP地址管控的流量属性信息: + +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* ASN:自治系统号选择,可以选择下拉菜单中的自治系统。 + +#### [3.配置约束条件](#accordion1_3) + +IP管控配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的IP监测流量日志。 +* 阻断预期效果:阻断承载于配置IP或IP组之上的TCP流量,即发送TCP的RST报文,并记录阻断日志。 +* 限速预期效果:限制承载于配置IP或IP组之上网络流量的传输速率。 +* 丢弃预期效果:丢弃承载于配置IP或IP组之上的网络流量报文,使得目的端无法收到报文。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/ip_white_list.md b/src/main/webapp/online-help/ntc/ip_white_list.md new file mode 100644 index 000000000..90b493552 --- /dev/null +++ b/src/main/webapp/online-help/ntc/ip_white_list.md @@ -0,0 +1,34 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对网络流量的IP白名单配置,将特定IP或IP组设置为白名单。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为单一选项白名单。 + +#### [2.业务配置属性](#accordion1_2) + +此处指流量的IP属性:即配置特定IP为白名单。 + +* IP Type:IP类型,可以选择IPv4或者IPv6。 +* IP Pattern:IP配置模式,可以选择特定IP、IP段或者IP掩码三种模式。 +* Client IP:具体的IP白名单配置。 + +#### [3.配置约束条件](#accordion1_3) + +IP白名单配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置标签](#accordion1_6) + +#### [5.预期效果](#accordion1_7) + +设置为白名单的IP或IP组上的网络流量不受其他配置的控制与影响,其上所有网络行为皆可正常无虞。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/p2p.md b/src/main/webapp/online-help/ntc/p2p.md new file mode 100644 index 000000000..f0724e090 --- /dev/null +++ b/src/main/webapp/online-help/ntc/p2p.md @@ -0,0 +1,54 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对P2P流量(包括EMULE协议与BT协议)的配置,从而对包含特定IP、EMULE搜索关键词与文件标识的P2P流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中配置的P2P流量信息,包括发现时间、IP、文件标识等。 + +#### [2.业务配置属性](#accordion1_2) + +P2P协议扩展管控的流量属性信息: + +* EMULE 搜索关键词:关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* 文件标识:首先选择标识类型,BT INFO 或者EMULE fileid;关键字填写十六进制数标识;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是二进制;大小写敏感。 +* IP:IP配置类型,EMULE SERVER、BT TRACKER分别为客户端与EMULE、BT服务器的通信,EMULE NODE、BT NODE分别为客户端与客户端之间的通信,IP配置类型四选一;选择IP类型、协议与客户端与服务端的IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字。关键字填写;子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +P2P协议管控配置的属性信息: + +* BT INFO:长度不超过20Byte。 +* EMULE Fileid:长度不超过16Byte。 +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* IP封堵效果:BT客户端(关闭utp及DHT相关设置)新添加的种子文件速度为0;Emule客户端(关闭迷惑协议)新添加的下载文件速度为0,Emule客户端服务器(不包括KAD网络)连接失败,无法进行Servers搜索。 +* IP监测效果:BT返回该链接含有的infohash值,Emule返回该链接含有的fileid和keywordhash或搜素关键词等信息。 +* BT INFOHASH封堵:客户端中对应要封堵的INFOHASH无下载速度(需先下配置,再新建bt下载任务),如果选择记录日志,则返回相应的INFOHASH封堵日志。 +* BT INFOHASH监测:客户端中对应监测INFOHASH无影响(需先下配置,再新建bt下载任务),返回对应的INFOHASH监测日志。 +* EMULE FILEID封堵:客户端中对应要封堵的FILEID无下载速度(需先下配置,再新建文件下载任务),如果选择记录日志,则返回相应的EMULE封堵日志。 +* EMULE FILEID监测:客户端中对应监测FILEID无影响(需先下配置,再新建文件下载任务),返回对应的监测日志。 +* EMULE搜索关键词命中封堵配置时,显示搜索结果列表为空,返回相应的EMULE封堵日志。 +* EMULE搜索关键词命中监测配置时,对搜索结果没有影响,界面返回实际对应的搜索关键词信息。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/stream_media.md b/src/main/webapp/online-help/ntc/stream_media.md new file mode 100644 index 000000000..6b2417539 --- /dev/null +++ b/src/main/webapp/online-help/ntc/stream_media.md @@ -0,0 +1,45 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对流媒体流量(包括 RTSP协议与RTMP协议)的配置,从而对包含特定IP或URL特征的流媒体流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中流媒体配置的流量信息,包括发现时间、IP、URL等。 + +#### [2.业务配置属性](#accordion1_2) + +流媒体协议扩展管控的流量属性信息: + +* URL:流媒体的URL。关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;非二进制;大小写不敏感。 +* IP:选择IP类型、协议、IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字,子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +流媒体协议管控配置的属性信息: + +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的流媒体流量监测日志。 +* 阻断预期效果:阻断符合配置条件的流媒体流量,即客户端无法正常访问并播放该流媒体音视频内容,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/ntc/voip.md b/src/main/webapp/online-help/ntc/voip.md new file mode 100644 index 000000000..ed148e67c --- /dev/null +++ b/src/main/webapp/online-help/ntc/voip.md @@ -0,0 +1,46 @@ +#### [0.功能简介](#accordion1_0) + +本页面完成针对VoIP流量(包括SIP协议与RTP协议)的配置,从而对包含特定IP、VoIP账号特征的VoIP流量进行监测或阻断。 + +#### [1.配置基础信息](#accordion1_1) + +配置基础信息包括:规则名称,执行动作,是否记录管控日志。 + +* 规则名称:用户自定义的该条配置的描述信息。 +* 执行动作:配置施加于网络传输单元时,对网络流量施加什么样的动作,此处为阻断、监测二选一。 +* 是否记录日志:对网络流量施加执行动作时,是否记录命中配置的VoIP流量信息,包括发现时间、IP、VoIP主被叫账号、通话语音等。 + +#### [2.业务配置属性](#accordion1_2) + +VoIP协议扩展管控的流量属性信息: + +* VoIP账号:关键字填写;匹配方式选择,例如子串匹配、前缀匹配、后缀匹配与精确匹配;是否二进制选择(此处是指关键字内容是否为二进制原始码流,选择是,则关键字处填写十六进制数);是否大小写敏感选择。 +* IP:选择IP类型、协议与客户端与服务端的IP模式、端口模式,并且填写对应的具体IP与端口值,选择匹配方向是单向还是双向匹配。 +* Subscribe ID:IP地址对应的用户信息关键字。关键字填写;子串匹配,非二进制,大小写不敏感。 + +#### [3.配置约束条件](#accordion1_3) + +VoIP协议管控配置的属性信息: + +* VoIP账号:长度不超过1500Byte。 +* 客户端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 客户端端口:端口与端口掩码范围是0-65535。 +* 服务端IP:合法的单IP;IP段只能配置x.x.x.0-x.x.x.255;IP/mask中mask值限制为16-32。 +* 服务端端口:端口与端口掩码范围是0-65535。 +* 另:客户端IP与服务端IP不能相同。 + +#### [4.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效。 + +#### [5.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 + +#### [6.预期效果](#accordion1_7) + +* 监测预期效果:记录符合配置条件的VoIP流量监测日志。 +* 阻断预期效果:阻断符合配置条件的VoIP通话,即客户端无法拨通本次VoIP电话,客户端与服务端均收到挂断、通话超时、服务器异常的虚假报文,并记录阻断日志。 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/cache_policy.md b/src/main/webapp/online-help/proxy/cache_policy.md new file mode 100644 index 000000000..0f3fe2864 --- /dev/null +++ b/src/main/webapp/online-help/proxy/cache_policy.md @@ -0,0 +1,32 @@ +#### [1.Function Introduction](#accordion1_1) + +On National Proxy System, Individual Cache policy rules determine whether to cache or not based on traffic attributes, such as URL and Cookies. + +#### [2.Action](#accordion1_2) + +For cache action, the optimization parameters are: + +* A Cache key:is a unique string that lets the National Proxy System look for web content when requests hit them. It’s made up of a hostname, path, and cookie parts. By default, the Proxy use the entire URL as the cache key. Selecting the correct cache key will ensure maximum cache footprint and increase cache hits. +* Ignore Query String in URL:in case the query strings doesn’t actually indicate that the object need to be different then you could EXCLUDE them from the cache key. For example, after ignoring “sqp” and “rs” of URL: “https://example.com/pic.jpg?sqp=UAAI&rs=AOn4”. +* Include Cookie Values:in case the server send different content for the same URL based on the cookie value, you can include that cookie value as a part of cache key. For example, the server may set a cookie at the client called "prefLang=ru" to record user preferred language, you could add "prefLang" to distinguish different web content. +* Disable Revalidate:is an ON-OFF switch. The pragma-no-cache header in a client’s request causes the proxy to re-fetch the entire object from the original server, even if the cached copy of the object is fresh. By default this option is switch OFF, which means a client’s non-conditional request results in a conditional GET request sent to the original server if the object is already in cache. The conditional request allows the original server to return the 304 Not Modified response, if the content in cache is still fresh. Thereby, the server-side bandwidth and latency consumed are lesser as the full content is not retrieved again from the original server. +* Cache Dynamic Content:is an ON-OFF switch. A URL is considered dynamic if it ends in “.asp(x)” or contains a question mark (?), a semicolon (;), or “cgi”. Ignore Query String overrides this option (switch on). +* Cache Cookied Content:is an ON-OFF switch. By default, the Proxy does NOT cache cookied content of any type. If this option is switch on, the system cache all Cookeid content except HTML. +* Ignore Request no-cache Headers:is an ON-OFF switch. By default, the proxy strictly observes client Cache-Control: no-cache directives. As known as: + * i. Authorization + * ii. WWW-Authenticate + * iii. Cache-Control: no-store + * iv. Cache-Control: no-cache +* If a requested object contains a no-cache header, then proxy forwards the request to the origin server even if it has a fresh copy in cache. You can configure proxy to ignore client no-cache directives such that it ignores no-cache headers from client requests and serves the object from its cache. Ignore Response no-cache Headers — is an ON-OFF switch. By default, a response from an origin server with a no-cache header is not stored in the cache. As known as: + * i. Cache-Control: no-store + * ii. Cache-Control: private + * iii. Set-Cookie + * iv. Cache-Control: no-cache + * v. WWW-Authenticate + * vi. Expires header with a value of 0 (zero) or a past date.If you configure proxy to ignore no-cache headers, then proxy also ignores no-store headers. The default behavior of observing no-cache directives is appropriate in most cases. +* Forcing Object Caching: is an ON-OFF switch. You can force Proxy to cache specific URLs (including dynamic URLs) for a specified duration, regardless of Cache-Control response headers. +* Minimum Use: sets the number of times an item must be requested by clients before Proxy caches it. This is useful if the cache is constantly filling up, as it ensures that only the most frequently accessed items are added to the cache. By default, Proxy cache object at its first appearance. The Counter resets in every 30 minutes. Note that the requests is counted in computing unit independently. +* Max Cache Object Size: sets the upper limit of an object size, larger object will not be cached. By default, Proxy does not cache object larger than 1 GB. +* Cache Pinning Time: configures Proxy to keep certain objects in the cache for a specified time. You can use this option to ensure that the most popular objects are in cache when needed and to prevent cache manager from deleting important objects. Proxy observes Cache-Control headers and pins an object in the cache only if it is indeed cacheable. +* Max Cache Size: sets the upper limit of the size of storage for a policy. By default, Proxy uses all available disk space. When the cache size reaches the limit, the cache manager removes the files that were least recently used to bring the cache size back under the limit. +* Inactive Time: specifies how long an item can remain in the cache without being accessed. A file that has not been requested for this time is automatically deleted from the cache by the cache manager, regardless of whether or not it has expired. \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/control_policy.md b/src/main/webapp/online-help/proxy/control_policy.md new file mode 100644 index 000000000..9c02cb194 --- /dev/null +++ b/src/main/webapp/online-help/proxy/control_policy.md @@ -0,0 +1,24 @@ +#### [1.Function Introduction](#accordion1_1) + +On National Proxy System, Individual Control policy rules determine whether to allow, block, redirect or replace a session based on traffic attributes, such as URL, request header fields, request body keywords, response header fields, response body keywords, IP address, Subscribe ID and their combination. You could specify these attributes in the submenu of Control Policy. + +#### [2.Action](#accordion1_2) + +You could select one of the five actions for above attributes, as known as: + +* Monitor:the Proxy produce a log to record matched HTTP session information. +* Block:the Proxy terminate matched HTTP session with an error page and produce a log. You MUST specify a Response Code and a Response Content to generate an error page. +* Redirect: the Proxy redirect matched HTTP session to a predefined URL. Since redirection need to be performed before delivering response to client, condition of response body is not applicable in this action. You MUST configure the redirect response via Response Code and Response URL. The Response URL MUST start with a scheme (http:// or https://). You SHOULD NOT select 301 as Response Code unless you exactly know what you are doing. This action produces a log. +* Replace:the Proxy Searches in a given HTTP part to Find a given string, and Replace any matches with another given string. If no match was found, the session remained untouched. For performance concerns, condition of request body and response body is not available in this action. For example, you can configure the Proxy to search in the response body of URL “www.example.com/index.html”, find every “string1” and replace with “string2”. This action produces a log. +* Whitelist:the Proxy pass-through the matched sessions and produce no log. +* In case of HTTP session matches one more policies, the priority order is Whitelist > Reject > Redirect > Replace > Monitor, action with higher priority overrides others. + +#### [3.Attibutes](#accordion1_3) + +The attributes are detailed in following context: + +* URL:From proxy’s perspective, a HTTP URL consists of a hierarchical sequence of three components: URL = hostname/path\[?query\] . The URL path name can also be specified by the user in the local writing system. If not already encoded, it is converted to UTF-8, and any characters not part of the basic URL character set are escaped as hexadecimal using percent-encoding; for example, search keywords “русский” in Google produces URL: https://www.google.com/search?q=%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9 To perform policy action on above URL, you could input the whole URL in the input box. Or, you could input original keywords and let the Proxy do the decoding, e.g. “google.com/search” & “русский”. Note that the scheme string MUST be excluded from the URL, it’s “https://” in this case. +* Request Header: is used to set conditions on request header fields. Header fields are colon-separated key-value pairs in clear-text string format, terminated by a carriage return (CR) and line feed (LF) character sequence. For example, “user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)“ is a header filed in request header. The Matching District is used to configure the field’s key, if the key was presented, the Proxy will search in the value for Keywords. +* Response Header: is used to set conditions on response header fields. Its configuration is similar to Request Header. +* Request Body:is used to set conditions on request’s body message. The Proxy searches the pre-configured Keywords in it. You can configure non-ASCII or non-utf8 keywords by turn on HEX. +* Response Body:is used to set conditions on response’s body message. Its configuration is similar to Request Body. \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/domain_intercept_policy.md b/src/main/webapp/online-help/proxy/domain_intercept_policy.md new file mode 100644 index 000000000..dad6045a7 --- /dev/null +++ b/src/main/webapp/online-help/proxy/domain_intercept_policy.md @@ -0,0 +1,34 @@ +#### [1.功能简介](#accordion1_1) + +域名拦截主要是根据域名对网站进行拦截,主要分为域名监测,域名白名单和域名限速功能,匹配的方式为子串匹配。当检测到请求的url中包含有配置的域名,根据上述三个功能,进行相应的替换替换,证书不替换和,限速功能。 + +#### [2\. 基础配置信息](#accordion1_2) + +* 域名:监测网站的域名,或是域名的子串 + +#### [3\. 业务配置属性](#accordion1_2) + +* 域名:请求URL中的域名,或是URL中域名的子串 +* 限速:对被测机器限制网速,根据配置的数值比列丢包 + +#### [4.配置约束条件](#accordion1_4) + +* 域名:配置的监测域名,合法的域名表示 +* 丢包率:在0.001-0.009之间 + +#### [5.预期效果](#accordion1_5) + +* 黑名单:浏览器证书替换 +* 白名单:浏览器证书不替换 +* 限速:测试有等比例接近的丢包 + +#### [6.配置生效区域](#accordion1_6) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效 + +#### [7.配置标签](#accordion1_7) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据。 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_block_log.md b/src/main/webapp/online-help/proxy/https_block_log.md new file mode 100644 index 000000000..2b5b142c2 --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_block_log.md @@ -0,0 +1,71 @@ +#### [1.基础信息](#accordion1_1) + +Proxy日志按照控制策略类型进行分类,分为HTTP(S)监测、HTTP(S)管控、HTTP(S)重定向配置、HTTP(S)替换。每类日志页面下有两个基础搜索选项:开始时间、结束时间。和三个功能按钮搜:搜索、重置、筛选和右侧的设置按钮。 + +* 选项名称:开始时间- +* 执行动作:点击“开始时间”可以选择搜索日志的时间范围。时间选项中有当前时间的日历和时间表,以确定具体的筛选时间,下方三个选项“clear”表示清空当前选择、“Today”表示将选择时间定为当前时间,“OK”表示确认。确认时间范围后,搜索结果将返回时间范围内的满足搜索条件的HTTP(S)管控日志 + +* 选项名称:结束时间- +* 执行动作:点击“结束时间”可以选择搜索日志的时间范围。时间选项中有当前时间的日历和时间表,以确定具体的筛选时间,下方三个选项“clear”表示清空当前选择、“Today”表示将选择时间定为当前时间,“OK”表示确认。确认时间范围后,搜索结果将返回时间范围内的满足搜索条件的HTTP(S)管控日志 + +* 选项名称:搜索- +* 执行动作:点击“搜索”,将返回满足时间范围和筛选条件内的HTTP(S)重定向日志 + +* 选项名称:重置- +* 执行动作:点击“重置”,将筛选条件和开始时间结束时间清空 + +* 选项名称:筛选- +* 执行动作:点击“筛选”,扩展日志筛选条件。eg.传输层协议、传输方向等 + +* 选项名称:筛选- +* 执行动作:点击“筛选”,选择查询结果输出的日志信息项 + +#### [2.拓展筛选项](#accordion1_3) + +点开筛选按钮后,会出现扩展搜索选项:传输层协议、传输方向、出入口、处理机IP、源IP、目的IP和配置ID。 + +* 选项名称:传输层协议- +* 执行动作:点击“筛选”——>选择“传输层协议”,可以选择:L2TP、IPv4\_UDP、IPv6、IPv6\_UDP、OpenVPN、MAC、MPLS、IPv4\_TCP、IPv4、IPv6\_TCP、PPTP、VLAN、GRE。确认筛选的传输层协议后,搜索结果将返回选定时间范围内的对应协议的HTTP(S)管控日志,不做选择时默认所有协议 + +* 选项名称:传输方向- +* 执行动作:点击“筛选”——>选择“传输方向”,可以选择:境内、境外。境内表示触发规则的源IP为内部IP,境外表示触发规则的源IP为外部IP。确认筛选的传输方向后,搜索结果将返回选定时间范围内的对应传输方向的HTTP(S)重定向日志,不做选择时默认境内外 + +* 选项名称:出入口- +* 执行动作:点击“筛选”——>选择“出入口”。暂时不支持该功能 + +* 选项名称:处理机IP- +* 执行动作:点击“筛选”——>选择“处理机IP”,输入筛选的处理机IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的处理机IP后,搜索结果将返回选定时间范围内的对应处理机IP的HTTP(S)管控日志,不做选择时默认所有IP + +* 选项名称:源IP- +* 执行动作:点击“筛选”——>选择“源IP”,输入筛选的源IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的源IP后,搜索结果将返回选定时间范围内的对应源IP的HTTP(S)管控日志,不做选择时默认所有IP + +* 选项名称:目的IP- +* 执行动作:点击“筛选”——>选择“目的IP”,输入筛选的目的IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的目的IP后,搜索结果将返回选定时间范围内的对应目的IP的HTTP(S)管控日志,不做选择时默认所有IP + +* 选项名称:配置ID- +* 执行动作:点击“筛选”——>选择“配置ID”,输入筛选的配置ID。确认筛选的目的IP后,搜索结果将返回选定时间范围内的对应配置ID的HTTP(S)重定向日志,不做选择时默认所有配置 + +#### [3.日志信息标签:配置ID、发现时间、出入口、URL、处理机IP、传输层协议、源目的IP端口等](#accordion1_2) + +此处对日志信息每项标签做解析,帮助使用人员理解日志具体信息: Proxy在命中记录日志的控制策略时将会产生相应的日志信息,命中配置的消息日志信息包括:配置ID、发现时间、出入口、URL、处理机IP、传输层协议、目的IP、源IP、目的端口、源端口、串联设备、方向、流类型、服务端地址、客户端地址、客户端ASN、服务端ASN、客户端用户名、服务端用户名、现场日志文件地址。 + +* 配置ID:命中配置的配置ID +* 发现时间:命中规则的时间 +* 出入口:暂不支持 +* URL:命中配置的URL +* 处理机IP:处理这条命中规则的服务器IP +* 传输层协议:这条消息的传输层协议 +* 目的IP:命中配置的连接的目的IP +* 源IP:命中配置的连接的源IP +* 目的端口:命中配置的连接的目的端口 +* 源端口:命中配置的连接的源端口 +* 串联设备:暂不支持 +* 方向:该日志是传输方向--境内/境外 +* 流类型:该流是单向或双向流 +* 服务端地址:该流服务端所在的地理区域,eg.Hong Kong、United States +* 客户端地址:该流客户端所在的地理区域,eg.Hong Kong、United States +* 客户端ASN:客户端的ASN号(自治系统号) +* 服务端ASN:服务端的ASN号(自治系统号) +* 客户端用户名:客户端账户的用户名 +* 服务端用户名:服务端账户的用户名 +* 现场日志文件地址:该日志保存的地址 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_block_policy.md b/src/main/webapp/online-help/proxy/https_block_policy.md new file mode 100644 index 000000000..e5670cab8 --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_block_policy.md @@ -0,0 +1,49 @@ +#### [1.功能简介](#accordion1_1) + +HTTP(s)阻断主要的功能是实现浏览器无法访问网站。当配置的测试机的IP地址等信息后,被测机器无法访问网站,阻断上网的功能,主要包括IP阻断,URL阻断,请求头域阻断,应答头域阻断,请求内容阻断,应答内容阻断,账号阻断 + +#### [2.基础配置信息](#accordion1_2) + +* IP:同“IP拦截” +* HTTP URL:“同域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* HTTP 应答头域:同“HTTP(s)监测” +* HTTP 请求内容:同“HTTP(s)监测” +* HTTP 应答内容:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [2.业务配置属性](#accordion1_3) + +* IP:同“HTTP(s)监测” +* HTTP URL:同“HTTP(s)监测” +* HTTP 请求头域:同“HTTP(s)监测” +* HTTP 应答头域:同“HTTP(s)监测” +* HTTP 请求内容:同“HTTP(s)监测” +* HTTP 应答内容:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [4.配置约束条件](#accordion1_4) + +* IP:同“IP拦截” +* URL:同“域名拦截” +* HTTP 请求头:同“HTTP(s)监测” +* HTTP 应答头:同“HTTP(s)监测” +* HTTP 请求内容:同“HTTP(s)监测” +* HTTP 应答内容:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [5.预期效果](#accordion1_5) + +* 阻断效果:浏览器无法访问页面 +* 日志检查:生成日志 + +#### [6.配置生效区域](#accordion1_6) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效 + +#### [7.配置标签](#accordion1_7) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据。 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_monitor_log.md b/src/main/webapp/online-help/proxy/https_monitor_log.md new file mode 100644 index 000000000..53dc60ed0 --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_monitor_log.md @@ -0,0 +1,71 @@ +#### [1.基础信息](#accordion1_1) + +Proxy日志按照控制策略类型进行分类,分为HTTP(S)监测、HTTP(S)管控、HTTP(S)重定向配置、HTTP(S)替换。每类日志页面下有两个基础搜索选项:开始时间、结束时间。和三个功能按钮搜:搜索、重置、筛选和右侧的设置按钮。 + +* 选项名称:开始时间- +* 执行动作:点击“开始时间”可以选择搜索日志的时间范围。时间选项中有当前时间的日历和时间表,以确定具体的筛选时间,下方三个选项“clear”表示清空当前选择、“Today”表示将选择时间定为当前时间,“OK”表示确认。确认时间范围后,搜索结果将返回时间范围内的满足搜索条件的HTTP(S)监测日志 + +* 选项名称:结束时间- +* 执行动作:点击“结束时间”可以选择搜索日志的时间范围。时间选项中有当前时间的日历和时间表,以确定具体的筛选时间,下方三个选项“clear”表示清空当前选择、“Today”表示将选择时间定为当前时间,“OK”表示确认。确认时间范围后,搜索结果将返回时间范围内的满足搜索条件的HTTP(S)监测日志 + +* 选项名称:搜索- +* 执行动作:点击“搜索”,将返回满足时间范围和筛选条件内的HTTP(S)监测日志 + +* 选项名称:重置- +* 执行动作:点击“重置”,将筛选条件和开始时间结束时间清空 + +* 选项名称:筛选- +* 执行动作:点击“筛选”,扩展日志筛选条件。eg.传输层协议、传输方向等 + +* 选项名称:筛选- +* 执行动作:点击“筛选”,选择查询结果输出的日志信息项 + +#### [2.拓展筛选项](#accordion1_3) + +点开筛选按钮后,会出现扩展搜索选项:传输层协议、传输方向、出入口、处理机IP、源IP、目的IP和配置ID。 + +* 选项名称:传输层协议- +* 执行动作:点击“筛选”——>选择“传输层协议”,可以选择:L2TP、IPv4\_UDP、IPv6、IPv6\_UDP、OpenVPN、MAC、MPLS、IPv4\_TCP、IPv4、IPv6\_TCP、PPTP、VLAN、GRE。确认筛选的传输层协议后,搜索结果将返回选定时间范围内的对应协议的HTTP(S)监测日志,不做选择时默认所有协议 + +* 选项名称:传输方向- +* 执行动作:点击“筛选”——>选择“传输方向”,可以选择:境内、境外。境内表示触发规则的源IP为内部IP,境外表示触发规则的源IP为外部IP。确认筛选的传输方向后,搜索结果将返回选定时间范围内的对应传输方向的HTTP(S)监测日志,不做选择时默认境内外 + +* 选项名称:出入口- +* 执行动作:点击“筛选”——>选择“出入口”。暂时不支持该功能 + +* 选项名称:处理机IP- +* 执行动作:点击“筛选”——>选择“处理机IP”,输入筛选的处理机IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的处理机IP后,搜索结果将返回选定时间范围内的对应处理机IP的HTTP(S)监测日志,不做选择时默认所有IP + +* 选项名称:源IP- +* 执行动作:点击“筛选”——>选择“源IP”,输入筛选的源IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的源IP后,搜索结果将返回选定时间范围内的对应源IP的HTTP(S)监测日志,不做选择时默认所有IP + +* 选项名称:目的IP- +* 执行动作:点击“筛选”——>选择“目的IP”,输入筛选的目的IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的目的IP后,搜索结果将返回选定时间范围内的对应目的IP的HTTP(S)监测日志,不做选择时默认所有IP + +* 选项名称:配置ID- +* 执行动作:点击“筛选”——>选择“配置ID”,输入筛选的配置ID。确认筛选的目的IP后,搜索结果将返回选定时间范围内的对应配置ID的HTTP(S)监测日志,不做选择时默认所有配置 + +#### [3.日志信息标签:配置ID、发现时间、出入口、URL、处理机IP、传输层协议、源目的IP端口等](#accordion1_2) + +此处对日志信息每项标签做解析,帮助使用人员理解日志具体信息: Proxy在命中记录日志的控制策略时将会产生相应的日志信息,命中配置的消息日志信息包括:配置ID、发现时间、出入口、URL、处理机IP、传输层协议、目的IP、源IP、目的端口、源端口、串联设备、方向、流类型、服务端地址、客户端地址、客户端ASN、服务端ASN、客户端用户名、服务端用户名、现场日志文件地址。 + +* 配置ID:命中配置的配置ID +* 发现时间:命中规则的时间 +* 出入口:暂不支持 +* URL:命中配置的URL +* 处理机IP:处理这条命中规则的服务器IP +* 传输层协议:这条消息的传输层协议 +* 目的IP:命中配置的连接的目的IP +* 源IP:命中配置的连接的源IP +* 目的端口:命中配置的连接的目的端口 +* 源端口:命中配置的连接的源端口 +* 串联设备:暂不支持 +* 方向:该日志是传输方向--境内/境外 +* 流类型:该流是单向或双向流 +* 服务端地址:该流服务端所在的地理区域,eg.Hong Kong、United States +* 客户端地址:该流客户端所在的地理区域,eg.Hong Kong、United States +* 客户端ASN:客户端的ASN号(自治系统号) +* 服务端ASN:服务端的ASN号(自治系统号) +* 客户端用户名:客户端账户的用户名 +* 服务端用户名:服务端账户的用户名 +* 现场日志文件地址:该日志保存的地址 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_monitor_policy.md b/src/main/webapp/online-help/proxy/https_monitor_policy.md new file mode 100644 index 000000000..757c14ae3 --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_monitor_policy.md @@ -0,0 +1,52 @@ +#### [1.功能简介](#accordion1_1) + +HTTP(s)监测与IP监测的功能类似,额外增加了其他的监测,主要包括URL监测,请求头域监测,应答头域监测,请求内容监测,应答内容监测,账号监测。 + +#### [2.基础配置信息](#accordion1_2) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:HTTP发送请求的头域信息 +* HTTP 应答头域:HTTP应答的头域信息 +* HTTP 请求内容:HTTP请求体中的内容 +* HTTP 应答内容:HTTP 响应体的内容 +* 账号:上网登陆账号 + +#### [3.业务配置属性](#accordion1_3) + +* IP:同“IP拦截” +* 端口:同“IP拦截” +* HTTP URL:同“域名拦截” +* URL:同“域名拦截” +* HTTP 请求头域:浏览器发送头信息的请求头,其中包括请求方法 +* HTTP 应答头域:HTTP响应的头信息 +* HTTP 请求内容:HTTP请求体 +* HTTP 应答内容:HTTP响应体 +* 账号:拨号上网账号 + +#### [4.配置约束条件](#accordion1_4) + +* IP:同“IP拦截” +* 端口:同“IP拦截” +* URL:配置的URL必须是可访问的 +* HTTP 请求头域:合法的请求头域 +* HTTP 应答头域:合法的应答头域 +* HTTP 请求内容:合法HTTP请求体 +* HTTP 应答内容:合法HTTP响应体 +* 账号:拨号上网的账号 + +#### [5.预期效果](#accordion1_5) + +* 证书替换:浏览器的证书替换,有日志 +* 账号监测:检测到配置的账号,有日志 + +#### [6.配置生效区域](#accordion1_6) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效 + +#### [7.配置标签](#accordion1_7) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据。 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_redirect_log.md b/src/main/webapp/online-help/proxy/https_redirect_log.md new file mode 100644 index 000000000..8953171a9 --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_redirect_log.md @@ -0,0 +1,71 @@ +#### [1.基础信息](#accordion1_1) + +Proxy日志按照控制策略类型进行分类,分为HTTP(S)监测、HTTP(S)管控、HTTP(S)重定向配置、HTTP(S)替换。每类日志页面下有两个基础搜索选项:开始时间、结束时间。和三个功能按钮搜:搜索、重置、筛选和右侧的设置按钮。 + +* 选项名称:开始时间- +* 执行动作:点击“开始时间”可以选择搜索日志的时间范围。时间选项中有当前时间的日历和时间表,以确定具体的筛选时间,下方三个选项“clear”表示清空当前选择、“Today”表示将选择时间定为当前时间,“OK”表示确认。确认时间范围后,搜索结果将返回时间范围内的满足搜索条件的HTTP(S)重定向配置日志 + +* 选项名称:结束时间- +* 执行动作:点击“结束时间”可以选择搜索日志的时间范围。时间选项中有当前时间的日历和时间表,以确定具体的筛选时间,下方三个选项“clear”表示清空当前选择、“Today”表示将选择时间定为当前时间,“OK”表示确认。确认时间范围后,搜索结果将返回时间范围内的满足搜索条件的HTTP(S)重定向配置日志 + +* 选项名称:搜索- +* 执行动作:点击“搜索”,将返回满足时间范围和筛选条件内的HTTP(S)重定向日志 + +* 选项名称:重置- +* 执行动作:点击“重置”,将筛选条件和开始时间结束时间清空 + +* 选项名称:筛选- +* 执行动作:点击“筛选”,扩展日志筛选条件。eg.传输层协议、传输方向等 + +* 选项名称:筛选- +* 执行动作:点击“筛选”,选择查询结果输出的日志信息项 + +#### [2.拓展筛选项](#accordion1_3) + +点开筛选按钮后,会出现扩展搜索选项:传输层协议、传输方向、出入口、处理机IP、源IP、目的IP和配置ID。 + +* 选项名称:传输层协议- +* 执行动作:点击“筛选”——>选择“传输层协议”,可以选择:L2TP、IPv4\_UDP、IPv6、IPv6\_UDP、OpenVPN、MAC、MPLS、IPv4\_TCP、IPv4、IPv6\_TCP、PPTP、VLAN、GRE。确认筛选的传输层协议后,搜索结果将返回选定时间范围内的对应协议的HTTP(S)重定向配置日志,不做选择时默认所有协议 + +* 选项名称:传输方向- +* 执行动作:点击“筛选”——>选择“传输方向”,可以选择:境内、境外。境内表示触发规则的源IP为内部IP,境外表示触发规则的源IP为外部IP。确认筛选的传输方向后,搜索结果将返回选定时间范围内的对应传输方向的HTTP(S)重定向日志,不做选择时默认境内外 + +* 选项名称:出入口- +* 执行动作:点击“筛选”——>选择“出入口”。暂时不支持该功能 + +* 选项名称:处理机IP- +* 执行动作:点击“筛选”——>选择“处理机IP”,输入筛选的处理机IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的处理机IP后,搜索结果将返回选定时间范围内的对应处理机IP的HTTP(S)重定向配置日志,不做选择时默认所有IP + +* 选项名称:源IP- +* 执行动作:点击“筛选”——>选择“源IP”,输入筛选的源IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的源IP后,搜索结果将返回选定时间范围内的对应源IP的HTTP(S)重定向配置日志,不做选择时默认所有IP + +* 选项名称:目的IP- +* 执行动作:点击“筛选”——>选择“目的IP”,输入筛选的目的IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的目的IP后,搜索结果将返回选定时间范围内的对应目的IP的HTTP(S)重定向配置日志,不做选择时默认所有IP + +* 选项名称:配置ID- +* 执行动作:点击“筛选”——>选择“配置ID”,输入筛选的配置ID。确认筛选的目的IP后,搜索结果将返回选定时间范围内的对应配置ID的HTTP(S)重定向日志,不做选择时默认所有配置 + +#### [3.日志信息标签:配置ID、发现时间、出入口、URL、处理机IP、传输层协议、源目的IP端口等](#accordion1_2) + +此处对日志信息每项标签做解析,帮助使用人员理解日志具体信息: Proxy在命中记录日志的控制策略时将会产生相应的日志信息,命中配置的消息日志信息包括:配置ID、发现时间、出入口、URL、处理机IP、传输层协议、目的IP、源IP、目的端口、源端口、串联设备、方向、流类型、服务端地址、客户端地址、客户端ASN、服务端ASN、客户端用户名、服务端用户名、现场日志文件地址。 + +* 配置ID:命中配置的配置ID +* 发现时间:命中规则的时间 +* 出入口:暂不支持 +* URL:命中配置的URL +* 处理机IP:处理这条命中规则的服务器IP +* 传输层协议:这条消息的传输层协议 +* 目的IP:命中配置的连接的目的IP +* 源IP:命中配置的连接的源IP +* 目的端口:命中配置的连接的目的端口 +* 源端口:命中配置的连接的源端口 +* 串联设备:暂不支持 +* 方向:该日志是传输方向--境内/境外 +* 流类型:该流是单向或双向流 +* 服务端地址:该流服务端所在的地理区域,eg.Hong Kong、United States +* 客户端地址:该流客户端所在的地理区域,eg.Hong Kong、United States +* 客户端ASN:客户端的ASN号(自治系统号) +* 服务端ASN:服务端的ASN号(自治系统号) +* 客户端用户名:客户端账户的用户名 +* 服务端用户名:服务端账户的用户名 +* 现场日志文件地址:该日志保存的地址 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_redirect_policy.md b/src/main/webapp/online-help/proxy/https_redirect_policy.md new file mode 100644 index 000000000..0291d616b --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_redirect_policy.md @@ -0,0 +1,49 @@ +#### [1.功能简介](#accordion1_1) + +HTTP(s)重定向主要对将请求的页面根据配置的信息重定向到指定的网页,主要包括应答重定向,IP重定向,URL重定向,请求头域重定向和应答头域重定向,请求内容重定向,应答内容重定向,账号重定向。 + +#### [2.基础配置信息](#accordion1_2) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* HTTP 应答头域:同“HTTP(s)监测” +* HTTP 请求内容:同“HTTP(s)监测” +* HTTP 应答内容:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [3.业务配置属性](#accordion1_3) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* HTTP 应答头域:同“HTTP(s)监测” +* HTTP 请求内容:同“HTTP(s)监测” +* HTTP 应答内容:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [4.配置约束条件](#accordion1_4) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* HTTP 应答头域:同“HTTP(s)监测” +* HTTP 请求内容:同“HTTP(s)监测” +* HTTP 应答内容:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [5.预期效果](#accordion1_5) + +* 页面重定向:浏览器重定向到指定的页面 +* 日志:生成日志 + +#### [6.配置生效区域](#accordion1_6) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效 + +#### [7.配置标签](#accordion1_7) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据。 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_replace_log.md b/src/main/webapp/online-help/proxy/https_replace_log.md new file mode 100644 index 000000000..64dd6bbc3 --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_replace_log.md @@ -0,0 +1,71 @@ +#### [1.基础信息](#accordion1_1) + +Proxy日志按照控制策略类型进行分类,分为HTTP(S)监测、HTTP(S)管控、HTTP(S)重定向配置、HTTP(S)替换。每类日志页面下有两个基础搜索选项:开始时间、结束时间。和三个功能按钮搜:搜索、重置、筛选和右侧的设置按钮。 + +* 选项名称:开始时间- +* 执行动作:点击“开始时间”可以选择搜索日志的时间范围。时间选项中有当前时间的日历和时间表,以确定具体的筛选时间,下方三个选项“clear”表示清空当前选择、“Today”表示将选择时间定为当前时间,“OK”表示确认。确认时间范围后,搜索结果将返回时间范围内的满足搜索条件的HTTP(S)替换日志 + +* 选项名称:结束时间- +* 执行动作:点击“结束时间”可以选择搜索日志的时间范围。时间选项中有当前时间的日历和时间表,以确定具体的筛选时间,下方三个选项“clear”表示清空当前选择、“Today”表示将选择时间定为当前时间,“OK”表示确认。确认时间范围后,搜索结果将返回时间范围内的满足搜索条件的HTTP(S)替换日志 + +* 选项名称:搜索- +* 执行动作:点击“搜索”,将返回满足时间范围和筛选条件内的HTTP(S)重定向日志 + +* 选项名称:重置- +* 执行动作:点击“重置”,将筛选条件和开始时间结束时间清空 + +* 选项名称:筛选- +* 执行动作:点击“筛选”,扩展日志筛选条件。eg.传输层协议、传输方向等 + +* 选项名称:筛选- +* 执行动作:点击“筛选”,选择查询结果输出的日志信息项 + +#### [2.拓展筛选项](#accordion1_3) + +点开筛选按钮后,会出现扩展搜索选项:传输层协议、传输方向、出入口、处理机IP、源IP、目的IP和配置ID。 + +* 选项名称:传输层协议- +* 执行动作:点击“筛选”——>选择“传输层协议”,可以选择:L2TP、IPv4\_UDP、IPv6、IPv6\_UDP、OpenVPN、MAC、MPLS、IPv4\_TCP、IPv4、IPv6\_TCP、PPTP、VLAN、GRE。确认筛选的传输层协议后,搜索结果将返回选定时间范围内的对应协议的HTTP(S)替换日志,不做选择时默认所有协议 + +* 选项名称:传输方向- +* 执行动作:点击“筛选”——>选择“传输方向”,可以选择:境内、境外。境内表示触发规则的源IP为内部IP,境外表示触发规则的源IP为外部IP。确认筛选的传输方向后,搜索结果将返回选定时间范围内的对应传输方向的HTTP(S)重定向日志,不做选择时默认境内外 + +* 选项名称:出入口- +* 执行动作:点击“筛选”——>选择“出入口”。暂时不支持该功能 + +* 选项名称:处理机IP- +* 执行动作:点击“筛选”——>选择“处理机IP”,输入筛选的处理机IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的处理机IP后,搜索结果将返回选定时间范围内的对应处理机IP的HTTP(S)替换日志,不做选择时默认所有IP + +* 选项名称:源IP- +* 执行动作:点击“筛选”——>选择“源IP”,输入筛选的源IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的源IP后,搜索结果将返回选定时间范围内的对应源IP的HTTP(S)替换日志,不做选择时默认所有IP + +* 选项名称:目的IP- +* 执行动作:点击“筛选”——>选择“目的IP”,输入筛选的目的IP地址,支持IPv4和IPv6,IPv4输入“IPv4 xxx”,IPv输入“IPv6 xxx”(xxx为对应IP地址),eg."IPv4 192.168.17.3"、"IPv6 fc00::1:1f"。确认筛选的目的IP后,搜索结果将返回选定时间范围内的对应目的IP的HTTP(S)替换日志,不做选择时默认所有IP + +* 选项名称:配置ID- +* 执行动作:点击“筛选”——>选择“配置ID”,输入筛选的配置ID。确认筛选的目的IP后,搜索结果将返回选定时间范围内的对应配置ID的HTTP(S)重定向日志,不做选择时默认所有配置 + +#### [3.日志信息标签:配置ID、发现时间、出入口、URL、处理机IP、传输层协议、源目的IP端口等](#accordion1_2) + +此处对日志信息每项标签做解析,帮助使用人员理解日志具体信息: Proxy在命中记录日志的控制策略时将会产生相应的日志信息,命中配置的消息日志信息包括:配置ID、发现时间、出入口、URL、处理机IP、传输层协议、目的IP、源IP、目的端口、源端口、串联设备、方向、流类型、服务端地址、客户端地址、客户端ASN、服务端ASN、客户端用户名、服务端用户名、现场日志文件地址。 + +* 配置ID:命中配置的配置ID +* 发现时间:命中规则的时间 +* 出入口:暂不支持 +* URL:命中配置的URL +* 处理机IP:处理这条命中规则的服务器IP +* 传输层协议:这条消息的传输层协议 +* 目的IP:命中配置的连接的目的IP +* 源IP:命中配置的连接的源IP +* 目的端口:命中配置的连接的目的端口 +* 源端口:命中配置的连接的源端口 +* 串联设备:暂不支持 +* 方向:该日志是传输方向--境内/境外 +* 流类型:该流是单向或双向流 +* 服务端地址:该流服务端所在的地理区域,eg.Hong Kong、United States +* 客户端地址:该流客户端所在的地理区域,eg.Hong Kong、United States +* 客户端ASN:客户端的ASN号(自治系统号) +* 服务端ASN:服务端的ASN号(自治系统号) +* 客户端用户名:客户端账户的用户名 +* 服务端用户名:服务端账户的用户名 +* 现场日志文件地址:该日志保存的地址 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_replace_policy.md b/src/main/webapp/online-help/proxy/https_replace_policy.md new file mode 100644 index 000000000..608522318 --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_replace_policy.md @@ -0,0 +1,43 @@ +#### [1.功能简介](#accordion1_1) + +HTTP(s)替换的主要功能是将访问网站的应答内容替换为配置的内容,主要包括IP替换,URL替换,请求头域替换和应答头域替换,账号替换 + +#### [2.基础配置信息](#accordion1_2) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* HTTP 应答头域:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [3.业务配置属性](#accordion1_2) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* HTTP 应答头域:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [4.配置约束条件](#accordion1_3) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* HTTP 应答头域:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [5.预期效果](#accordion1_4) + +* 证书检查:浏览器的证书被替换 +* 日志检查:产生日志信息 + +#### [6.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效 + +#### [7.配置标签](#accordion1_6) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据。 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/https_whiteList_policy.md b/src/main/webapp/online-help/proxy/https_whiteList_policy.md new file mode 100644 index 000000000..6fffe3015 --- /dev/null +++ b/src/main/webapp/online-help/proxy/https_whiteList_policy.md @@ -0,0 +1,39 @@ +#### [1.功能简介](#accordion1_1) + +HTTP(s)白名单主要是对访问的网站进行拦截,但是不替换证书,从而不解析网站的加密流量,主要包括IP拦截白名单,URL白名单,请求头域白名单,账号白名单 + +#### [2.基础配置信息](#accordion1_2) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [3.业务配置属性](#accordion1_2) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [4.配置约束条件](#accordion1_3) + +* IP:同“IP拦截” +* HTTP URL:同“域名拦截” +* HTTP 请求头域:同“HTTP(s)监测” +* 账号:同“HTTP(s)监测” + +#### [5.预期效果](#accordion1_4) + +* 证书检查:证书未替换 + +#### [6.配置生效区域](#accordion1_5) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效 + +#### [7.配置标签](#accordion1_6) + +* 来函:官方或其他组织下达的配置流量管控依据 +* 分类:配置所属的类别 +* 性质:配置所属的性质 +* 标签:配置所属的标签 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/intercept_policy.md b/src/main/webapp/online-help/proxy/intercept_policy.md new file mode 100644 index 000000000..ab37be760 --- /dev/null +++ b/src/main/webapp/online-help/proxy/intercept_policy.md @@ -0,0 +1,19 @@ +#### [1.Function Introduction](#accordion1_1) + +On National Proxy System, Individual Intercept policy rules determines whether to intercept/optimize a connection based on traffic attributes, such as IP address, domain name and Subscribe ID. You could specify these attributes in IP Intercept and Domain Intercept. + +#### [2.Action](#accordion1_2) + +Both IP intercept and Domain Intercept are subject two actions: + +* Bypass: the Proxy passes through the network connection without apply an optimization or policy checking. It’s could be used to bypass SSL pinning applications, such as Apple Store and WhatsApp, or a of a VIP’s IP address. In case of traffic matches one more policies, bypass overrides intercept. +* Intercept: the National Proxy System intercepts network traffic for further control policy and cache policy checking. When a connection is set to intercept, the proxy terminates the connection and initiates a new connection between client and server. If the connection is SSL encrypted, the original certificate is replaced with a substitute one. + + When Intercept Related Domains is enabled, domains that share one certificates with the specified domain are considered as the same. For example, if the intercept facebook.com with Intercept Related Domain option, then *.xx.fbcdn.net, fb.com, .messenger.com and etc. are also intercepted. There may be side effects that intercept many different websites when they were hosted in a same CDN provider (Content Delivery Network). + + Key ring determines which certificate will be used to generate substitute certificate. You could configure key ring through Proxy Policy Object page. If no key ring is specified, proxy will use the default one. + + Intercept policy produces no log. You can find out if the interception is successful by checking if the certificate is issued by your pre-configured Root CA. You need a PC which traffic has already directed to the Proxy, and a web browser to test the policy. For Chrome and Microsoft Internet Explorer, you could click the lock icon on the address bar to view certificate. For Firefox, after you clicking the lock icon, click “>” button to show connection details, click “more information”, and then click “view certificate”. If the browser warning that the connection is not secure, one possible reason is you haven’t install/trust the root certificate yet. + + +### Note: You should exercise caution because web applications may not cooperate with SSL interception, such as SSL pinning, mutual authentication or non-standard SSL implementation. \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/ip_intercept_policy.md b/src/main/webapp/online-help/proxy/ip_intercept_policy.md new file mode 100644 index 000000000..c04c505ab --- /dev/null +++ b/src/main/webapp/online-help/proxy/ip_intercept_policy.md @@ -0,0 +1,45 @@ +#### [1.功能简介](#accordion1_1) + +IP拦截主要用于配置拦截的IP地址和端口号,测试拦截的效果,其中包括拦截黑名单和拦截白名单,当选择黑名单,这配置了IP地址的被测机器的浏览器证书替换,当选择白名单,则浏览器的证书不会替换。拦截的端口一般配置为服务的端口。 + +#### [2.配置基础属性](#accordion1_2) + +* 源IP:用户的IP地址 +* 目的IP:网络服务器的IP +* 源端口:用户的端口 +* 目的端口:服务使用的端口 +* 端口掩码:使用掩码表示的端口 +* IP范围:表示一段范围内的IP地址 +* IP掩码:使用掩码方式表示的IP段地址 + +#### [3.业务配置属性](#accordion1_3) + +* 源IP:报文中的源IP +* 目的IP:报文中目的IP +* 源端口:报文中的源端口 +* 目的端口:报文中的目的端口 + +#### [4.配置约束条件](#accordion1_4) + +* 源IP:与目的IP不同,且合法 +* 源端口:在0——65535范围以内 +* 目的IP:与源IP不同,且合法 +* 目的端口:在0——65535范围以为 +* IP范围:x.x.x.0——x.x.x.255 +* IP掩码:x.x.x.x/mask,mask属于16—32 + +#### [5.预期效果](#accordion1_5) + +* 黑名单:浏览器证书替换 +* 白名单:证书未替换 + +#### [6.配置生效区域](#accordion1_6) + +配置的生效区域,生效区域包括地区,以及ISP,地区和ISP可组合,即某个地区的某个运营商流量生效, 或者某个地区的所有流量生效,或者某个运营商的所有流量生效,也可全域生效 + +#### [7.配置标签](#accordion1_7) + +* 来函:必选项,官方或其他组织下达的配置流量管控依据。 +* 分类:非必选项,配置分类,例如内容安全、网络攻击等。 +* 性质:非必选项,配置性质,例如政治、暴力、宗教等。 +* 标签:非必选项,自定义标签。 \ No newline at end of file diff --git a/src/main/webapp/online-help/proxy/proxy_policy_object.md b/src/main/webapp/online-help/proxy/proxy_policy_object.md new file mode 100644 index 000000000..431374e12 --- /dev/null +++ b/src/main/webapp/online-help/proxy/proxy_policy_object.md @@ -0,0 +1,154 @@ +#### [1.Function Introduction](#accordion1_1) + +A policy object is a single object or a collective unit that groups discrete identities such as IP addresses, URLs, applications, or users. With policy objects that are a collective unit, you can reference the object in policy instead of manually selecting multiple objects one at a time. Typically, when creating a policy object, you group objects that require similar permissions in policy. + +#### [2.Key Ring](#accordion1_2) + +On National Proxy System, Key Ring is a pair of private key and public certificate. You can also import a certificate chain containing multiple certificates. Key Ring is a policy object, you can reference it in Intercept Policy. There are three Certificate Type: + +* End-entity Certificate: is used for web servers to identify themselves. The Public Key File MUST be .p12 format that contains entire certificate chain. The Private Key File could be .pem, .key or .p12 format. This certificate type is not applicable to Domain Intercept for it cannot be used to sign other certificates. Expire After parameter is also not applicable to end-entity certificate for the same reason. +* Intermedia Certificate: is used to sign other certificates. An intermediate certificate must be signed by another intermediate certificate, or a root certificate. The Public Key File MUST be .p12 format that contains entire certificate chain. The Expire After parameter indicates the expiration of the substitute certificate that was issued by this intermedia certificate. +* Root Certificate: is used to sign other certificates. The Public Key File could be .der, .cer, .crt or .pem format. The Expire After parameter has the same meaning as Intermedia Certificate. Specification of certificate formats: + * .pem- (Privacy-enhanced Electronic Mail) Base64 encoded DER certificate, enclosed between "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" + * .cer, .crt, .der – usually in binary DER form, but Base64-encoded certificates are common too (see .pem above) + * .p12 – PKCS#12, may contain certificate(s) (public) and private keys (without password protected) + +#### [3.Trusted Certificate](#accordion1_3) + +National Proxy System has a build-in trusted certificate authorities list. When the original certificate is issued by a certificate authority that not in the list, the proxy will issued the substitute certificate with an untrusted root certificate, and so consequently, the browser could identify unsecure connections. + +You can add a custom certificate authority to the trusted certificate authorities of the system. + +The certificate MUST be PEM format. + +Following are the National Proxy System’s default trusted certificate authorities: + +* ACCVRAIZ1 +* Actalis Authentication Root CA +* AddTrust External CA Root +* AffirmTrust Commercial +* AffirmTrust Networking +* AffirmTrust Premium +* AffirmTrust Premium ECC +* Amazon Root CA 1 +* Amazon Root CA 2 +* Amazon Root CA 3 +* Amazon Root CA 4 +* Atos TrustedRoot 2011 +* Autoridad de Certificacion Firmaprofesional CIF A62634068 +* Baltimore CyberTrust Root +* Buypass Class 2 Root CA +* Buypass Class 3 Root CA +* CA Disig Root R2 +* CFCA EV ROOT +* COMODO Certification Authority +* COMODO ECC Certification Authority +* COMODO RSA Certification Authority +* Certigna +* Certinomis - Root CA +* Class 2 Primary CA +* Certplus Root CA G1 +* Certplus Root CA G2 +* Certum Trusted Network CA +* Certum Trusted Network CA 2 +* Chambers of Commerce Root - 2008 +* AAA Certificate Services +* Cybertrust Global Root +* D-TRUST Root Class 3 CA 2 2009 +* D-TRUST Root Class 3 CA 2 EV 2009 +* DST Root CA X3 +* Deutsche Telekom Root CA 2 +* DigiCert Assured ID Root CA +* DigiCert Assured ID Root G2 +* DigiCert Assured ID Root G3 +* DigiCert Global Root CA +* DigiCert Global Root G2 +* DigiCert Global Root G3 +* DigiCert High Assurance EV Root CA +* DigiCert Trusted Root G4 +* E-Tugra Certification Authority +* EC-ACC +* EE Certification Centre Root CA +* Entrust.net Certification Authority (2048) +* Entrust Root Certification Authority +* Entrust Root Certification Authority - EC1 +* Entrust Root Certification Authority - G2 +* GDCA TrustAUTH R5 ROOT +* GeoTrust Global CA +* GeoTrust Primary Certification Authority +* GeoTrust Primary Certification Authority - G2 +* GeoTrust Primary Certification Authority - G3 +* GeoTrust Universal CA +* GeoTrust Universal CA 2 +* GlobalSign +* GlobalSign +* GlobalSign Root CA +* GlobalSign +* GlobalSign +* Global Chambersign Root - 2008 +* Go Daddy Root Certificate Authority - G2 +* Hellenic Academic and Research Institutions ECC RootCA 2015 +* Hellenic Academic and Research Institutions RootCA 2011 +* Hellenic Academic and Research Institutions RootCA 2015 +* Hongkong Post Root CA 1 +* ISRG Root X1 +* IdenTrust Commercial Root CA 1 +* IdenTrust Public Sector Root CA 1 +* Izenpe.com +* LuxTrust Global Root 2 +* Microsec e-Szigno Root CA 2009 +* NetLock Arany (Class Gold) Főtanúsítvány +* Network Solutions Certificate Authority +* OISTE WISeKey Global Root GA CA +* OISTE WISeKey Global Root GB CA +* OpenTrust Root CA G1 +* OpenTrust Root CA G2 +* OpenTrust Root CA G3 +* QuoVadis Root Certification Authority +* QuoVadis Root CA 1 G3 +* QuoVadis Root CA 2 +* QuoVadis Root CA 2 G3 +* QuoVadis Root CA 3 +* QuoVadis Root CA 3 G3 +* SSL.com EV Root Certification Authority ECC +* SSL.com EV Root Certification Authority RSA R2 +* SSL.com Root Certification Authority ECC +* SSL.com Root Certification Authority RSA +* SZAFIR ROOT CA2 +* SecureSign RootCA11 +* SecureTrust CA +* Secure Global CA +* Sonera Class2 CA +* Staat der Nederlanden EV Root CA +* Staat der Nederlanden Root CA - G2 +* Staat der Nederlanden Root CA - G3 +* Starfield Root Certificate Authority - G2 +* Starfield Services Root Certificate Authority - G2 +* SwissSign Gold CA - G2 +* SwissSign Silver CA - G2 +* T-TeleSec GlobalRoot Class 2 +* T-TeleSec GlobalRoot Class 3 +* TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1 +* TWCA Global Root CA +* TWCA Root Certification Authority +* TeliaSonera Root CA v1 +* TrustCor ECA-1 +* TrustCor RootCert CA-1 +* TrustCor RootCert CA-2 +* TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5 +* USERTrust ECC Certification Authority +* USERTrust RSA Certification Authority +* VeriSign Class 3 Public Primary Certification Authority - G4 +* VeriSign Class 3 Public Primary Certification Authority - G5 +* VeriSign Universal Root Certification Authority +* VeriSign Class 3 Public Primary Certification Authority - G3 +* Visa eCommerce Root +* XRamp Global Certification Authority +* thawte Primary Root CA +* thawte Primary Root CA - G2 +* thawte Primary Root CA - G3 +* Microsoft Root Authority +* Microsoft Root Certificate Authority +* Microsoft Root Certificate Authority 2010 +* Microsoft Root Certificate Authority 2011 +* Baltimore CyberTrust Root \ No newline at end of file diff --git a/src/main/webapp/online-help/ysp/audio_sample.md b/src/main/webapp/online-help/ysp/audio_sample.md new file mode 100644 index 000000000..5b0f519cd --- /dev/null +++ b/src/main/webapp/online-help/ysp/audio_sample.md @@ -0,0 +1,37 @@ +#### [1.功能简介](#accordion1_1) + +音频样例匹配功能,可对网络流量中的音频内容进行分析,找出与用户配置的音频样例相匹配的音视频流量,并执行阻断与监测动作,产生日志 + +#### [2.配置基础信息](#accordion1_2) + +* 规则名称:统一填写 +* 执行动作:(阻断与监测)统一填写 + +#### [3.业务配置属性](#accordion1_3) + +* 源文件:上传本地音频文件,将以该文件中包含的音频信息与流量中传输的音频进行匹配,命中后执行配置动作,产生日志 +* 置信度:当执行动作为监测时,用户可指定匹配命中的最小置信度,置信度可选值为70、80、90、100 + +#### [4.配置约束条件](#accordion1_4) + +* 上传的本地音频文件大小应不大于20MB +* 上传的本地音频文件时长应不大于2分钟 +* 支持的本地音频文件格式为:mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm,ogv,wav,mp3 + +#### [5.配置生效区域](#accordion1_5) + +统一填写 + +#### [6.配置标签](#accordion1_6) + +* 统一填写 + +#### [7.预期效果](#accordion1_7) + +* 首次分析阻断效果:命中样例配置后,客户端收到NTC系统发送的虚假RST报文,如此时该音视频未缓存或下载完成,则中断当前音视频的播放或下载 +* 后续访问阻断效果:首次分析命中后,会生成该音视频的传输特征,后续访问直接依据传输特征进行阻断 + +#### [8.免责声明](#accordion1_8) + +* 对于音视频编码的索引信息在音视频文件尾部的情况,本系统不予支持 +* 由于音视频内容分析滞后于网络传输,本系统不保证首次观看音视频时的阻断效果 \ No newline at end of file diff --git a/src/main/webapp/online-help/ysp/file_digest.md b/src/main/webapp/online-help/ysp/file_digest.md new file mode 100644 index 000000000..a3133b45f --- /dev/null +++ b/src/main/webapp/online-help/ysp/file_digest.md @@ -0,0 +1,35 @@ +#### [1.功能简介](#accordion1_1) + +文件摘要检测功能,可提取网络流量中传输文件的摘要信息,并找出与用户配置的文件具有相似摘要的流量,命中配置后,执行阻断与监测动作,产生日志 + +#### [2.配置基础信息](#accordion1_2) + +* 规则名称:统一填写 +* 执行动作:(阻断与监测)统一填写 + +#### [3.业务配置属性](#accordion1_3) + +* 文件:上传本地文件,该文件将与流量中包含的文件进行匹配,命中后执行配置动作,产生日志 +* 置信度:当执行动作为监测时,用户可指定匹配命中的最小置信度,置信度可选值为70、80、90、100 + +#### [4.配置约束条件](#accordion1_4) + +* 上传的本地文件大小应不大于20MB +* 支持的本地文件格式为:txt,doc,img,docx,pptx,xlsx,xls,ppt + +#### [5.配置生效区域](#accordion1_5) + +统一填写 + +#### [6.配置标签](#accordion1_6) + +* 统一填写 + +#### [7.预期效果](#accordion1_7) + +* 首次分析阻断效果:当客户端下载某文件,并命中文件摘要配置后,客户端将收到NTC系统发送的虚假RST报文,如此时该文件未下载完成,则中断当前文件的下载 +* 后续访问阻断效果:首次分析命中后,会生成该文件的传输特征,后续下载请求直接依据传输特征进行阻断 + +#### [8.免责声明](#accordion1_8) + +* 由于文件摘要的分析滞后于网络传输,本系统不保证首次文件下载时的阻断效果 \ No newline at end of file diff --git a/src/main/webapp/online-help/ysp/picture_sample.md b/src/main/webapp/online-help/ysp/picture_sample.md new file mode 100644 index 000000000..2ca481a9f --- /dev/null +++ b/src/main/webapp/online-help/ysp/picture_sample.md @@ -0,0 +1,33 @@ +#### [1.功能简介](#accordion1_1) + +图片样例匹配功能,可对网络流量中的图片内容进行分析,找出与用户配置的图片样例相匹配的图片流量,并执行阻断与监测动作,产生日志 + +#### [2.配置基础信息](#accordion1_2) + +* 规则名称:统一填写 +* 执行动作:阻断与监测(统一填写) + +#### [3.业务配置属性](#accordion1_3) + +* 源文件:上传本地图片文件,将以该文件中包含的图片画面信息与流量中传输的图片进行匹配,命中后执行配置动作,产生日志 +* 置信度:当执行动作为监测时,用户可指定匹配命中的最小置信度,置信度可选值为70、80、90、100 + +#### [4\. 配置约束条件](#accordion1_4) + +* 支持的上传图片格式为:bmp,jpg,tiff,raw,gif + +#### [5.配置生效区域](#accordion1_5) + +统一填写 + +#### [6.配置标签](#accordion1_6) + +* 统一填写 + +#### [7.预期效果](#accordion1_7) + +* 阻断效果:客户端访问某图片命中图片样例配置后,会生成该图片的传输特征,后续对该图片的访问直接依据传输特征进行阻断 + +#### [8.免责声明](#accordion1_8) + +* 对于图片文件大于4MB的图片,本系统不予支持 \ No newline at end of file diff --git a/src/main/webapp/online-help/ysp/video_sample.md b/src/main/webapp/online-help/ysp/video_sample.md new file mode 100644 index 000000000..a5a52f764 --- /dev/null +++ b/src/main/webapp/online-help/ysp/video_sample.md @@ -0,0 +1,38 @@ +#### [1.功能简介](#accordion1_1) + +视频样例匹配功能,可对网络流量中的视频内容进行分析,找出与用户配置的视频样例相匹配的视频流量,并执行阻断与监测动作,产生日志 + +#### [2.配置基础信息](#accordion1_2) + +* 规则名称:统一填写 +* 执行动作:(阻断与监测)统一填写 + +#### [3.业务配置属性](#accordion1_3) + +* 源文件:上传本地视频文件,将以该文件中包含的视频画面信息与流量中传输的视频进行匹配,命中后执行配置动作,产生日志 +* 置信度:当执行动作为监测时,用户可指定匹配命中的最小置信度,置信度可选值为70、80、90、100 + +#### [4.配置约束条件](#accordion1_4) + +* 上传的本地视频文件大小应不大于20MB +* 上传的本地视频文件时长应不大于2分钟 +* 支持的本地视频文件格式为:mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm + +#### [5.配置生效区域](#accordion1_5) + +统一填写 + +#### [6.配置标签](#accordion1_6) + +* 统一填写 + +#### [7.预期效果](#accordion1_7) + +* 首次分析阻断效果:命中样例配置后,客户端收到NTC系统发送的虚假RST报文,如此时该视频未缓存或下载完成,则中断当前视频的播放或下载 +* 后续访问阻断效果:首次分析命中后,会生成该视频的传输特征,后续访问直接依据传输特征进行阻断 + +#### [8.免责声明](#accordion1_8) + +* 对于音视频编码的索引信息在音视频文件尾部的情况,本系统不予支持 +* 对于分辨率大于4兆的视频,本系统不予支持 +* 由于音视频内容分析滞后于网络传输,本系统不保证首次观看音视频时的阻断效果 \ No newline at end of file diff --git a/src/main/webapp/online-help/ysp/video_scene.md b/src/main/webapp/online-help/ysp/video_scene.md new file mode 100644 index 000000000..d39e1c838 --- /dev/null +++ b/src/main/webapp/online-help/ysp/video_scene.md @@ -0,0 +1,34 @@ +#### [1.功能简介](#accordion1_1) + +视频场景检测功能,可检测出网络中传输的包含视频色情场景的流量,并根据用户配置,进行阻断或监测,产生日志 + +#### [2.配置基础信息](#accordion1_2) + +* 执行动作:(阻断与监测)统一填写 + +#### [3.业务配置属性](#accordion1_3) + +* 置信度:当执行动作为监测时,用户可指定匹配命中的最小置信度,置信度可选值为70、80、90、100 + +#### [4.配置约束条件](#accordion1_4) + +* 无 + +#### [5.配置生效区域](#accordion1_5) + +统一填写 + +#### [6.配置标签](#accordion1_6) + +* 统一填写 + +#### [7.预期效果](#accordion1_7) + +* 首次分析阻断效果:检测到色情场景后,客户端收到NTC系统发送的虚假RST报文,如此时该视频未缓存或下载完成,则中断当前视频的播放或下载 +* 后续访问阻断效果:首次分析命中后,会生成该视频的传输特征,后续访问直接通过传输特征进行阻断 + +#### [8.免责声明](#accordion1_8) + +* 对于音视频编码的索引信息在音视频文件尾部的情况,本系统不予支持 +* 对于分辨率大于4兆的视频,本系统不予支持 +* 由于音视频内容分析滞后于网络传输,本系统不保证首次观看音视频时的阻断效果 \ No newline at end of file diff --git a/src/main/webapp/online-help/ysp/voip_sample.md b/src/main/webapp/online-help/ysp/voip_sample.md new file mode 100644 index 000000000..7aa781fc2 --- /dev/null +++ b/src/main/webapp/online-help/ysp/voip_sample.md @@ -0,0 +1,35 @@ +#### [1.功能简介](#accordion1_1) + +VOIP样例匹配功能,可对VOIP流量中的语音内容进行分析,找出与用户配置的音频样例相匹配的VOIP流量,并执行阻断与监测动作,产生日志 + +#### [2.配置基础信息](#accordion1_2) + +* 规则名称:统一填写 +* 执行动作:(阻断与监测)统一填写 + +#### [3.业务配置属性](#accordion1_3) + +* 源文件:上传本地音频文件,将以该文件中包含的音频信息与流量中传输的VOIP音频内容进行匹配,命中后执行配置动作,产生日志 +* 置信度:当执行动作为监测时,用户可指定匹配命中的最小置信度,置信度可选值为70、80、90、100 + +#### [4.配置约束条件](#accordion1_4) + +* 上传的本地音频文件大小应不大于20MB +* 上传的本地音频文件时长应不大于2分钟 +* 支持的本地音频文件格式为:mp4,flv,asf,wmv,avi,mpeg,mov,dat,m4v,m4p,m4b,webm,ogv,wav,mp3 + +#### [5.配置生效区域](#accordion1_5) + +统一填写 + +#### [6.配置标签](#accordion1_6) + +* 统一填写 + +#### [7.预期效果](#accordion1_7) + +* 阻断效果:命中配置后,通过串联设备临时规则,丢弃后续传输报文,已接通的VOIP电话不中断,但无后继语音内容 + +#### [8.免责声明](#accordion1_8) + +无 \ No newline at end of file diff --git a/src/main/webapp/static/global/plugins/editor.md-master/.gitignore b/src/main/webapp/static/global/plugins/editor.md-master/.gitignore new file mode 100644 index 000000000..9a85439cf --- /dev/null +++ b/src/main/webapp/static/global/plugins/editor.md-master/.gitignore @@ -0,0 +1,15 @@ +logs +*.log +*.pid +*.seed +node_modules/ +.sass-cache/ +research/ +test/ +backup/ +examples/uploads/**/* +*.bat +*.sh +.project +.url +css/*.map \ No newline at end of file diff --git a/src/main/webapp/static/global/plugins/editor.md-master/.jshintrc b/src/main/webapp/static/global/plugins/editor.md-master/.jshintrc new file mode 100644 index 000000000..470e1950d --- /dev/null +++ b/src/main/webapp/static/global/plugins/editor.md-master/.jshintrc @@ -0,0 +1,20 @@ +{ + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 4, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "double", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "white": true +} \ No newline at end of file diff --git a/src/main/webapp/static/global/plugins/editor.md-master/BUGS.md b/src/main/webapp/static/global/plugins/editor.md-master/BUGS.md new file mode 100644 index 000000000..9c61c2d80 --- /dev/null +++ b/src/main/webapp/static/global/plugins/editor.md-master/BUGS.md @@ -0,0 +1,22 @@ +#Bugs + +> 说明:删除线表示已经解决。 + +####IE8 + +- ~~不能加载;~~ +- flowChart(流程图)、sequenceDiagram(序列图)不支持IE8; +- ~~不支持Markdown转HTML页面解析预览;~~ + +####IE8 & IE9 & IE10 + +- KaTeX会出现解析错误,但不影响程序运行; + +####Sea.js + +- ~~Raphael.js无法加载;~~ + +####Require.js + +- ~~CodeMirror编辑器的代码无法高亮;~~ +- ~~sequenceDiagram不支持: `Uncaught TypeError: Cannot call method 'isArray' of undefined.`~~ diff --git a/src/main/webapp/static/global/plugins/editor.md-master/CHANGE.md b/src/main/webapp/static/global/plugins/editor.md-master/CHANGE.md new file mode 100644 index 000000000..519813719 --- /dev/null +++ b/src/main/webapp/static/global/plugins/editor.md-master/CHANGE.md @@ -0,0 +1,534 @@ +## 更新日志 + +### v1.0.x + +##### v1.0.0 beta + +预览版:基本功能完成; + +##### v1.0.0 releases + +发布 v1.0.0 正式版。 + +主要更新: + +- 新建分支 `mathjax-version`,但不打算继续对此分支进行开发; + +- 移除 MathJax,改用 KaTeX [#2](https://github.com/pandao/editor.md/issues/2),解析和预览响应速度大幅度提高 [#3](https://github.com/pandao/editor.md/issues/3); + - 移除 `mathjax` 配置项; + - 移除 `mathjaxURL` 属性; + - 移除 `setMathJaxConfig()` 方法; + - 移除 `loadMathJax()` 方法; + - 移除MathJax的所有示例; + - 新增 `tex` 配置项,表示是否开启支持科学公式 TeX ,基于 KaTeX; + - 新增 `katexURL` 属性; + - 新增 `loadKaTeX` 方法; + - 新增 KaTeX 的示例; + +- `setCodeEditor()` 方法更名为 `setCodeMirror()`; + +- 合并 CodeMirror 使用到的多个 JS 模块文件,大幅减少 HTTP 请求,加快下载速度; + - 新增合并后的两个模块文件:`./lib/codemirror/modes.min.js`、`./lib/codemirror/addons.min.js` ; + - `Gulpfile.js` 新增合并 CodeMirror 模块文件的任务方法 `codemirror-mode` 和 `codemirror-addon` ; + - 另外在使用 Require.js 时,因为 CodeMirror 的严格模块依赖的限制,不能使用上述合并的模块文件,仍然采用动态加载多个模块文件; + +- 更新 `README.md` 等相关文档和示例; + +- 解决 Sea.js 环境下 Raphael.js 无法运行导致不支持流程图和时序图的问题,即必须先加载 Raphael.js ,后加载 Sea.js ; + +### v1.1.x + +##### v1.1.0 + +主要更新: + +- 设计并更换了 Logo; +- 新增添加图片、链接、锚点链接、代码块、预格式文本等操作弹出对话框层及示例; +- 新增支持图片(跨域)上传; +- 改用 ` + +``` + +> Tip: Editor.md can auto append `"); + markdownTextarea = this.markdownTextarea = editor.children("textarea"); + } + + markdownTextarea.addClass(classNames.textarea.markdown).attr("placeholder", settings.placeholder); + + if (typeof markdownTextarea.attr("name") === "undefined" || markdownTextarea.attr("name") === "") + { + markdownTextarea.attr("name", (settings.name !== "") ? settings.name : id + "-markdown-doc"); + } + + var appendElements = [ + (!settings.readOnly) ? "" : "", + ( (settings.saveHTMLToTextarea) ? "" : "" ), + "
", + "
", + "
" + ].join("\n"); + + editor.append(appendElements).addClass(classPrefix + "vertical"); + + if (settings.theme !== "") + { + editor.addClass(classPrefix + "theme-" + settings.theme); + } + + this.mask = editor.children("." + classPrefix + "mask"); + this.containerMask = editor.children("." + classPrefix + "container-mask"); + + if (settings.markdown !== "") + { + markdownTextarea.val(settings.markdown); + } + + if (settings.appendMarkdown !== "") + { + markdownTextarea.val(markdownTextarea.val() + settings.appendMarkdown); + } + + this.htmlTextarea = editor.children("." + classNames.textarea.html); + this.preview = editor.children("." + classPrefix + "preview"); + this.previewContainer = this.preview.children("." + classPrefix + "preview-container"); + + if (settings.previewTheme !== "") + { + this.preview.addClass(classPrefix + "preview-theme-" + settings.previewTheme); + } + + if (typeof define === "function" && define.amd) + { + if (typeof katex !== "undefined") + { + editormd.$katex = katex; + } + + if (settings.searchReplace && !settings.readOnly) + { + editormd.loadCSS(settings.path + "codemirror/addon/dialog/dialog"); + editormd.loadCSS(settings.path + "codemirror/addon/search/matchesonscrollbar"); + } + } + + if ((typeof define === "function" && define.amd) || !settings.autoLoadModules) + { + if (typeof CodeMirror !== "undefined") { + editormd.$CodeMirror = CodeMirror; + } + + if (typeof marked !== "undefined") { + editormd.$marked = marked; + } + + this.setCodeMirror().setToolbar().loadedDisplay(); + } + else + { + this.loadQueues(); + } + + return this; + }, + + /** + * 所需组件加载队列 + * Required components loading queue + * + * @returns {editormd} 返回editormd的实例对象 + */ + + loadQueues : function() { + var _this = this; + var settings = this.settings; + var loadPath = settings.path; + + var loadFlowChartOrSequenceDiagram = function() { + + if (editormd.isIE8) + { + _this.loadedDisplay(); + + return ; + } + + if (settings.flowChart || settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "raphael.min", function() { + + editormd.loadScript(loadPath + "underscore.min", function() { + + if (!settings.flowChart && settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "sequence-diagram.min", function() { + _this.loadedDisplay(); + }); + } + else if (settings.flowChart && !settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "flowchart.min", function() { + editormd.loadScript(loadPath + "jquery.flowchart.min", function() { + _this.loadedDisplay(); + }); + }); + } + else if (settings.flowChart && settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "flowchart.min", function() { + editormd.loadScript(loadPath + "jquery.flowchart.min", function() { + editormd.loadScript(loadPath + "sequence-diagram.min", function() { + _this.loadedDisplay(); + }); + }); + }); + } + }); + + }); + } + else + { + _this.loadedDisplay(); + } + }; + + editormd.loadCSS(loadPath + "codemirror/codemirror.min"); + + if (settings.searchReplace && !settings.readOnly) + { + editormd.loadCSS(loadPath + "codemirror/addon/dialog/dialog"); + editormd.loadCSS(loadPath + "codemirror/addon/search/matchesonscrollbar"); + } + + if (settings.codeFold) + { + editormd.loadCSS(loadPath + "codemirror/addon/fold/foldgutter"); + } + + editormd.loadScript(loadPath + "codemirror/codemirror.min", function() { + editormd.$CodeMirror = CodeMirror; + + editormd.loadScript(loadPath + "codemirror/modes.min", function() { + + editormd.loadScript(loadPath + "codemirror/addons.min", function() { + + _this.setCodeMirror(); + + if (settings.mode !== "gfm" && settings.mode !== "markdown") + { + _this.loadedDisplay(); + + return false; + } + + _this.setToolbar(); + + editormd.loadScript(loadPath + "marked.min", function() { + + editormd.$marked = marked; + + if (settings.previewCodeHighlight) + { + editormd.loadScript(loadPath + "prettify.min", function() { + loadFlowChartOrSequenceDiagram(); + }); + } + else + { + loadFlowChartOrSequenceDiagram(); + } + }); + + }); + + }); + + }); + + return this; + }, + + /** + * 设置 Editor.md 的整体主题,主要是工具栏 + * Setting Editor.md theme + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setTheme : function(theme) { + var editor = this.editor; + var oldTheme = this.settings.theme; + var themePrefix = this.classPrefix + "theme-"; + + editor.removeClass(themePrefix + oldTheme).addClass(themePrefix + theme); + + this.settings.theme = theme; + + return this; + }, + + /** + * 设置 CodeMirror(编辑区)的主题 + * Setting CodeMirror (Editor area) theme + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setEditorTheme : function(theme) { + var settings = this.settings; + settings.editorTheme = theme; + + if (theme !== "default") + { + editormd.loadCSS(settings.path + "codemirror/theme/" + settings.editorTheme); + } + + this.cm.setOption("theme", theme); + + return this; + }, + + /** + * setEditorTheme() 的别名 + * setEditorTheme() alias + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setCodeMirrorTheme : function (theme) { + this.setEditorTheme(theme); + + return this; + }, + + /** + * 设置 Editor.md 的主题 + * Setting Editor.md theme + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setPreviewTheme : function(theme) { + var preview = this.preview; + var oldTheme = this.settings.previewTheme; + var themePrefix = this.classPrefix + "preview-theme-"; + + preview.removeClass(themePrefix + oldTheme).addClass(themePrefix + theme); + + this.settings.previewTheme = theme; + + return this; + }, + + /** + * 配置和初始化CodeMirror组件 + * CodeMirror initialization + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setCodeMirror : function() { + var settings = this.settings; + var editor = this.editor; + + if (settings.editorTheme !== "default") + { + editormd.loadCSS(settings.path + "codemirror/theme/" + settings.editorTheme); + } + + var codeMirrorConfig = { + mode : settings.mode, + theme : settings.editorTheme, + tabSize : settings.tabSize, + dragDrop : false, + autofocus : settings.autoFocus, + autoCloseTags : settings.autoCloseTags, + readOnly : (settings.readOnly) ? "nocursor" : false, + indentUnit : settings.indentUnit, + lineNumbers : settings.lineNumbers, + lineWrapping : settings.lineWrapping, + extraKeys : { + "Ctrl-Q": function(cm) { + cm.foldCode(cm.getCursor()); + } + }, + foldGutter : settings.codeFold, + gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], + matchBrackets : settings.matchBrackets, + indentWithTabs : settings.indentWithTabs, + styleActiveLine : settings.styleActiveLine, + styleSelectedText : settings.styleSelectedText, + autoCloseBrackets : settings.autoCloseBrackets, + showTrailingSpace : settings.showTrailingSpace, + highlightSelectionMatches : ( (!settings.matchWordHighlight) ? false : { showToken: (settings.matchWordHighlight === "onselected") ? false : /\w/ } ) + }; + + this.codeEditor = this.cm = editormd.$CodeMirror.fromTextArea(this.markdownTextarea[0], codeMirrorConfig); + this.codeMirror = this.cmElement = editor.children(".CodeMirror"); + + if (settings.value !== "") + { + this.cm.setValue(settings.value); + } + + this.codeMirror.css({ + fontSize : settings.fontSize, + width : (!settings.watch) ? "100%" : "50%" + }); + + if (settings.autoHeight) + { + this.codeMirror.css("height", "auto"); + this.cm.setOption("viewportMargin", Infinity); + } + + if (!settings.lineNumbers) + { + this.codeMirror.find(".CodeMirror-gutters").css("border-right", "none"); + } + + return this; + }, + + /** + * 获取CodeMirror的配置选项 + * Get CodeMirror setting options + * + * @returns {Mixed} return CodeMirror setting option value + */ + + getCodeMirrorOption : function(key) { + return this.cm.getOption(key); + }, + + /** + * 配置和重配置CodeMirror的选项 + * CodeMirror setting options / resettings + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setCodeMirrorOption : function(key, value) { + + this.cm.setOption(key, value); + + return this; + }, + + /** + * 添加 CodeMirror 键盘快捷键 + * Add CodeMirror keyboard shortcuts key map + * + * @returns {editormd} 返回editormd的实例对象 + */ + + addKeyMap : function(map, bottom) { + this.cm.addKeyMap(map, bottom); + + return this; + }, + + /** + * 移除 CodeMirror 键盘快捷键 + * Remove CodeMirror keyboard shortcuts key map + * + * @returns {editormd} 返回editormd的实例对象 + */ + + removeKeyMap : function(map) { + this.cm.removeKeyMap(map); + + return this; + }, + + /** + * 跳转到指定的行 + * Goto CodeMirror line + * + * @param {String|Intiger} line line number or "first"|"last" + * @returns {editormd} 返回editormd的实例对象 + */ + + gotoLine : function (line) { + + var settings = this.settings; + + if (!settings.gotoLine) + { + return this; + } + + var cm = this.cm; + var editor = this.editor; + var count = cm.lineCount(); + var preview = this.preview; + + if (typeof line === "string") + { + if(line === "last") + { + line = count; + } + + if (line === "first") + { + line = 1; + } + } + + if (typeof line !== "number") + { + alert("Error: The line number must be an integer."); + return this; + } + + line = parseInt(line) - 1; + + if (line > count) + { + alert("Error: The line number range 1-" + count); + + return this; + } + + cm.setCursor( {line : line, ch : 0} ); + + var scrollInfo = cm.getScrollInfo(); + var clientHeight = scrollInfo.clientHeight; + var coords = cm.charCoords({line : line, ch : 0}, "local"); + + cm.scrollTo(null, (coords.top + coords.bottom - clientHeight) / 2); + + if (settings.watch) + { + var cmScroll = this.codeMirror.find(".CodeMirror-scroll")[0]; + var height = $(cmScroll).height(); + var scrollTop = cmScroll.scrollTop; + var percent = (scrollTop / cmScroll.scrollHeight); + + if (scrollTop === 0) + { + preview.scrollTop(0); + } + else if (scrollTop + height >= cmScroll.scrollHeight - 16) + { + preview.scrollTop(preview[0].scrollHeight); + } + else + { + preview.scrollTop(preview[0].scrollHeight * percent); + } + } + + cm.focus(); + + return this; + }, + + /** + * 扩展当前实例对象,可同时设置多个或者只设置一个 + * Extend editormd instance object, can mutil setting. + * + * @returns {editormd} this(editormd instance object.) + */ + + extend : function() { + if (typeof arguments[1] !== "undefined") + { + if (typeof arguments[1] === "function") + { + arguments[1] = $.proxy(arguments[1], this); + } + + this[arguments[0]] = arguments[1]; + } + + if (typeof arguments[0] === "object" && typeof arguments[0].length === "undefined") + { + $.extend(true, this, arguments[0]); + } + + return this; + }, + + /** + * 设置或扩展当前实例对象,单个设置 + * Extend editormd instance object, one by one + * + * @param {String|Object} key option key + * @param {String|Object} value option value + * @returns {editormd} this(editormd instance object.) + */ + + set : function (key, value) { + + if (typeof value !== "undefined" && typeof value === "function") + { + value = $.proxy(value, this); + } + + this[key] = value; + + return this; + }, + + /** + * 重新配置 + * Resetting editor options + * + * @param {String|Object} key option key + * @param {String|Object} value option value + * @returns {editormd} this(editormd instance object.) + */ + + config : function(key, value) { + var settings = this.settings; + + if (typeof key === "object") + { + settings = $.extend(true, settings, key); + } + + if (typeof key === "string") + { + settings[key] = value; + } + + this.settings = settings; + this.recreate(); + + return this; + }, + + /** + * 注册事件处理方法 + * Bind editor event handle + * + * @param {String} eventType event type + * @param {Function} callback 回调函数 + * @returns {editormd} this(editormd instance object.) + */ + + on : function(eventType, callback) { + var settings = this.settings; + + if (typeof settings["on" + eventType] !== "undefined") + { + settings["on" + eventType] = $.proxy(callback, this); + } + + return this; + }, + + /** + * 解除事件处理方法 + * Unbind editor event handle + * + * @param {String} eventType event type + * @returns {editormd} this(editormd instance object.) + */ + + off : function(eventType) { + var settings = this.settings; + + if (typeof settings["on" + eventType] !== "undefined") + { + settings["on" + eventType] = function(){}; + } + + return this; + }, + + /** + * 显示工具栏 + * Display toolbar + * + * @param {Function} [callback=function(){}] 回调函数 + * @returns {editormd} 返回editormd的实例对象 + */ + + showToolbar : function(callback) { + var settings = this.settings; + + if(settings.readOnly) { + return this; + } + + if (settings.toolbar && (this.toolbar.length < 1 || this.toolbar.find("." + this.classPrefix + "menu").html() === "") ) + { + this.setToolbar(); + } + + settings.toolbar = true; + + this.toolbar.show(); + this.resize(); + + $.proxy(callback || function(){}, this)(); + + return this; + }, + + /** + * 隐藏工具栏 + * Hide toolbar + * + * @param {Function} [callback=function(){}] 回调函数 + * @returns {editormd} this(editormd instance object.) + */ + + hideToolbar : function(callback) { + var settings = this.settings; + + settings.toolbar = false; + this.toolbar.hide(); + this.resize(); + + $.proxy(callback || function(){}, this)(); + + return this; + }, + + /** + * 页面滚动时工具栏的固定定位 + * Set toolbar in window scroll auto fixed position + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setToolbarAutoFixed : function(fixed) { + + var state = this.state; + var editor = this.editor; + var toolbar = this.toolbar; + var settings = this.settings; + + if (typeof fixed !== "undefined") + { + settings.toolbarAutoFixed = fixed; + } + + var autoFixedHandle = function(){ + var $window = $(window); + var top = $window.scrollTop(); + + if (!settings.toolbarAutoFixed) + { + return false; + } + + if (top - editor.offset().top > 10 && top < editor.height()) + { + toolbar.css({ + position : "fixed", + width : editor.width() + "px", + left : ($window.width() - editor.width()) / 2 + "px" + }); + } + else + { + toolbar.css({ + position : "absolute", + width : "100%", + left : 0 + }); + } + }; + + if (!state.fullscreen && !state.preview && settings.toolbar && settings.toolbarAutoFixed) + { + $(window).bind("scroll", autoFixedHandle); + } + + return this; + }, + + /** + * 配置和初始化工具栏 + * Set toolbar and Initialization + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setToolbar : function() { + var settings = this.settings; + + if(settings.readOnly) { + return this; + } + + var editor = this.editor; + var preview = this.preview; + var classPrefix = this.classPrefix; + + var toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); + + if (settings.toolbar && toolbar.length < 1) + { + var toolbarHTML = "
"; + + editor.append(toolbarHTML); + toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); + } + + if (!settings.toolbar) + { + toolbar.hide(); + + return this; + } + + toolbar.show(); + + var icons = (typeof settings.toolbarIcons === "function") ? settings.toolbarIcons() + : ((typeof settings.toolbarIcons === "string") ? editormd.toolbarModes[settings.toolbarIcons] : settings.toolbarIcons); + + var toolbarMenu = toolbar.find("." + this.classPrefix + "menu"), menu = ""; + var pullRight = false; + + for (var i = 0, len = icons.length; i < len; i++) + { + var name = icons[i]; + + if (name === "||") + { + pullRight = true; + } + else if (name === "|") + { + menu += "
  • |
  • "; + } + else + { + var isHeader = (/h(\d)/.test(name)); + var index = name; + + if (name === "watch" && !settings.watch) { + index = "unwatch"; + } + + var title = settings.lang.toolbar[index]; + var iconTexts = settings.toolbarIconTexts[index]; + var iconClass = settings.toolbarIconsClass[index]; + + title = (typeof title === "undefined") ? "" : title; + iconTexts = (typeof iconTexts === "undefined") ? "" : iconTexts; + iconClass = (typeof iconClass === "undefined") ? "" : iconClass; + + var menuItem = pullRight ? "
  • " : "
  • "; + + if (typeof settings.toolbarCustomIcons[name] !== "undefined" && typeof settings.toolbarCustomIcons[name] !== "function") + { + menuItem += settings.toolbarCustomIcons[name]; + } + else + { + menuItem += ""; + menuItem += ""+((isHeader) ? name.toUpperCase() : ( (iconClass === "") ? iconTexts : "") ) + ""; + menuItem += ""; + } + + menuItem += "
  • "; + + menu = pullRight ? menuItem + menu : menu + menuItem; + } + } + + toolbarMenu.html(menu); + + toolbarMenu.find("[title=\"Lowercase\"]").attr("title", settings.lang.toolbar.lowercase); + toolbarMenu.find("[title=\"ucwords\"]").attr("title", settings.lang.toolbar.ucwords); + + this.setToolbarHandler(); + this.setToolbarAutoFixed(); + + return this; + }, + + /** + * 工具栏图标事件处理对象序列 + * Get toolbar icons event handlers + * + * @param {Object} cm CodeMirror的实例对象 + * @param {String} name 要获取的事件处理器名称 + * @returns {Object} 返回处理对象序列 + */ + + dialogLockScreen : function() { + $.proxy(editormd.dialogLockScreen, this)(); + + return this; + }, + + dialogShowMask : function(dialog) { + $.proxy(editormd.dialogShowMask, this)(dialog); + + return this; + }, + + getToolbarHandles : function(name) { + var toolbarHandlers = this.toolbarHandlers = editormd.toolbarHandlers; + + return (name && typeof toolbarIconHandlers[name] !== "undefined") ? toolbarHandlers[name] : toolbarHandlers; + }, + + /** + * 工具栏图标事件处理器 + * Bind toolbar icons event handle + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setToolbarHandler : function() { + var _this = this; + var settings = this.settings; + + if (!settings.toolbar || settings.readOnly) { + return this; + } + + var toolbar = this.toolbar; + var cm = this.cm; + var classPrefix = this.classPrefix; + var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu > li > a"); + var toolbarIconHandlers = this.getToolbarHandles(); + + toolbarIcons.bind(editormd.mouseOrTouch("click", "touchend"), function(event) { + + var icon = $(this).children(".fa"); + var name = icon.attr("name"); + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (name === "") { + return ; + } + + _this.activeIcon = icon; + + if (typeof toolbarIconHandlers[name] !== "undefined") + { + $.proxy(toolbarIconHandlers[name], _this)(cm); + } + else + { + if (typeof settings.toolbarHandlers[name] !== "undefined") + { + $.proxy(settings.toolbarHandlers[name], _this)(cm, icon, cursor, selection); + } + } + + if (name !== "link" && name !== "reference-link" && name !== "image" && name !== "code-block" && + name !== "preformatted-text" && name !== "watch" && name !== "preview" && name !== "search" && name !== "fullscreen" && name !== "info") + { + cm.focus(); + } + + return false; + + }); + + return this; + }, + + /** + * 动态创建对话框 + * Creating custom dialogs + * + * @param {Object} options 配置项键值对 Key/Value + * @returns {dialog} 返回创建的dialog的jQuery实例对象 + */ + + createDialog : function(options) { + return $.proxy(editormd.createDialog, this)(options); + }, + + /** + * 创建关于Editor.md的对话框 + * Create about Editor.md dialog + * + * @returns {editormd} 返回editormd的实例对象 + */ + + createInfoDialog : function() { + var _this = this; + var editor = this.editor; + var classPrefix = this.classPrefix; + + var infoDialogHTML = [ + "
    ", + "
    ", + "

    " + editormd.title + "v" + editormd.version + "

    ", + "

    " + this.lang.description + "

    ", + "

    " + editormd.homePage + "

    ", + "

    Copyright © 2015 Pandao, The MIT License.

    ", + "
    ", + "", + "
    " + ].join("\n"); + + editor.append(infoDialogHTML); + + var infoDialog = this.infoDialog = editor.children("." + classPrefix + "dialog-info"); + + infoDialog.find("." + classPrefix + "dialog-close").bind(editormd.mouseOrTouch("click", "touchend"), function() { + _this.hideInfoDialog(); + }); + + infoDialog.css("border", (editormd.isIE8) ? "1px solid #ddd" : "").css("z-index", editormd.dialogZindex).show(); + + this.infoDialogPosition(); + + return this; + }, + + /** + * 关于Editor.md对话居中定位 + * Editor.md dialog position handle + * + * @returns {editormd} 返回editormd的实例对象 + */ + + infoDialogPosition : function() { + var infoDialog = this.infoDialog; + + var _infoDialogPosition = function() { + infoDialog.css({ + top : ($(window).height() - infoDialog.height()) / 2 + "px", + left : ($(window).width() - infoDialog.width()) / 2 + "px" + }); + }; + + _infoDialogPosition(); + + $(window).resize(_infoDialogPosition); + + return this; + }, + + /** + * 显示关于Editor.md + * Display about Editor.md dialog + * + * @returns {editormd} 返回editormd的实例对象 + */ + + showInfoDialog : function() { + + $("html,body").css("overflow-x", "hidden"); + + var _this = this; + var editor = this.editor; + var settings = this.settings; + var infoDialog = this.infoDialog = editor.children("." + this.classPrefix + "dialog-info"); + + if (infoDialog.length < 1) + { + this.createInfoDialog(); + } + + this.lockScreen(true); + + this.mask.css({ + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }).show(); + + infoDialog.css("z-index", editormd.dialogZindex).show(); + + this.infoDialogPosition(); + + return this; + }, + + /** + * 隐藏关于Editor.md + * Hide about Editor.md dialog + * + * @returns {editormd} 返回editormd的实例对象 + */ + + hideInfoDialog : function() { + $("html,body").css("overflow-x", ""); + this.infoDialog.hide(); + this.mask.hide(); + this.lockScreen(false); + + return this; + }, + + /** + * 锁屏 + * lock screen + * + * @param {Boolean} lock Boolean 布尔值,是否锁屏 + * @returns {editormd} 返回editormd的实例对象 + */ + + lockScreen : function(lock) { + editormd.lockScreen(lock); + this.resize(); + + return this; + }, + + /** + * 编辑器界面重建,用于动态语言包或模块加载等 + * Recreate editor + * + * @returns {editormd} 返回editormd的实例对象 + */ + + recreate : function() { + var _this = this; + var editor = this.editor; + var settings = this.settings; + + this.codeMirror.remove(); + + this.setCodeMirror(); + + if (!settings.readOnly) + { + if (editor.find(".editormd-dialog").length > 0) { + editor.find(".editormd-dialog").remove(); + } + + if (settings.toolbar) + { + this.getToolbarHandles(); + this.setToolbar(); + } + } + + this.loadedDisplay(true); + + return this; + }, + + /** + * 高亮预览HTML的pre代码部分 + * highlight of preview codes + * + * @returns {editormd} 返回editormd的实例对象 + */ + + previewCodeHighlight : function() { + var settings = this.settings; + var previewContainer = this.previewContainer; + + if (settings.previewCodeHighlight) + { + previewContainer.find("pre").addClass("prettyprint linenums"); + + if (typeof prettyPrint !== "undefined") + { + prettyPrint(); + } + } + + return this; + }, + + /** + * 解析TeX(KaTeX)科学公式 + * TeX(KaTeX) Renderer + * + * @returns {editormd} 返回editormd的实例对象 + */ + + katexRender : function() { + + if (timer === null) + { + return this; + } + + this.previewContainer.find("." + editormd.classNames.tex).each(function(){ + var tex = $(this); + editormd.$katex.render(tex.text(), tex[0]); + + tex.find(".katex").css("font-size", "1.6em"); + }); + + return this; + }, + + /** + * 解析和渲染流程图及时序图 + * FlowChart and SequenceDiagram Renderer + * + * @returns {editormd} 返回editormd的实例对象 + */ + + flowChartAndSequenceDiagramRender : function() { + var $this = this; + var settings = this.settings; + var previewContainer = this.previewContainer; + + if (editormd.isIE8) { + return this; + } + + if (settings.flowChart) { + if (flowchartTimer === null) { + return this; + } + + previewContainer.find(".flowchart").flowChart(); + } + + if (settings.sequenceDiagram) { + previewContainer.find(".sequence-diagram").sequenceDiagram({theme: "simple"}); + } + + var preview = $this.preview; + var codeMirror = $this.codeMirror; + var codeView = codeMirror.find(".CodeMirror-scroll"); + + var height = codeView.height(); + var scrollTop = codeView.scrollTop(); + var percent = (scrollTop / codeView[0].scrollHeight); + var tocHeight = 0; + + preview.find(".markdown-toc-list").each(function(){ + tocHeight += $(this).height(); + }); + + var tocMenuHeight = preview.find(".editormd-toc-menu").height(); + tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight; + + if (scrollTop === 0) + { + preview.scrollTop(0); + } + else if (scrollTop + height >= codeView[0].scrollHeight - 16) + { + preview.scrollTop(preview[0].scrollHeight); + } + else + { + preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent); + } + + return this; + }, + + /** + * 注册键盘快捷键处理 + * Register CodeMirror keyMaps (keyboard shortcuts). + * + * @param {Object} keyMap KeyMap key/value {"(Ctrl/Shift/Alt)-Key" : function(){}} + * @returns {editormd} return this + */ + + registerKeyMaps : function(keyMap) { + + var _this = this; + var cm = this.cm; + var settings = this.settings; + var toolbarHandlers = editormd.toolbarHandlers; + var disabledKeyMaps = settings.disabledKeyMaps; + + keyMap = keyMap || null; + + if (keyMap) + { + for (var i in keyMap) + { + if ($.inArray(i, disabledKeyMaps) < 0) + { + var map = {}; + map[i] = keyMap[i]; + + cm.addKeyMap(keyMap); + } + } + } + else + { + for (var k in editormd.keyMaps) + { + var _keyMap = editormd.keyMaps[k]; + var handle = (typeof _keyMap === "string") ? $.proxy(toolbarHandlers[_keyMap], _this) : $.proxy(_keyMap, _this); + + if ($.inArray(k, ["F9", "F10", "F11"]) < 0 && $.inArray(k, disabledKeyMaps) < 0) + { + var _map = {}; + _map[k] = handle; + + cm.addKeyMap(_map); + } + } + + $(window).keydown(function(event) { + + var keymaps = { + "120" : "F9", + "121" : "F10", + "122" : "F11" + }; + + if ( $.inArray(keymaps[event.keyCode], disabledKeyMaps) < 0 ) + { + switch (event.keyCode) + { + case 120: + $.proxy(toolbarHandlers["watch"], _this)(); + return false; + break; + + case 121: + $.proxy(toolbarHandlers["preview"], _this)(); + return false; + break; + + case 122: + $.proxy(toolbarHandlers["fullscreen"], _this)(); + return false; + break; + + default: + break; + } + } + }); + } + + return this; + }, + + /** + * 绑定同步滚动 + * + * @returns {editormd} return this + */ + + bindScrollEvent : function() { + + var _this = this; + var preview = this.preview; + var settings = this.settings; + var codeMirror = this.codeMirror; + var mouseOrTouch = editormd.mouseOrTouch; + + if (!settings.syncScrolling) { + return this; + } + + var cmBindScroll = function() { + codeMirror.find(".CodeMirror-scroll").bind(mouseOrTouch("scroll", "touchmove"), function(event) { + var height = $(this).height(); + var scrollTop = $(this).scrollTop(); + var percent = (scrollTop / $(this)[0].scrollHeight); + + var tocHeight = 0; + + preview.find(".markdown-toc-list").each(function(){ + tocHeight += $(this).height(); + }); + + var tocMenuHeight = preview.find(".editormd-toc-menu").height(); + tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight; + + if (scrollTop === 0) + { + preview.scrollTop(0); + } + else if (scrollTop + height >= $(this)[0].scrollHeight - 16) + { + preview.scrollTop(preview[0].scrollHeight); + } + else + { + preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent); + } + + $.proxy(settings.onscroll, _this)(event); + }); + }; + + var cmUnbindScroll = function() { + codeMirror.find(".CodeMirror-scroll").unbind(mouseOrTouch("scroll", "touchmove")); + }; + + var previewBindScroll = function() { + + preview.bind(mouseOrTouch("scroll", "touchmove"), function(event) { + var height = $(this).height(); + var scrollTop = $(this).scrollTop(); + var percent = (scrollTop / $(this)[0].scrollHeight); + var codeView = codeMirror.find(".CodeMirror-scroll"); + + if(scrollTop === 0) + { + codeView.scrollTop(0); + } + else if (scrollTop + height >= $(this)[0].scrollHeight) + { + codeView.scrollTop(codeView[0].scrollHeight); + } + else + { + codeView.scrollTop(codeView[0].scrollHeight * percent); + } + + $.proxy(settings.onpreviewscroll, _this)(event); + }); + + }; + + var previewUnbindScroll = function() { + preview.unbind(mouseOrTouch("scroll", "touchmove")); + }; + + codeMirror.bind({ + mouseover : cmBindScroll, + mouseout : cmUnbindScroll, + touchstart : cmBindScroll, + touchend : cmUnbindScroll + }); + + if (settings.syncScrolling === "single") { + return this; + } + + preview.bind({ + mouseover : previewBindScroll, + mouseout : previewUnbindScroll, + touchstart : previewBindScroll, + touchend : previewUnbindScroll + }); + + return this; + }, + + bindChangeEvent : function() { + + var _this = this; + var cm = this.cm; + var settings = this.settings; + + if (!settings.syncScrolling) { + return this; + } + + cm.on("change", function(_cm, changeObj) { + + if (settings.watch) + { + _this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); + } + + timer = setTimeout(function() { + clearTimeout(timer); + _this.save(); + timer = null; + }, settings.delay); + }); + + return this; + }, + + /** + * 加载队列完成之后的显示处理 + * Display handle of the module queues loaded after. + * + * @param {Boolean} recreate 是否为重建编辑器 + * @returns {editormd} 返回editormd的实例对象 + */ + + loadedDisplay : function(recreate) { + + recreate = recreate || false; + + var _this = this; + var editor = this.editor; + var preview = this.preview; + var settings = this.settings; + + this.containerMask.hide(); + + this.save(); + + if (settings.watch) { + preview.show(); + } + + editor.data("oldWidth", editor.width()).data("oldHeight", editor.height()); // 为了兼容Zepto + + this.resize(); + this.registerKeyMaps(); + + $(window).resize(function(){ + _this.resize(); + }); + + this.bindScrollEvent().bindChangeEvent(); + + if (!recreate) + { + $.proxy(settings.onload, this)(); + } + + this.state.loaded = true; + + return this; + }, + + /** + * 设置编辑器的宽度 + * Set editor width + * + * @param {Number|String} width 编辑器宽度值 + * @returns {editormd} 返回editormd的实例对象 + */ + + width : function(width) { + + this.editor.css("width", (typeof width === "number") ? width + "px" : width); + this.resize(); + + return this; + }, + + /** + * 设置编辑器的高度 + * Set editor height + * + * @param {Number|String} height 编辑器高度值 + * @returns {editormd} 返回editormd的实例对象 + */ + + height : function(height) { + + this.editor.css("height", (typeof height === "number") ? height + "px" : height); + this.resize(); + + return this; + }, + + /** + * 调整编辑器的尺寸和布局 + * Resize editor layout + * + * @param {Number|String} [width=null] 编辑器宽度值 + * @param {Number|String} [height=null] 编辑器高度值 + * @returns {editormd} 返回editormd的实例对象 + */ + + resize : function(width, height) { + + width = width || null; + height = height || null; + + var state = this.state; + var editor = this.editor; + var preview = this.preview; + var toolbar = this.toolbar; + var settings = this.settings; + var codeMirror = this.codeMirror; + + if (width) + { + editor.css("width", (typeof width === "number") ? width + "px" : width); + } + + if (settings.autoHeight && !state.fullscreen && !state.preview) + { + editor.css("height", "auto"); + codeMirror.css("height", "auto"); + } + else + { + if (height) + { + editor.css("height", (typeof height === "number") ? height + "px" : height); + } + + if (state.fullscreen) + { + editor.height($(window).height()); + } + + if (settings.toolbar && !settings.readOnly) + { + codeMirror.css("margin-top", toolbar.height() + 1).height(editor.height() - toolbar.height()); + } + else + { + codeMirror.css("margin-top", 0).height(editor.height()); + } + } + + if(settings.watch) + { + codeMirror.width(editor.width() / 2); + preview.width((!state.preview) ? editor.width() / 2 : editor.width()); + + this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); + + if (settings.toolbar && !settings.readOnly) + { + preview.css("top", toolbar.height() + 1); + } + else + { + preview.css("top", 0); + } + + if (settings.autoHeight && !state.fullscreen && !state.preview) + { + preview.height(""); + } + else + { + var previewHeight = (settings.toolbar && !settings.readOnly) ? editor.height() - toolbar.height() : editor.height(); + + preview.height(previewHeight); + } + } + else + { + codeMirror.width(editor.width()); + preview.hide(); + } + + if (state.loaded) + { + $.proxy(settings.onresize, this)(); + } + + return this; + }, + + /** + * 解析和保存Markdown代码 + * Parse & Saving Markdown source code + * + * @returns {editormd} 返回editormd的实例对象 + */ + + save : function() { + + if (timer === null) + { + return this; + } + + var _this = this; + var state = this.state; + var settings = this.settings; + var cm = this.cm; + var cmValue = cm.getValue(); + var previewContainer = this.previewContainer; + + if (settings.mode !== "gfm" && settings.mode !== "markdown") + { + this.markdownTextarea.val(cmValue); + + return this; + } + + var marked = editormd.$marked; + var markdownToC = this.markdownToC = []; + var rendererOptions = this.markedRendererOptions = { + toc : settings.toc, + tocm : settings.tocm, + tocStartLevel : settings.tocStartLevel, + pageBreak : settings.pageBreak, + taskList : settings.taskList, + emoji : settings.emoji, + tex : settings.tex, + atLink : settings.atLink, // for @link + emailLink : settings.emailLink, // for mail address auto link + flowChart : settings.flowChart, + sequenceDiagram : settings.sequenceDiagram, + previewCodeHighlight : settings.previewCodeHighlight, + }; + + var markedOptions = this.markedOptions = { + renderer : editormd.markedRenderer(markdownToC, rendererOptions), + gfm : true, + tables : true, + breaks : true, + pedantic : false, + sanitize : (settings.htmlDecode) ? false : true, // 关闭忽略HTML标签,即开启识别HTML标签,默认为false + smartLists : true, + smartypants : true + }; + + marked.setOptions(markedOptions); + + var newMarkdownDoc = editormd.$marked(cmValue, markedOptions); + + //console.info("cmValue", cmValue, newMarkdownDoc); + + newMarkdownDoc = editormd.filterHTMLTags(newMarkdownDoc, settings.htmlDecode); + + //console.error("cmValue", cmValue, newMarkdownDoc); + + this.markdownTextarea.text(cmValue); + + cm.save(); + + if (settings.saveHTMLToTextarea) + { + this.htmlTextarea.text(newMarkdownDoc); + } + + if(settings.watch || (!settings.watch && state.preview)) + { + previewContainer.html(newMarkdownDoc); + + this.previewCodeHighlight(); + + if (settings.toc) + { + var tocContainer = (settings.tocContainer === "") ? previewContainer : $(settings.tocContainer); + var tocMenu = tocContainer.find("." + this.classPrefix + "toc-menu"); + + tocContainer.attr("previewContainer", (settings.tocContainer === "") ? "true" : "false"); + + if (settings.tocContainer !== "" && tocMenu.length > 0) + { + tocMenu.remove(); + } + + editormd.markdownToCRenderer(markdownToC, tocContainer, settings.tocDropdown, settings.tocStartLevel); + + if (settings.tocDropdown || tocContainer.find("." + this.classPrefix + "toc-menu").length > 0) + { + editormd.tocDropdownMenu(tocContainer, (settings.tocTitle !== "") ? settings.tocTitle : this.lang.tocTitle); + } + + if (settings.tocContainer !== "") + { + previewContainer.find(".markdown-toc").css("border", "none"); + } + } + + if (settings.tex) + { + if (!editormd.kaTeXLoaded && settings.autoLoadModules) + { + editormd.loadKaTeX(function() { + editormd.$katex = katex; + editormd.kaTeXLoaded = true; + _this.katexRender(); + }); + } + else + { + editormd.$katex = katex; + this.katexRender(); + } + } + + if (settings.flowChart || settings.sequenceDiagram) + { + flowchartTimer = setTimeout(function(){ + clearTimeout(flowchartTimer); + _this.flowChartAndSequenceDiagramRender(); + flowchartTimer = null; + }, 10); + } + + if (state.loaded) + { + $.proxy(settings.onchange, this)(); + } + } + + return this; + }, + + /** + * 聚焦光标位置 + * Focusing the cursor position + * + * @returns {editormd} 返回editormd的实例对象 + */ + + focus : function() { + this.cm.focus(); + + return this; + }, + + /** + * 设置光标的位置 + * Set cursor position + * + * @param {Object} cursor 要设置的光标位置键值对象,例:{line:1, ch:0} + * @returns {editormd} 返回editormd的实例对象 + */ + + setCursor : function(cursor) { + this.cm.setCursor(cursor); + + return this; + }, + + /** + * 获取当前光标的位置 + * Get the current position of the cursor + * + * @returns {Cursor} 返回一个光标Cursor对象 + */ + + getCursor : function() { + return this.cm.getCursor(); + }, + + /** + * 设置光标选中的范围 + * Set cursor selected ranges + * + * @param {Object} from 开始位置的光标键值对象,例:{line:1, ch:0} + * @param {Object} to 结束位置的光标键值对象,例:{line:1, ch:0} + * @returns {editormd} 返回editormd的实例对象 + */ + + setSelection : function(from, to) { + + this.cm.setSelection(from, to); + + return this; + }, + + /** + * 获取光标选中的文本 + * Get the texts from cursor selected + * + * @returns {String} 返回选中文本的字符串形式 + */ + + getSelection : function() { + return this.cm.getSelection(); + }, + + /** + * 设置光标选中的文本范围 + * Set the cursor selection ranges + * + * @param {Array} ranges cursor selection ranges array + * @returns {Array} return this + */ + + setSelections : function(ranges) { + this.cm.setSelections(ranges); + + return this; + }, + + /** + * 获取光标选中的文本范围 + * Get the cursor selection ranges + * + * @returns {Array} return selection ranges array + */ + + getSelections : function() { + return this.cm.getSelections(); + }, + + /** + * 替换当前光标选中的文本或在当前光标处插入新字符 + * Replace the text at the current cursor selected or insert a new character at the current cursor position + * + * @param {String} value 要插入的字符值 + * @returns {editormd} 返回editormd的实例对象 + */ + + replaceSelection : function(value) { + this.cm.replaceSelection(value); + + return this; + }, + + /** + * 在当前光标处插入新字符 + * Insert a new character at the current cursor position + * + * 同replaceSelection()方法 + * With the replaceSelection() method + * + * @param {String} value 要插入的字符值 + * @returns {editormd} 返回editormd的实例对象 + */ + + insertValue : function(value) { + this.replaceSelection(value); + + return this; + }, + + /** + * 追加markdown + * append Markdown to editor + * + * @param {String} md 要追加的markdown源文档 + * @returns {editormd} 返回editormd的实例对象 + */ + + appendMarkdown : function(md) { + var settings = this.settings; + var cm = this.cm; + + cm.setValue(cm.getValue() + md); + + return this; + }, + + /** + * 设置和传入编辑器的markdown源文档 + * Set Markdown source document + * + * @param {String} md 要传入的markdown源文档 + * @returns {editormd} 返回editormd的实例对象 + */ + + setMarkdown : function(md) { + this.cm.setValue(md || this.settings.markdown); + + return this; + }, + + /** + * 获取编辑器的markdown源文档 + * Set Editor.md markdown/CodeMirror value + * + * @returns {editormd} 返回editormd的实例对象 + */ + + getMarkdown : function() { + return this.cm.getValue(); + }, + + /** + * 获取编辑器的源文档 + * Get CodeMirror value + * + * @returns {editormd} 返回editormd的实例对象 + */ + + getValue : function() { + return this.cm.getValue(); + }, + + /** + * 设置编辑器的源文档 + * Set CodeMirror value + * + * @param {String} value set code/value/string/text + * @returns {editormd} 返回editormd的实例对象 + */ + + setValue : function(value) { + this.cm.setValue(value); + + return this; + }, + + /** + * 清空编辑器 + * Empty CodeMirror editor container + * + * @returns {editormd} 返回editormd的实例对象 + */ + + clear : function() { + this.cm.setValue(""); + + return this; + }, + + /** + * 获取解析后存放在Textarea的HTML源码 + * Get parsed html code from Textarea + * + * @returns {String} 返回HTML源码 + */ + + getHTML : function() { + if (!this.settings.saveHTMLToTextarea) + { + alert("Error: settings.saveHTMLToTextarea == false"); + + return false; + } + + return this.htmlTextarea.val(); + }, + + /** + * getHTML()的别名 + * getHTML (alias) + * + * @returns {String} Return html code 返回HTML源码 + */ + + getTextareaSavedHTML : function() { + return this.getHTML(); + }, + + /** + * 获取预览窗口的HTML源码 + * Get html from preview container + * + * @returns {editormd} 返回editormd的实例对象 + */ + + getPreviewedHTML : function() { + if (!this.settings.watch) + { + alert("Error: settings.watch == false"); + + return false; + } + + return this.previewContainer.html(); + }, + + /** + * 开启实时预览 + * Enable real-time watching + * + * @returns {editormd} 返回editormd的实例对象 + */ + + watch : function(callback) { + var settings = this.settings; + + if ($.inArray(settings.mode, ["gfm", "markdown"]) < 0) + { + return this; + } + + this.state.watching = settings.watch = true; + this.preview.show(); + + if (this.toolbar) + { + var watchIcon = settings.toolbarIconsClass.watch; + var unWatchIcon = settings.toolbarIconsClass.unwatch; + + var icon = this.toolbar.find(".fa[name=watch]"); + icon.parent().attr("title", settings.lang.toolbar.watch); + icon.removeClass(unWatchIcon).addClass(watchIcon); + } + + this.codeMirror.css("border-right", "1px solid #ddd").width(this.editor.width() / 2); + + timer = 0; + + this.save().resize(); + + if (!settings.onwatch) + { + settings.onwatch = callback || function() {}; + } + + $.proxy(settings.onwatch, this)(); + + return this; + }, + + /** + * 关闭实时预览 + * Disable real-time watching + * + * @returns {editormd} 返回editormd的实例对象 + */ + + unwatch : function(callback) { + var settings = this.settings; + this.state.watching = settings.watch = false; + this.preview.hide(); + + if (this.toolbar) + { + var watchIcon = settings.toolbarIconsClass.watch; + var unWatchIcon = settings.toolbarIconsClass.unwatch; + + var icon = this.toolbar.find(".fa[name=watch]"); + icon.parent().attr("title", settings.lang.toolbar.unwatch); + icon.removeClass(watchIcon).addClass(unWatchIcon); + } + + this.codeMirror.css("border-right", "none").width(this.editor.width()); + + this.resize(); + + if (!settings.onunwatch) + { + settings.onunwatch = callback || function() {}; + } + + $.proxy(settings.onunwatch, this)(); + + return this; + }, + + /** + * 显示编辑器 + * Show editor + * + * @param {Function} [callback=function()] 回调函数 + * @returns {editormd} 返回editormd的实例对象 + */ + + show : function(callback) { + callback = callback || function() {}; + + var _this = this; + this.editor.show(0, function() { + $.proxy(callback, _this)(); + }); + + return this; + }, + + /** + * 隐藏编辑器 + * Hide editor + * + * @param {Function} [callback=function()] 回调函数 + * @returns {editormd} 返回editormd的实例对象 + */ + + hide : function(callback) { + callback = callback || function() {}; + + var _this = this; + this.editor.hide(0, function() { + $.proxy(callback, _this)(); + }); + + return this; + }, + + /** + * 隐藏编辑器部分,只预览HTML + * Enter preview html state + * + * @returns {editormd} 返回editormd的实例对象 + */ + + previewing : function() { + + var _this = this; + var editor = this.editor; + var preview = this.preview; + var toolbar = this.toolbar; + var settings = this.settings; + var codeMirror = this.codeMirror; + var previewContainer = this.previewContainer; + + if ($.inArray(settings.mode, ["gfm", "markdown"]) < 0) { + return this; + } + + if (settings.toolbar && toolbar) { + toolbar.toggle(); + toolbar.find(".fa[name=preview]").toggleClass("active"); + } + + codeMirror.toggle(); + + var escHandle = function(event) { + if (event.shiftKey && event.keyCode === 27) { + _this.previewed(); + } + }; + + if (codeMirror.css("display") === "none") // 为了兼容Zepto,而不使用codeMirror.is(":hidden") + { + this.state.preview = true; + + if (this.state.fullscreen) { + preview.css("background", "#fff"); + } + + editor.find("." + this.classPrefix + "preview-close-btn").show().bind(editormd.mouseOrTouch("click", "touchend"), function(){ + _this.previewed(); + }); + + if (!settings.watch) + { + this.save(); + } + else + { + previewContainer.css("padding", ""); + } + + previewContainer.addClass(this.classPrefix + "preview-active"); + + preview.show().css({ + position : "", + top : 0, + width : editor.width(), + height : (settings.autoHeight && !this.state.fullscreen) ? "auto" : editor.height() + }); + + if (this.state.loaded) + { + $.proxy(settings.onpreviewing, this)(); + } + + $(window).bind("keyup", escHandle); + } + else + { + $(window).unbind("keyup", escHandle); + this.previewed(); + } + }, + + /** + * 显示编辑器部分,退出只预览HTML + * Exit preview html state + * + * @returns {editormd} 返回editormd的实例对象 + */ + + previewed : function() { + + var editor = this.editor; + var preview = this.preview; + var toolbar = this.toolbar; + var settings = this.settings; + var previewContainer = this.previewContainer; + var previewCloseBtn = editor.find("." + this.classPrefix + "preview-close-btn"); + + this.state.preview = false; + + this.codeMirror.show(); + + if (settings.toolbar) { + toolbar.show(); + } + + preview[(settings.watch) ? "show" : "hide"](); + + previewCloseBtn.hide().unbind(editormd.mouseOrTouch("click", "touchend")); + + previewContainer.removeClass(this.classPrefix + "preview-active"); + + if (settings.watch) + { + previewContainer.css("padding", "20px"); + } + + preview.css({ + background : null, + position : "absolute", + width : editor.width() / 2, + height : (settings.autoHeight && !this.state.fullscreen) ? "auto" : editor.height() - toolbar.height(), + top : (settings.toolbar) ? toolbar.height() : 0 + }); + + if (this.state.loaded) + { + $.proxy(settings.onpreviewed, this)(); + } + + return this; + }, + + /** + * 编辑器全屏显示 + * Fullscreen show + * + * @returns {editormd} 返回editormd的实例对象 + */ + + fullscreen : function() { + + var _this = this; + var state = this.state; + var editor = this.editor; + var preview = this.preview; + var toolbar = this.toolbar; + var settings = this.settings; + var fullscreenClass = this.classPrefix + "fullscreen"; + + if (toolbar) { + toolbar.find(".fa[name=fullscreen]").parent().toggleClass("active"); + } + + var escHandle = function(event) { + if (!event.shiftKey && event.keyCode === 27) + { + if (state.fullscreen) + { + _this.fullscreenExit(); + } + } + }; + + if (!editor.hasClass(fullscreenClass)) + { + state.fullscreen = true; + + $("html,body").css("overflow", "hidden"); + + editor.css({ + width : $(window).width(), + height : $(window).height() + }).addClass(fullscreenClass); + + this.resize(); + + $.proxy(settings.onfullscreen, this)(); + + $(window).bind("keyup", escHandle); + } + else + { + $(window).unbind("keyup", escHandle); + this.fullscreenExit(); + } + + return this; + }, + + /** + * 编辑器退出全屏显示 + * Exit fullscreen state + * + * @returns {editormd} 返回editormd的实例对象 + */ + + fullscreenExit : function() { + + var editor = this.editor; + var settings = this.settings; + var toolbar = this.toolbar; + var fullscreenClass = this.classPrefix + "fullscreen"; + + this.state.fullscreen = false; + + if (toolbar) { + toolbar.find(".fa[name=fullscreen]").parent().removeClass("active"); + } + + $("html,body").css("overflow", ""); + + editor.css({ + width : editor.data("oldWidth"), + height : editor.data("oldHeight") + }).removeClass(fullscreenClass); + + this.resize(); + + $.proxy(settings.onfullscreenExit, this)(); + + return this; + }, + + /** + * 加载并执行插件 + * Load and execute the plugin + * + * @param {String} name plugin name / function name + * @param {String} path plugin load path + * @returns {editormd} 返回editormd的实例对象 + */ + + executePlugin : function(name, path) { + + var _this = this; + var cm = this.cm; + var settings = this.settings; + + path = settings.pluginPath + path; + + if (typeof define === "function") + { + if (typeof this[name] === "undefined") + { + alert("Error: " + name + " plugin is not found, you are not load this plugin."); + + return this; + } + + this[name](cm); + + return this; + } + + if ($.inArray(path, editormd.loadFiles.plugin) < 0) + { + editormd.loadPlugin(path, function() { + editormd.loadPlugins[name] = _this[name]; + _this[name](cm); + }); + } + else + { + $.proxy(editormd.loadPlugins[name], this)(cm); + } + + return this; + }, + + /** + * 搜索替换 + * Search & replace + * + * @param {String} command CodeMirror serach commands, "find, fintNext, fintPrev, clearSearch, replace, replaceAll" + * @returns {editormd} return this + */ + + search : function(command) { + var settings = this.settings; + + if (!settings.searchReplace) + { + alert("Error: settings.searchReplace == false"); + return this; + } + + if (!settings.readOnly) + { + this.cm.execCommand(command || "find"); + } + + return this; + }, + + searchReplace : function() { + this.search("replace"); + + return this; + }, + + searchReplaceAll : function() { + this.search("replaceAll"); + + return this; + } + }; + + editormd.fn.init.prototype = editormd.fn; + + /** + * 锁屏 + * lock screen when dialog opening + * + * @returns {void} + */ + + editormd.dialogLockScreen = function() { + var settings = this.settings || {dialogLockScreen : true}; + + if (settings.dialogLockScreen) + { + $("html,body").css("overflow", "hidden"); + this.resize(); + } + }; + + /** + * 显示透明背景层 + * Display mask layer when dialog opening + * + * @param {Object} dialog dialog jQuery object + * @returns {void} + */ + + editormd.dialogShowMask = function(dialog) { + var editor = this.editor; + var settings = this.settings || {dialogShowMask : true}; + + dialog.css({ + top : ($(window).height() - dialog.height()) / 2 + "px", + left : ($(window).width() - dialog.width()) / 2 + "px" + }); + + if (settings.dialogShowMask) { + editor.children("." + this.classPrefix + "mask").css("z-index", parseInt(dialog.css("z-index")) - 1).show(); + } + }; + + editormd.toolbarHandlers = { + undo : function() { + this.cm.undo(); + }, + + redo : function() { + this.cm.redo(); + }, + + bold : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("**" + selection + "**"); + + if(selection === "") { + cm.setCursor(cursor.line, cursor.ch + 2); + } + }, + + del : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("~~" + selection + "~~"); + + if(selection === "") { + cm.setCursor(cursor.line, cursor.ch + 2); + } + }, + + italic : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("*" + selection + "*"); + + if(selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + + quote : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("> " + selection); + cm.setCursor(cursor.line, cursor.ch + 2); + } + else + { + cm.replaceSelection("> " + selection); + } + + //cm.replaceSelection("> " + selection); + //cm.setCursor(cursor.line, (selection === "") ? cursor.ch + 2 : cursor.ch + selection.length + 2); + }, + + ucfirst : function() { + var cm = this.cm; + var selection = cm.getSelection(); + var selections = cm.listSelections(); + + cm.replaceSelection(editormd.firstUpperCase(selection)); + cm.setSelections(selections); + }, + + ucwords : function() { + var cm = this.cm; + var selection = cm.getSelection(); + var selections = cm.listSelections(); + + cm.replaceSelection(editormd.wordsFirstUpperCase(selection)); + cm.setSelections(selections); + }, + + uppercase : function() { + var cm = this.cm; + var selection = cm.getSelection(); + var selections = cm.listSelections(); + + cm.replaceSelection(selection.toUpperCase()); + cm.setSelections(selections); + }, + + lowercase : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + var selections = cm.listSelections(); + + cm.replaceSelection(selection.toLowerCase()); + cm.setSelections(selections); + }, + + h1 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("# " + selection); + cm.setCursor(cursor.line, cursor.ch + 2); + } + else + { + cm.replaceSelection("# " + selection); + } + }, + + h2 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("## " + selection); + cm.setCursor(cursor.line, cursor.ch + 3); + } + else + { + cm.replaceSelection("## " + selection); + } + }, + + h3 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("### " + selection); + cm.setCursor(cursor.line, cursor.ch + 4); + } + else + { + cm.replaceSelection("### " + selection); + } + }, + + h4 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("#### " + selection); + cm.setCursor(cursor.line, cursor.ch + 5); + } + else + { + cm.replaceSelection("#### " + selection); + } + }, + + h5 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("##### " + selection); + cm.setCursor(cursor.line, cursor.ch + 6); + } + else + { + cm.replaceSelection("##### " + selection); + } + }, + + h6 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("###### " + selection); + cm.setCursor(cursor.line, cursor.ch + 7); + } + else + { + cm.replaceSelection("###### " + selection); + } + }, + + "list-ul" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (selection === "") + { + cm.replaceSelection("- " + selection); + } + else + { + var selectionText = selection.split("\n"); + + for (var i = 0, len = selectionText.length; i < len; i++) + { + selectionText[i] = (selectionText[i] === "") ? "" : "- " + selectionText[i]; + } + + cm.replaceSelection(selectionText.join("\n")); + } + }, + + "list-ol" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if(selection === "") + { + cm.replaceSelection("1. " + selection); + } + else + { + var selectionText = selection.split("\n"); + + for (var i = 0, len = selectionText.length; i < len; i++) + { + selectionText[i] = (selectionText[i] === "") ? "" : (i+1) + ". " + selectionText[i]; + } + + cm.replaceSelection(selectionText.join("\n")); + } + }, + + hr : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection(((cursor.ch !== 0) ? "\n\n" : "\n") + "------------\n\n"); + }, + + tex : function() { + if (!this.settings.tex) + { + alert("settings.tex === false"); + return this; + } + + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("$$" + selection + "$$"); + + if(selection === "") { + cm.setCursor(cursor.line, cursor.ch + 2); + } + }, + + link : function() { + this.executePlugin("linkDialog", "link-dialog/link-dialog"); + }, + + "reference-link" : function() { + this.executePlugin("referenceLinkDialog", "reference-link-dialog/reference-link-dialog"); + }, + + pagebreak : function() { + if (!this.settings.pageBreak) + { + alert("settings.pageBreak === false"); + return this; + } + + var cm = this.cm; + var selection = cm.getSelection(); + + cm.replaceSelection("\r\n[========]\r\n"); + }, + + image : function() { + this.executePlugin("imageDialog", "image-dialog/image-dialog"); + }, + + code : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("`" + selection + "`"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + + "code-block" : function() { + this.executePlugin("codeBlockDialog", "code-block-dialog/code-block-dialog"); + }, + + "preformatted-text" : function() { + this.executePlugin("preformattedTextDialog", "preformatted-text-dialog/preformatted-text-dialog"); + }, + + table : function() { + this.executePlugin("tableDialog", "table-dialog/table-dialog"); + }, + + datetime : function() { + var cm = this.cm; + var selection = cm.getSelection(); + var date = new Date(); + var langName = this.settings.lang.name; + var datefmt = editormd.dateFormat() + " " + editormd.dateFormat((langName === "zh-cn" || langName === "zh-tw") ? "cn-week-day" : "week-day"); + + cm.replaceSelection(datefmt); + }, + + emoji : function() { + this.executePlugin("emojiDialog", "emoji-dialog/emoji-dialog"); + }, + + "html-entities" : function() { + this.executePlugin("htmlEntitiesDialog", "html-entities-dialog/html-entities-dialog"); + }, + + "goto-line" : function() { + this.executePlugin("gotoLineDialog", "goto-line-dialog/goto-line-dialog"); + }, + + watch : function() { + this[this.settings.watch ? "unwatch" : "watch"](); + }, + + preview : function() { + this.previewing(); + }, + + fullscreen : function() { + this.fullscreen(); + }, + + clear : function() { + this.clear(); + }, + + search : function() { + this.search(); + }, + + help : function() { + this.executePlugin("helpDialog", "help-dialog/help-dialog"); + }, + + info : function() { + this.showInfoDialog(); + } + }; + + editormd.keyMaps = { + "Ctrl-1" : "h1", + "Ctrl-2" : "h2", + "Ctrl-3" : "h3", + "Ctrl-4" : "h4", + "Ctrl-5" : "h5", + "Ctrl-6" : "h6", + "Ctrl-B" : "bold", // if this is string == editormd.toolbarHandlers.xxxx + "Ctrl-D" : "datetime", + + "Ctrl-E" : function() { // emoji + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (!this.settings.emoji) + { + alert("Error: settings.emoji == false"); + return ; + } + + cm.replaceSelection(":" + selection + ":"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + "Ctrl-Alt-G" : "goto-line", + "Ctrl-H" : "hr", + "Ctrl-I" : "italic", + "Ctrl-K" : "code", + + "Ctrl-L" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + var title = (selection === "") ? "" : " \""+selection+"\""; + + cm.replaceSelection("[" + selection + "]("+title+")"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + "Ctrl-U" : "list-ul", + + "Shift-Ctrl-A" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (!this.settings.atLink) + { + alert("Error: settings.atLink == false"); + return ; + } + + cm.replaceSelection("@" + selection); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + + "Shift-Ctrl-C" : "code", + "Shift-Ctrl-Q" : "quote", + "Shift-Ctrl-S" : "del", + "Shift-Ctrl-K" : "tex", // KaTeX + + "Shift-Alt-C" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection(["```", selection, "```"].join("\n")); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 3); + } + }, + + "Shift-Ctrl-Alt-C" : "code-block", + "Shift-Ctrl-H" : "html-entities", + "Shift-Alt-H" : "help", + "Shift-Ctrl-E" : "emoji", + "Shift-Ctrl-U" : "uppercase", + "Shift-Alt-U" : "ucwords", + "Shift-Ctrl-Alt-U" : "ucfirst", + "Shift-Alt-L" : "lowercase", + + "Shift-Ctrl-I" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + var title = (selection === "") ? "" : " \""+selection+"\""; + + cm.replaceSelection("![" + selection + "]("+title+")"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 4); + } + }, + + "Shift-Ctrl-Alt-I" : "image", + "Shift-Ctrl-L" : "link", + "Shift-Ctrl-O" : "list-ol", + "Shift-Ctrl-P" : "preformatted-text", + "Shift-Ctrl-T" : "table", + "Shift-Alt-P" : "pagebreak", + "F9" : "watch", + "F10" : "preview", + "F11" : "fullscreen", + }; + + /** + * 清除字符串两边的空格 + * Clear the space of strings both sides. + * + * @param {String} str string + * @returns {String} trimed string + */ + + var trim = function(str) { + return (!String.prototype.trim) ? str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "") : str.trim(); + }; + + editormd.trim = trim; + + /** + * 所有单词首字母大写 + * Words first to uppercase + * + * @param {String} str string + * @returns {String} string + */ + + var ucwords = function (str) { + return str.toLowerCase().replace(/\b(\w)|\s(\w)/g, function($1) { + return $1.toUpperCase(); + }); + }; + + editormd.ucwords = editormd.wordsFirstUpperCase = ucwords; + + /** + * 字符串首字母大写 + * Only string first char to uppercase + * + * @param {String} str string + * @returns {String} string + */ + + var firstUpperCase = function(str) { + return str.toLowerCase().replace(/\b(\w)/, function($1){ + return $1.toUpperCase(); + }); + }; + + var ucfirst = firstUpperCase; + + editormd.firstUpperCase = editormd.ucfirst = firstUpperCase; + + editormd.urls = { + atLinkBase : "https://github.com/" + }; + + editormd.regexs = { + atLink : /@(\w+)/g, + email : /(\w+)@(\w+)\.(\w+)\.?(\w+)?/g, + emailLink : /(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g, + emoji : /:([\w\+-]+):/g, + emojiDatetime : /(\d{2}:\d{2}:\d{2})/g, + twemoji : /:(tw-([\w]+)-?(\w+)?):/g, + fontAwesome : /:(fa-([\w]+)(-(\w+)){0,}):/g, + editormdLogo : /:(editormd-logo-?(\w+)?):/g, + pageBreak : /^\[[=]{8,}\]$/ + }; + + // Emoji graphics files url path + editormd.emoji = { + path : "http://www.emoji-cheat-sheet.com/graphics/emojis/", + ext : ".png" + }; + + // Twitter Emoji (Twemoji) graphics files url path + editormd.twemoji = { + path : "http://twemoji.maxcdn.com/36x36/", + ext : ".png" + }; + + /** + * 自定义marked的解析器 + * Custom Marked renderer rules + * + * @param {Array} markdownToC 传入用于接收TOC的数组 + * @returns {Renderer} markedRenderer 返回marked的Renderer自定义对象 + */ + + editormd.markedRenderer = function(markdownToC, options) { + var defaults = { + toc : true, // Table of contents + tocm : false, + tocStartLevel : 1, // Said from H1 to create ToC + pageBreak : true, + atLink : true, // for @link + emailLink : true, // for mail address auto link + taskList : false, // Enable Github Flavored Markdown task lists + emoji : false, // :emoji: , Support Twemoji, fontAwesome, Editor.md logo emojis. + tex : false, // TeX(LaTeX), based on KaTeX + flowChart : false, // flowChart.js only support IE9+ + sequenceDiagram : false, // sequenceDiagram.js only support IE9+ + }; + + var settings = $.extend(defaults, options || {}); + var marked = editormd.$marked; + var markedRenderer = new marked.Renderer(); + markdownToC = markdownToC || []; + + var regexs = editormd.regexs; + var atLinkReg = regexs.atLink; + var emojiReg = regexs.emoji; + var emailReg = regexs.email; + var emailLinkReg = regexs.emailLink; + var twemojiReg = regexs.twemoji; + var faIconReg = regexs.fontAwesome; + var editormdLogoReg = regexs.editormdLogo; + var pageBreakReg = regexs.pageBreak; + + markedRenderer.emoji = function(text) { + + text = text.replace(editormd.regexs.emojiDatetime, function($1) { + return $1.replace(/:/g, ":"); + }); + + var matchs = text.match(emojiReg); + + if (!matchs || !settings.emoji) { + return text; + } + + for (var i = 0, len = matchs.length; i < len; i++) + { + if (matchs[i] === ":+1:") { + matchs[i] = ":\\+1:"; + } + + text = text.replace(new RegExp(matchs[i]), function($1, $2){ + var faMatchs = $1.match(faIconReg); + var name = $1.replace(/:/g, ""); + + if (faMatchs) + { + for (var fa = 0, len1 = faMatchs.length; fa < len1; fa++) + { + var faName = faMatchs[fa].replace(/:/g, ""); + + return ""; + } + } + else + { + var emdlogoMathcs = $1.match(editormdLogoReg); + var twemojiMatchs = $1.match(twemojiReg); + + if (emdlogoMathcs) + { + for (var x = 0, len2 = emdlogoMathcs.length; x < len2; x++) + { + var logoName = emdlogoMathcs[x].replace(/:/g, ""); + return ""; + } + } + else if (twemojiMatchs) + { + for (var t = 0, len3 = twemojiMatchs.length; t < len3; t++) + { + var twe = twemojiMatchs[t].replace(/:/g, "").replace("tw-", ""); + return "\"twemoji-""; + } + } + else + { + var src = (name === "+1") ? "plus1" : name; + src = (src === "black_large_square") ? "black_square" : src; + src = (src === "moon") ? "waxing_gibbous_moon" : src; + + return "\":""; + } + } + }); + } + + return text; + }; + + markedRenderer.atLink = function(text) { + + if (atLinkReg.test(text)) + { + if (settings.atLink) + { + text = text.replace(emailReg, function($1, $2, $3, $4) { + return $1.replace(/@/g, "_#_@_#_"); + }); + + text = text.replace(atLinkReg, function($1, $2) { + return "" + $1 + ""; + }).replace(/_#_@_#_/g, "@"); + } + + if (settings.emailLink) + { + text = text.replace(emailLinkReg, function($1, $2, $3, $4, $5) { + return (!$2 && $.inArray($5, "jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|")) < 0) ? ""+$1+"" : $1; + }); + } + + return text; + } + + return text; + }; + + markedRenderer.link = function (href, title, text) { + + if (this.options.sanitize) { + try { + var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase(); + } catch(e) { + return ""; + } + + if (prot.indexOf("javascript:") === 0) { + return ""; + } + } + + var out = "" + text.replace(/@/g, "@") + ""; + } + + if (title) { + out += " title=\"" + title + "\""; + } + + out += ">" + text + ""; + + return out; + }; + + markedRenderer.heading = function(text, level, raw) { + + var linkText = text; + var hasLinkReg = /\s*\]*)\>(.*)\<\/a\>\s*/; + var getLinkTextReg = /\s*\]+)\>([^\>]*)\<\/a\>\s*/g; + + if (hasLinkReg.test(text)) + { + var tempText = []; + text = text.split(/\]+)\>([^\>]*)\<\/a\>/); + + for (var i = 0, len = text.length; i < len; i++) + { + tempText.push(text[i].replace(/\s*href\=\"(.*)\"\s*/g, "")); + } + + text = tempText.join(" "); + } + + text = trim(text); + + var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-"); + var toc = { + text : text, + level : level, + slug : escapedText + }; + + var isChinese = /^[\u4e00-\u9fa5]+$/.test(text); + var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-"); + + markdownToC.push(toc); + + var headingHTML = ""; + + headingHTML += ""; + headingHTML += ""; + headingHTML += (hasLinkReg) ? this.atLink(this.emoji(linkText)) : this.atLink(this.emoji(text)); + headingHTML += ""; + + return headingHTML; + }; + + markedRenderer.pageBreak = function(text) { + if (pageBreakReg.test(text) && settings.pageBreak) + { + text = "
    "; + } + + return text; + }; + + markedRenderer.paragraph = function(text) { + var isTeXInline = /\$\$(.*)\$\$/g.test(text); + var isTeXLine = /^\$\$(.*)\$\$$/.test(text); + var isTeXAddClass = (isTeXLine) ? " class=\"" + editormd.classNames.tex + "\"" : ""; + var isToC = (settings.tocm) ? /^(\[TOC\]|\[TOCM\])$/.test(text) : /^\[TOC\]$/.test(text); + var isToCMenu = /^\[TOCM\]$/.test(text); + + if (!isTeXLine && isTeXInline) + { + text = text.replace(/(\$\$([^\$]*)\$\$)+/g, function($1, $2) { + return "" + $2.replace(/\$/g, "") + ""; + }); + } + else + { + text = (isTeXLine) ? text.replace(/\$/g, "") : text; + } + + var tocHTML = "
    " + text + "
    "; + + return (isToC) ? ( (isToCMenu) ? "
    " + tocHTML + "

    " : tocHTML ) + : ( (pageBreakReg.test(text)) ? this.pageBreak(text) : "" + this.atLink(this.emoji(text)) + "

    \n" ); + }; + + markedRenderer.code = function (code, lang, escaped) { + + if (lang === "seq" || lang === "sequence") + { + return "
    " + code + "
    "; + } + else if ( lang === "flow") + { + return "
    " + code + "
    "; + } + else if ( lang === "math" || lang === "latex" || lang === "katex") + { + return "

    " + code + "

    "; + } + else + { + + return marked.Renderer.prototype.code.apply(this, arguments); + } + }; + + markedRenderer.tablecell = function(content, flags) { + var type = (flags.header) ? "th" : "td"; + var tag = (flags.align) ? "<" + type +" style=\"text-align:" + flags.align + "\">" : "<" + type + ">"; + + return tag + this.atLink(this.emoji(content)) + "\n"; + }; + + markedRenderer.listitem = function(text) { + if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text)) + { + text = text.replace(/^\s*\[\s\]\s*/, " ") + .replace(/^\s*\[x\]\s*/, " "); + + return "
  • " + this.atLink(this.emoji(text)) + "
  • "; + } + else + { + return "
  • " + this.atLink(this.emoji(text)) + "
  • "; + } + }; + + return markedRenderer; + }; + + /** + * + * 生成TOC(Table of Contents) + * Creating ToC (Table of Contents) + * + * @param {Array} toc 从marked获取的TOC数组列表 + * @param {Element} container 插入TOC的容器元素 + * @param {Integer} startLevel Hx 起始层级 + * @returns {Object} tocContainer 返回ToC列表容器层的jQuery对象元素 + */ + + editormd.markdownToCRenderer = function(toc, container, tocDropdown, startLevel) { + + var html = ""; + var lastLevel = 0; + var classPrefix = this.classPrefix; + + startLevel = startLevel || 1; + + for (var i = 0, len = toc.length; i < len; i++) + { + var text = toc[i].text; + var level = toc[i].level; + + if (level < startLevel) { + continue; + } + + if (level > lastLevel) + { + html += ""; + } + else if (level < lastLevel) + { + html += (new Array(lastLevel - level + 2)).join(""); + } + else + { + html += ""; + } + + html += "
  • " + text + "
      "; + lastLevel = level; + } + + var tocContainer = container.find(".markdown-toc"); + + if ((tocContainer.length < 1 && container.attr("previewContainer") === "false")) + { + var tocHTML = "
      "; + + tocHTML = (tocDropdown) ? "
      " + tocHTML + "
      " : tocHTML; + + container.html(tocHTML); + + tocContainer = container.find(".markdown-toc"); + } + + if (tocDropdown) + { + tocContainer.wrap("

      "); + } + + tocContainer.html("
        ").children(".markdown-toc-list").html(html.replace(/\r?\n?\\<\/ul\>/g, "")); + + return tocContainer; + }; + + /** + * + * 生成TOC下拉菜单 + * Creating ToC dropdown menu + * + * @param {Object} container 插入TOC的容器jQuery对象元素 + * @param {String} tocTitle ToC title + * @returns {Object} return toc-menu object + */ + + editormd.tocDropdownMenu = function(container, tocTitle) { + + tocTitle = tocTitle || "Table of Contents"; + + var zindex = 400; + var tocMenus = container.find("." + this.classPrefix + "toc-menu"); + + tocMenus.each(function() { + var $this = $(this); + var toc = $this.children(".markdown-toc"); + var icon = ""; + var btn = "" + icon + tocTitle + ""; + var menu = toc.children("ul"); + var list = menu.find("li"); + + toc.append(btn); + + list.first().before("
      • " + tocTitle + " " + icon + "

      • "); + + $this.mouseover(function(){ + menu.show(); + + list.each(function(){ + var li = $(this); + var ul = li.children("ul"); + + if (ul.html() === "") + { + ul.remove(); + } + + if (ul.length > 0 && ul.html() !== "") + { + var firstA = li.children("a").first(); + + if (firstA.children(".fa").length < 1) + { + firstA.append( $(icon).css({ float:"right", paddingTop:"4px" }) ); + } + } + + li.mouseover(function(){ + ul.css("z-index", zindex).show(); + zindex += 1; + }).mouseleave(function(){ + ul.hide(); + }); + }); + }).mouseleave(function(){ + menu.hide(); + }); + }); + + return tocMenus; + }; + + /** + * 简单地过滤指定的HTML标签 + * Filter custom html tags + * + * @param {String} html 要过滤HTML + * @param {String} filters 要过滤的标签 + * @returns {String} html 返回过滤的HTML + */ + + editormd.filterHTMLTags = function(html, filters) { + + if (typeof html !== "string") { + html = new String(html); + } + + if (typeof filters !== "string") { + return html; + } + + var expression = filters.split("|"); + var filterTags = expression[0].split(","); + var attrs = expression[1]; + + for (var i = 0, len = filterTags.length; i < len; i++) + { + var tag = filterTags[i]; + + html = html.replace(new RegExp("\<\s*" + tag + "\s*([^\>]*)\>([^\>]*)\<\s*\/" + tag + "\s*\>", "igm"), ""); + } + + //return html; + + if (typeof attrs !== "undefined") + { + var htmlTagRegex = /\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/ig; + + if (attrs === "*") + { + html = html.replace(htmlTagRegex, function($1, $2, $3, $4, $5) { + return "<" + $2 + ">" + $4 + ""; + }); + } + else if (attrs === "on*") + { + html = html.replace(htmlTagRegex, function($1, $2, $3, $4, $5) { + var el = $("<" + $2 + ">" + $4 + ""); + var _attrs = $($1)[0].attributes; + var $attrs = {}; + + $.each(_attrs, function(i, e) { + if (e.nodeName !== '"') $attrs[e.nodeName] = e.nodeValue; + }); + + $.each($attrs, function(i) { + if (i.indexOf("on") === 0) { + delete $attrs[i]; + } + }); + + el.attr($attrs); + + var text = (typeof el[1] !== "undefined") ? $(el[1]).text() : ""; + + return el[0].outerHTML + text; + }); + } + else + { + html = html.replace(htmlTagRegex, function($1, $2, $3, $4) { + var filterAttrs = attrs.split(","); + var el = $($1); + el.html($4); + + $.each(filterAttrs, function(i) { + el.attr(filterAttrs[i], null); + }); + + return el[0].outerHTML; + }); + } + } + + return html; + }; + + /** + * 将Markdown文档解析为HTML用于前台显示 + * Parse Markdown to HTML for Font-end preview. + * + * @param {String} id 用于显示HTML的对象ID + * @param {Object} [options={}] 配置选项,可选 + * @returns {Object} div 返回jQuery对象元素 + */ + + editormd.markdownToHTML = function(id, options) { + var defaults = { + gfm : true, + toc : true, + tocm : false, + tocStartLevel : 1, + tocTitle : "目录", + tocDropdown : false, + tocContainer : "", + markdown : "", + markdownSourceCode : false, + htmlDecode : false, + autoLoadKaTeX : true, + pageBreak : true, + atLink : true, // for @link + emailLink : true, // for mail address auto link + tex : false, + taskList : false, // Github Flavored Markdown task lists + emoji : false, + flowChart : false, + sequenceDiagram : false, + previewCodeHighlight : true + }; + + editormd.$marked = marked; + + var div = $("#" + id); + var settings = div.settings = $.extend(true, defaults, options || {}); + var saveTo = div.find("textarea"); + + if (saveTo.length < 1) + { + div.append(""); + saveTo = div.find("textarea"); + } + + var markdownDoc = (settings.markdown === "") ? saveTo.val() : settings.markdown; + var markdownToC = []; + + var rendererOptions = { + toc : settings.toc, + tocm : settings.tocm, + tocStartLevel : settings.tocStartLevel, + taskList : settings.taskList, + emoji : settings.emoji, + tex : settings.tex, + pageBreak : settings.pageBreak, + atLink : settings.atLink, // for @link + emailLink : settings.emailLink, // for mail address auto link + flowChart : settings.flowChart, + sequenceDiagram : settings.sequenceDiagram, + previewCodeHighlight : settings.previewCodeHighlight, + }; + + var markedOptions = { + renderer : editormd.markedRenderer(markdownToC, rendererOptions), + gfm : settings.gfm, + tables : true, + breaks : true, + pedantic : false, + sanitize : (settings.htmlDecode) ? false : true, // 是否忽略HTML标签,即是否开启HTML标签解析,为了安全性,默认不开启 + smartLists : true, + smartypants : true + }; + + markdownDoc = new String(markdownDoc); + + var markdownParsed = marked(markdownDoc, markedOptions); + + markdownParsed = editormd.filterHTMLTags(markdownParsed, settings.htmlDecode); + + if (settings.markdownSourceCode) { + saveTo.text(markdownDoc); + } else { + saveTo.remove(); + } + + div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed); + + var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div; + + if (settings.tocContainer !== "") + { + tocContainer.attr("previewContainer", false); + } + + if (settings.toc) + { + div.tocContainer = this.markdownToCRenderer(markdownToC, tocContainer, settings.tocDropdown, settings.tocStartLevel); + + if (settings.tocDropdown || div.find("." + this.classPrefix + "toc-menu").length > 0) + { + this.tocDropdownMenu(div, settings.tocTitle); + } + + if (settings.tocContainer !== "") + { + div.find(".editormd-toc-menu, .editormd-markdown-toc").remove(); + } + } + + if (settings.previewCodeHighlight) + { + div.find("pre").addClass("prettyprint linenums"); + prettyPrint(); + } + + if (!editormd.isIE8) + { + if (settings.flowChart) { + div.find(".flowchart").flowChart(); + } + + if (settings.sequenceDiagram) { + div.find(".sequence-diagram").sequenceDiagram({theme: "simple"}); + } + } + + if (settings.tex) + { + var katexHandle = function() { + div.find("." + editormd.classNames.tex).each(function(){ + var tex = $(this); + katex.render(tex.html().replace(/</g, "<").replace(/>/g, ">"), tex[0]); + tex.find(".katex").css("font-size", "1.6em"); + }); + }; + + if (settings.autoLoadKaTeX && !editormd.$katex && !editormd.kaTeXLoaded) + { + this.loadKaTeX(function() { + editormd.$katex = katex; + editormd.kaTeXLoaded = true; + katexHandle(); + }); + } + else + { + katexHandle(); + } + } + + div.getMarkdown = function() { + return saveTo.val(); + }; + + return div; + }; + + // Editor.md themes, change toolbar themes etc. + // added @1.5.0 + editormd.themes = ["default", "dark"]; + + // Preview area themes + // added @1.5.0 + editormd.previewThemes = ["default", "dark"]; + + // CodeMirror / editor area themes + // @1.5.0 rename -> editorThemes, old version -> themes + editormd.editorThemes = [ + "default", "3024-day", "3024-night", + "ambiance", "ambiance-mobile", + "base16-dark", "base16-light", "blackboard", + "cobalt", + "eclipse", "elegant", "erlang-dark", + "lesser-dark", + "mbo", "mdn-like", "midnight", "monokai", + "neat", "neo", "night", + "paraiso-dark", "paraiso-light", "pastel-on-dark", + "rubyblue", + "solarized", + "the-matrix", "tomorrow-night-eighties", "twilight", + "vibrant-ink", + "xq-dark", "xq-light" + ]; + + editormd.loadPlugins = {}; + + editormd.loadFiles = { + js : [], + css : [], + plugin : [] + }; + + /** + * 动态加载Editor.md插件,但不立即执行 + * Load editor.md plugins + * + * @param {String} fileName 插件文件路径 + * @param {Function} [callback=function()] 加载成功后执行的回调函数 + * @param {String} [into="head"] 嵌入页面的位置 + */ + + editormd.loadPlugin = function(fileName, callback, into) { + callback = callback || function() {}; + + this.loadScript(fileName, function() { + editormd.loadFiles.plugin.push(fileName); + callback(); + }, into); + }; + + /** + * 动态加载CSS文件的方法 + * Load css file method + * + * @param {String} fileName CSS文件名 + * @param {Function} [callback=function()] 加载成功后执行的回调函数 + * @param {String} [into="head"] 嵌入页面的位置 + */ + + editormd.loadCSS = function(fileName, callback, into) { + into = into || "head"; + callback = callback || function() {}; + + var css = document.createElement("link"); + css.type = "text/css"; + css.rel = "stylesheet"; + css.onload = css.onreadystatechange = function() { + editormd.loadFiles.css.push(fileName); + callback(); + }; + + css.href = fileName + ".css"; + + if(into === "head") { + document.getElementsByTagName("head")[0].appendChild(css); + } else { + document.body.appendChild(css); + } + }; + + editormd.isIE = (navigator.appName == "Microsoft Internet Explorer"); + editormd.isIE8 = (editormd.isIE && navigator.appVersion.match(/8./i) == "8."); + + /** + * 动态加载JS文件的方法 + * Load javascript file method + * + * @param {String} fileName JS文件名 + * @param {Function} [callback=function()] 加载成功后执行的回调函数 + * @param {String} [into="head"] 嵌入页面的位置 + */ + + editormd.loadScript = function(fileName, callback, into) { + + into = into || "head"; + callback = callback || function() {}; + + var script = null; + script = document.createElement("script"); + script.id = fileName.replace(/[\./]+/g, "-"); + script.type = "text/javascript"; + script.src = fileName + ".js"; + + if (editormd.isIE8) + { + script.onreadystatechange = function() { + if(script.readyState) + { + if (script.readyState === "loaded" || script.readyState === "complete") + { + script.onreadystatechange = null; + editormd.loadFiles.js.push(fileName); + callback(); + } + } + }; + } + else + { + script.onload = function() { + editormd.loadFiles.js.push(fileName); + callback(); + }; + } + + if (into === "head") { + document.getElementsByTagName("head")[0].appendChild(script); + } else { + document.body.appendChild(script); + } + }; + + // 使用国外的CDN,加载速度有时会很慢,或者自定义URL + // You can custom KaTeX load url. + editormd.katexURL = { + css : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min", + js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min" + }; + + editormd.kaTeXLoaded = false; + + /** + * 加载KaTeX文件 + * load KaTeX files + * + * @param {Function} [callback=function()] 加载成功后执行的回调函数 + */ + + editormd.loadKaTeX = function (callback) { + editormd.loadCSS(editormd.katexURL.css, function(){ + editormd.loadScript(editormd.katexURL.js, callback || function(){}); + }); + }; + + /** + * 锁屏 + * lock screen + * + * @param {Boolean} lock Boolean 布尔值,是否锁屏 + * @returns {void} + */ + + editormd.lockScreen = function(lock) { + $("html,body").css("overflow", (lock) ? "hidden" : ""); + }; + + /** + * 动态创建对话框 + * Creating custom dialogs + * + * @param {Object} options 配置项键值对 Key/Value + * @returns {dialog} 返回创建的dialog的jQuery实例对象 + */ + + editormd.createDialog = function(options) { + var defaults = { + name : "", + width : 420, + height: 240, + title : "", + drag : true, + closed : true, + content : "", + mask : true, + maskStyle : { + backgroundColor : "#fff", + opacity : 0.1 + }, + lockScreen : true, + footer : true, + buttons : false + }; + + options = $.extend(true, defaults, options); + + var $this = this; + var editor = this.editor; + var classPrefix = editormd.classPrefix; + var guid = (new Date()).getTime(); + var dialogName = ( (options.name === "") ? classPrefix + "dialog-" + guid : options.name); + var mouseOrTouch = editormd.mouseOrTouch; + + var html = "
        "; + + if (options.title !== "") + { + html += "
        "; + html += "" + options.title + ""; + html += "
        "; + } + + if (options.closed) + { + html += ""; + } + + html += "
        " + options.content; + + if (options.footer || typeof options.footer === "string") + { + html += "
        " + ( (typeof options.footer === "boolean") ? "" : options.footer) + "
        "; + } + + html += "
        "; + + html += "
        "; + html += "
        "; + html += "
        "; + + editor.append(html); + + var dialog = editor.find("." + dialogName); + + dialog.lockScreen = function(lock) { + if (options.lockScreen) + { + $("html,body").css("overflow", (lock) ? "hidden" : ""); + $this.resize(); + } + + return dialog; + }; + + dialog.showMask = function() { + if (options.mask) + { + editor.find("." + classPrefix + "mask").css(options.maskStyle).css("z-index", editormd.dialogZindex - 1).show(); + } + return dialog; + }; + + dialog.hideMask = function() { + if (options.mask) + { + editor.find("." + classPrefix + "mask").hide(); + } + + return dialog; + }; + + dialog.loading = function(show) { + var loading = dialog.find("." + classPrefix + "dialog-mask"); + loading[(show) ? "show" : "hide"](); + + return dialog; + }; + + dialog.lockScreen(true).showMask(); + + dialog.show().css({ + zIndex : editormd.dialogZindex, + border : (editormd.isIE8) ? "1px solid #ddd" : "", + width : (typeof options.width === "number") ? options.width + "px" : options.width, + height : (typeof options.height === "number") ? options.height + "px" : options.height + }); + + var dialogPosition = function(){ + dialog.css({ + top : ($(window).height() - dialog.height()) / 2 + "px", + left : ($(window).width() - dialog.width()) / 2 + "px" + }); + }; + + dialogPosition(); + + $(window).resize(dialogPosition); + + dialog.children("." + classPrefix + "dialog-close").bind(mouseOrTouch("click", "touchend"), function() { + dialog.hide().lockScreen(false).hideMask(); + }); + + if (typeof options.buttons === "object") + { + var footer = dialog.footer = dialog.find("." + classPrefix + "dialog-footer"); + + for (var key in options.buttons) + { + var btn = options.buttons[key]; + var btnClassName = classPrefix + key + "-btn"; + + footer.append(""); + btn[1] = $.proxy(btn[1], dialog); + footer.children("." + btnClassName).bind(mouseOrTouch("click", "touchend"), btn[1]); + } + } + + if (options.title !== "" && options.drag) + { + var posX, posY; + var dialogHeader = dialog.children("." + classPrefix + "dialog-header"); + + if (!options.mask) { + dialogHeader.bind(mouseOrTouch("click", "touchend"), function(){ + editormd.dialogZindex += 2; + dialog.css("z-index", editormd.dialogZindex); + }); + } + + dialogHeader.mousedown(function(e) { + e = e || window.event; //IE + posX = e.clientX - parseInt(dialog[0].style.left); + posY = e.clientY - parseInt(dialog[0].style.top); + + document.onmousemove = moveAction; + }); + + var userCanSelect = function (obj) { + obj.removeClass(classPrefix + "user-unselect").off("selectstart"); + }; + + var userUnselect = function (obj) { + obj.addClass(classPrefix + "user-unselect").on("selectstart", function(event) { // selectstart for IE + return false; + }); + }; + + var moveAction = function (e) { + e = e || window.event; //IE + + var left, top, nowLeft = parseInt(dialog[0].style.left), nowTop = parseInt(dialog[0].style.top); + + if( nowLeft >= 0 ) { + if( nowLeft + dialog.width() <= $(window).width()) { + left = e.clientX - posX; + } else { + left = $(window).width() - dialog.width(); + document.onmousemove = null; + } + } else { + left = 0; + document.onmousemove = null; + } + + if( nowTop >= 0 ) { + top = e.clientY - posY; + } else { + top = 0; + document.onmousemove = null; + } + + + document.onselectstart = function() { + return false; + }; + + userUnselect($("body")); + userUnselect(dialog); + dialog[0].style.left = left + "px"; + dialog[0].style.top = top + "px"; + }; + + document.onmouseup = function() { + userCanSelect($("body")); + userCanSelect(dialog); + + document.onselectstart = null; + document.onmousemove = null; + }; + + dialogHeader.touchDraggable = function() { + var offset = null; + var start = function(e) { + var orig = e.originalEvent; + var pos = $(this).parent().position(); + + offset = { + x : orig.changedTouches[0].pageX - pos.left, + y : orig.changedTouches[0].pageY - pos.top + }; + }; + + var move = function(e) { + e.preventDefault(); + var orig = e.originalEvent; + + $(this).parent().css({ + top : orig.changedTouches[0].pageY - offset.y, + left : orig.changedTouches[0].pageX - offset.x + }); + }; + + this.bind("touchstart", start).bind("touchmove", move); + }; + + dialogHeader.touchDraggable(); + } + + editormd.dialogZindex += 2; + + return dialog; + }; + + /** + * 鼠标和触摸事件的判断/选择方法 + * MouseEvent or TouchEvent type switch + * + * @param {String} [mouseEventType="click"] 供选择的鼠标事件 + * @param {String} [touchEventType="touchend"] 供选择的触摸事件 + * @returns {String} EventType 返回事件类型名称 + */ + + editormd.mouseOrTouch = function(mouseEventType, touchEventType) { + mouseEventType = mouseEventType || "click"; + touchEventType = touchEventType || "touchend"; + + var eventType = mouseEventType; + + try { + document.createEvent("TouchEvent"); + eventType = touchEventType; + } catch(e) {} + + return eventType; + }; + + /** + * 日期时间的格式化方法 + * Datetime format method + * + * @param {String} [format=""] 日期时间的格式,类似PHP的格式 + * @returns {String} datefmt 返回格式化后的日期时间字符串 + */ + + editormd.dateFormat = function(format) { + format = format || ""; + + var addZero = function(d) { + return (d < 10) ? "0" + d : d; + }; + + var date = new Date(); + var year = date.getFullYear(); + var year2 = year.toString().slice(2, 4); + var month = addZero(date.getMonth() + 1); + var day = addZero(date.getDate()); + var weekDay = date.getDay(); + var hour = addZero(date.getHours()); + var min = addZero(date.getMinutes()); + var second = addZero(date.getSeconds()); + var ms = addZero(date.getMilliseconds()); + var datefmt = ""; + + var ymd = year2 + "-" + month + "-" + day; + var fymd = year + "-" + month + "-" + day; + var hms = hour + ":" + min + ":" + second; + + switch (format) + { + case "UNIX Time" : + datefmt = date.getTime(); + break; + + case "UTC" : + datefmt = date.toUTCString(); + break; + + case "yy" : + datefmt = year2; + break; + + case "year" : + case "yyyy" : + datefmt = year; + break; + + case "month" : + case "mm" : + datefmt = month; + break; + + case "cn-week-day" : + case "cn-wd" : + var cnWeekDays = ["日", "一", "二", "三", "四", "五", "六"]; + datefmt = "星期" + cnWeekDays[weekDay]; + break; + + case "week-day" : + case "wd" : + var weekDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; + datefmt = weekDays[weekDay]; + break; + + case "day" : + case "dd" : + datefmt = day; + break; + + case "hour" : + case "hh" : + datefmt = hour; + break; + + case "min" : + case "ii" : + datefmt = min; + break; + + case "second" : + case "ss" : + datefmt = second; + break; + + case "ms" : + datefmt = ms; + break; + + case "yy-mm-dd" : + datefmt = ymd; + break; + + case "yyyy-mm-dd" : + datefmt = fymd; + break; + + case "yyyy-mm-dd h:i:s ms" : + case "full + ms" : + datefmt = fymd + " " + hms + " " + ms; + break; + + case "full" : + case "yyyy-mm-dd h:i:s" : + default: + datefmt = fymd + " " + hms; + break; + } + + return datefmt; + }; + + return editormd; + +})); diff --git a/src/main/webapp/static/global/plugins/editor.md-master/editormd.amd.min.js b/src/main/webapp/static/global/plugins/editor.md-master/editormd.amd.min.js new file mode 100644 index 000000000..83f5f6e75 --- /dev/null +++ b/src/main/webapp/static/global/plugins/editor.md-master/editormd.amd.min.js @@ -0,0 +1,4 @@ +/*! Editor.md v1.5.0 | editormd.amd.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-06-09 */ +!function(e){"use strict";if("function"==typeof require&&"object"==typeof exports&&"object"==typeof module)module.exports=e;else if("function"==typeof define)if(define.amd){var t="codemirror/mode/",i="codemirror/addon/",o=["jquery","marked","prettify","katex","raphael","underscore","flowchart","jqueryflowchart","sequenceDiagram","codemirror/lib/codemirror",t+"css/css",t+"sass/sass",t+"shell/shell",t+"sql/sql",t+"clike/clike",t+"php/php",t+"xml/xml",t+"markdown/markdown",t+"javascript/javascript",t+"htmlmixed/htmlmixed",t+"gfm/gfm",t+"http/http",t+"go/go",t+"dart/dart",t+"coffeescript/coffeescript",t+"nginx/nginx",t+"python/python",t+"perl/perl",t+"lua/lua",t+"r/r",t+"ruby/ruby",t+"rst/rst",t+"smartymixed/smartymixed",t+"vb/vb",t+"vbscript/vbscript",t+"velocity/velocity",t+"xquery/xquery",t+"yaml/yaml",t+"erlang/erlang",t+"jade/jade",i+"edit/trailingspace",i+"dialog/dialog",i+"search/searchcursor",i+"search/search",i+"scroll/annotatescrollbar",i+"search/matchesonscrollbar",i+"display/placeholder",i+"edit/closetag",i+"fold/foldcode",i+"fold/foldgutter",i+"fold/indent-fold",i+"fold/brace-fold",i+"fold/xml-fold",i+"fold/markdown-fold",i+"fold/comment-fold",i+"mode/overlay",i+"selection/active-line",i+"edit/closebrackets",i+"display/fullscreen",i+"search/match-highlighter"];define(o,e)}else define(["jquery"],e);else window.editormd=e()}(function(){"function"==typeof define&&define.amd&&(e=arguments[0],marked=arguments[1],prettify=arguments[2],katex=arguments[3],Raphael=arguments[4],_=arguments[5],flowchart=arguments[6],CodeMirror=arguments[9]);var e="undefined"!=typeof jQuery?jQuery:Zepto;if("undefined"!=typeof e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.5.0",t.homePage="https://pandao.github.io/editor.md/",t.classPrefix="editormd-",t.toolbarModes={full:["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","info"],simple:["undo","redo","|","bold","del","italic","quote","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","watch","preview","fullscreen","|","help","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},t.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",delay:300,autoLoadModules:!0,watch:!0,placeholder:"Enjoy Markdown! coding now...",gotoLine:!0,codeFold:!1,autoHeight:!1,autoFocus:!0,autoCloseTags:!0,searchReplace:!0,syncScrolling:!0,readOnly:!1,tabSize:4,indentUnit:4,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,showTrailingSpace:!0,matchBrackets:!0,indentWithTabs:!0,styleSelectedText:!0,matchWordHighlight:!0,styleActiveLine:!0,dialogLockScreen:!0,dialogShowMask:!0,dialogDraggable:!0,dialogMaskBgColor:"#fff",dialogMaskOpacity:.1,fontSize:"13px",saveHTMLToTextarea:!1,disabledKeyMaps:[],onload:function(){},onresize:function(){},onchange:function(){},onwatch:null,onunwatch:null,onpreviewing:function(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return t.toolbarHandlers.ucwords},lowercase:function(){return t.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'a',ucwords:'Aa'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:t.classPrefix+"bold",h2:t.classPrefix+"bold",h3:t.classPrefix+"bold",h4:t.classPrefix+"bold",h5:t.classPrefix+"bold",h6:t.classPrefix+"bold","list-ul":"fa-list-ul","list-ol":"fa-list-ol",hr:"fa-minus",link:"fa-link","reference-link":"fa-anchor",image:"fa-picture-o",code:"fa-code","preformatted-text":"fa-file-code-o","code-block":"fa-file-code-o",table:"fa-table",datetime:"fa-clock-o",emoji:"fa-smile-o","html-entities":"fa-copyright",pagebreak:"fa-newspaper-o","goto-line":"fa-terminal",watch:"fa-eye-slash",unwatch:"fa-eye",preview:"fa-desktop",search:"fa-search",fullscreen:"fa-arrows-alt",clear:"fa-eraser",help:"fa-question-circle",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线Markdown编辑器
        Open source online Markdown editor.",tocTitle:"目录",toolbar:{undo:"撤销(Ctrl+Z)",redo:"重做(Ctrl+Y)",bold:"粗体",del:"删除线",italic:"斜体",quote:"引用",ucwords:"将每个单词首字母转成大写",uppercase:"将所选转换成大写",lowercase:"将所选转换成小写",h1:"标题1",h2:"标题2",h3:"标题3",h4:"标题4",h5:"标题5",h6:"标题6","list-ul":"无序列表","list-ol":"有序列表",hr:"横线",link:"链接","reference-link":"引用链接",image:"添加图片",code:"行内代码","preformatted-text":"预格式文本 / 代码块(缩进风格)","code-block":"代码块(多语言风格)",table:"添加表格",datetime:"日期时间",emoji:"Emoji表情","html-entities":"HTML实体字符",pagebreak:"插入分页符","goto-line":"跳转到行",watch:"关闭实时预览",unwatch:"开启实时预览",preview:"全窗口预览HTML(按 Shift + ESC还原)",fullscreen:"全屏(按ESC还原)",clear:"清空",search:"搜索",help:"使用帮助",info:"关于"+t.title},buttons:{enter:"确定",cancel:"取消",close:"关闭"},dialog:{link:{title:"添加链接",url:"链接地址",urlTitle:"链接标题",urlEmpty:"错误:请填写链接地址。"},referenceLink:{title:"添加引用链接",name:"引用名称",url:"链接地址",urlId:"链接ID",urlTitle:"链接标题",nameEmpty:"错误:引用链接的名称不能为空。",idEmpty:"错误:请填写引用链接的ID。",urlEmpty:"错误:请填写引用链接的URL地址。"},image:{title:"添加图片",url:"图片地址",link:"图片链接",alt:"图片描述",uploadButton:"本地上传",imageURLEmpty:"错误:图片地址不能为空。",uploadFileEmpty:"错误:上传的图片不能为空。",formatNotAllowed:"错误:只允许上传图片文件,允许上传的图片文件格式有:"},preformattedText:{title:"添加预格式文本或代码块",emptyAlert:"错误:请填写预格式文本或代码的内容。"},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。"},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},t.classNames={tex:t.classPrefix+"tex"},t.dialogZindex=99999,t.$katex=null,t.$marked=null,t.$CodeMirror=null,t.$prettyPrint=null;var i,o;t.prototype=t.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(i,o){o=o||{},"object"==typeof i&&(o=i);var r=this.classPrefix=t.classPrefix,n=this.settings=e.extend(!0,t.defaults,o);i="object"==typeof i?n.id:i;var a=this.editor=e("#"+i);this.id=i,this.lang=n.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};n.pluginPath=""===n.pluginPath?n.path+"../plugins/":n.pluginPath,this.state.watching=n.watch?!0:!1,a.hasClass("editormd")||a.addClass("editormd"),a.css({width:"number"==typeof n.width?n.width+"px":n.width,height:"number"==typeof n.height?n.height+"px":n.height}),n.autoHeight&&a.css("height","auto");var l=this.markdownTextarea=a.children("textarea");l.length<1&&(a.append(""),l=this.markdownTextarea=a.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",n.placeholder),("undefined"==typeof l.attr("name")||""===l.attr("name"))&&l.attr("name",""!==n.name?n.name:i+"-markdown-doc");var c=[n.readOnly?"":'',n.saveHTMLToTextarea?'':"",'
        ','
        ','
        '].join("\n");return a.append(c).addClass(r+"vertical"),""!==n.theme&&a.addClass(r+"theme-"+n.theme),this.mask=a.children("."+r+"mask"),this.containerMask=a.children("."+r+"container-mask"),""!==n.markdown&&l.val(n.markdown),""!==n.appendMarkdown&&l.val(l.val()+n.appendMarkdown),this.htmlTextarea=a.children("."+s.textarea.html),this.preview=a.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==n.previewTheme&&this.preview.addClass(r+"preview-theme-"+n.previewTheme),"function"==typeof define&&define.amd&&("undefined"!=typeof katex&&(t.$katex=katex),n.searchReplace&&!n.readOnly&&(t.loadCSS(n.path+"codemirror/addon/dialog/dialog"),t.loadCSS(n.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!n.autoLoadModules?("undefined"!=typeof CodeMirror&&(t.$CodeMirror=CodeMirror),"undefined"!=typeof marked&&(t.$marked=marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,i=this.settings,o=i.path,r=function(){return t.isIE8?void e.loadedDisplay():void(i.flowChart||i.sequenceDiagram?t.loadScript(o+"raphael.min",function(){t.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay())};return t.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(t.loadCSS(o+"codemirror/addon/dialog/dialog"),t.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&t.loadCSS(o+"codemirror/addon/fold/foldgutter"),t.loadScript(o+"codemirror/codemirror.min",function(){t.$CodeMirror=CodeMirror,t.loadScript(o+"codemirror/modes.min",function(){t.loadScript(o+"codemirror/addons.min",function(){return e.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode?(e.loadedDisplay(),!1):(e.setToolbar(),void t.loadScript(o+"marked.min",function(){t.$marked=marked,i.previewCodeHighlight?t.loadScript(o+"prettify.min",function(){r()}):r()}))})})}),this},setTheme:function(e){var t=this.editor,i=this.settings.theme,o=this.classPrefix+"theme-";return t.removeClass(o+i).addClass(o+e),this.settings.theme=e,this},setEditorTheme:function(e){var i=this.settings;return i.editorTheme=e,"default"!==e&&t.loadCSS(i.path+"codemirror/theme/"+i.editorTheme),this.cm.setOption("theme",e),this},setCodeMirrorTheme:function(e){return this.setEditorTheme(e),this},setPreviewTheme:function(e){var t=this.preview,i=this.settings.previewTheme,o=this.classPrefix+"preview-theme-";return t.removeClass(o+i).addClass(o+e),this.settings.previewTheme=e,this},setCodeMirror:function(){var e=this.settings,i=this.editor;"default"!==e.editorTheme&&t.loadCSS(e.path+"codemirror/theme/"+e.editorTheme);var o={mode:e.mode,theme:e.editorTheme,tabSize:e.tabSize,dragDrop:!1,autofocus:e.autoFocus,autoCloseTags:e.autoCloseTags,readOnly:e.readOnly?"nocursor":!1,indentUnit:e.indentUnit,lineNumbers:e.lineNumbers,lineWrapping:e.lineWrapping,extraKeys:{"Ctrl-Q":function(e){e.foldCode(e.getCursor())}},foldGutter:e.codeFold,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],matchBrackets:e.matchBrackets,indentWithTabs:e.indentWithTabs,styleActiveLine:e.styleActiveLine,styleSelectedText:e.styleSelectedText,autoCloseBrackets:e.autoCloseBrackets,showTrailingSpace:e.showTrailingSpace,highlightSelectionMatches:e.matchWordHighlight?{showToken:"onselected"===e.matchWordHighlight?!1:/\w/}:!1};return this.codeEditor=this.cm=t.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=i.children(".CodeMirror"),""!==e.value&&this.cm.setValue(e.value),this.codeMirror.css({fontSize:e.fontSize,width:e.watch?"50%":"100%"}),e.autoHeight&&(this.codeMirror.css("height","auto"),this.cm.setOption("viewportMargin",1/0)),e.lineNumbers||this.codeMirror.find(".CodeMirror-gutters").css("border-right","none"),this},getCodeMirrorOption:function(e){return this.cm.getOption(e)},setCodeMirrorOption:function(e,t){return this.cm.setOption(e,t),this},addKeyMap:function(e,t){return this.cm.addKeyMap(e,t),this},removeKeyMap:function(e){return this.cm.removeKeyMap(e),this},gotoLine:function(t){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=(this.editor,o.lineCount()),n=this.preview;if("string"==typeof t&&("last"===t&&(t=r),"first"===t&&(t=1)),"number"!=typeof t)return alert("Error: The line number must be an integer."),this;if(t=parseInt(t)-1,t>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:t,ch:0});var a=o.getScrollInfo(),s=a.clientHeight,l=o.charCoords({line:t,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=e(c).height(),d=c.scrollTop,u=d/c.scrollHeight;n.scrollTop(0===d?0:d+h>=c.scrollHeight-16?n[0].scrollHeight:n[0].scrollHeight*u)}return o.focus(),this},extend:function(){return"undefined"!=typeof arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=e.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&"undefined"==typeof arguments[0].length&&e.extend(!0,this,arguments[0]),this},set:function(t,i){return"undefined"!=typeof i&&"function"==typeof i&&(i=e.proxy(i,this)),this[t]=i,this},config:function(t,i){var o=this.settings;return"object"==typeof t&&(o=e.extend(!0,o,t)),"string"==typeof t&&(o[t]=i),this.settings=o,this.recreate(),this},on:function(t,i){var o=this.settings;return"undefined"!=typeof o["on"+t]&&(o["on"+t]=e.proxy(i,this)),this},off:function(e){var t=this.settings;return"undefined"!=typeof t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(t){var i=this.settings;return i.readOnly?this:(i.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),i.toolbar=!0,this.toolbar.show(),this.resize(),e.proxy(t||function(){},this)(),this)},hideToolbar:function(t){var i=this.settings;return i.toolbar=!1,this.toolbar.hide(),this.resize(),e.proxy(t||function(){},this)(),this},setToolbarAutoFixed:function(t){var i=this.state,o=this.editor,r=this.toolbar,n=this.settings;"undefined"!=typeof t&&(n.toolbarAutoFixed=t);var a=function(){var t=e(window),i=t.scrollTop();return n.toolbarAutoFixed?void r.css(i-o.offset().top>10&&i
          ';i.append(n),r=this.toolbar=i.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var a="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?t.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=a.length;d>h;h++){var u=a[h];if("||"===u)c=!0;else if("|"===u)l+='
        • |
        • ';else{var f=/h(\d)/.test(u),g=u;"watch"!==u||e.watch||(g="unwatch");var p=e.lang.toolbar[g],m=e.toolbarIconTexts[g],w=e.toolbarIconsClass[g];p="undefined"==typeof p?"":p,m="undefined"==typeof m?"":m,w="undefined"==typeof w?"":w;var v=c?'
        • ':"
        • ";"undefined"!=typeof e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='',v+=''+(f?u.toUpperCase():""===w?m:"")+"",v+=""),v+="
        • ",l=c?v+l:l+v}}return s.html(l),s.find('[title="Lowercase"]').attr("title",e.lang.toolbar.lowercase),s.find('[title="ucwords"]').attr("title",e.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed(),this},dialogLockScreen:function(){return e.proxy(t.dialogLockScreen,this)(),this},dialogShowMask:function(i){return e.proxy(t.dialogShowMask,this)(i),this},getToolbarHandles:function(e){var i=this.toolbarHandlers=t.toolbarHandlers;return e&&"undefined"!=typeof toolbarIconHandlers[e]?i[e]:i},setToolbarHandler:function(){var i=this,o=this.settings;if(!o.toolbar||o.readOnly)return this;var r=this.toolbar,n=this.cm,a=this.classPrefix,s=this.toolbarIcons=r.find("."+a+"menu > li > a"),l=this.getToolbarHandles();return s.bind(t.mouseOrTouch("click","touchend"),function(t){var r=e(this).children(".fa"),a=r.attr("name"),s=n.getCursor(),c=n.getSelection();return""!==a?(i.activeIcon=r,"undefined"!=typeof l[a]?e.proxy(l[a],i)(n):"undefined"!=typeof o.toolbarHandlers[a]&&e.proxy(o.toolbarHandlers[a],i)(n,r,s,c),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&n.focus(),!1):void 0}),this},createDialog:function(i){return e.proxy(t.createDialog,this)(i)},createInfoDialog:function(){var e=this,i=this.editor,o=this.classPrefix,r=['
          ','
          ','

          '+t.title+"v"+t.version+"

          ","

          "+this.lang.description+"

          ",'

          '+t.homePage+'

          ','

          Copyright © 2015 Pandao, The MIT License.

          ',"
          ",'',"
          "].join("\n");i.append(r);var n=this.infoDialog=i.children("."+o+"dialog-info");return n.find("."+o+"dialog-close").bind(t.mouseOrTouch("click","touchend"),function(){e.hideInfoDialog()}),n.css("border",t.isIE8?"1px solid #ddd":"").css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var t=this.infoDialog,i=function(){t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"})};return i(),e(window).resize(i),this},showInfoDialog:function(){e("html,body").css("overflow-x","hidden");var i=this.editor,o=this.settings,r=this.infoDialog=i.children("."+this.classPrefix+"dialog-info");return r.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:o.dialogMaskOpacity,backgroundColor:o.dialogMaskBgColor}).show(),r.css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return e("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return t.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(e.find(".editormd-dialog").length>0&&e.find(".editormd-dialog").remove(),t.toolbar&&(this.getToolbarHandles(),this.setToolbar())),this.loadedDisplay(!0),this},previewCodeHighlight:function(){var e=this.settings,t=this.previewContainer;return e.previewCodeHighlight&&(t.find("pre").addClass("prettyprint linenums"),"undefined"!=typeof prettyPrint&&prettyPrint()),this},katexRender:function(){return null===i?this:(this.previewContainer.find("."+t.classNames.tex).each(function(){var i=e(this);t.$katex.render(i.text(),i[0]),i.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var i=this,r=this.settings,n=this.previewContainer;if(t.isIE8)return this;if(r.flowChart){if(null===o)return this;n.find(".flowchart").flowChart()}r.sequenceDiagram&&n.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var a=i.preview,s=i.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;a.find(".markdown-toc-list").each(function(){u+=e(this).height()});var f=a.find(".editormd-toc-menu").height();return f=f?f:0,a.scrollTop(0===h?0:h+c>=l[0].scrollHeight-16?a[0].scrollHeight:(a[0].scrollHeight+u+f)*d),this},registerKeyMaps:function(i){var o=this,r=this.cm,n=this.settings,a=t.toolbarHandlers,s=n.disabledKeyMaps;if(i=i||null){for(var l in i)if(e.inArray(l,s)<0){var c={};c[l]=i[l],r.addKeyMap(i)}}else{for(var h in t.keyMaps){var d=t.keyMaps[h],u="string"==typeof d?e.proxy(a[d],o):e.proxy(d,o);if(e.inArray(h,["F9","F10","F11"])<0&&e.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}e(window).keydown(function(t){var i={120:"F9",121:"F10",122:"F11"};if(e.inArray(i[t.keyCode],s)<0)switch(t.keyCode){case 120:return e.proxy(a.watch,o)(),!1;case 121:return e.proxy(a.preview,o)(),!1;case 122:return e.proxy(a.fullscreen,o)(),!1}})}return this},bindScrollEvent:function(){var i=this,o=this.preview,r=this.settings,n=this.codeMirror,a=t.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){n.find(".CodeMirror-scroll").bind(a("scroll","touchmove"),function(t){var n=e(this).height(),a=e(this).scrollTop(),s=a/e(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=e(this).height()});var c=o.find(".editormd-toc-menu").height();c=c?c:0,o.scrollTop(0===a?0:a+n>=e(this)[0].scrollHeight-16?o[0].scrollHeight:(o[0].scrollHeight+l+c)*s),e.proxy(r.onscroll,i)(t)})},l=function(){n.find(".CodeMirror-scroll").unbind(a("scroll","touchmove"))},c=function(){o.bind(a("scroll","touchmove"),function(t){var o=e(this).height(),a=e(this).scrollTop(),s=a/e(this)[0].scrollHeight,l=n.find(".CodeMirror-scroll");l.scrollTop(0===a?0:a+o>=e(this)[0].scrollHeight?l[0].scrollHeight:l[0].scrollHeight*s),e.proxy(r.onpreviewscroll,i)(t)})},h=function(){o.unbind(a("scroll","touchmove"))};return n.bind({mouseover:s,mouseout:l,touchstart:s,touchend:l}),"single"===r.syncScrolling?this:(o.bind({mouseover:c,mouseout:h,touchstart:c,touchend:h}),this)},bindChangeEvent:function(){var e=this,t=this.cm,o=this.settings;return o.syncScrolling?(t.on("change",function(t,r){o.watch&&e.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),i=setTimeout(function(){clearTimeout(i),e.save(),i=null},o.delay)}),this):this},loadedDisplay:function(t){t=t||!1;var i=this,o=this.editor,r=this.preview,n=this.settings;return this.containerMask.hide(),this.save(),n.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),e(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),t||e.proxy(n.onload,this)(),this.state.loaded=!0,this},width:function(e){return this.editor.css("width","number"==typeof e?e+"px":e),this.resize(),this},height:function(e){return this.editor.css("height","number"==typeof e?e+"px":e),this.resize(),this},resize:function(t,i){t=t||null,i=i||null;var o=this.state,r=this.editor,n=this.preview,a=this.toolbar,s=this.settings,l=this.codeMirror;if(t&&r.css("width","number"==typeof t?t+"px":t),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(e(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",a.height()+1).height(r.height()-a.height()):l.css("margin-top",0).height(r.height())):(r.css("height","auto"),l.css("height","auto")),s.watch)if(l.width(r.width()/2),n.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?n.css("top",a.height()+1):n.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-a.height():r.height();n.height(c)}else n.height("");else l.width(r.width()),n.hide();return o.loaded&&e.proxy(s.onresize,this)(),this},save:function(){if(null===i)return this;var r=this,n=this.state,a=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==a.mode&&"markdown"!==a.mode)return this.markdownTextarea.val(l),this;var h=t.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:a.toc,tocm:a.tocm,tocStartLevel:a.tocStartLevel,pageBreak:a.pageBreak,taskList:a.taskList,emoji:a.emoji,tex:a.tex,atLink:a.atLink,emailLink:a.emailLink,flowChart:a.flowChart,sequenceDiagram:a.sequenceDiagram,previewCodeHighlight:a.previewCodeHighlight},f=this.markedOptions={renderer:t.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:a.htmlDecode?!1:!0,smartLists:!0,smartypants:!0};h.setOptions(f);var g=t.$marked(l,f);if(g=t.filterHTMLTags(g,a.htmlDecode),this.markdownTextarea.text(l),s.save(),a.saveHTMLToTextarea&&this.htmlTextarea.text(g),a.watch||!a.watch&&n.preview){if(c.html(g),this.previewCodeHighlight(),a.toc){var p=""===a.tocContainer?c:e(a.tocContainer),m=p.find("."+this.classPrefix+"toc-menu");p.attr("previewContainer",""===a.tocContainer?"true":"false"),""!==a.tocContainer&&m.length>0&&m.remove(),t.markdownToCRenderer(d,p,a.tocDropdown,a.tocStartLevel),(a.tocDropdown||p.find("."+this.classPrefix+"toc-menu").length>0)&&t.tocDropdownMenu(p,""!==a.tocTitle?a.tocTitle:this.lang.tocTitle),""!==a.tocContainer&&c.find(".markdown-toc").css("border","none")}a.tex&&(!t.kaTeXLoaded&&a.autoLoadModules?t.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,r.katexRender()}):(t.$katex=katex,this.katexRender())),(a.flowChart||a.sequenceDiagram)&&(o=setTimeout(function(){clearTimeout(o),r.flowChartAndSequenceDiagramRender(),o=null},10)),n.loaded&&e.proxy(a.onchange,this)()}return this},focus:function(){return this.cm.focus(),this},setCursor:function(e){return this.cm.setCursor(e),this},getCursor:function(){return this.cm.getCursor()},setSelection:function(e,t){return this.cm.setSelection(e,t),this},getSelection:function(){return this.cm.getSelection()},setSelections:function(e){return this.cm.setSelections(e),this},getSelections:function(){return this.cm.getSelections()},replaceSelection:function(e){return this.cm.replaceSelection(e),this},insertValue:function(e){return this.replaceSelection(e),this},appendMarkdown:function(e){var t=(this.settings,this.cm);return t.setValue(t.getValue()+e),this},setMarkdown:function(e){return this.cm.setValue(e||this.settings.markdown),this},getMarkdown:function(){return this.cm.getValue()},getValue:function(){return this.cm.getValue()},setValue:function(e){return this.cm.setValue(e),this},clear:function(){return this.cm.setValue(""),this},getHTML:function(){return this.settings.saveHTMLToTextarea?this.htmlTextarea.val():(alert("Error: settings.saveHTMLToTextarea == false"),!1)},getTextareaSavedHTML:function(){return this.getHTML()},getPreviewedHTML:function(){return this.settings.watch?this.previewContainer.html():(alert("Error: settings.watch == false"),!1)},watch:function(t){var o=this.settings;if(e.inArray(o.mode,["gfm","markdown"])<0)return this;if(this.state.watching=o.watch=!0,this.preview.show(),this.toolbar){var r=o.toolbarIconsClass.watch,n=o.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",o.lang.toolbar.watch),a.removeClass(n).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),i=0,this.save().resize(),o.onwatch||(o.onwatch=t||function(){}),e.proxy(o.onwatch,this)(),this},unwatch:function(t){var i=this.settings;if(this.state.watching=i.watch=!1,this.preview.hide(),this.toolbar){var o=i.toolbarIconsClass.watch,r=i.toolbarIconsClass.unwatch,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",i.lang.toolbar.unwatch),n.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=t||function(){}),e.proxy(i.onunwatch,this)(),this},show:function(t){t=t||function(){};var i=this;return this.editor.show(0,function(){e.proxy(t,i)()}),this},hide:function(t){t=t||function(){};var i=this;return this.editor.hide(0,function(){e.proxy(t,i)()}),this},previewing:function(){var i=this,o=this.editor,r=this.preview,n=this.toolbar,a=this.settings,s=this.codeMirror,l=this.previewContainer;if(e.inArray(a.mode,["gfm","markdown"])<0)return this;a.toolbar&&n&&(n.toggle(),n.find(".fa[name=preview]").toggleClass("active")),s.toggle();var c=function(e){e.shiftKey&&27===e.keyCode&&i.previewed()};"none"===s.css("display")?(this.state.preview=!0,this.state.fullscreen&&r.css("background","#fff"),o.find("."+this.classPrefix+"preview-close-btn").show().bind(t.mouseOrTouch("click","touchend"),function(){i.previewed()}),a.watch?l.css("padding",""):this.save(),l.addClass(this.classPrefix+"preview-active"),r.show().css({position:"",top:0,width:o.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":o.height()}),this.state.loaded&&e.proxy(a.onpreviewing,this)(),e(window).bind("keyup",c)):(e(window).unbind("keyup",c),this.previewed())},previewed:function(){var i=this.editor,o=this.preview,r=this.toolbar,n=this.settings,a=this.previewContainer,s=i.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),n.toolbar&&r.show(),o[n.watch?"show":"hide"](),s.hide().unbind(t.mouseOrTouch("click","touchend")),a.removeClass(this.classPrefix+"preview-active"),n.watch&&a.css("padding","20px"),o.css({background:null,position:"absolute",width:i.width()/2,height:n.autoHeight&&!this.state.fullscreen?"auto":i.height()-r.height(),top:n.toolbar?r.height():0}),this.state.loaded&&e.proxy(n.onpreviewed,this)(),this},fullscreen:function(){var t=this,i=this.state,o=this.editor,r=(this.preview,this.toolbar),n=this.settings,a=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()};return o.hasClass(a)?(e(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,e("html,body").css("overflow","hidden"),o.css({width:e(window).width(),height:e(window).height()}).addClass(a),this.resize(),e.proxy(n.onfullscreen,this)(),e(window).bind("keyup",s)),this},fullscreenExit:function(){var t=this.editor,i=this.settings,o=this.toolbar,r=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,o&&o.find(".fa[name=fullscreen]").parent().removeClass("active"),e("html,body").css("overflow",""),t.css({width:t.data("oldWidth"),height:t.data("oldHeight")}).removeClass(r),this.resize(),e.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(i,o){var r=this,n=this.cm,a=this.settings;return o=a.pluginPath+o,"function"==typeof define?"undefined"==typeof this[i]?(alert("Error: "+i+" plugin is not found, you are not load this plugin."),this):(this[i](n),this):(e.inArray(o,t.loadFiles.plugin)<0?t.loadPlugin(o,function(){t.loadPlugins[i]=r[i],r[i](n)}):e.proxy(t.loadPlugins[i],this)(n),this)},search:function(e){var t=this.settings;return t.searchReplace?(t.readOnly||this.cm.execCommand(e||"find"),this):(alert("Error: settings.searchReplace == false"),this)},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},t.fn.init.prototype=t.fn,t.dialogLockScreen=function(){var t=this.settings||{dialogLockScreen:!0};t.dialogLockScreen&&(e("html,body").css("overflow","hidden"),this.resize())},t.dialogShowMask=function(t){var i=this.editor,o=this.settings||{dialogShowMask:!0};t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(t.css("z-index"))-1).show()},t.toolbarHandlers={undo:function(){this.cm.undo()},redo:function(){this.cm.redo()},bold:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(); + +e.replaceSelection("**"+i+"**"),""===i&&e.setCursor(t.line,t.ch+2)},del:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("~~"+i+"~~"),""===i&&e.setCursor(t.line,t.ch+2)},italic:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("*"+i+"*"),""===i&&e.setCursor(t.line,t.ch+1)},quote:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("> "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("> "+i)},ucfirst:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.firstUpperCase(i)),e.setSelections(o)},ucwords:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.wordsFirstUpperCase(i)),e.setSelections(o)},uppercase:function(){var e=this.cm,t=e.getSelection(),i=e.listSelections();e.replaceSelection(t.toUpperCase()),e.setSelections(i)},lowercase:function(){var e=this.cm,t=(e.getCursor(),e.getSelection()),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("# "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("# "+i)},h2:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("## "+i),e.setCursor(t.line,t.ch+3)):e.replaceSelection("## "+i)},h3:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("### "+i),e.setCursor(t.line,t.ch+4)):e.replaceSelection("### "+i)},h4:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("#### "+i),e.setCursor(t.line,t.ch+5)):e.replaceSelection("#### "+i)},h5:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("##### "+i),e.setCursor(t.line,t.ch+6)):e.replaceSelection("##### "+i)},h6:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("###### "+i),e.setCursor(t.line,t.ch+7)):e.replaceSelection("###### "+i)},"list-ul":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;r>o;o++)i[o]=""===i[o]?"":"- "+i[o];e.replaceSelection(i.join("\n"))}},"list-ol":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("1. "+t);else{for(var i=t.split("\n"),o=0,r=i.length;r>o;o++)i[o]=""===i[o]?"":o+1+". "+i[o];e.replaceSelection(i.join("\n"))}},hr:function(){{var e=this.cm,t=e.getCursor();e.getSelection()}e.replaceSelection((0!==t.ch?"\n\n":"\n")+"------------\n\n")},tex:function(){if(!this.settings.tex)return alert("settings.tex === false"),this;var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("$$"+i+"$$"),""===i&&e.setCursor(t.line,t.ch+2)},link:function(){this.executePlugin("linkDialog","link-dialog/link-dialog")},"reference-link":function(){this.executePlugin("referenceLinkDialog","reference-link-dialog/reference-link-dialog")},pagebreak:function(){if(!this.settings.pageBreak)return alert("settings.pageBreak === false"),this;{var e=this.cm;e.getSelection()}e.replaceSelection("\r\n[========]\r\n")},image:function(){this.executePlugin("imageDialog","image-dialog/image-dialog")},code:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("`"+i+"`"),""===i&&e.setCursor(t.line,t.ch+1)},"code-block":function(){this.executePlugin("codeBlockDialog","code-block-dialog/code-block-dialog")},"preformatted-text":function(){this.executePlugin("preformattedTextDialog","preformatted-text-dialog/preformatted-text-dialog")},table:function(){this.executePlugin("tableDialog","table-dialog/table-dialog")},datetime:function(){var e=this.cm,i=(e.getSelection(),new Date,this.settings.lang.name),o=t.dateFormat()+" "+t.dateFormat("zh-cn"===i||"zh-tw"===i?"cn-week-day":"week-day");e.replaceSelection(o)},emoji:function(){this.executePlugin("emojiDialog","emoji-dialog/emoji-dialog")},"html-entities":function(){this.executePlugin("htmlEntitiesDialog","html-entities-dialog/html-entities-dialog")},"goto-line":function(){this.executePlugin("gotoLineDialog","goto-line-dialog/goto-line-dialog")},watch:function(){this[this.settings.watch?"unwatch":"watch"]()},preview:function(){this.previewing()},fullscreen:function(){this.fullscreen()},clear:function(){this.clear()},search:function(){this.search()},help:function(){this.executePlugin("helpDialog","help-dialog/help-dialog")},info:function(){this.showInfoDialog()}},t.keyMaps={"Ctrl-1":"h1","Ctrl-2":"h2","Ctrl-3":"h3","Ctrl-4":"h4","Ctrl-5":"h5","Ctrl-6":"h6","Ctrl-B":"bold","Ctrl-D":"datetime","Ctrl-E":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();return this.settings.emoji?(e.replaceSelection(":"+i+":"),void(""===i&&e.setCursor(t.line,t.ch+1))):void alert("Error: settings.emoji == false")},"Ctrl-Alt-G":"goto-line","Ctrl-H":"hr","Ctrl-I":"italic","Ctrl-K":"code","Ctrl-L":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+1)},"Ctrl-U":"list-ul","Shift-Ctrl-A":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();return this.settings.atLink?(e.replaceSelection("@"+i),void(""===i&&e.setCursor(t.line,t.ch+1))):void alert("Error: settings.atLink == false")},"Shift-Ctrl-C":"code","Shift-Ctrl-Q":"quote","Shift-Ctrl-S":"del","Shift-Ctrl-K":"tex","Shift-Alt-C":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection(["```",i,"```"].join("\n")),""===i&&e.setCursor(t.line,t.ch+3)},"Shift-Ctrl-Alt-C":"code-block","Shift-Ctrl-H":"html-entities","Shift-Alt-H":"help","Shift-Ctrl-E":"emoji","Shift-Ctrl-U":"uppercase","Shift-Alt-U":"ucwords","Shift-Ctrl-Alt-U":"ucfirst","Shift-Alt-L":"lowercase","Shift-Ctrl-I":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("!["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+4)},"Shift-Ctrl-Alt-I":"image","Shift-Ctrl-L":"link","Shift-Ctrl-O":"list-ol","Shift-Ctrl-P":"preformatted-text","Shift-Ctrl-T":"table","Shift-Alt-P":"pagebreak",F9:"watch",F10:"preview",F11:"fullscreen"};var r=function(e){return String.prototype.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};t.trim=r;var n=function(e){return e.toLowerCase().replace(/\b(\w)|\s(\w)/g,function(e){return e.toUpperCase()})};t.ucwords=t.wordsFirstUpperCase=n;var a=function(e){return e.toLowerCase().replace(/\b(\w)/,function(e){return e.toUpperCase()})};return t.firstUpperCase=t.ucfirst=a,t.urls={atLinkBase:"https://github.com/"},t.regexs={atLink:/@(\w+)/g,email:/(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,emailLink:/(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,emoji:/:([\w\+-]+):/g,emojiDatetime:/(\d{2}:\d{2}:\d{2})/g,twemoji:/:(tw-([\w]+)-?(\w+)?):/g,fontAwesome:/:(fa-([\w]+)(-(\w+)){0,}):/g,editormdLogo:/:(editormd-logo-?(\w+)?):/g,pageBreak:/^\[[=]{8,}\]$/},t.emoji={path:"http://www.emoji-cheat-sheet.com/graphics/emojis/",ext:".png"},t.twemoji={path:"http://twemoji.maxcdn.com/36x36/",ext:".png"},t.markedRenderer=function(i,o){var n={toc:!0,tocm:!1,tocStartLevel:1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1},a=e.extend(n,o||{}),s=t.$marked,l=new s.Renderer;i=i||[];var c=t.regexs,h=c.atLink,d=c.emoji,u=c.email,f=c.emailLink,g=c.twemoji,p=c.fontAwesome,m=c.editormdLogo,w=c.pageBreak;return l.emoji=function(e){e=e.replace(t.regexs.emojiDatetime,function(e){return e.replace(/:/g,":")});var i=e.match(d);if(!i||!a.emoji)return e;for(var o=0,r=i.length;r>o;o++)":+1:"===i[o]&&(i[o]=":\\+1:"),e=e.replace(new RegExp(i[o]),function(e,i){var o=e.match(p),r=e.replace(/:/g,"");if(o)for(var n=0,a=o.length;a>n;n++){var s=o[n].replace(/:/g,"");return''}else{var l=e.match(m),c=e.match(g);if(l)for(var h=0,d=l.length;d>h;h++){var u=l[h].replace(/:/g,"");return''}else{if(!c){var f="+1"===r?"plus1":r;return f="black_large_square"===f?"black_square":f,f="moon"===f?"waxing_gibbous_moon":f,':'+r+':'}for(var w=0,v=c.length;v>w;w++){var k=c[w].replace(/:/g,"").replace("tw-","");return'twemoji-'+k+''}}}});return e},l.atLink=function(i){return h.test(i)?(a.atLink&&(i=i.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(h,function(e,i){return''+e+""}).replace(/_#_@_#_/g,"@")),a.emailLink&&(i=i.replace(f,function(t,i,o,r,n){return!i&&e.inArray(n,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?''+t+"":t})),i):i},l.link=function(e,t,i){if(this.options.sanitize){try{var o=decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(r){return""}if(0===o.indexOf("javascript:"))return""}var n=''+i.replace(/@/g,"@")+""):(t&&(n+=' title="'+t+'"'),n+=">"+i+"")},l.heading=function(e,t,o){var n=e,a=/\s*\]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var s=[];e=e.split(/\]+)\>([^\>]*)\<\/a\>/);for(var l=0,c=e.length;c>l;l++)s.push(e[l].replace(/\s*href\=\"(.*)\"\s*/g,""));e=s.join(" ")}e=r(e);var h=e.toLowerCase().replace(/[^\w]+/g,"-"),d={text:e,level:t,slug:h},u=/^[\u4e00-\u9fa5]+$/.test(e),f=u?escape(e).replace(/\%/g,""):e.toLowerCase().replace(/[^\w]+/g,"-");i.push(d);var g="';return g+='',g+='',g+=this.atLink(a?this.emoji(n):this.emoji(e)),g+=""},l.pageBreak=function(e){return w.test(e)&&a.pageBreak&&(e='
          '),e},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",n=a.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return''+i.replace(/\$/g,"")+""}):o?e.replace(/\$/g,""):e;var l='
          '+e+"
          ";return n?s?'
          '+l+"

          ":l:w.test(e)?this.pageBreak(e):""+this.atLink(this.emoji(e))+"

          \n"},l.code=function(e,i,o){return"seq"===i||"sequence"===i?'
          '+e+"
          ":"flow"===i?'
          '+e+"
          ":"math"===i||"latex"===i||"katex"===i?'

          '+e+"

          ":s.Renderer.prototype.code.apply(this,arguments)},l.tablecell=function(e,t){var i=t.header?"th":"td",o=t.align?"<"+i+' style="text-align:'+t.align+'">':"<"+i+">";return o+this.atLink(this.emoji(e))+"\n"},l.listitem=function(e){return a.taskList&&/^\s*\[[x\s]\]\s*/.test(e)?(e=e.replace(/^\s*\[\s\]\s*/,' ').replace(/^\s*\[x\]\s*/,' '),'
        • '+this.atLink(this.emoji(e))+"
        • "):"
        • "+this.atLink(this.emoji(e))+"
        • "},l},t.markdownToCRenderer=function(e,t,i,o){var r="",n=0,a=this.classPrefix;o=o||1;for(var s=0,l=e.length;l>s;s++){var c=e[s].text,h=e[s].level;o>h||(r+=h>n?"":n>h?new Array(n-h+2).join("
      • "):"",r+='
      • '+c+"
          ",n=h)}var d=t.find(".markdown-toc");if(d.length<1&&"false"===t.attr("previewContainer")){var u='
          ';u=i?'
          '+u+"
          ":u,t.html(u),d=t.find(".markdown-toc")}return i&&d.wrap('

          '),d.html('
            ').children(".markdown-toc-list").html(r.replace(/\r?\n?\\<\/ul\>/g,"")),d},t.tocDropdownMenu=function(t,i){i=i||"Table of Contents";var o=400,r=t.find("."+this.classPrefix+"toc-menu");return r.each(function(){var t=e(this),r=t.children(".markdown-toc"),n='',a=''+n+i+"",s=r.children("ul"),l=s.find("li");r.append(a),l.first().before("
          • "+i+" "+n+"

          • "),t.mouseover(function(){s.show(),l.each(function(){var t=e(this),i=t.children("ul");if(""===i.html()&&i.remove(),i.length>0&&""!==i.html()){var r=t.children("a").first();r.children(".fa").length<1&&r.append(e(n).css({"float":"right",paddingTop:"4px"}))}t.mouseover(function(){i.css("z-index",o).show(),o+=1}).mouseleave(function(){i.hide()})})}).mouseleave(function(){s.hide()})}),r},t.filterHTMLTags=function(t,i){if("string"!=typeof t&&(t=new String(t)),"string"!=typeof i)return t;for(var o=i.split("|"),r=o[0].split(","),n=o[1],a=0,s=r.length;s>a;a++){var l=r[a];t=t.replace(new RegExp("]*)>([^>]*)","igm"),"")}if("undefined"!=typeof n){var c=/\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/gi;t="*"===n?t.replace(c,function(e,t,i,o,r){return"<"+t+">"+o+""}):"on*"===n?t.replace(c,function(t,i,o,r,n){var a=e("<"+i+">"+r+""),s=e(t)[0].attributes,l={};e.each(s,function(e,t){'"'!==t.nodeName&&(l[t.nodeName]=t.nodeValue)}),e.each(l,function(e){0===e.indexOf("on")&&delete l[e]}),a.attr(l);var c="undefined"!=typeof a[1]?e(a[1]).text():"";return a[0].outerHTML+c}):t.replace(c,function(t,i,o,r){var a=n.split(","),s=e(t);return s.html(r),e.each(a,function(e){s.attr(a[e],null)}),s[0].outerHTML})}return t},t.markdownToHTML=function(i,o){var r={gfm:!0,toc:!0,tocm:!1,tocStartLevel:1,tocTitle:"目录",tocDropdown:!1,tocContainer:"",markdown:"",markdownSourceCode:!1,htmlDecode:!1,autoLoadKaTeX:!0,pageBreak:!0,atLink:!0,emailLink:!0,tex:!1,taskList:!1,emoji:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0};t.$marked=marked;var n=e("#"+i),a=n.settings=e.extend(!0,r,o||{}),s=n.find("textarea");s.length<1&&(n.append(""),s=n.find("textarea"));var l=""===a.markdown?s.val():a.markdown,c=[],h={toc:a.toc,tocm:a.tocm,tocStartLevel:a.tocStartLevel,taskList:a.taskList,emoji:a.emoji,tex:a.tex,pageBreak:a.pageBreak,atLink:a.atLink,emailLink:a.emailLink,flowChart:a.flowChart,sequenceDiagram:a.sequenceDiagram,previewCodeHighlight:a.previewCodeHighlight},d={renderer:t.markedRenderer(c,h),gfm:a.gfm,tables:!0,breaks:!0,pedantic:!1,sanitize:a.htmlDecode?!1:!0,smartLists:!0,smartypants:!0};l=new String(l);var u=marked(l,d);u=t.filterHTMLTags(u,a.htmlDecode),a.markdownSourceCode?s.text(l):s.remove(),n.addClass("markdown-body "+this.classPrefix+"html-preview").append(u);var f=""!==a.tocContainer?e(a.tocContainer):n;if(""!==a.tocContainer&&f.attr("previewContainer",!1),a.toc&&(n.tocContainer=this.markdownToCRenderer(c,f,a.tocDropdown,a.tocStartLevel),(a.tocDropdown||n.find("."+this.classPrefix+"toc-menu").length>0)&&this.tocDropdownMenu(n,a.tocTitle),""!==a.tocContainer&&n.find(".editormd-toc-menu, .editormd-markdown-toc").remove()),a.previewCodeHighlight&&(n.find("pre").addClass("prettyprint linenums"),prettyPrint()),t.isIE8||(a.flowChart&&n.find(".flowchart").flowChart(),a.sequenceDiagram&&n.find(".sequence-diagram").sequenceDiagram({theme:"simple"})),a.tex){var g=function(){n.find("."+t.classNames.tex).each(function(){var t=e(this);katex.render(t.html().replace(/</g,"<").replace(/>/g,">"),t[0]),t.find(".katex").css("font-size","1.6em")})};!a.autoLoadKaTeX||t.$katex||t.kaTeXLoaded?g():this.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,g()})}return n.getMarkdown=function(){return s.val()},n},t.themes=["default","dark"],t.previewThemes=["default","dark"],t.editorThemes=["default","3024-day","3024-night","ambiance","ambiance-mobile","base16-dark","base16-light","blackboard","cobalt","eclipse","elegant","erlang-dark","lesser-dark","mbo","mdn-like","midnight","monokai","neat","neo","night","paraiso-dark","paraiso-light","pastel-on-dark","rubyblue","solarized","the-matrix","tomorrow-night-eighties","twilight","vibrant-ink","xq-dark","xq-light"],t.loadPlugins={},t.loadFiles={js:[],css:[],plugin:[]},t.loadPlugin=function(e,i,o){i=i||function(){},this.loadScript(e,function(){t.loadFiles.plugin.push(e),i()},o)},t.loadCSS=function(e,i,o){o=o||"head",i=i||function(){};var r=document.createElement("link");r.type="text/css",r.rel="stylesheet",r.onload=r.onreadystatechange=function(){t.loadFiles.css.push(e),i()},r.href=e+".css","head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.isIE="Microsoft Internet Explorer"==navigator.appName,t.isIE8=t.isIE&&"8."==navigator.appVersion.match(/8./i),t.loadScript=function(e,i,o){o=o||"head",i=i||function(){};var r=null;r=document.createElement("script"),r.id=e.replace(/[\./]+/g,"-"),r.type="text/javascript",r.src=e+".js",t.isIE8?r.onreadystatechange=function(){r.readyState&&("loaded"===r.readyState||"complete"===r.readyState)&&(r.onreadystatechange=null,t.loadFiles.js.push(e),i())}:r.onload=function(){t.loadFiles.js.push(e),i()},"head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.katexURL={css:"//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min",js:"//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min"},t.kaTeXLoaded=!1,t.loadKaTeX=function(e){t.loadCSS(t.katexURL.css,function(){t.loadScript(t.katexURL.js,e||function(){})})},t.lockScreen=function(t){e("html,body").css("overflow",t?"hidden":"")},t.createDialog=function(i){var o={name:"",width:420,height:240,title:"",drag:!0,closed:!0,content:"",mask:!0,maskStyle:{backgroundColor:"#fff",opacity:.1},lockScreen:!0,footer:!0,buttons:!1};i=e.extend(!0,o,i);var r=this,n=this.editor,a=t.classPrefix,s=(new Date).getTime(),l=""===i.name?a+"dialog-"+s:i.name,c=t.mouseOrTouch,h='
            ';""!==i.title&&(h+='
            ",h+=''+i.title+"",h+="
            "),i.closed&&(h+=''),h+='
            '+i.content,(i.footer||"string"==typeof i.footer)&&(h+='"),h+="
            ",h+='
            ',h+='
            ',h+="
            ",n.append(h);var d=n.find("."+l);d.lockScreen=function(t){return i.lockScreen&&(e("html,body").css("overflow",t?"hidden":""),r.resize()),d},d.showMask=function(){return i.mask&&n.find("."+a+"mask").css(i.maskStyle).css("z-index",t.dialogZindex-1).show(),d},d.hideMask=function(){return i.mask&&n.find("."+a+"mask").hide(),d},d.loading=function(e){var t=d.find("."+a+"dialog-mask");return t[e?"show":"hide"](),d},d.lockScreen(!0).showMask(),d.show().css({zIndex:t.dialogZindex,border:t.isIE8?"1px solid #ddd":"",width:"number"==typeof i.width?i.width+"px":i.width,height:"number"==typeof i.height?i.height+"px":i.height});var u=function(){d.css({top:(e(window).height()-d.height())/2+"px",left:(e(window).width()-d.width())/2+"px"})};if(u(),e(window).resize(u),d.children("."+a+"dialog-close").bind(c("click","touchend"),function(){d.hide().lockScreen(!1).hideMask()}),"object"==typeof i.buttons){var f=d.footer=d.find("."+a+"dialog-footer");for(var g in i.buttons){var p=i.buttons[g],m=a+g+"-btn";f.append('"),p[1]=e.proxy(p[1],d),f.children("."+m).bind(c("click","touchend"),p[1])}}if(""!==i.title&&i.drag){var w,v,k=d.children("."+a+"dialog-header");i.mask||k.bind(c("click","touchend"),function(){t.dialogZindex+=2,d.css("z-index",t.dialogZindex)}),k.mousedown(function(e){e=e||window.event,w=e.clientX-parseInt(d[0].style.left),v=e.clientY-parseInt(d[0].style.top),document.onmousemove=y});var b=function(e){e.removeClass(a+"user-unselect").off("selectstart")},x=function(e){e.addClass(a+"user-unselect").on("selectstart",function(e){return!1})},y=function(t){t=t||window.event;var i,o,r=parseInt(d[0].style.left),n=parseInt(d[0].style.top);r>=0?r+d.width()<=e(window).width()?i=t.clientX-w:(i=e(window).width()-d.width(),document.onmousemove=null):(i=0,document.onmousemove=null),n>=0?o=t.clientY-v:(o=0,document.onmousemove=null),document.onselectstart=function(){return!1},x(e("body")),x(d),d[0].style.left=i+"px",d[0].style.top=o+"px"};document.onmouseup=function(){b(e("body")),b(d),document.onselectstart=null,document.onmousemove=null},k.touchDraggable=function(){var t=null,i=function(i){var o=i.originalEvent,r=e(this).parent().position();t={x:o.changedTouches[0].pageX-r.left,y:o.changedTouches[0].pageY-r.top}},o=function(i){i.preventDefault();var o=i.originalEvent;e(this).parent().css({top:o.changedTouches[0].pageY-t.y,left:o.changedTouches[0].pageX-t.x})};this.bind("touchstart",i).bind("touchmove",o)},k.touchDraggable()}return t.dialogZindex+=2,d},t.mouseOrTouch=function(e,t){e=e||"click",t=t||"touchend";var i=e;try{document.createEvent("TouchEvent"),i=t}catch(o){}return i},t.dateFormat=function(e){e=e||"";var t=function(e){return 10>e?"0"+e:e},i=new Date,o=i.getFullYear(),r=o.toString().slice(2,4),n=t(i.getMonth()+1),a=t(i.getDate()),s=i.getDay(),l=t(i.getHours()),c=t(i.getMinutes()),h=t(i.getSeconds()),d=t(i.getMilliseconds()),u="",f=r+"-"+n+"-"+a,g=o+"-"+n+"-"+a,p=l+":"+c+":"+h;switch(e){case"UNIX Time":u=i.getTime();break;case"UTC":u=i.toUTCString();break;case"yy":u=r;break;case"year":case"yyyy":u=o;break;case"month":case"mm":u=n;break;case"cn-week-day":case"cn-wd":var m=["日","一","二","三","四","五","六"];u="星期"+m[s];break;case"week-day":case"wd":var w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];u=w[s];break;case"day":case"dd":u=a;break;case"hour":case"hh":u=l;break;case"min":case"ii":u=c;break;case"second":case"ss":u=h;break;case"ms":u=d;break;case"yy-mm-dd":u=f;break;case"yyyy-mm-dd":u=g;break;case"yyyy-mm-dd h:i:s ms":case"full + ms":u=g+" "+p+" "+d;break;case"full":case"yyyy-mm-dd h:i:s":default:u=g+" "+p}return u},t}}); \ No newline at end of file diff --git a/src/main/webapp/static/global/plugins/editor.md-master/editormd.js b/src/main/webapp/static/global/plugins/editor.md-master/editormd.js new file mode 100644 index 000000000..b901a8bb3 --- /dev/null +++ b/src/main/webapp/static/global/plugins/editor.md-master/editormd.js @@ -0,0 +1,4598 @@ +/* + * Editor.md + * + * @file editormd.js + * @version v1.5.0 + * @description Open source online markdown editor. + * @license MIT License + * @author Pandao + * {@link https://github.com/pandao/editor.md} + * @updateTime 2015-06-09 + */ + +;(function(factory) { + "use strict"; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) // for Require.js + { + /* Require.js define replace */ + } + else + { + define(["jquery"], factory); // for Sea.js + } + } + else + { + window.editormd = factory(); + } + +}(function() { + + /* Require.js assignment replace */ + + "use strict"; + + var $ = (typeof (jQuery) !== "undefined") ? jQuery : Zepto; + + if (typeof ($) === "undefined") { + return ; + } + + /** + * editormd + * + * @param {String} id 编辑器的ID + * @param {Object} options 配置选项 Key/Value + * @returns {Object} editormd 返回editormd对象 + */ + + var editormd = function (id, options) { + return new editormd.fn.init(id, options); + }; + + editormd.title = editormd.$name = "Editor.md"; + editormd.version = "1.5.0"; + editormd.homePage = "https://pandao.github.io/editor.md/"; + editormd.classPrefix = "editormd-"; + + editormd.toolbarModes = { + full : [ + "undo", "redo", "|", + "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|", + "h1", "h2", "h3", "h4", "h5", "h6", "|", + "list-ul", "list-ol", "hr", "|", + "link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime", "emoji", "html-entities", "pagebreak", "|", + "goto-line", "watch", "preview", "fullscreen", "clear", "search", "|", + "help", "info" + ], + simple : [ + "undo", "redo", "|", + "bold", "del", "italic", "quote", "uppercase", "lowercase", "|", + "h1", "h2", "h3", "h4", "h5", "h6", "|", + "list-ul", "list-ol", "hr", "|", + "watch", "preview", "fullscreen", "|", + "help", "info" + ], + mini : [ + "undo", "redo", "|", + "watch", "preview", "|", + "help", "info" + ] + }; + + editormd.defaults = { + mode : "gfm", //gfm or markdown + name : "", // Form element name + value : "", // value for CodeMirror, if mode not gfm/markdown + theme : "", // Editor.md self themes, before v1.5.0 is CodeMirror theme, default empty + editorTheme : "default", // Editor area, this is CodeMirror theme at v1.5.0 + previewTheme : "", // Preview area theme, default empty + markdown : "", // Markdown source code + appendMarkdown : "", // if in init textarea value not empty, append markdown to textarea + width : "100%", + height : "100%", + path : "./lib/", // Dependents module file directory + pluginPath : "", // If this empty, default use settings.path + "../plugins/" + delay : 300, // Delay parse markdown to html, Uint : ms + autoLoadModules : true, // Automatic load dependent module files + watch : true, + placeholder : "Enjoy Markdown! coding now...", + gotoLine : true, + codeFold : false, + autoHeight : false, + autoFocus : true, + autoCloseTags : true, + searchReplace : true, + syncScrolling : true, // true | false | "single", default true + readOnly : false, + tabSize : 4, + indentUnit : 4, + lineNumbers : true, + lineWrapping : true, + autoCloseBrackets : true, + showTrailingSpace : true, + matchBrackets : true, + indentWithTabs : true, + styleSelectedText : true, + matchWordHighlight : true, // options: true, false, "onselected" + styleActiveLine : true, // Highlight the current line + dialogLockScreen : true, + dialogShowMask : true, + dialogDraggable : true, + dialogMaskBgColor : "#fff", + dialogMaskOpacity : 0.1, + fontSize : "13px", + saveHTMLToTextarea : false, + disabledKeyMaps : [], + + onload : function() {}, + onresize : function() {}, + onchange : function() {}, + onwatch : null, + onunwatch : null, + onpreviewing : function() {}, + onpreviewed : function() {}, + onfullscreen : function() {}, + onfullscreenExit : function() {}, + onscroll : function() {}, + onpreviewscroll : function() {}, + + imageUpload : false, + imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"], + imageUploadURL : "", + crossDomainUpload : false, + uploadCallbackURL : "", + + toc : true, // Table of contents + tocm : false, // Using [TOCM], auto create ToC dropdown menu + tocTitle : "", // for ToC dropdown menu btn + tocDropdown : false, + tocContainer : "", + tocStartLevel : 1, // Said from H1 to create ToC + htmlDecode : false, // Open the HTML tag identification + pageBreak : true, // Enable parse page break [========] + atLink : true, // for @link + emailLink : true, // for email address auto link + taskList : false, // Enable Github Flavored Markdown task lists + emoji : false, // :emoji: , Support Github emoji, Twitter Emoji (Twemoji); + // Support FontAwesome icon emoji :fa-xxx: > Using fontAwesome icon web fonts; + // Support Editor.md logo icon emoji :editormd-logo: :editormd-logo-1x: > 1~8x; + tex : false, // TeX(LaTeX), based on KaTeX + flowChart : false, // flowChart.js only support IE9+ + sequenceDiagram : false, // sequenceDiagram.js only support IE9+ + previewCodeHighlight : true, + + toolbar : true, // show/hide toolbar + toolbarAutoFixed : true, // on window scroll auto fixed position + toolbarIcons : "full", + toolbarTitles : {}, + toolbarHandlers : { + ucwords : function() { + return editormd.toolbarHandlers.ucwords; + }, + lowercase : function() { + return editormd.toolbarHandlers.lowercase; + } + }, + toolbarCustomIcons : { // using html tag create toolbar icon, unused default tag. + lowercase : "a", + "ucwords" : "Aa" + }, + toolbarIconsClass : { + undo : "fa-undo", + redo : "fa-repeat", + bold : "fa-bold", + del : "fa-strikethrough", + italic : "fa-italic", + quote : "fa-quote-left", + uppercase : "fa-font", + h1 : editormd.classPrefix + "bold", + h2 : editormd.classPrefix + "bold", + h3 : editormd.classPrefix + "bold", + h4 : editormd.classPrefix + "bold", + h5 : editormd.classPrefix + "bold", + h6 : editormd.classPrefix + "bold", + "list-ul" : "fa-list-ul", + "list-ol" : "fa-list-ol", + hr : "fa-minus", + link : "fa-link", + "reference-link" : "fa-anchor", + image : "fa-picture-o", + code : "fa-code", + "preformatted-text" : "fa-file-code-o", + "code-block" : "fa-file-code-o", + table : "fa-table", + datetime : "fa-clock-o", + emoji : "fa-smile-o", + "html-entities" : "fa-copyright", + pagebreak : "fa-newspaper-o", + "goto-line" : "fa-terminal", // fa-crosshairs + watch : "fa-eye-slash", + unwatch : "fa-eye", + preview : "fa-desktop", + search : "fa-search", + fullscreen : "fa-arrows-alt", + clear : "fa-eraser", + help : "fa-question-circle", + info : "fa-info-circle" + }, + toolbarIconTexts : {}, + + lang : { + name : "zh-cn", + description : "开源在线Markdown编辑器
            Open source online Markdown editor.", + tocTitle : "目录", + toolbar : { + undo : "撤销(Ctrl+Z)", + redo : "重做(Ctrl+Y)", + bold : "粗体", + del : "删除线", + italic : "斜体", + quote : "引用", + ucwords : "将每个单词首字母转成大写", + uppercase : "将所选转换成大写", + lowercase : "将所选转换成小写", + h1 : "标题1", + h2 : "标题2", + h3 : "标题3", + h4 : "标题4", + h5 : "标题5", + h6 : "标题6", + "list-ul" : "无序列表", + "list-ol" : "有序列表", + hr : "横线", + link : "链接", + "reference-link" : "引用链接", + image : "添加图片", + code : "行内代码", + "preformatted-text" : "预格式文本 / 代码块(缩进风格)", + "code-block" : "代码块(多语言风格)", + table : "添加表格", + datetime : "日期时间", + emoji : "Emoji表情", + "html-entities" : "HTML实体字符", + pagebreak : "插入分页符", + "goto-line" : "跳转到行", + watch : "关闭实时预览", + unwatch : "开启实时预览", + preview : "全窗口预览HTML(按 Shift + ESC还原)", + fullscreen : "全屏(按ESC还原)", + clear : "清空", + search : "搜索", + help : "使用帮助", + info : "关于" + editormd.title + }, + buttons : { + enter : "确定", + cancel : "取消", + close : "关闭" + }, + dialog : { + link : { + title : "添加链接", + url : "链接地址", + urlTitle : "链接标题", + urlEmpty : "错误:请填写链接地址。" + }, + referenceLink : { + title : "添加引用链接", + name : "引用名称", + url : "链接地址", + urlId : "链接ID", + urlTitle : "链接标题", + nameEmpty: "错误:引用链接的名称不能为空。", + idEmpty : "错误:请填写引用链接的ID。", + urlEmpty : "错误:请填写引用链接的URL地址。" + }, + image : { + title : "添加图片", + url : "图片地址", + link : "图片链接", + alt : "图片描述", + uploadButton : "本地上传", + imageURLEmpty : "错误:图片地址不能为空。", + uploadFileEmpty : "错误:上传的图片不能为空。", + formatNotAllowed : "错误:只允许上传图片文件,允许上传的图片文件格式有:" + }, + preformattedText : { + title : "添加预格式文本或代码块", + emptyAlert : "错误:请填写预格式文本或代码的内容。" + }, + codeBlock : { + title : "添加代码块", + selectLabel : "代码语言:", + selectDefaultText : "请选择代码语言", + otherLanguage : "其他语言", + unselectedLanguageAlert : "错误:请选择代码所属的语言类型。", + codeEmptyAlert : "错误:请填写代码内容。" + }, + htmlEntities : { + title : "HTML 实体字符" + }, + help : { + title : "使用帮助" + } + } + } + }; + + editormd.classNames = { + tex : editormd.classPrefix + "tex" + }; + + editormd.dialogZindex = 99999; + + editormd.$katex = null; + editormd.$marked = null; + editormd.$CodeMirror = null; + editormd.$prettyPrint = null; + + var timer, flowchartTimer; + + editormd.prototype = editormd.fn = { + state : { + watching : false, + loaded : false, + preview : false, + fullscreen : false + }, + + /** + * 构造函数/实例初始化 + * Constructor / instance initialization + * + * @param {String} id 编辑器的ID + * @param {Object} [options={}] 配置选项 Key/Value + * @returns {editormd} 返回editormd的实例对象 + */ + + init : function (id, options) { + + options = options || {}; + + if (typeof id === "object") + { + options = id; + } + + var _this = this; + var classPrefix = this.classPrefix = editormd.classPrefix; + var settings = this.settings = $.extend(true, editormd.defaults, options); + + id = (typeof id === "object") ? settings.id : id; + + var editor = this.editor = $("#" + id); + + this.id = id; + this.lang = settings.lang; + + var classNames = this.classNames = { + textarea : { + html : classPrefix + "html-textarea", + markdown : classPrefix + "markdown-textarea" + } + }; + + settings.pluginPath = (settings.pluginPath === "") ? settings.path + "../plugins/" : settings.pluginPath; + + this.state.watching = (settings.watch) ? true : false; + + if ( !editor.hasClass("editormd") ) { + editor.addClass("editormd"); + } + + editor.css({ + width : (typeof settings.width === "number") ? settings.width + "px" : settings.width, + height : (typeof settings.height === "number") ? settings.height + "px" : settings.height + }); + + if (settings.autoHeight) + { + editor.css("height", "auto"); + } + + var markdownTextarea = this.markdownTextarea = editor.children("textarea"); + + if (markdownTextarea.length < 1) + { + editor.append(""); + markdownTextarea = this.markdownTextarea = editor.children("textarea"); + } + + markdownTextarea.addClass(classNames.textarea.markdown).attr("placeholder", settings.placeholder); + + if (typeof markdownTextarea.attr("name") === "undefined" || markdownTextarea.attr("name") === "") + { + markdownTextarea.attr("name", (settings.name !== "") ? settings.name : id + "-markdown-doc"); + } + + var appendElements = [ + (!settings.readOnly) ? "" : "", + ( (settings.saveHTMLToTextarea) ? "" : "" ), + "
            ", + "
            ", + "
            " + ].join("\n"); + + editor.append(appendElements).addClass(classPrefix + "vertical"); + + if (settings.theme !== "") + { + editor.addClass(classPrefix + "theme-" + settings.theme); + } + + this.mask = editor.children("." + classPrefix + "mask"); + this.containerMask = editor.children("." + classPrefix + "container-mask"); + + if (settings.markdown !== "") + { + markdownTextarea.val(settings.markdown); + } + + if (settings.appendMarkdown !== "") + { + markdownTextarea.val(markdownTextarea.val() + settings.appendMarkdown); + } + + this.htmlTextarea = editor.children("." + classNames.textarea.html); + this.preview = editor.children("." + classPrefix + "preview"); + this.previewContainer = this.preview.children("." + classPrefix + "preview-container"); + + if (settings.previewTheme !== "") + { + this.preview.addClass(classPrefix + "preview-theme-" + settings.previewTheme); + } + + if (typeof define === "function" && define.amd) + { + if (typeof katex !== "undefined") + { + editormd.$katex = katex; + } + + if (settings.searchReplace && !settings.readOnly) + { + editormd.loadCSS(settings.path + "codemirror/addon/dialog/dialog"); + editormd.loadCSS(settings.path + "codemirror/addon/search/matchesonscrollbar"); + } + } + + if ((typeof define === "function" && define.amd) || !settings.autoLoadModules) + { + if (typeof CodeMirror !== "undefined") { + editormd.$CodeMirror = CodeMirror; + } + + if (typeof marked !== "undefined") { + editormd.$marked = marked; + } + + this.setCodeMirror().setToolbar().loadedDisplay(); + } + else + { + this.loadQueues(); + } + + return this; + }, + + /** + * 所需组件加载队列 + * Required components loading queue + * + * @returns {editormd} 返回editormd的实例对象 + */ + + loadQueues : function() { + var _this = this; + var settings = this.settings; + var loadPath = settings.path; + + var loadFlowChartOrSequenceDiagram = function() { + + if (editormd.isIE8) + { + _this.loadedDisplay(); + + return ; + } + + if (settings.flowChart || settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "raphael.min", function() { + + editormd.loadScript(loadPath + "underscore.min", function() { + + if (!settings.flowChart && settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "sequence-diagram.min", function() { + _this.loadedDisplay(); + }); + } + else if (settings.flowChart && !settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "flowchart.min", function() { + editormd.loadScript(loadPath + "jquery.flowchart.min", function() { + _this.loadedDisplay(); + }); + }); + } + else if (settings.flowChart && settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "flowchart.min", function() { + editormd.loadScript(loadPath + "jquery.flowchart.min", function() { + editormd.loadScript(loadPath + "sequence-diagram.min", function() { + _this.loadedDisplay(); + }); + }); + }); + } + }); + + }); + } + else + { + _this.loadedDisplay(); + } + }; + + editormd.loadCSS(loadPath + "codemirror/codemirror.min"); + + if (settings.searchReplace && !settings.readOnly) + { + editormd.loadCSS(loadPath + "codemirror/addon/dialog/dialog"); + editormd.loadCSS(loadPath + "codemirror/addon/search/matchesonscrollbar"); + } + + if (settings.codeFold) + { + editormd.loadCSS(loadPath + "codemirror/addon/fold/foldgutter"); + } + + editormd.loadScript(loadPath + "codemirror/codemirror.min", function() { + editormd.$CodeMirror = CodeMirror; + + editormd.loadScript(loadPath + "codemirror/modes.min", function() { + + editormd.loadScript(loadPath + "codemirror/addons.min", function() { + + _this.setCodeMirror(); + + if (settings.mode !== "gfm" && settings.mode !== "markdown") + { + _this.loadedDisplay(); + + return false; + } + + _this.setToolbar(); + + editormd.loadScript(loadPath + "marked.min", function() { + + editormd.$marked = marked; + + if (settings.previewCodeHighlight) + { + editormd.loadScript(loadPath + "prettify.min", function() { + loadFlowChartOrSequenceDiagram(); + }); + } + else + { + loadFlowChartOrSequenceDiagram(); + } + }); + + }); + + }); + + }); + + return this; + }, + + /** + * 设置 Editor.md 的整体主题,主要是工具栏 + * Setting Editor.md theme + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setTheme : function(theme) { + var editor = this.editor; + var oldTheme = this.settings.theme; + var themePrefix = this.classPrefix + "theme-"; + + editor.removeClass(themePrefix + oldTheme).addClass(themePrefix + theme); + + this.settings.theme = theme; + + return this; + }, + + /** + * 设置 CodeMirror(编辑区)的主题 + * Setting CodeMirror (Editor area) theme + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setEditorTheme : function(theme) { + var settings = this.settings; + settings.editorTheme = theme; + + if (theme !== "default") + { + editormd.loadCSS(settings.path + "codemirror/theme/" + settings.editorTheme); + } + + this.cm.setOption("theme", theme); + + return this; + }, + + /** + * setEditorTheme() 的别名 + * setEditorTheme() alias + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setCodeMirrorTheme : function (theme) { + this.setEditorTheme(theme); + + return this; + }, + + /** + * 设置 Editor.md 的主题 + * Setting Editor.md theme + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setPreviewTheme : function(theme) { + var preview = this.preview; + var oldTheme = this.settings.previewTheme; + var themePrefix = this.classPrefix + "preview-theme-"; + + preview.removeClass(themePrefix + oldTheme).addClass(themePrefix + theme); + + this.settings.previewTheme = theme; + + return this; + }, + + /** + * 配置和初始化CodeMirror组件 + * CodeMirror initialization + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setCodeMirror : function() { + var settings = this.settings; + var editor = this.editor; + + if (settings.editorTheme !== "default") + { + editormd.loadCSS(settings.path + "codemirror/theme/" + settings.editorTheme); + } + + var codeMirrorConfig = { + mode : settings.mode, + theme : settings.editorTheme, + tabSize : settings.tabSize, + dragDrop : false, + autofocus : settings.autoFocus, + autoCloseTags : settings.autoCloseTags, + readOnly : (settings.readOnly) ? "nocursor" : false, + indentUnit : settings.indentUnit, + lineNumbers : settings.lineNumbers, + lineWrapping : settings.lineWrapping, + extraKeys : { + "Ctrl-Q": function(cm) { + cm.foldCode(cm.getCursor()); + } + }, + foldGutter : settings.codeFold, + gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], + matchBrackets : settings.matchBrackets, + indentWithTabs : settings.indentWithTabs, + styleActiveLine : settings.styleActiveLine, + styleSelectedText : settings.styleSelectedText, + autoCloseBrackets : settings.autoCloseBrackets, + showTrailingSpace : settings.showTrailingSpace, + highlightSelectionMatches : ( (!settings.matchWordHighlight) ? false : { showToken: (settings.matchWordHighlight === "onselected") ? false : /\w/ } ) + }; + + this.codeEditor = this.cm = editormd.$CodeMirror.fromTextArea(this.markdownTextarea[0], codeMirrorConfig); + this.codeMirror = this.cmElement = editor.children(".CodeMirror"); + + if (settings.value !== "") + { + this.cm.setValue(settings.value); + } + + this.codeMirror.css({ + fontSize : settings.fontSize, + width : (!settings.watch) ? "100%" : "50%" + }); + + if (settings.autoHeight) + { + this.codeMirror.css("height", "auto"); + this.cm.setOption("viewportMargin", Infinity); + } + + if (!settings.lineNumbers) + { + this.codeMirror.find(".CodeMirror-gutters").css("border-right", "none"); + } + + return this; + }, + + /** + * 获取CodeMirror的配置选项 + * Get CodeMirror setting options + * + * @returns {Mixed} return CodeMirror setting option value + */ + + getCodeMirrorOption : function(key) { + return this.cm.getOption(key); + }, + + /** + * 配置和重配置CodeMirror的选项 + * CodeMirror setting options / resettings + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setCodeMirrorOption : function(key, value) { + + this.cm.setOption(key, value); + + return this; + }, + + /** + * 添加 CodeMirror 键盘快捷键 + * Add CodeMirror keyboard shortcuts key map + * + * @returns {editormd} 返回editormd的实例对象 + */ + + addKeyMap : function(map, bottom) { + this.cm.addKeyMap(map, bottom); + + return this; + }, + + /** + * 移除 CodeMirror 键盘快捷键 + * Remove CodeMirror keyboard shortcuts key map + * + * @returns {editormd} 返回editormd的实例对象 + */ + + removeKeyMap : function(map) { + this.cm.removeKeyMap(map); + + return this; + }, + + /** + * 跳转到指定的行 + * Goto CodeMirror line + * + * @param {String|Intiger} line line number or "first"|"last" + * @returns {editormd} 返回editormd的实例对象 + */ + + gotoLine : function (line) { + + var settings = this.settings; + + if (!settings.gotoLine) + { + return this; + } + + var cm = this.cm; + var editor = this.editor; + var count = cm.lineCount(); + var preview = this.preview; + + if (typeof line === "string") + { + if(line === "last") + { + line = count; + } + + if (line === "first") + { + line = 1; + } + } + + if (typeof line !== "number") + { + alert("Error: The line number must be an integer."); + return this; + } + + line = parseInt(line) - 1; + + if (line > count) + { + alert("Error: The line number range 1-" + count); + + return this; + } + + cm.setCursor( {line : line, ch : 0} ); + + var scrollInfo = cm.getScrollInfo(); + var clientHeight = scrollInfo.clientHeight; + var coords = cm.charCoords({line : line, ch : 0}, "local"); + + cm.scrollTo(null, (coords.top + coords.bottom - clientHeight) / 2); + + if (settings.watch) + { + var cmScroll = this.codeMirror.find(".CodeMirror-scroll")[0]; + var height = $(cmScroll).height(); + var scrollTop = cmScroll.scrollTop; + var percent = (scrollTop / cmScroll.scrollHeight); + + if (scrollTop === 0) + { + preview.scrollTop(0); + } + else if (scrollTop + height >= cmScroll.scrollHeight - 16) + { + preview.scrollTop(preview[0].scrollHeight); + } + else + { + preview.scrollTop(preview[0].scrollHeight * percent); + } + } + + cm.focus(); + + return this; + }, + + /** + * 扩展当前实例对象,可同时设置多个或者只设置一个 + * Extend editormd instance object, can mutil setting. + * + * @returns {editormd} this(editormd instance object.) + */ + + extend : function() { + if (typeof arguments[1] !== "undefined") + { + if (typeof arguments[1] === "function") + { + arguments[1] = $.proxy(arguments[1], this); + } + + this[arguments[0]] = arguments[1]; + } + + if (typeof arguments[0] === "object" && typeof arguments[0].length === "undefined") + { + $.extend(true, this, arguments[0]); + } + + return this; + }, + + /** + * 设置或扩展当前实例对象,单个设置 + * Extend editormd instance object, one by one + * + * @param {String|Object} key option key + * @param {String|Object} value option value + * @returns {editormd} this(editormd instance object.) + */ + + set : function (key, value) { + + if (typeof value !== "undefined" && typeof value === "function") + { + value = $.proxy(value, this); + } + + this[key] = value; + + return this; + }, + + /** + * 重新配置 + * Resetting editor options + * + * @param {String|Object} key option key + * @param {String|Object} value option value + * @returns {editormd} this(editormd instance object.) + */ + + config : function(key, value) { + var settings = this.settings; + + if (typeof key === "object") + { + settings = $.extend(true, settings, key); + } + + if (typeof key === "string") + { + settings[key] = value; + } + + this.settings = settings; + this.recreate(); + + return this; + }, + + /** + * 注册事件处理方法 + * Bind editor event handle + * + * @param {String} eventType event type + * @param {Function} callback 回调函数 + * @returns {editormd} this(editormd instance object.) + */ + + on : function(eventType, callback) { + var settings = this.settings; + + if (typeof settings["on" + eventType] !== "undefined") + { + settings["on" + eventType] = $.proxy(callback, this); + } + + return this; + }, + + /** + * 解除事件处理方法 + * Unbind editor event handle + * + * @param {String} eventType event type + * @returns {editormd} this(editormd instance object.) + */ + + off : function(eventType) { + var settings = this.settings; + + if (typeof settings["on" + eventType] !== "undefined") + { + settings["on" + eventType] = function(){}; + } + + return this; + }, + + /** + * 显示工具栏 + * Display toolbar + * + * @param {Function} [callback=function(){}] 回调函数 + * @returns {editormd} 返回editormd的实例对象 + */ + + showToolbar : function(callback) { + var settings = this.settings; + + if(settings.readOnly) { + return this; + } + + if (settings.toolbar && (this.toolbar.length < 1 || this.toolbar.find("." + this.classPrefix + "menu").html() === "") ) + { + this.setToolbar(); + } + + settings.toolbar = true; + + this.toolbar.show(); + this.resize(); + + $.proxy(callback || function(){}, this)(); + + return this; + }, + + /** + * 隐藏工具栏 + * Hide toolbar + * + * @param {Function} [callback=function(){}] 回调函数 + * @returns {editormd} this(editormd instance object.) + */ + + hideToolbar : function(callback) { + var settings = this.settings; + + settings.toolbar = false; + this.toolbar.hide(); + this.resize(); + + $.proxy(callback || function(){}, this)(); + + return this; + }, + + /** + * 页面滚动时工具栏的固定定位 + * Set toolbar in window scroll auto fixed position + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setToolbarAutoFixed : function(fixed) { + + var state = this.state; + var editor = this.editor; + var toolbar = this.toolbar; + var settings = this.settings; + + if (typeof fixed !== "undefined") + { + settings.toolbarAutoFixed = fixed; + } + + var autoFixedHandle = function(){ + var $window = $(window); + var top = $window.scrollTop(); + + if (!settings.toolbarAutoFixed) + { + return false; + } + + if (top - editor.offset().top > 10 && top < editor.height()) + { + toolbar.css({ + position : "fixed", + width : editor.width() + "px", + left : ($window.width() - editor.width()) / 2 + "px" + }); + } + else + { + toolbar.css({ + position : "absolute", + width : "100%", + left : 0 + }); + } + }; + + if (!state.fullscreen && !state.preview && settings.toolbar && settings.toolbarAutoFixed) + { + $(window).bind("scroll", autoFixedHandle); + } + + return this; + }, + + /** + * 配置和初始化工具栏 + * Set toolbar and Initialization + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setToolbar : function() { + var settings = this.settings; + + if(settings.readOnly) { + return this; + } + + var editor = this.editor; + var preview = this.preview; + var classPrefix = this.classPrefix; + + var toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); + + if (settings.toolbar && toolbar.length < 1) + { + var toolbarHTML = "
              "; + + editor.append(toolbarHTML); + toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); + } + + if (!settings.toolbar) + { + toolbar.hide(); + + return this; + } + + toolbar.show(); + + var icons = (typeof settings.toolbarIcons === "function") ? settings.toolbarIcons() + : ((typeof settings.toolbarIcons === "string") ? editormd.toolbarModes[settings.toolbarIcons] : settings.toolbarIcons); + + var toolbarMenu = toolbar.find("." + this.classPrefix + "menu"), menu = ""; + var pullRight = false; + + for (var i = 0, len = icons.length; i < len; i++) + { + var name = icons[i]; + + if (name === "||") + { + pullRight = true; + } + else if (name === "|") + { + menu += "
            • |
            • "; + } + else + { + var isHeader = (/h(\d)/.test(name)); + var index = name; + + if (name === "watch" && !settings.watch) { + index = "unwatch"; + } + + var title = settings.lang.toolbar[index]; + var iconTexts = settings.toolbarIconTexts[index]; + var iconClass = settings.toolbarIconsClass[index]; + + title = (typeof title === "undefined") ? "" : title; + iconTexts = (typeof iconTexts === "undefined") ? "" : iconTexts; + iconClass = (typeof iconClass === "undefined") ? "" : iconClass; + + var menuItem = pullRight ? "
            • " : "
            • "; + + if (typeof settings.toolbarCustomIcons[name] !== "undefined" && typeof settings.toolbarCustomIcons[name] !== "function") + { + menuItem += settings.toolbarCustomIcons[name]; + } + else + { + menuItem += ""; + menuItem += ""+((isHeader) ? name.toUpperCase() : ( (iconClass === "") ? iconTexts : "") ) + ""; + menuItem += ""; + } + + menuItem += "
            • "; + + menu = pullRight ? menuItem + menu : menu + menuItem; + } + } + + toolbarMenu.html(menu); + + toolbarMenu.find("[title=\"Lowercase\"]").attr("title", settings.lang.toolbar.lowercase); + toolbarMenu.find("[title=\"ucwords\"]").attr("title", settings.lang.toolbar.ucwords); + + this.setToolbarHandler(); + this.setToolbarAutoFixed(); + + return this; + }, + + /** + * 工具栏图标事件处理对象序列 + * Get toolbar icons event handlers + * + * @param {Object} cm CodeMirror的实例对象 + * @param {String} name 要获取的事件处理器名称 + * @returns {Object} 返回处理对象序列 + */ + + dialogLockScreen : function() { + $.proxy(editormd.dialogLockScreen, this)(); + + return this; + }, + + dialogShowMask : function(dialog) { + $.proxy(editormd.dialogShowMask, this)(dialog); + + return this; + }, + + getToolbarHandles : function(name) { + var toolbarHandlers = this.toolbarHandlers = editormd.toolbarHandlers; + + return (name && typeof toolbarIconHandlers[name] !== "undefined") ? toolbarHandlers[name] : toolbarHandlers; + }, + + /** + * 工具栏图标事件处理器 + * Bind toolbar icons event handle + * + * @returns {editormd} 返回editormd的实例对象 + */ + + setToolbarHandler : function() { + var _this = this; + var settings = this.settings; + + if (!settings.toolbar || settings.readOnly) { + return this; + } + + var toolbar = this.toolbar; + var cm = this.cm; + var classPrefix = this.classPrefix; + var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu > li > a"); + var toolbarIconHandlers = this.getToolbarHandles(); + + toolbarIcons.bind(editormd.mouseOrTouch("click", "touchend"), function(event) { + + var icon = $(this).children(".fa"); + var name = icon.attr("name"); + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (name === "") { + return ; + } + + _this.activeIcon = icon; + + if (typeof toolbarIconHandlers[name] !== "undefined") + { + $.proxy(toolbarIconHandlers[name], _this)(cm); + } + else + { + if (typeof settings.toolbarHandlers[name] !== "undefined") + { + $.proxy(settings.toolbarHandlers[name], _this)(cm, icon, cursor, selection); + } + } + + if (name !== "link" && name !== "reference-link" && name !== "image" && name !== "code-block" && + name !== "preformatted-text" && name !== "watch" && name !== "preview" && name !== "search" && name !== "fullscreen" && name !== "info") + { + cm.focus(); + } + + return false; + + }); + + return this; + }, + + /** + * 动态创建对话框 + * Creating custom dialogs + * + * @param {Object} options 配置项键值对 Key/Value + * @returns {dialog} 返回创建的dialog的jQuery实例对象 + */ + + createDialog : function(options) { + return $.proxy(editormd.createDialog, this)(options); + }, + + /** + * 创建关于Editor.md的对话框 + * Create about Editor.md dialog + * + * @returns {editormd} 返回editormd的实例对象 + */ + + createInfoDialog : function() { + var _this = this; + var editor = this.editor; + var classPrefix = this.classPrefix; + + var infoDialogHTML = [ + "
              ", + "
              ", + "

              " + editormd.title + "v" + editormd.version + "

              ", + "

              " + this.lang.description + "

              ", + "

              " + editormd.homePage + "

              ", + "

              Copyright © 2015 Pandao, The MIT License.

              ", + "
              ", + "", + "
              " + ].join("\n"); + + editor.append(infoDialogHTML); + + var infoDialog = this.infoDialog = editor.children("." + classPrefix + "dialog-info"); + + infoDialog.find("." + classPrefix + "dialog-close").bind(editormd.mouseOrTouch("click", "touchend"), function() { + _this.hideInfoDialog(); + }); + + infoDialog.css("border", (editormd.isIE8) ? "1px solid #ddd" : "").css("z-index", editormd.dialogZindex).show(); + + this.infoDialogPosition(); + + return this; + }, + + /** + * 关于Editor.md对话居中定位 + * Editor.md dialog position handle + * + * @returns {editormd} 返回editormd的实例对象 + */ + + infoDialogPosition : function() { + var infoDialog = this.infoDialog; + + var _infoDialogPosition = function() { + infoDialog.css({ + top : ($(window).height() - infoDialog.height()) / 2 + "px", + left : ($(window).width() - infoDialog.width()) / 2 + "px" + }); + }; + + _infoDialogPosition(); + + $(window).resize(_infoDialogPosition); + + return this; + }, + + /** + * 显示关于Editor.md + * Display about Editor.md dialog + * + * @returns {editormd} 返回editormd的实例对象 + */ + + showInfoDialog : function() { + + $("html,body").css("overflow-x", "hidden"); + + var _this = this; + var editor = this.editor; + var settings = this.settings; + var infoDialog = this.infoDialog = editor.children("." + this.classPrefix + "dialog-info"); + + if (infoDialog.length < 1) + { + this.createInfoDialog(); + } + + this.lockScreen(true); + + this.mask.css({ + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }).show(); + + infoDialog.css("z-index", editormd.dialogZindex).show(); + + this.infoDialogPosition(); + + return this; + }, + + /** + * 隐藏关于Editor.md + * Hide about Editor.md dialog + * + * @returns {editormd} 返回editormd的实例对象 + */ + + hideInfoDialog : function() { + $("html,body").css("overflow-x", ""); + this.infoDialog.hide(); + this.mask.hide(); + this.lockScreen(false); + + return this; + }, + + /** + * 锁屏 + * lock screen + * + * @param {Boolean} lock Boolean 布尔值,是否锁屏 + * @returns {editormd} 返回editormd的实例对象 + */ + + lockScreen : function(lock) { + editormd.lockScreen(lock); + this.resize(); + + return this; + }, + + /** + * 编辑器界面重建,用于动态语言包或模块加载等 + * Recreate editor + * + * @returns {editormd} 返回editormd的实例对象 + */ + + recreate : function() { + var _this = this; + var editor = this.editor; + var settings = this.settings; + + this.codeMirror.remove(); + + this.setCodeMirror(); + + if (!settings.readOnly) + { + if (editor.find(".editormd-dialog").length > 0) { + editor.find(".editormd-dialog").remove(); + } + + if (settings.toolbar) + { + this.getToolbarHandles(); + this.setToolbar(); + } + } + + this.loadedDisplay(true); + + return this; + }, + + /** + * 高亮预览HTML的pre代码部分 + * highlight of preview codes + * + * @returns {editormd} 返回editormd的实例对象 + */ + + previewCodeHighlight : function() { + var settings = this.settings; + var previewContainer = this.previewContainer; + + if (settings.previewCodeHighlight) + { + previewContainer.find("pre").addClass("prettyprint linenums"); + + if (typeof prettyPrint !== "undefined") + { + prettyPrint(); + } + } + + return this; + }, + + /** + * 解析TeX(KaTeX)科学公式 + * TeX(KaTeX) Renderer + * + * @returns {editormd} 返回editormd的实例对象 + */ + + katexRender : function() { + + if (timer === null) + { + return this; + } + + this.previewContainer.find("." + editormd.classNames.tex).each(function(){ + var tex = $(this); + editormd.$katex.render(tex.text(), tex[0]); + + tex.find(".katex").css("font-size", "1.6em"); + }); + + return this; + }, + + /** + * 解析和渲染流程图及时序图 + * FlowChart and SequenceDiagram Renderer + * + * @returns {editormd} 返回editormd的实例对象 + */ + + flowChartAndSequenceDiagramRender : function() { + var $this = this; + var settings = this.settings; + var previewContainer = this.previewContainer; + + if (editormd.isIE8) { + return this; + } + + if (settings.flowChart) { + if (flowchartTimer === null) { + return this; + } + + previewContainer.find(".flowchart").flowChart(); + } + + if (settings.sequenceDiagram) { + previewContainer.find(".sequence-diagram").sequenceDiagram({theme: "simple"}); + } + + var preview = $this.preview; + var codeMirror = $this.codeMirror; + var codeView = codeMirror.find(".CodeMirror-scroll"); + + var height = codeView.height(); + var scrollTop = codeView.scrollTop(); + var percent = (scrollTop / codeView[0].scrollHeight); + var tocHeight = 0; + + preview.find(".markdown-toc-list").each(function(){ + tocHeight += $(this).height(); + }); + + var tocMenuHeight = preview.find(".editormd-toc-menu").height(); + tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight; + + if (scrollTop === 0) + { + preview.scrollTop(0); + } + else if (scrollTop + height >= codeView[0].scrollHeight - 16) + { + preview.scrollTop(preview[0].scrollHeight); + } + else + { + preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent); + } + + return this; + }, + + /** + * 注册键盘快捷键处理 + * Register CodeMirror keyMaps (keyboard shortcuts). + * + * @param {Object} keyMap KeyMap key/value {"(Ctrl/Shift/Alt)-Key" : function(){}} + * @returns {editormd} return this + */ + + registerKeyMaps : function(keyMap) { + + var _this = this; + var cm = this.cm; + var settings = this.settings; + var toolbarHandlers = editormd.toolbarHandlers; + var disabledKeyMaps = settings.disabledKeyMaps; + + keyMap = keyMap || null; + + if (keyMap) + { + for (var i in keyMap) + { + if ($.inArray(i, disabledKeyMaps) < 0) + { + var map = {}; + map[i] = keyMap[i]; + + cm.addKeyMap(keyMap); + } + } + } + else + { + for (var k in editormd.keyMaps) + { + var _keyMap = editormd.keyMaps[k]; + var handle = (typeof _keyMap === "string") ? $.proxy(toolbarHandlers[_keyMap], _this) : $.proxy(_keyMap, _this); + + if ($.inArray(k, ["F9", "F10", "F11"]) < 0 && $.inArray(k, disabledKeyMaps) < 0) + { + var _map = {}; + _map[k] = handle; + + cm.addKeyMap(_map); + } + } + + $(window).keydown(function(event) { + + var keymaps = { + "120" : "F9", + "121" : "F10", + "122" : "F11" + }; + + if ( $.inArray(keymaps[event.keyCode], disabledKeyMaps) < 0 ) + { + switch (event.keyCode) + { + case 120: + $.proxy(toolbarHandlers["watch"], _this)(); + return false; + break; + + case 121: + $.proxy(toolbarHandlers["preview"], _this)(); + return false; + break; + + case 122: + $.proxy(toolbarHandlers["fullscreen"], _this)(); + return false; + break; + + default: + break; + } + } + }); + } + + return this; + }, + + /** + * 绑定同步滚动 + * + * @returns {editormd} return this + */ + + bindScrollEvent : function() { + + var _this = this; + var preview = this.preview; + var settings = this.settings; + var codeMirror = this.codeMirror; + var mouseOrTouch = editormd.mouseOrTouch; + + if (!settings.syncScrolling) { + return this; + } + + var cmBindScroll = function() { + codeMirror.find(".CodeMirror-scroll").bind(mouseOrTouch("scroll", "touchmove"), function(event) { + var height = $(this).height(); + var scrollTop = $(this).scrollTop(); + var percent = (scrollTop / $(this)[0].scrollHeight); + + var tocHeight = 0; + + preview.find(".markdown-toc-list").each(function(){ + tocHeight += $(this).height(); + }); + + var tocMenuHeight = preview.find(".editormd-toc-menu").height(); + tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight; + + if (scrollTop === 0) + { + preview.scrollTop(0); + } + else if (scrollTop + height >= $(this)[0].scrollHeight - 16) + { + preview.scrollTop(preview[0].scrollHeight); + } + else + { + preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent); + } + + $.proxy(settings.onscroll, _this)(event); + }); + }; + + var cmUnbindScroll = function() { + codeMirror.find(".CodeMirror-scroll").unbind(mouseOrTouch("scroll", "touchmove")); + }; + + var previewBindScroll = function() { + + preview.bind(mouseOrTouch("scroll", "touchmove"), function(event) { + var height = $(this).height(); + var scrollTop = $(this).scrollTop(); + var percent = (scrollTop / $(this)[0].scrollHeight); + var codeView = codeMirror.find(".CodeMirror-scroll"); + + if(scrollTop === 0) + { + codeView.scrollTop(0); + } + else if (scrollTop + height >= $(this)[0].scrollHeight) + { + codeView.scrollTop(codeView[0].scrollHeight); + } + else + { + codeView.scrollTop(codeView[0].scrollHeight * percent); + } + + $.proxy(settings.onpreviewscroll, _this)(event); + }); + + }; + + var previewUnbindScroll = function() { + preview.unbind(mouseOrTouch("scroll", "touchmove")); + }; + + codeMirror.bind({ + mouseover : cmBindScroll, + mouseout : cmUnbindScroll, + touchstart : cmBindScroll, + touchend : cmUnbindScroll + }); + + if (settings.syncScrolling === "single") { + return this; + } + + preview.bind({ + mouseover : previewBindScroll, + mouseout : previewUnbindScroll, + touchstart : previewBindScroll, + touchend : previewUnbindScroll + }); + + return this; + }, + + bindChangeEvent : function() { + + var _this = this; + var cm = this.cm; + var settings = this.settings; + + if (!settings.syncScrolling) { + return this; + } + + cm.on("change", function(_cm, changeObj) { + + if (settings.watch) + { + _this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); + } + + timer = setTimeout(function() { + clearTimeout(timer); + _this.save(); + timer = null; + }, settings.delay); + }); + + return this; + }, + + /** + * 加载队列完成之后的显示处理 + * Display handle of the module queues loaded after. + * + * @param {Boolean} recreate 是否为重建编辑器 + * @returns {editormd} 返回editormd的实例对象 + */ + + loadedDisplay : function(recreate) { + + recreate = recreate || false; + + var _this = this; + var editor = this.editor; + var preview = this.preview; + var settings = this.settings; + + this.containerMask.hide(); + + this.save(); + + if (settings.watch) { + preview.show(); + } + + editor.data("oldWidth", editor.width()).data("oldHeight", editor.height()); // 为了兼容Zepto + + this.resize(); + this.registerKeyMaps(); + + $(window).resize(function(){ + _this.resize(); + }); + + this.bindScrollEvent().bindChangeEvent(); + + if (!recreate) + { + $.proxy(settings.onload, this)(); + } + + this.state.loaded = true; + + return this; + }, + + /** + * 设置编辑器的宽度 + * Set editor width + * + * @param {Number|String} width 编辑器宽度值 + * @returns {editormd} 返回editormd的实例对象 + */ + + width : function(width) { + + this.editor.css("width", (typeof width === "number") ? width + "px" : width); + this.resize(); + + return this; + }, + + /** + * 设置编辑器的高度 + * Set editor height + * + * @param {Number|String} height 编辑器高度值 + * @returns {editormd} 返回editormd的实例对象 + */ + + height : function(height) { + + this.editor.css("height", (typeof height === "number") ? height + "px" : height); + this.resize(); + + return this; + }, + + /** + * 调整编辑器的尺寸和布局 + * Resize editor layout + * + * @param {Number|String} [width=null] 编辑器宽度值 + * @param {Number|String} [height=null] 编辑器高度值 + * @returns {editormd} 返回editormd的实例对象 + */ + + resize : function(width, height) { + + width = width || null; + height = height || null; + + var state = this.state; + var editor = this.editor; + var preview = this.preview; + var toolbar = this.toolbar; + var settings = this.settings; + var codeMirror = this.codeMirror; + + if (width) + { + editor.css("width", (typeof width === "number") ? width + "px" : width); + } + + if (settings.autoHeight && !state.fullscreen && !state.preview) + { + editor.css("height", "auto"); + codeMirror.css("height", "auto"); + } + else + { + if (height) + { + editor.css("height", (typeof height === "number") ? height + "px" : height); + } + + if (state.fullscreen) + { + editor.height($(window).height()); + } + + if (settings.toolbar && !settings.readOnly) + { + codeMirror.css("margin-top", toolbar.height() + 1).height(editor.height() - toolbar.height()); + } + else + { + codeMirror.css("margin-top", 0).height(editor.height()); + } + } + + if(settings.watch) + { + codeMirror.width(editor.width() / 2); + preview.width((!state.preview) ? editor.width() / 2 : editor.width()); + + this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); + + if (settings.toolbar && !settings.readOnly) + { + preview.css("top", toolbar.height() + 1); + } + else + { + preview.css("top", 0); + } + + if (settings.autoHeight && !state.fullscreen && !state.preview) + { + preview.height(""); + } + else + { + var previewHeight = (settings.toolbar && !settings.readOnly) ? editor.height() - toolbar.height() : editor.height(); + + preview.height(previewHeight); + } + } + else + { + codeMirror.width(editor.width()); + preview.hide(); + } + + if (state.loaded) + { + $.proxy(settings.onresize, this)(); + } + + return this; + }, + + /** + * 解析和保存Markdown代码 + * Parse & Saving Markdown source code + * + * @returns {editormd} 返回editormd的实例对象 + */ + + save : function() { + + var _this = this; + var state = this.state; + var settings = this.settings; + + if (timer === null && !(!settings.watch && state.preview)) + { + return this; + } + + var cm = this.cm; + var cmValue = cm.getValue(); + var previewContainer = this.previewContainer; + + if (settings.mode !== "gfm" && settings.mode !== "markdown") + { + this.markdownTextarea.val(cmValue); + + return this; + } + + var marked = editormd.$marked; + var markdownToC = this.markdownToC = []; + var rendererOptions = this.markedRendererOptions = { + toc : settings.toc, + tocm : settings.tocm, + tocStartLevel : settings.tocStartLevel, + pageBreak : settings.pageBreak, + taskList : settings.taskList, + emoji : settings.emoji, + tex : settings.tex, + atLink : settings.atLink, // for @link + emailLink : settings.emailLink, // for mail address auto link + flowChart : settings.flowChart, + sequenceDiagram : settings.sequenceDiagram, + previewCodeHighlight : settings.previewCodeHighlight, + }; + + var markedOptions = this.markedOptions = { + renderer : editormd.markedRenderer(markdownToC, rendererOptions), + gfm : true, + tables : true, + breaks : true, + pedantic : false, + sanitize : (settings.htmlDecode) ? false : true, // 关闭忽略HTML标签,即开启识别HTML标签,默认为false + smartLists : true, + smartypants : true + }; + + marked.setOptions(markedOptions); + + var newMarkdownDoc = editormd.$marked(cmValue, markedOptions); + + //console.info("cmValue", cmValue, newMarkdownDoc); + + newMarkdownDoc = editormd.filterHTMLTags(newMarkdownDoc, settings.htmlDecode); + + //console.error("cmValue", cmValue, newMarkdownDoc); + + this.markdownTextarea.text(cmValue); + + cm.save(); + + if (settings.saveHTMLToTextarea) + { + this.htmlTextarea.text(newMarkdownDoc); + } + + if(settings.watch || (!settings.watch && state.preview)) + { + previewContainer.html(newMarkdownDoc); + + this.previewCodeHighlight(); + + if (settings.toc) + { + var tocContainer = (settings.tocContainer === "") ? previewContainer : $(settings.tocContainer); + var tocMenu = tocContainer.find("." + this.classPrefix + "toc-menu"); + + tocContainer.attr("previewContainer", (settings.tocContainer === "") ? "true" : "false"); + + if (settings.tocContainer !== "" && tocMenu.length > 0) + { + tocMenu.remove(); + } + + editormd.markdownToCRenderer(markdownToC, tocContainer, settings.tocDropdown, settings.tocStartLevel); + + if (settings.tocDropdown || tocContainer.find("." + this.classPrefix + "toc-menu").length > 0) + { + editormd.tocDropdownMenu(tocContainer, (settings.tocTitle !== "") ? settings.tocTitle : this.lang.tocTitle); + } + + if (settings.tocContainer !== "") + { + previewContainer.find(".markdown-toc").css("border", "none"); + } + } + + if (settings.tex) + { + if (!editormd.kaTeXLoaded && settings.autoLoadModules) + { + editormd.loadKaTeX(function() { + editormd.$katex = katex; + editormd.kaTeXLoaded = true; + _this.katexRender(); + }); + } + else + { + editormd.$katex = katex; + this.katexRender(); + } + } + + if (settings.flowChart || settings.sequenceDiagram) + { + flowchartTimer = setTimeout(function(){ + clearTimeout(flowchartTimer); + _this.flowChartAndSequenceDiagramRender(); + flowchartTimer = null; + }, 10); + } + + if (state.loaded) + { + $.proxy(settings.onchange, this)(); + } + } + + return this; + }, + + /** + * 聚焦光标位置 + * Focusing the cursor position + * + * @returns {editormd} 返回editormd的实例对象 + */ + + focus : function() { + this.cm.focus(); + + return this; + }, + + /** + * 设置光标的位置 + * Set cursor position + * + * @param {Object} cursor 要设置的光标位置键值对象,例:{line:1, ch:0} + * @returns {editormd} 返回editormd的实例对象 + */ + + setCursor : function(cursor) { + this.cm.setCursor(cursor); + + return this; + }, + + /** + * 获取当前光标的位置 + * Get the current position of the cursor + * + * @returns {Cursor} 返回一个光标Cursor对象 + */ + + getCursor : function() { + return this.cm.getCursor(); + }, + + /** + * 设置光标选中的范围 + * Set cursor selected ranges + * + * @param {Object} from 开始位置的光标键值对象,例:{line:1, ch:0} + * @param {Object} to 结束位置的光标键值对象,例:{line:1, ch:0} + * @returns {editormd} 返回editormd的实例对象 + */ + + setSelection : function(from, to) { + + this.cm.setSelection(from, to); + + return this; + }, + + /** + * 获取光标选中的文本 + * Get the texts from cursor selected + * + * @returns {String} 返回选中文本的字符串形式 + */ + + getSelection : function() { + return this.cm.getSelection(); + }, + + /** + * 设置光标选中的文本范围 + * Set the cursor selection ranges + * + * @param {Array} ranges cursor selection ranges array + * @returns {Array} return this + */ + + setSelections : function(ranges) { + this.cm.setSelections(ranges); + + return this; + }, + + /** + * 获取光标选中的文本范围 + * Get the cursor selection ranges + * + * @returns {Array} return selection ranges array + */ + + getSelections : function() { + return this.cm.getSelections(); + }, + + /** + * 替换当前光标选中的文本或在当前光标处插入新字符 + * Replace the text at the current cursor selected or insert a new character at the current cursor position + * + * @param {String} value 要插入的字符值 + * @returns {editormd} 返回editormd的实例对象 + */ + + replaceSelection : function(value) { + this.cm.replaceSelection(value); + + return this; + }, + + /** + * 在当前光标处插入新字符 + * Insert a new character at the current cursor position + * + * 同replaceSelection()方法 + * With the replaceSelection() method + * + * @param {String} value 要插入的字符值 + * @returns {editormd} 返回editormd的实例对象 + */ + + insertValue : function(value) { + this.replaceSelection(value); + + return this; + }, + + /** + * 追加markdown + * append Markdown to editor + * + * @param {String} md 要追加的markdown源文档 + * @returns {editormd} 返回editormd的实例对象 + */ + + appendMarkdown : function(md) { + var settings = this.settings; + var cm = this.cm; + + cm.setValue(cm.getValue() + md); + + return this; + }, + + /** + * 设置和传入编辑器的markdown源文档 + * Set Markdown source document + * + * @param {String} md 要传入的markdown源文档 + * @returns {editormd} 返回editormd的实例对象 + */ + + setMarkdown : function(md) { + this.cm.setValue(md || this.settings.markdown); + + return this; + }, + + /** + * 获取编辑器的markdown源文档 + * Set Editor.md markdown/CodeMirror value + * + * @returns {editormd} 返回editormd的实例对象 + */ + + getMarkdown : function() { + return this.cm.getValue(); + }, + + /** + * 获取编辑器的源文档 + * Get CodeMirror value + * + * @returns {editormd} 返回editormd的实例对象 + */ + + getValue : function() { + return this.cm.getValue(); + }, + + /** + * 设置编辑器的源文档 + * Set CodeMirror value + * + * @param {String} value set code/value/string/text + * @returns {editormd} 返回editormd的实例对象 + */ + + setValue : function(value) { + this.cm.setValue(value); + + return this; + }, + + /** + * 清空编辑器 + * Empty CodeMirror editor container + * + * @returns {editormd} 返回editormd的实例对象 + */ + + clear : function() { + this.cm.setValue(""); + + return this; + }, + + /** + * 获取解析后存放在Textarea的HTML源码 + * Get parsed html code from Textarea + * + * @returns {String} 返回HTML源码 + */ + + getHTML : function() { + if (!this.settings.saveHTMLToTextarea) + { + alert("Error: settings.saveHTMLToTextarea == false"); + + return false; + } + + return this.htmlTextarea.val(); + }, + + /** + * getHTML()的别名 + * getHTML (alias) + * + * @returns {String} Return html code 返回HTML源码 + */ + + getTextareaSavedHTML : function() { + return this.getHTML(); + }, + + /** + * 获取预览窗口的HTML源码 + * Get html from preview container + * + * @returns {editormd} 返回editormd的实例对象 + */ + + getPreviewedHTML : function() { + if (!this.settings.watch) + { + alert("Error: settings.watch == false"); + + return false; + } + + return this.previewContainer.html(); + }, + + /** + * 开启实时预览 + * Enable real-time watching + * + * @returns {editormd} 返回editormd的实例对象 + */ + + watch : function(callback) { + var settings = this.settings; + + if ($.inArray(settings.mode, ["gfm", "markdown"]) < 0) + { + return this; + } + + this.state.watching = settings.watch = true; + this.preview.show(); + + if (this.toolbar) + { + var watchIcon = settings.toolbarIconsClass.watch; + var unWatchIcon = settings.toolbarIconsClass.unwatch; + + var icon = this.toolbar.find(".fa[name=watch]"); + icon.parent().attr("title", settings.lang.toolbar.watch); + icon.removeClass(unWatchIcon).addClass(watchIcon); + } + + this.codeMirror.css("border-right", "1px solid #ddd").width(this.editor.width() / 2); + + timer = 0; + + this.save().resize(); + + if (!settings.onwatch) + { + settings.onwatch = callback || function() {}; + } + + $.proxy(settings.onwatch, this)(); + + return this; + }, + + /** + * 关闭实时预览 + * Disable real-time watching + * + * @returns {editormd} 返回editormd的实例对象 + */ + + unwatch : function(callback) { + var settings = this.settings; + this.state.watching = settings.watch = false; + this.preview.hide(); + + if (this.toolbar) + { + var watchIcon = settings.toolbarIconsClass.watch; + var unWatchIcon = settings.toolbarIconsClass.unwatch; + + var icon = this.toolbar.find(".fa[name=watch]"); + icon.parent().attr("title", settings.lang.toolbar.unwatch); + icon.removeClass(watchIcon).addClass(unWatchIcon); + } + + this.codeMirror.css("border-right", "none").width(this.editor.width()); + + this.resize(); + + if (!settings.onunwatch) + { + settings.onunwatch = callback || function() {}; + } + + $.proxy(settings.onunwatch, this)(); + + return this; + }, + + /** + * 显示编辑器 + * Show editor + * + * @param {Function} [callback=function()] 回调函数 + * @returns {editormd} 返回editormd的实例对象 + */ + + show : function(callback) { + callback = callback || function() {}; + + var _this = this; + this.editor.show(0, function() { + $.proxy(callback, _this)(); + }); + + return this; + }, + + /** + * 隐藏编辑器 + * Hide editor + * + * @param {Function} [callback=function()] 回调函数 + * @returns {editormd} 返回editormd的实例对象 + */ + + hide : function(callback) { + callback = callback || function() {}; + + var _this = this; + this.editor.hide(0, function() { + $.proxy(callback, _this)(); + }); + + return this; + }, + + /** + * 隐藏编辑器部分,只预览HTML + * Enter preview html state + * + * @returns {editormd} 返回editormd的实例对象 + */ + + previewing : function() { + + var _this = this; + var editor = this.editor; + var preview = this.preview; + var toolbar = this.toolbar; + var settings = this.settings; + var codeMirror = this.codeMirror; + var previewContainer = this.previewContainer; + + if ($.inArray(settings.mode, ["gfm", "markdown"]) < 0) { + return this; + } + + if (settings.toolbar && toolbar) { + toolbar.toggle(); + toolbar.find(".fa[name=preview]").toggleClass("active"); + } + + codeMirror.toggle(); + + var escHandle = function(event) { + if (event.shiftKey && event.keyCode === 27) { + _this.previewed(); + } + }; + + if (codeMirror.css("display") === "none") // 为了兼容Zepto,而不使用codeMirror.is(":hidden") + { + this.state.preview = true; + + if (this.state.fullscreen) { + preview.css("background", "#fff"); + } + + editor.find("." + this.classPrefix + "preview-close-btn").show().bind(editormd.mouseOrTouch("click", "touchend"), function(){ + _this.previewed(); + }); + + if (!settings.watch) + { + this.save(); + } + else + { + previewContainer.css("padding", ""); + } + + previewContainer.addClass(this.classPrefix + "preview-active"); + + preview.show().css({ + position : "", + top : 0, + width : editor.width(), + height : (settings.autoHeight && !this.state.fullscreen) ? "auto" : editor.height() + }); + + if (this.state.loaded) + { + $.proxy(settings.onpreviewing, this)(); + } + + $(window).bind("keyup", escHandle); + } + else + { + $(window).unbind("keyup", escHandle); + this.previewed(); + } + }, + + /** + * 显示编辑器部分,退出只预览HTML + * Exit preview html state + * + * @returns {editormd} 返回editormd的实例对象 + */ + + previewed : function() { + + var editor = this.editor; + var preview = this.preview; + var toolbar = this.toolbar; + var settings = this.settings; + var previewContainer = this.previewContainer; + var previewCloseBtn = editor.find("." + this.classPrefix + "preview-close-btn"); + + this.state.preview = false; + + this.codeMirror.show(); + + if (settings.toolbar) { + toolbar.show(); + } + + preview[(settings.watch) ? "show" : "hide"](); + + previewCloseBtn.hide().unbind(editormd.mouseOrTouch("click", "touchend")); + + previewContainer.removeClass(this.classPrefix + "preview-active"); + + if (settings.watch) + { + previewContainer.css("padding", "20px"); + } + + preview.css({ + background : null, + position : "absolute", + width : editor.width() / 2, + height : (settings.autoHeight && !this.state.fullscreen) ? "auto" : editor.height() - toolbar.height(), + top : (settings.toolbar) ? toolbar.height() : 0 + }); + + if (this.state.loaded) + { + $.proxy(settings.onpreviewed, this)(); + } + + return this; + }, + + /** + * 编辑器全屏显示 + * Fullscreen show + * + * @returns {editormd} 返回editormd的实例对象 + */ + + fullscreen : function() { + + var _this = this; + var state = this.state; + var editor = this.editor; + var preview = this.preview; + var toolbar = this.toolbar; + var settings = this.settings; + var fullscreenClass = this.classPrefix + "fullscreen"; + + if (toolbar) { + toolbar.find(".fa[name=fullscreen]").parent().toggleClass("active"); + } + + var escHandle = function(event) { + if (!event.shiftKey && event.keyCode === 27) + { + if (state.fullscreen) + { + _this.fullscreenExit(); + } + } + }; + + if (!editor.hasClass(fullscreenClass)) + { + state.fullscreen = true; + + $("html,body").css("overflow", "hidden"); + + editor.css({ + width : $(window).width(), + height : $(window).height() + }).addClass(fullscreenClass); + + this.resize(); + + $.proxy(settings.onfullscreen, this)(); + + $(window).bind("keyup", escHandle); + } + else + { + $(window).unbind("keyup", escHandle); + this.fullscreenExit(); + } + + return this; + }, + + /** + * 编辑器退出全屏显示 + * Exit fullscreen state + * + * @returns {editormd} 返回editormd的实例对象 + */ + + fullscreenExit : function() { + + var editor = this.editor; + var settings = this.settings; + var toolbar = this.toolbar; + var fullscreenClass = this.classPrefix + "fullscreen"; + + this.state.fullscreen = false; + + if (toolbar) { + toolbar.find(".fa[name=fullscreen]").parent().removeClass("active"); + } + + $("html,body").css("overflow", ""); + + editor.css({ + width : editor.data("oldWidth"), + height : editor.data("oldHeight") + }).removeClass(fullscreenClass); + + this.resize(); + + $.proxy(settings.onfullscreenExit, this)(); + + return this; + }, + + /** + * 加载并执行插件 + * Load and execute the plugin + * + * @param {String} name plugin name / function name + * @param {String} path plugin load path + * @returns {editormd} 返回editormd的实例对象 + */ + + executePlugin : function(name, path) { + + var _this = this; + var cm = this.cm; + var settings = this.settings; + + path = settings.pluginPath + path; + + if (typeof define === "function") + { + if (typeof this[name] === "undefined") + { + alert("Error: " + name + " plugin is not found, you are not load this plugin."); + + return this; + } + + this[name](cm); + + return this; + } + + if ($.inArray(path, editormd.loadFiles.plugin) < 0) + { + editormd.loadPlugin(path, function() { + editormd.loadPlugins[name] = _this[name]; + _this[name](cm); + }); + } + else + { + $.proxy(editormd.loadPlugins[name], this)(cm); + } + + return this; + }, + + /** + * 搜索替换 + * Search & replace + * + * @param {String} command CodeMirror serach commands, "find, fintNext, fintPrev, clearSearch, replace, replaceAll" + * @returns {editormd} return this + */ + + search : function(command) { + var settings = this.settings; + + if (!settings.searchReplace) + { + alert("Error: settings.searchReplace == false"); + return this; + } + + if (!settings.readOnly) + { + this.cm.execCommand(command || "find"); + } + + return this; + }, + + searchReplace : function() { + this.search("replace"); + + return this; + }, + + searchReplaceAll : function() { + this.search("replaceAll"); + + return this; + } + }; + + editormd.fn.init.prototype = editormd.fn; + + /** + * 锁屏 + * lock screen when dialog opening + * + * @returns {void} + */ + + editormd.dialogLockScreen = function() { + var settings = this.settings || {dialogLockScreen : true}; + + if (settings.dialogLockScreen) + { + $("html,body").css("overflow", "hidden"); + this.resize(); + } + }; + + /** + * 显示透明背景层 + * Display mask layer when dialog opening + * + * @param {Object} dialog dialog jQuery object + * @returns {void} + */ + + editormd.dialogShowMask = function(dialog) { + var editor = this.editor; + var settings = this.settings || {dialogShowMask : true}; + + dialog.css({ + top : ($(window).height() - dialog.height()) / 2 + "px", + left : ($(window).width() - dialog.width()) / 2 + "px" + }); + + if (settings.dialogShowMask) { + editor.children("." + this.classPrefix + "mask").css("z-index", parseInt(dialog.css("z-index")) - 1).show(); + } + }; + + editormd.toolbarHandlers = { + undo : function() { + this.cm.undo(); + }, + + redo : function() { + this.cm.redo(); + }, + + bold : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("**" + selection + "**"); + + if(selection === "") { + cm.setCursor(cursor.line, cursor.ch + 2); + } + }, + + del : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("~~" + selection + "~~"); + + if(selection === "") { + cm.setCursor(cursor.line, cursor.ch + 2); + } + }, + + italic : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("*" + selection + "*"); + + if(selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + + quote : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("> " + selection); + cm.setCursor(cursor.line, cursor.ch + 2); + } + else + { + cm.replaceSelection("> " + selection); + } + + //cm.replaceSelection("> " + selection); + //cm.setCursor(cursor.line, (selection === "") ? cursor.ch + 2 : cursor.ch + selection.length + 2); + }, + + ucfirst : function() { + var cm = this.cm; + var selection = cm.getSelection(); + var selections = cm.listSelections(); + + cm.replaceSelection(editormd.firstUpperCase(selection)); + cm.setSelections(selections); + }, + + ucwords : function() { + var cm = this.cm; + var selection = cm.getSelection(); + var selections = cm.listSelections(); + + cm.replaceSelection(editormd.wordsFirstUpperCase(selection)); + cm.setSelections(selections); + }, + + uppercase : function() { + var cm = this.cm; + var selection = cm.getSelection(); + var selections = cm.listSelections(); + + cm.replaceSelection(selection.toUpperCase()); + cm.setSelections(selections); + }, + + lowercase : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + var selections = cm.listSelections(); + + cm.replaceSelection(selection.toLowerCase()); + cm.setSelections(selections); + }, + + h1 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("# " + selection); + cm.setCursor(cursor.line, cursor.ch + 2); + } + else + { + cm.replaceSelection("# " + selection); + } + }, + + h2 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("## " + selection); + cm.setCursor(cursor.line, cursor.ch + 3); + } + else + { + cm.replaceSelection("## " + selection); + } + }, + + h3 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("### " + selection); + cm.setCursor(cursor.line, cursor.ch + 4); + } + else + { + cm.replaceSelection("### " + selection); + } + }, + + h4 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("#### " + selection); + cm.setCursor(cursor.line, cursor.ch + 5); + } + else + { + cm.replaceSelection("#### " + selection); + } + }, + + h5 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("##### " + selection); + cm.setCursor(cursor.line, cursor.ch + 6); + } + else + { + cm.replaceSelection("##### " + selection); + } + }, + + h6 : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (cursor.ch !== 0) + { + cm.setCursor(cursor.line, 0); + cm.replaceSelection("###### " + selection); + cm.setCursor(cursor.line, cursor.ch + 7); + } + else + { + cm.replaceSelection("###### " + selection); + } + }, + + "list-ul" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (selection === "") + { + cm.replaceSelection("- " + selection); + } + else + { + var selectionText = selection.split("\n"); + + for (var i = 0, len = selectionText.length; i < len; i++) + { + selectionText[i] = (selectionText[i] === "") ? "" : "- " + selectionText[i]; + } + + cm.replaceSelection(selectionText.join("\n")); + } + }, + + "list-ol" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if(selection === "") + { + cm.replaceSelection("1. " + selection); + } + else + { + var selectionText = selection.split("\n"); + + for (var i = 0, len = selectionText.length; i < len; i++) + { + selectionText[i] = (selectionText[i] === "") ? "" : (i+1) + ". " + selectionText[i]; + } + + cm.replaceSelection(selectionText.join("\n")); + } + }, + + hr : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection(((cursor.ch !== 0) ? "\n\n" : "\n") + "------------\n\n"); + }, + + tex : function() { + if (!this.settings.tex) + { + alert("settings.tex === false"); + return this; + } + + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("$$" + selection + "$$"); + + if(selection === "") { + cm.setCursor(cursor.line, cursor.ch + 2); + } + }, + + link : function() { + this.executePlugin("linkDialog", "link-dialog/link-dialog"); + }, + + "reference-link" : function() { + this.executePlugin("referenceLinkDialog", "reference-link-dialog/reference-link-dialog"); + }, + + pagebreak : function() { + if (!this.settings.pageBreak) + { + alert("settings.pageBreak === false"); + return this; + } + + var cm = this.cm; + var selection = cm.getSelection(); + + cm.replaceSelection("\r\n[========]\r\n"); + }, + + image : function() { + this.executePlugin("imageDialog", "image-dialog/image-dialog"); + }, + + code : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection("`" + selection + "`"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + + "code-block" : function() { + this.executePlugin("codeBlockDialog", "code-block-dialog/code-block-dialog"); + }, + + "preformatted-text" : function() { + this.executePlugin("preformattedTextDialog", "preformatted-text-dialog/preformatted-text-dialog"); + }, + + table : function() { + this.executePlugin("tableDialog", "table-dialog/table-dialog"); + }, + + datetime : function() { + var cm = this.cm; + var selection = cm.getSelection(); + var date = new Date(); + var langName = this.settings.lang.name; + var datefmt = editormd.dateFormat() + " " + editormd.dateFormat((langName === "zh-cn" || langName === "zh-tw") ? "cn-week-day" : "week-day"); + + cm.replaceSelection(datefmt); + }, + + emoji : function() { + this.executePlugin("emojiDialog", "emoji-dialog/emoji-dialog"); + }, + + "html-entities" : function() { + this.executePlugin("htmlEntitiesDialog", "html-entities-dialog/html-entities-dialog"); + }, + + "goto-line" : function() { + this.executePlugin("gotoLineDialog", "goto-line-dialog/goto-line-dialog"); + }, + + watch : function() { + this[this.settings.watch ? "unwatch" : "watch"](); + }, + + preview : function() { + this.previewing(); + }, + + fullscreen : function() { + this.fullscreen(); + }, + + clear : function() { + this.clear(); + }, + + search : function() { + this.search(); + }, + + help : function() { + this.executePlugin("helpDialog", "help-dialog/help-dialog"); + }, + + info : function() { + this.showInfoDialog(); + } + }; + + editormd.keyMaps = { + "Ctrl-1" : "h1", + "Ctrl-2" : "h2", + "Ctrl-3" : "h3", + "Ctrl-4" : "h4", + "Ctrl-5" : "h5", + "Ctrl-6" : "h6", + "Ctrl-B" : "bold", // if this is string == editormd.toolbarHandlers.xxxx + "Ctrl-D" : "datetime", + + "Ctrl-E" : function() { // emoji + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (!this.settings.emoji) + { + alert("Error: settings.emoji == false"); + return ; + } + + cm.replaceSelection(":" + selection + ":"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + "Ctrl-Alt-G" : "goto-line", + "Ctrl-H" : "hr", + "Ctrl-I" : "italic", + "Ctrl-K" : "code", + + "Ctrl-L" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + var title = (selection === "") ? "" : " \""+selection+"\""; + + cm.replaceSelection("[" + selection + "]("+title+")"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + "Ctrl-U" : "list-ul", + + "Shift-Ctrl-A" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + if (!this.settings.atLink) + { + alert("Error: settings.atLink == false"); + return ; + } + + cm.replaceSelection("@" + selection); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + }, + + "Shift-Ctrl-C" : "code", + "Shift-Ctrl-Q" : "quote", + "Shift-Ctrl-S" : "del", + "Shift-Ctrl-K" : "tex", // KaTeX + + "Shift-Alt-C" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + cm.replaceSelection(["```", selection, "```"].join("\n")); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 3); + } + }, + + "Shift-Ctrl-Alt-C" : "code-block", + "Shift-Ctrl-H" : "html-entities", + "Shift-Alt-H" : "help", + "Shift-Ctrl-E" : "emoji", + "Shift-Ctrl-U" : "uppercase", + "Shift-Alt-U" : "ucwords", + "Shift-Ctrl-Alt-U" : "ucfirst", + "Shift-Alt-L" : "lowercase", + + "Shift-Ctrl-I" : function() { + var cm = this.cm; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + + var title = (selection === "") ? "" : " \""+selection+"\""; + + cm.replaceSelection("![" + selection + "]("+title+")"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 4); + } + }, + + "Shift-Ctrl-Alt-I" : "image", + "Shift-Ctrl-L" : "link", + "Shift-Ctrl-O" : "list-ol", + "Shift-Ctrl-P" : "preformatted-text", + "Shift-Ctrl-T" : "table", + "Shift-Alt-P" : "pagebreak", + "F9" : "watch", + "F10" : "preview", + "F11" : "fullscreen", + }; + + /** + * 清除字符串两边的空格 + * Clear the space of strings both sides. + * + * @param {String} str string + * @returns {String} trimed string + */ + + var trim = function(str) { + return (!String.prototype.trim) ? str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "") : str.trim(); + }; + + editormd.trim = trim; + + /** + * 所有单词首字母大写 + * Words first to uppercase + * + * @param {String} str string + * @returns {String} string + */ + + var ucwords = function (str) { + return str.toLowerCase().replace(/\b(\w)|\s(\w)/g, function($1) { + return $1.toUpperCase(); + }); + }; + + editormd.ucwords = editormd.wordsFirstUpperCase = ucwords; + + /** + * 字符串首字母大写 + * Only string first char to uppercase + * + * @param {String} str string + * @returns {String} string + */ + + var firstUpperCase = function(str) { + return str.toLowerCase().replace(/\b(\w)/, function($1){ + return $1.toUpperCase(); + }); + }; + + var ucfirst = firstUpperCase; + + editormd.firstUpperCase = editormd.ucfirst = firstUpperCase; + + editormd.urls = { + atLinkBase : "https://github.com/" + }; + + editormd.regexs = { + atLink : /@(\w+)/g, + email : /(\w+)@(\w+)\.(\w+)\.?(\w+)?/g, + emailLink : /(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g, + emoji : /:([\w\+-]+):/g, + emojiDatetime : /(\d{2}:\d{2}:\d{2})/g, + twemoji : /:(tw-([\w]+)-?(\w+)?):/g, + fontAwesome : /:(fa-([\w]+)(-(\w+)){0,}):/g, + editormdLogo : /:(editormd-logo-?(\w+)?):/g, + pageBreak : /^\[[=]{8,}\]$/ + }; + + // Emoji graphics files url path + editormd.emoji = { + path : "http://www.emoji-cheat-sheet.com/graphics/emojis/", + ext : ".png" + }; + + // Twitter Emoji (Twemoji) graphics files url path + editormd.twemoji = { + path : "http://twemoji.maxcdn.com/36x36/", + ext : ".png" + }; + + /** + * 自定义marked的解析器 + * Custom Marked renderer rules + * + * @param {Array} markdownToC 传入用于接收TOC的数组 + * @returns {Renderer} markedRenderer 返回marked的Renderer自定义对象 + */ + + editormd.markedRenderer = function(markdownToC, options) { + var defaults = { + toc : true, // Table of contents + tocm : false, + tocStartLevel : 1, // Said from H1 to create ToC + pageBreak : true, + atLink : true, // for @link + emailLink : true, // for mail address auto link + taskList : false, // Enable Github Flavored Markdown task lists + emoji : false, // :emoji: , Support Twemoji, fontAwesome, Editor.md logo emojis. + tex : false, // TeX(LaTeX), based on KaTeX + flowChart : false, // flowChart.js only support IE9+ + sequenceDiagram : false, // sequenceDiagram.js only support IE9+ + }; + + var settings = $.extend(defaults, options || {}); + var marked = editormd.$marked; + var markedRenderer = new marked.Renderer(); + markdownToC = markdownToC || []; + + var regexs = editormd.regexs; + var atLinkReg = regexs.atLink; + var emojiReg = regexs.emoji; + var emailReg = regexs.email; + var emailLinkReg = regexs.emailLink; + var twemojiReg = regexs.twemoji; + var faIconReg = regexs.fontAwesome; + var editormdLogoReg = regexs.editormdLogo; + var pageBreakReg = regexs.pageBreak; + + markedRenderer.emoji = function(text) { + + text = text.replace(editormd.regexs.emojiDatetime, function($1) { + return $1.replace(/:/g, ":"); + }); + + var matchs = text.match(emojiReg); + + if (!matchs || !settings.emoji) { + return text; + } + + for (var i = 0, len = matchs.length; i < len; i++) + { + if (matchs[i] === ":+1:") { + matchs[i] = ":\\+1:"; + } + + text = text.replace(new RegExp(matchs[i]), function($1, $2){ + var faMatchs = $1.match(faIconReg); + var name = $1.replace(/:/g, ""); + + if (faMatchs) + { + for (var fa = 0, len1 = faMatchs.length; fa < len1; fa++) + { + var faName = faMatchs[fa].replace(/:/g, ""); + + return ""; + } + } + else + { + var emdlogoMathcs = $1.match(editormdLogoReg); + var twemojiMatchs = $1.match(twemojiReg); + + if (emdlogoMathcs) + { + for (var x = 0, len2 = emdlogoMathcs.length; x < len2; x++) + { + var logoName = emdlogoMathcs[x].replace(/:/g, ""); + return ""; + } + } + else if (twemojiMatchs) + { + for (var t = 0, len3 = twemojiMatchs.length; t < len3; t++) + { + var twe = twemojiMatchs[t].replace(/:/g, "").replace("tw-", ""); + return "\"twemoji-""; + } + } + else + { + var src = (name === "+1") ? "plus1" : name; + src = (src === "black_large_square") ? "black_square" : src; + src = (src === "moon") ? "waxing_gibbous_moon" : src; + + return "\":""; + } + } + }); + } + + return text; + }; + + markedRenderer.atLink = function(text) { + + if (atLinkReg.test(text)) + { + if (settings.atLink) + { + text = text.replace(emailReg, function($1, $2, $3, $4) { + return $1.replace(/@/g, "_#_@_#_"); + }); + + text = text.replace(atLinkReg, function($1, $2) { + return "" + $1 + ""; + }).replace(/_#_@_#_/g, "@"); + } + + if (settings.emailLink) + { + text = text.replace(emailLinkReg, function($1, $2, $3, $4, $5) { + return (!$2 && $.inArray($5, "jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|")) < 0) ? ""+$1+"" : $1; + }); + } + + return text; + } + + return text; + }; + + markedRenderer.link = function (href, title, text) { + + if (this.options.sanitize) { + try { + var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase(); + } catch(e) { + return ""; + } + + if (prot.indexOf("javascript:") === 0) { + return ""; + } + } + + var out = "" + text.replace(/@/g, "@") + ""; + } + + if (title) { + out += " title=\"" + title + "\""; + } + + out += ">" + text + ""; + + return out; + }; + + markedRenderer.heading = function(text, level, raw) { + + var linkText = text; + var hasLinkReg = /\s*\]*)\>(.*)\<\/a\>\s*/; + var getLinkTextReg = /\s*\]+)\>([^\>]*)\<\/a\>\s*/g; + + if (hasLinkReg.test(text)) + { + var tempText = []; + text = text.split(/\]+)\>([^\>]*)\<\/a\>/); + + for (var i = 0, len = text.length; i < len; i++) + { + tempText.push(text[i].replace(/\s*href\=\"(.*)\"\s*/g, "")); + } + + text = tempText.join(" "); + } + + text = trim(text); + + var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-"); + var toc = { + text : text, + level : level, + slug : escapedText + }; + + var isChinese = /^[\u4e00-\u9fa5]+$/.test(text); + var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-"); + + markdownToC.push(toc); + + var headingHTML = ""; + + headingHTML += ""; + headingHTML += ""; + headingHTML += (hasLinkReg) ? this.atLink(this.emoji(linkText)) : this.atLink(this.emoji(text)); + headingHTML += ""; + + return headingHTML; + }; + + markedRenderer.pageBreak = function(text) { + if (pageBreakReg.test(text) && settings.pageBreak) + { + text = "
              "; + } + + return text; + }; + + markedRenderer.paragraph = function(text) { + var isTeXInline = /\$\$(.*)\$\$/g.test(text); + var isTeXLine = /^\$\$(.*)\$\$$/.test(text); + var isTeXAddClass = (isTeXLine) ? " class=\"" + editormd.classNames.tex + "\"" : ""; + var isToC = (settings.tocm) ? /^(\[TOC\]|\[TOCM\])$/.test(text) : /^\[TOC\]$/.test(text); + var isToCMenu = /^\[TOCM\]$/.test(text); + + if (!isTeXLine && isTeXInline) + { + text = text.replace(/(\$\$([^\$]*)\$\$)+/g, function($1, $2) { + return "" + $2.replace(/\$/g, "") + ""; + }); + } + else + { + text = (isTeXLine) ? text.replace(/\$/g, "") : text; + } + + var tocHTML = "
              " + text + "
              "; + + return (isToC) ? ( (isToCMenu) ? "
              " + tocHTML + "

              " : tocHTML ) + : ( (pageBreakReg.test(text)) ? this.pageBreak(text) : "" + this.atLink(this.emoji(text)) + "

              \n" ); + }; + + markedRenderer.code = function (code, lang, escaped) { + + if (lang === "seq" || lang === "sequence") + { + return "
              " + code + "
              "; + } + else if ( lang === "flow") + { + return "
              " + code + "
              "; + } + else if ( lang === "math" || lang === "latex" || lang === "katex") + { + return "

              " + code + "

              "; + } + else + { + + return marked.Renderer.prototype.code.apply(this, arguments); + } + }; + + markedRenderer.tablecell = function(content, flags) { + var type = (flags.header) ? "th" : "td"; + var tag = (flags.align) ? "<" + type +" style=\"text-align:" + flags.align + "\">" : "<" + type + ">"; + + return tag + this.atLink(this.emoji(content)) + "\n"; + }; + + markedRenderer.listitem = function(text) { + if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text)) + { + text = text.replace(/^\s*\[\s\]\s*/, " ") + .replace(/^\s*\[x\]\s*/, " "); + + return "
            • " + this.atLink(this.emoji(text)) + "
            • "; + } + else + { + return "
            • " + this.atLink(this.emoji(text)) + "
            • "; + } + }; + + return markedRenderer; + }; + + /** + * + * 生成TOC(Table of Contents) + * Creating ToC (Table of Contents) + * + * @param {Array} toc 从marked获取的TOC数组列表 + * @param {Element} container 插入TOC的容器元素 + * @param {Integer} startLevel Hx 起始层级 + * @returns {Object} tocContainer 返回ToC列表容器层的jQuery对象元素 + */ + + editormd.markdownToCRenderer = function(toc, container, tocDropdown, startLevel) { + + var html = ""; + var lastLevel = 0; + var classPrefix = this.classPrefix; + + startLevel = startLevel || 1; + + for (var i = 0, len = toc.length; i < len; i++) + { + var text = toc[i].text; + var level = toc[i].level; + + if (level < startLevel) { + continue; + } + + if (level > lastLevel) + { + html += ""; + } + else if (level < lastLevel) + { + html += (new Array(lastLevel - level + 2)).join("
          • "); + } + else + { + html += ""; + } + + html += "
          • " + text + "
              "; + lastLevel = level; + } + + var tocContainer = container.find(".markdown-toc"); + + if ((tocContainer.length < 1 && container.attr("previewContainer") === "false")) + { + var tocHTML = "
              "; + + tocHTML = (tocDropdown) ? "
              " + tocHTML + "
              " : tocHTML; + + container.html(tocHTML); + + tocContainer = container.find(".markdown-toc"); + } + + if (tocDropdown) + { + tocContainer.wrap("

              "); + } + + tocContainer.html("
                ").children(".markdown-toc-list").html(html.replace(/\r?\n?\\<\/ul\>/g, "")); + + return tocContainer; + }; + + /** + * + * 生成TOC下拉菜单 + * Creating ToC dropdown menu + * + * @param {Object} container 插入TOC的容器jQuery对象元素 + * @param {String} tocTitle ToC title + * @returns {Object} return toc-menu object + */ + + editormd.tocDropdownMenu = function(container, tocTitle) { + + tocTitle = tocTitle || "Table of Contents"; + + var zindex = 400; + var tocMenus = container.find("." + this.classPrefix + "toc-menu"); + + tocMenus.each(function() { + var $this = $(this); + var toc = $this.children(".markdown-toc"); + var icon = ""; + var btn = "" + icon + tocTitle + ""; + var menu = toc.children("ul"); + var list = menu.find("li"); + + toc.append(btn); + + list.first().before("
              • " + tocTitle + " " + icon + "

              • "); + + $this.mouseover(function(){ + menu.show(); + + list.each(function(){ + var li = $(this); + var ul = li.children("ul"); + + if (ul.html() === "") + { + ul.remove(); + } + + if (ul.length > 0 && ul.html() !== "") + { + var firstA = li.children("a").first(); + + if (firstA.children(".fa").length < 1) + { + firstA.append( $(icon).css({ float:"right", paddingTop:"4px" }) ); + } + } + + li.mouseover(function(){ + ul.css("z-index", zindex).show(); + zindex += 1; + }).mouseleave(function(){ + ul.hide(); + }); + }); + }).mouseleave(function(){ + menu.hide(); + }); + }); + + return tocMenus; + }; + + /** + * 简单地过滤指定的HTML标签 + * Filter custom html tags + * + * @param {String} html 要过滤HTML + * @param {String} filters 要过滤的标签 + * @returns {String} html 返回过滤的HTML + */ + + editormd.filterHTMLTags = function(html, filters) { + + if (typeof html !== "string") { + html = new String(html); + } + + if (typeof filters !== "string") { + return html; + } + + var expression = filters.split("|"); + var filterTags = expression[0].split(","); + var attrs = expression[1]; + + for (var i = 0, len = filterTags.length; i < len; i++) + { + var tag = filterTags[i]; + + html = html.replace(new RegExp("\<\s*" + tag + "\s*([^\>]*)\>([^\>]*)\<\s*\/" + tag + "\s*\>", "igm"), ""); + } + + //return html; + + if (typeof attrs !== "undefined") + { + var htmlTagRegex = /\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/ig; + + if (attrs === "*") + { + html = html.replace(htmlTagRegex, function($1, $2, $3, $4, $5) { + return "<" + $2 + ">" + $4 + ""; + }); + } + else if (attrs === "on*") + { + html = html.replace(htmlTagRegex, function($1, $2, $3, $4, $5) { + var el = $("<" + $2 + ">" + $4 + ""); + var _attrs = $($1)[0].attributes; + var $attrs = {}; + + $.each(_attrs, function(i, e) { + if (e.nodeName !== '"') $attrs[e.nodeName] = e.nodeValue; + }); + + $.each($attrs, function(i) { + if (i.indexOf("on") === 0) { + delete $attrs[i]; + } + }); + + el.attr($attrs); + + var text = (typeof el[1] !== "undefined") ? $(el[1]).text() : ""; + + return el[0].outerHTML + text; + }); + } + else + { + html = html.replace(htmlTagRegex, function($1, $2, $3, $4) { + var filterAttrs = attrs.split(","); + var el = $($1); + el.html($4); + + $.each(filterAttrs, function(i) { + el.attr(filterAttrs[i], null); + }); + + return el[0].outerHTML; + }); + } + } + + return html; + }; + + /** + * 将Markdown文档解析为HTML用于前台显示 + * Parse Markdown to HTML for Font-end preview. + * + * @param {String} id 用于显示HTML的对象ID + * @param {Object} [options={}] 配置选项,可选 + * @returns {Object} div 返回jQuery对象元素 + */ + + editormd.markdownToHTML = function(id, options) { + var defaults = { + gfm : true, + toc : true, + tocm : false, + tocStartLevel : 1, + tocTitle : "目录", + tocDropdown : false, + tocContainer : "", + markdown : "", + markdownSourceCode : false, + htmlDecode : false, + autoLoadKaTeX : true, + pageBreak : true, + atLink : true, // for @link + emailLink : true, // for mail address auto link + tex : false, + taskList : false, // Github Flavored Markdown task lists + emoji : false, + flowChart : false, + sequenceDiagram : false, + previewCodeHighlight : true + }; + + editormd.$marked = marked; + + var div = $("#" + id); + var settings = div.settings = $.extend(true, defaults, options || {}); + var saveTo = div.find("textarea"); + + if (saveTo.length < 1) + { + div.append(""); + saveTo = div.find("textarea"); + } + + var markdownDoc = (settings.markdown === "") ? saveTo.val() : settings.markdown; + var markdownToC = []; + + var rendererOptions = { + toc : settings.toc, + tocm : settings.tocm, + tocStartLevel : settings.tocStartLevel, + taskList : settings.taskList, + emoji : settings.emoji, + tex : settings.tex, + pageBreak : settings.pageBreak, + atLink : settings.atLink, // for @link + emailLink : settings.emailLink, // for mail address auto link + flowChart : settings.flowChart, + sequenceDiagram : settings.sequenceDiagram, + previewCodeHighlight : settings.previewCodeHighlight, + }; + + var markedOptions = { + renderer : editormd.markedRenderer(markdownToC, rendererOptions), + gfm : settings.gfm, + tables : true, + breaks : true, + pedantic : false, + sanitize : (settings.htmlDecode) ? false : true, // 是否忽略HTML标签,即是否开启HTML标签解析,为了安全性,默认不开启 + smartLists : true, + smartypants : true + }; + + markdownDoc = new String(markdownDoc); + + var markdownParsed = marked(markdownDoc, markedOptions); + + markdownParsed = editormd.filterHTMLTags(markdownParsed, settings.htmlDecode); + + if (settings.markdownSourceCode) { + saveTo.text(markdownDoc); + } else { + saveTo.remove(); + } + + div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed); + + var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div; + + if (settings.tocContainer !== "") + { + tocContainer.attr("previewContainer", false); + } + + if (settings.toc) + { + div.tocContainer = this.markdownToCRenderer(markdownToC, tocContainer, settings.tocDropdown, settings.tocStartLevel); + + if (settings.tocDropdown || div.find("." + this.classPrefix + "toc-menu").length > 0) + { + this.tocDropdownMenu(div, settings.tocTitle); + } + + if (settings.tocContainer !== "") + { + div.find(".editormd-toc-menu, .editormd-markdown-toc").remove(); + } + } + + if (settings.previewCodeHighlight) + { + div.find("pre").addClass("prettyprint linenums"); + prettyPrint(); + } + + if (!editormd.isIE8) + { + if (settings.flowChart) { + div.find(".flowchart").flowChart(); + } + + if (settings.sequenceDiagram) { + div.find(".sequence-diagram").sequenceDiagram({theme: "simple"}); + } + } + + if (settings.tex) + { + var katexHandle = function() { + div.find("." + editormd.classNames.tex).each(function(){ + var tex = $(this); + katex.render(tex.html().replace(/</g, "<").replace(/>/g, ">"), tex[0]); + tex.find(".katex").css("font-size", "1.6em"); + }); + }; + + if (settings.autoLoadKaTeX && !editormd.$katex && !editormd.kaTeXLoaded) + { + this.loadKaTeX(function() { + editormd.$katex = katex; + editormd.kaTeXLoaded = true; + katexHandle(); + }); + } + else + { + katexHandle(); + } + } + + div.getMarkdown = function() { + return saveTo.val(); + }; + + return div; + }; + + // Editor.md themes, change toolbar themes etc. + // added @1.5.0 + editormd.themes = ["default", "dark"]; + + // Preview area themes + // added @1.5.0 + editormd.previewThemes = ["default", "dark"]; + + // CodeMirror / editor area themes + // @1.5.0 rename -> editorThemes, old version -> themes + editormd.editorThemes = [ + "default", "3024-day", "3024-night", + "ambiance", "ambiance-mobile", + "base16-dark", "base16-light", "blackboard", + "cobalt", + "eclipse", "elegant", "erlang-dark", + "lesser-dark", + "mbo", "mdn-like", "midnight", "monokai", + "neat", "neo", "night", + "paraiso-dark", "paraiso-light", "pastel-on-dark", + "rubyblue", + "solarized", + "the-matrix", "tomorrow-night-eighties", "twilight", + "vibrant-ink", + "xq-dark", "xq-light" + ]; + + editormd.loadPlugins = {}; + + editormd.loadFiles = { + js : [], + css : [], + plugin : [] + }; + + /** + * 动态加载Editor.md插件,但不立即执行 + * Load editor.md plugins + * + * @param {String} fileName 插件文件路径 + * @param {Function} [callback=function()] 加载成功后执行的回调函数 + * @param {String} [into="head"] 嵌入页面的位置 + */ + + editormd.loadPlugin = function(fileName, callback, into) { + callback = callback || function() {}; + + this.loadScript(fileName, function() { + editormd.loadFiles.plugin.push(fileName); + callback(); + }, into); + }; + + /** + * 动态加载CSS文件的方法 + * Load css file method + * + * @param {String} fileName CSS文件名 + * @param {Function} [callback=function()] 加载成功后执行的回调函数 + * @param {String} [into="head"] 嵌入页面的位置 + */ + + editormd.loadCSS = function(fileName, callback, into) { + into = into || "head"; + callback = callback || function() {}; + + var css = document.createElement("link"); + css.type = "text/css"; + css.rel = "stylesheet"; + css.onload = css.onreadystatechange = function() { + editormd.loadFiles.css.push(fileName); + callback(); + }; + + css.href = fileName + ".css"; + + if(into === "head") { + document.getElementsByTagName("head")[0].appendChild(css); + } else { + document.body.appendChild(css); + } + }; + + editormd.isIE = (navigator.appName == "Microsoft Internet Explorer"); + editormd.isIE8 = (editormd.isIE && navigator.appVersion.match(/8./i) == "8."); + + /** + * 动态加载JS文件的方法 + * Load javascript file method + * + * @param {String} fileName JS文件名 + * @param {Function} [callback=function()] 加载成功后执行的回调函数 + * @param {String} [into="head"] 嵌入页面的位置 + */ + + editormd.loadScript = function(fileName, callback, into) { + + into = into || "head"; + callback = callback || function() {}; + + var script = null; + script = document.createElement("script"); + script.id = fileName.replace(/[\./]+/g, "-"); + script.type = "text/javascript"; + script.src = fileName + ".js"; + + if (editormd.isIE8) + { + script.onreadystatechange = function() { + if(script.readyState) + { + if (script.readyState === "loaded" || script.readyState === "complete") + { + script.onreadystatechange = null; + editormd.loadFiles.js.push(fileName); + callback(); + } + } + }; + } + else + { + script.onload = function() { + editormd.loadFiles.js.push(fileName); + callback(); + }; + } + + if (into === "head") { + document.getElementsByTagName("head")[0].appendChild(script); + } else { + document.body.appendChild(script); + } + }; + + // 使用国外的CDN,加载速度有时会很慢,或者自定义URL + // You can custom KaTeX load url. + editormd.katexURL = { + css : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min", + js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min" + }; + + editormd.kaTeXLoaded = false; + + /** + * 加载KaTeX文件 + * load KaTeX files + * + * @param {Function} [callback=function()] 加载成功后执行的回调函数 + */ + + editormd.loadKaTeX = function (callback) { + editormd.loadCSS(editormd.katexURL.css, function(){ + editormd.loadScript(editormd.katexURL.js, callback || function(){}); + }); + }; + + /** + * 锁屏 + * lock screen + * + * @param {Boolean} lock Boolean 布尔值,是否锁屏 + * @returns {void} + */ + + editormd.lockScreen = function(lock) { + $("html,body").css("overflow", (lock) ? "hidden" : ""); + }; + + /** + * 动态创建对话框 + * Creating custom dialogs + * + * @param {Object} options 配置项键值对 Key/Value + * @returns {dialog} 返回创建的dialog的jQuery实例对象 + */ + + editormd.createDialog = function(options) { + var defaults = { + name : "", + width : 420, + height: 240, + title : "", + drag : true, + closed : true, + content : "", + mask : true, + maskStyle : { + backgroundColor : "#fff", + opacity : 0.1 + }, + lockScreen : true, + footer : true, + buttons : false + }; + + options = $.extend(true, defaults, options); + + var $this = this; + var editor = this.editor; + var classPrefix = editormd.classPrefix; + var guid = (new Date()).getTime(); + var dialogName = ( (options.name === "") ? classPrefix + "dialog-" + guid : options.name); + var mouseOrTouch = editormd.mouseOrTouch; + + var html = "
                "; + + if (options.title !== "") + { + html += "
                "; + html += "" + options.title + ""; + html += "
                "; + } + + if (options.closed) + { + html += ""; + } + + html += "
                " + options.content; + + if (options.footer || typeof options.footer === "string") + { + html += "
                " + ( (typeof options.footer === "boolean") ? "" : options.footer) + "
                "; + } + + html += "
                "; + + html += "
                "; + html += "
                "; + html += "
                "; + + editor.append(html); + + var dialog = editor.find("." + dialogName); + + dialog.lockScreen = function(lock) { + if (options.lockScreen) + { + $("html,body").css("overflow", (lock) ? "hidden" : ""); + $this.resize(); + } + + return dialog; + }; + + dialog.showMask = function() { + if (options.mask) + { + editor.find("." + classPrefix + "mask").css(options.maskStyle).css("z-index", editormd.dialogZindex - 1).show(); + } + return dialog; + }; + + dialog.hideMask = function() { + if (options.mask) + { + editor.find("." + classPrefix + "mask").hide(); + } + + return dialog; + }; + + dialog.loading = function(show) { + var loading = dialog.find("." + classPrefix + "dialog-mask"); + loading[(show) ? "show" : "hide"](); + + return dialog; + }; + + dialog.lockScreen(true).showMask(); + + dialog.show().css({ + zIndex : editormd.dialogZindex, + border : (editormd.isIE8) ? "1px solid #ddd" : "", + width : (typeof options.width === "number") ? options.width + "px" : options.width, + height : (typeof options.height === "number") ? options.height + "px" : options.height + }); + + var dialogPosition = function(){ + dialog.css({ + top : ($(window).height() - dialog.height()) / 2 + "px", + left : ($(window).width() - dialog.width()) / 2 + "px" + }); + }; + + dialogPosition(); + + $(window).resize(dialogPosition); + + dialog.children("." + classPrefix + "dialog-close").bind(mouseOrTouch("click", "touchend"), function() { + dialog.hide().lockScreen(false).hideMask(); + }); + + if (typeof options.buttons === "object") + { + var footer = dialog.footer = dialog.find("." + classPrefix + "dialog-footer"); + + for (var key in options.buttons) + { + var btn = options.buttons[key]; + var btnClassName = classPrefix + key + "-btn"; + + footer.append(""); + btn[1] = $.proxy(btn[1], dialog); + footer.children("." + btnClassName).bind(mouseOrTouch("click", "touchend"), btn[1]); + } + } + + if (options.title !== "" && options.drag) + { + var posX, posY; + var dialogHeader = dialog.children("." + classPrefix + "dialog-header"); + + if (!options.mask) { + dialogHeader.bind(mouseOrTouch("click", "touchend"), function(){ + editormd.dialogZindex += 2; + dialog.css("z-index", editormd.dialogZindex); + }); + } + + dialogHeader.mousedown(function(e) { + e = e || window.event; //IE + posX = e.clientX - parseInt(dialog[0].style.left); + posY = e.clientY - parseInt(dialog[0].style.top); + + document.onmousemove = moveAction; + }); + + var userCanSelect = function (obj) { + obj.removeClass(classPrefix + "user-unselect").off("selectstart"); + }; + + var userUnselect = function (obj) { + obj.addClass(classPrefix + "user-unselect").on("selectstart", function(event) { // selectstart for IE + return false; + }); + }; + + var moveAction = function (e) { + e = e || window.event; //IE + + var left, top, nowLeft = parseInt(dialog[0].style.left), nowTop = parseInt(dialog[0].style.top); + + if( nowLeft >= 0 ) { + if( nowLeft + dialog.width() <= $(window).width()) { + left = e.clientX - posX; + } else { + left = $(window).width() - dialog.width(); + document.onmousemove = null; + } + } else { + left = 0; + document.onmousemove = null; + } + + if( nowTop >= 0 ) { + top = e.clientY - posY; + } else { + top = 0; + document.onmousemove = null; + } + + + document.onselectstart = function() { + return false; + }; + + userUnselect($("body")); + userUnselect(dialog); + dialog[0].style.left = left + "px"; + dialog[0].style.top = top + "px"; + }; + + document.onmouseup = function() { + userCanSelect($("body")); + userCanSelect(dialog); + + document.onselectstart = null; + document.onmousemove = null; + }; + + dialogHeader.touchDraggable = function() { + var offset = null; + var start = function(e) { + var orig = e.originalEvent; + var pos = $(this).parent().position(); + + offset = { + x : orig.changedTouches[0].pageX - pos.left, + y : orig.changedTouches[0].pageY - pos.top + }; + }; + + var move = function(e) { + e.preventDefault(); + var orig = e.originalEvent; + + $(this).parent().css({ + top : orig.changedTouches[0].pageY - offset.y, + left : orig.changedTouches[0].pageX - offset.x + }); + }; + + this.bind("touchstart", start).bind("touchmove", move); + }; + + dialogHeader.touchDraggable(); + } + + editormd.dialogZindex += 2; + + return dialog; + }; + + /** + * 鼠标和触摸事件的判断/选择方法 + * MouseEvent or TouchEvent type switch + * + * @param {String} [mouseEventType="click"] 供选择的鼠标事件 + * @param {String} [touchEventType="touchend"] 供选择的触摸事件 + * @returns {String} EventType 返回事件类型名称 + */ + + editormd.mouseOrTouch = function(mouseEventType, touchEventType) { + mouseEventType = mouseEventType || "click"; + touchEventType = touchEventType || "touchend"; + + var eventType = mouseEventType; + + try { + document.createEvent("TouchEvent"); + eventType = touchEventType; + } catch(e) {} + + return eventType; + }; + + /** + * 日期时间的格式化方法 + * Datetime format method + * + * @param {String} [format=""] 日期时间的格式,类似PHP的格式 + * @returns {String} datefmt 返回格式化后的日期时间字符串 + */ + + editormd.dateFormat = function(format) { + format = format || ""; + + var addZero = function(d) { + return (d < 10) ? "0" + d : d; + }; + + var date = new Date(); + var year = date.getFullYear(); + var year2 = year.toString().slice(2, 4); + var month = addZero(date.getMonth() + 1); + var day = addZero(date.getDate()); + var weekDay = date.getDay(); + var hour = addZero(date.getHours()); + var min = addZero(date.getMinutes()); + var second = addZero(date.getSeconds()); + var ms = addZero(date.getMilliseconds()); + var datefmt = ""; + + var ymd = year2 + "-" + month + "-" + day; + var fymd = year + "-" + month + "-" + day; + var hms = hour + ":" + min + ":" + second; + + switch (format) + { + case "UNIX Time" : + datefmt = date.getTime(); + break; + + case "UTC" : + datefmt = date.toUTCString(); + break; + + case "yy" : + datefmt = year2; + break; + + case "year" : + case "yyyy" : + datefmt = year; + break; + + case "month" : + case "mm" : + datefmt = month; + break; + + case "cn-week-day" : + case "cn-wd" : + var cnWeekDays = ["日", "一", "二", "三", "四", "五", "六"]; + datefmt = "星期" + cnWeekDays[weekDay]; + break; + + case "week-day" : + case "wd" : + var weekDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; + datefmt = weekDays[weekDay]; + break; + + case "day" : + case "dd" : + datefmt = day; + break; + + case "hour" : + case "hh" : + datefmt = hour; + break; + + case "min" : + case "ii" : + datefmt = min; + break; + + case "second" : + case "ss" : + datefmt = second; + break; + + case "ms" : + datefmt = ms; + break; + + case "yy-mm-dd" : + datefmt = ymd; + break; + + case "yyyy-mm-dd" : + datefmt = fymd; + break; + + case "yyyy-mm-dd h:i:s ms" : + case "full + ms" : + datefmt = fymd + " " + hms + " " + ms; + break; + + case "full" : + case "yyyy-mm-dd h:i:s" : + default: + datefmt = fymd + " " + hms; + break; + } + + return datefmt; + }; + + return editormd; + +})); diff --git a/src/main/webapp/static/global/plugins/editor.md-master/editormd.min.js b/src/main/webapp/static/global/plugins/editor.md-master/editormd.min.js new file mode 100644 index 000000000..f3f38cc17 --- /dev/null +++ b/src/main/webapp/static/global/plugins/editor.md-master/editormd.min.js @@ -0,0 +1,3 @@ +/*! Editor.md v1.5.0 | editormd.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-06-09 */ +!function(e){"use strict";"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd||define(["jquery"],e):window.editormd=e()}(function(){"use strict";var e="undefined"!=typeof jQuery?jQuery:Zepto;if("undefined"!=typeof e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.5.0",t.homePage="https://pandao.github.io/editor.md/",t.classPrefix="editormd-",t.toolbarModes={full:["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","info"],simple:["undo","redo","|","bold","del","italic","quote","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","watch","preview","fullscreen","|","help","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},t.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",delay:300,autoLoadModules:!0,watch:!0,placeholder:"Enjoy Markdown! coding now...",gotoLine:!0,codeFold:!1,autoHeight:!1,autoFocus:!0,autoCloseTags:!0,searchReplace:!0,syncScrolling:!0,readOnly:!1,tabSize:4,indentUnit:4,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,showTrailingSpace:!0,matchBrackets:!0,indentWithTabs:!0,styleSelectedText:!0,matchWordHighlight:!0,styleActiveLine:!0,dialogLockScreen:!0,dialogShowMask:!0,dialogDraggable:!0,dialogMaskBgColor:"#fff",dialogMaskOpacity:.1,fontSize:"13px",saveHTMLToTextarea:!1,disabledKeyMaps:[],onload:function(){},onresize:function(){},onchange:function(){},onwatch:null,onunwatch:null,onpreviewing:function(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return t.toolbarHandlers.ucwords},lowercase:function(){return t.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'a',ucwords:'Aa'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:t.classPrefix+"bold",h2:t.classPrefix+"bold",h3:t.classPrefix+"bold",h4:t.classPrefix+"bold",h5:t.classPrefix+"bold",h6:t.classPrefix+"bold","list-ul":"fa-list-ul","list-ol":"fa-list-ol",hr:"fa-minus",link:"fa-link","reference-link":"fa-anchor",image:"fa-picture-o",code:"fa-code","preformatted-text":"fa-file-code-o","code-block":"fa-file-code-o",table:"fa-table",datetime:"fa-clock-o",emoji:"fa-smile-o","html-entities":"fa-copyright",pagebreak:"fa-newspaper-o","goto-line":"fa-terminal",watch:"fa-eye-slash",unwatch:"fa-eye",preview:"fa-desktop",search:"fa-search",fullscreen:"fa-arrows-alt",clear:"fa-eraser",help:"fa-question-circle",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线Markdown编辑器
                Open source online Markdown editor.",tocTitle:"目录",toolbar:{undo:"撤销(Ctrl+Z)",redo:"重做(Ctrl+Y)",bold:"粗体",del:"删除线",italic:"斜体",quote:"引用",ucwords:"将每个单词首字母转成大写",uppercase:"将所选转换成大写",lowercase:"将所选转换成小写",h1:"标题1",h2:"标题2",h3:"标题3",h4:"标题4",h5:"标题5",h6:"标题6","list-ul":"无序列表","list-ol":"有序列表",hr:"横线",link:"链接","reference-link":"引用链接",image:"添加图片",code:"行内代码","preformatted-text":"预格式文本 / 代码块(缩进风格)","code-block":"代码块(多语言风格)",table:"添加表格",datetime:"日期时间",emoji:"Emoji表情","html-entities":"HTML实体字符",pagebreak:"插入分页符","goto-line":"跳转到行",watch:"关闭实时预览",unwatch:"开启实时预览",preview:"全窗口预览HTML(按 Shift + ESC还原)",fullscreen:"全屏(按ESC还原)",clear:"清空",search:"搜索",help:"使用帮助",info:"关于"+t.title},buttons:{enter:"确定",cancel:"取消",close:"关闭"},dialog:{link:{title:"添加链接",url:"链接地址",urlTitle:"链接标题",urlEmpty:"错误:请填写链接地址。"},referenceLink:{title:"添加引用链接",name:"引用名称",url:"链接地址",urlId:"链接ID",urlTitle:"链接标题",nameEmpty:"错误:引用链接的名称不能为空。",idEmpty:"错误:请填写引用链接的ID。",urlEmpty:"错误:请填写引用链接的URL地址。"},image:{title:"添加图片",url:"图片地址",link:"图片链接",alt:"图片描述",uploadButton:"本地上传",imageURLEmpty:"错误:图片地址不能为空。",uploadFileEmpty:"错误:上传的图片不能为空。",formatNotAllowed:"错误:只允许上传图片文件,允许上传的图片文件格式有:"},preformattedText:{title:"添加预格式文本或代码块",emptyAlert:"错误:请填写预格式文本或代码的内容。"},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。"},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},t.classNames={tex:t.classPrefix+"tex"},t.dialogZindex=99999,t.$katex=null,t.$marked=null,t.$CodeMirror=null,t.$prettyPrint=null;var i,o;t.prototype=t.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(i,o){o=o||{},"object"==typeof i&&(o=i);var r=this.classPrefix=t.classPrefix,n=this.settings=e.extend(!0,t.defaults,o);i="object"==typeof i?n.id:i;var a=this.editor=e("#"+i);this.id=i,this.lang=n.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};n.pluginPath=""===n.pluginPath?n.path+"../plugins/":n.pluginPath,this.state.watching=n.watch?!0:!1,a.hasClass("editormd")||a.addClass("editormd"),a.css({width:"number"==typeof n.width?n.width+"px":n.width,height:"number"==typeof n.height?n.height+"px":n.height}),n.autoHeight&&a.css("height","auto");var l=this.markdownTextarea=a.children("textarea");l.length<1&&(a.append(""),l=this.markdownTextarea=a.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",n.placeholder),("undefined"==typeof l.attr("name")||""===l.attr("name"))&&l.attr("name",""!==n.name?n.name:i+"-markdown-doc");var c=[n.readOnly?"":'',n.saveHTMLToTextarea?'':"",'
                ','
                ','
                '].join("\n");return a.append(c).addClass(r+"vertical"),""!==n.theme&&a.addClass(r+"theme-"+n.theme),this.mask=a.children("."+r+"mask"),this.containerMask=a.children("."+r+"container-mask"),""!==n.markdown&&l.val(n.markdown),""!==n.appendMarkdown&&l.val(l.val()+n.appendMarkdown),this.htmlTextarea=a.children("."+s.textarea.html),this.preview=a.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==n.previewTheme&&this.preview.addClass(r+"preview-theme-"+n.previewTheme),"function"==typeof define&&define.amd&&("undefined"!=typeof katex&&(t.$katex=katex),n.searchReplace&&!n.readOnly&&(t.loadCSS(n.path+"codemirror/addon/dialog/dialog"),t.loadCSS(n.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!n.autoLoadModules?("undefined"!=typeof CodeMirror&&(t.$CodeMirror=CodeMirror),"undefined"!=typeof marked&&(t.$marked=marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,i=this.settings,o=i.path,r=function(){return t.isIE8?void e.loadedDisplay():void(i.flowChart||i.sequenceDiagram?t.loadScript(o+"raphael.min",function(){t.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay())};return t.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(t.loadCSS(o+"codemirror/addon/dialog/dialog"),t.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&t.loadCSS(o+"codemirror/addon/fold/foldgutter"),t.loadScript(o+"codemirror/codemirror.min",function(){t.$CodeMirror=CodeMirror,t.loadScript(o+"codemirror/modes.min",function(){t.loadScript(o+"codemirror/addons.min",function(){return e.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode?(e.loadedDisplay(),!1):(e.setToolbar(),void t.loadScript(o+"marked.min",function(){t.$marked=marked,i.previewCodeHighlight?t.loadScript(o+"prettify.min",function(){r()}):r()}))})})}),this},setTheme:function(e){var t=this.editor,i=this.settings.theme,o=this.classPrefix+"theme-";return t.removeClass(o+i).addClass(o+e),this.settings.theme=e,this},setEditorTheme:function(e){var i=this.settings;return i.editorTheme=e,"default"!==e&&t.loadCSS(i.path+"codemirror/theme/"+i.editorTheme),this.cm.setOption("theme",e),this},setCodeMirrorTheme:function(e){return this.setEditorTheme(e),this},setPreviewTheme:function(e){var t=this.preview,i=this.settings.previewTheme,o=this.classPrefix+"preview-theme-";return t.removeClass(o+i).addClass(o+e),this.settings.previewTheme=e,this},setCodeMirror:function(){var e=this.settings,i=this.editor;"default"!==e.editorTheme&&t.loadCSS(e.path+"codemirror/theme/"+e.editorTheme);var o={mode:e.mode,theme:e.editorTheme,tabSize:e.tabSize,dragDrop:!1,autofocus:e.autoFocus,autoCloseTags:e.autoCloseTags,readOnly:e.readOnly?"nocursor":!1,indentUnit:e.indentUnit,lineNumbers:e.lineNumbers,lineWrapping:e.lineWrapping,extraKeys:{"Ctrl-Q":function(e){e.foldCode(e.getCursor())}},foldGutter:e.codeFold,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],matchBrackets:e.matchBrackets,indentWithTabs:e.indentWithTabs,styleActiveLine:e.styleActiveLine,styleSelectedText:e.styleSelectedText,autoCloseBrackets:e.autoCloseBrackets,showTrailingSpace:e.showTrailingSpace,highlightSelectionMatches:e.matchWordHighlight?{showToken:"onselected"===e.matchWordHighlight?!1:/\w/}:!1};return this.codeEditor=this.cm=t.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=i.children(".CodeMirror"),""!==e.value&&this.cm.setValue(e.value),this.codeMirror.css({fontSize:e.fontSize,width:e.watch?"50%":"100%"}),e.autoHeight&&(this.codeMirror.css("height","auto"),this.cm.setOption("viewportMargin",1/0)),e.lineNumbers||this.codeMirror.find(".CodeMirror-gutters").css("border-right","none"),this},getCodeMirrorOption:function(e){return this.cm.getOption(e)},setCodeMirrorOption:function(e,t){return this.cm.setOption(e,t),this},addKeyMap:function(e,t){return this.cm.addKeyMap(e,t),this},removeKeyMap:function(e){return this.cm.removeKeyMap(e),this},gotoLine:function(t){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=(this.editor,o.lineCount()),n=this.preview;if("string"==typeof t&&("last"===t&&(t=r),"first"===t&&(t=1)),"number"!=typeof t)return alert("Error: The line number must be an integer."),this;if(t=parseInt(t)-1,t>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:t,ch:0});var a=o.getScrollInfo(),s=a.clientHeight,l=o.charCoords({line:t,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=e(c).height(),d=c.scrollTop,u=d/c.scrollHeight;n.scrollTop(0===d?0:d+h>=c.scrollHeight-16?n[0].scrollHeight:n[0].scrollHeight*u)}return o.focus(),this},extend:function(){return"undefined"!=typeof arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=e.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&"undefined"==typeof arguments[0].length&&e.extend(!0,this,arguments[0]),this},set:function(t,i){return"undefined"!=typeof i&&"function"==typeof i&&(i=e.proxy(i,this)),this[t]=i,this},config:function(t,i){var o=this.settings;return"object"==typeof t&&(o=e.extend(!0,o,t)),"string"==typeof t&&(o[t]=i),this.settings=o,this.recreate(),this},on:function(t,i){var o=this.settings;return"undefined"!=typeof o["on"+t]&&(o["on"+t]=e.proxy(i,this)),this},off:function(e){var t=this.settings;return"undefined"!=typeof t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(t){var i=this.settings;return i.readOnly?this:(i.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),i.toolbar=!0,this.toolbar.show(),this.resize(),e.proxy(t||function(){},this)(),this)},hideToolbar:function(t){var i=this.settings;return i.toolbar=!1,this.toolbar.hide(),this.resize(),e.proxy(t||function(){},this)(),this},setToolbarAutoFixed:function(t){var i=this.state,o=this.editor,r=this.toolbar,n=this.settings;"undefined"!=typeof t&&(n.toolbarAutoFixed=t);var a=function(){var t=e(window),i=t.scrollTop();return n.toolbarAutoFixed?void r.css(i-o.offset().top>10&&i
                  ';i.append(n),r=this.toolbar=i.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var a="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?t.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=a.length;d>h;h++){var u=a[h];if("||"===u)c=!0;else if("|"===u)l+='
                • |
                • ';else{var f=/h(\d)/.test(u),g=u;"watch"!==u||e.watch||(g="unwatch");var p=e.lang.toolbar[g],m=e.toolbarIconTexts[g],w=e.toolbarIconsClass[g];p="undefined"==typeof p?"":p,m="undefined"==typeof m?"":m,w="undefined"==typeof w?"":w;var v=c?'
                • ':"
                • ";"undefined"!=typeof e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='',v+=''+(f?u.toUpperCase():""===w?m:"")+"",v+=""),v+="
                • ",l=c?v+l:l+v}}return s.html(l),s.find('[title="Lowercase"]').attr("title",e.lang.toolbar.lowercase),s.find('[title="ucwords"]').attr("title",e.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed(),this},dialogLockScreen:function(){return e.proxy(t.dialogLockScreen,this)(),this},dialogShowMask:function(i){return e.proxy(t.dialogShowMask,this)(i),this},getToolbarHandles:function(e){var i=this.toolbarHandlers=t.toolbarHandlers;return e&&"undefined"!=typeof toolbarIconHandlers[e]?i[e]:i},setToolbarHandler:function(){var i=this,o=this.settings;if(!o.toolbar||o.readOnly)return this;var r=this.toolbar,n=this.cm,a=this.classPrefix,s=this.toolbarIcons=r.find("."+a+"menu > li > a"),l=this.getToolbarHandles();return s.bind(t.mouseOrTouch("click","touchend"),function(t){var r=e(this).children(".fa"),a=r.attr("name"),s=n.getCursor(),c=n.getSelection();return""!==a?(i.activeIcon=r,"undefined"!=typeof l[a]?e.proxy(l[a],i)(n):"undefined"!=typeof o.toolbarHandlers[a]&&e.proxy(o.toolbarHandlers[a],i)(n,r,s,c),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&n.focus(),!1):void 0}),this},createDialog:function(i){return e.proxy(t.createDialog,this)(i)},createInfoDialog:function(){var e=this,i=this.editor,o=this.classPrefix,r=['
                  ','
                  ','

                  '+t.title+"v"+t.version+"

                  ","

                  "+this.lang.description+"

                  ",'

                  '+t.homePage+'

                  ','

                  Copyright © 2015 Pandao, The MIT License.

                  ',"
                  ",'',"
                  "].join("\n");i.append(r);var n=this.infoDialog=i.children("."+o+"dialog-info");return n.find("."+o+"dialog-close").bind(t.mouseOrTouch("click","touchend"),function(){e.hideInfoDialog()}),n.css("border",t.isIE8?"1px solid #ddd":"").css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var t=this.infoDialog,i=function(){t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"})};return i(),e(window).resize(i),this},showInfoDialog:function(){e("html,body").css("overflow-x","hidden");var i=this.editor,o=this.settings,r=this.infoDialog=i.children("."+this.classPrefix+"dialog-info");return r.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:o.dialogMaskOpacity,backgroundColor:o.dialogMaskBgColor}).show(),r.css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return e("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return t.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(e.find(".editormd-dialog").length>0&&e.find(".editormd-dialog").remove(),t.toolbar&&(this.getToolbarHandles(),this.setToolbar())),this.loadedDisplay(!0),this},previewCodeHighlight:function(){var e=this.settings,t=this.previewContainer;return e.previewCodeHighlight&&(t.find("pre").addClass("prettyprint linenums"),"undefined"!=typeof prettyPrint&&prettyPrint()),this},katexRender:function(){return null===i?this:(this.previewContainer.find("."+t.classNames.tex).each(function(){var i=e(this);t.$katex.render(i.text(),i[0]),i.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var i=this,r=this.settings,n=this.previewContainer;if(t.isIE8)return this;if(r.flowChart){if(null===o)return this;n.find(".flowchart").flowChart()}r.sequenceDiagram&&n.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var a=i.preview,s=i.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;a.find(".markdown-toc-list").each(function(){u+=e(this).height()});var f=a.find(".editormd-toc-menu").height();return f=f?f:0,a.scrollTop(0===h?0:h+c>=l[0].scrollHeight-16?a[0].scrollHeight:(a[0].scrollHeight+u+f)*d),this},registerKeyMaps:function(i){var o=this,r=this.cm,n=this.settings,a=t.toolbarHandlers,s=n.disabledKeyMaps;if(i=i||null){for(var l in i)if(e.inArray(l,s)<0){var c={};c[l]=i[l],r.addKeyMap(i)}}else{for(var h in t.keyMaps){var d=t.keyMaps[h],u="string"==typeof d?e.proxy(a[d],o):e.proxy(d,o);if(e.inArray(h,["F9","F10","F11"])<0&&e.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}e(window).keydown(function(t){var i={120:"F9",121:"F10",122:"F11"};if(e.inArray(i[t.keyCode],s)<0)switch(t.keyCode){case 120:return e.proxy(a.watch,o)(),!1;case 121:return e.proxy(a.preview,o)(),!1;case 122:return e.proxy(a.fullscreen,o)(),!1}})}return this},bindScrollEvent:function(){var i=this,o=this.preview,r=this.settings,n=this.codeMirror,a=t.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){n.find(".CodeMirror-scroll").bind(a("scroll","touchmove"),function(t){var n=e(this).height(),a=e(this).scrollTop(),s=a/e(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=e(this).height()});var c=o.find(".editormd-toc-menu").height();c=c?c:0,o.scrollTop(0===a?0:a+n>=e(this)[0].scrollHeight-16?o[0].scrollHeight:(o[0].scrollHeight+l+c)*s),e.proxy(r.onscroll,i)(t)})},l=function(){n.find(".CodeMirror-scroll").unbind(a("scroll","touchmove"))},c=function(){o.bind(a("scroll","touchmove"),function(t){var o=e(this).height(),a=e(this).scrollTop(),s=a/e(this)[0].scrollHeight,l=n.find(".CodeMirror-scroll");l.scrollTop(0===a?0:a+o>=e(this)[0].scrollHeight?l[0].scrollHeight:l[0].scrollHeight*s),e.proxy(r.onpreviewscroll,i)(t)})},h=function(){o.unbind(a("scroll","touchmove"))};return n.bind({mouseover:s,mouseout:l,touchstart:s,touchend:l}),"single"===r.syncScrolling?this:(o.bind({mouseover:c,mouseout:h,touchstart:c,touchend:h}),this)},bindChangeEvent:function(){var e=this,t=this.cm,o=this.settings;return o.syncScrolling?(t.on("change",function(t,r){o.watch&&e.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),i=setTimeout(function(){clearTimeout(i),e.save(),i=null},o.delay)}),this):this},loadedDisplay:function(t){t=t||!1;var i=this,o=this.editor,r=this.preview,n=this.settings;return this.containerMask.hide(),this.save(),n.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),e(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),t||e.proxy(n.onload,this)(),this.state.loaded=!0,this},width:function(e){return this.editor.css("width","number"==typeof e?e+"px":e),this.resize(),this},height:function(e){return this.editor.css("height","number"==typeof e?e+"px":e),this.resize(),this},resize:function(t,i){t=t||null,i=i||null;var o=this.state,r=this.editor,n=this.preview,a=this.toolbar,s=this.settings,l=this.codeMirror;if(t&&r.css("width","number"==typeof t?t+"px":t),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(e(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",a.height()+1).height(r.height()-a.height()):l.css("margin-top",0).height(r.height())):(r.css("height","auto"),l.css("height","auto")),s.watch)if(l.width(r.width()/2),n.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?n.css("top",a.height()+1):n.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-a.height():r.height();n.height(c)}else n.height("");else l.width(r.width()),n.hide();return o.loaded&&e.proxy(s.onresize,this)(),this},save:function(){if(null===i)return this;var r=this,n=this.state,a=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==a.mode&&"markdown"!==a.mode)return this.markdownTextarea.val(l),this;var h=t.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:a.toc,tocm:a.tocm,tocStartLevel:a.tocStartLevel,pageBreak:a.pageBreak,taskList:a.taskList,emoji:a.emoji,tex:a.tex,atLink:a.atLink,emailLink:a.emailLink,flowChart:a.flowChart,sequenceDiagram:a.sequenceDiagram,previewCodeHighlight:a.previewCodeHighlight},f=this.markedOptions={renderer:t.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:a.htmlDecode?!1:!0,smartLists:!0,smartypants:!0};h.setOptions(f);var g=t.$marked(l,f);if(g=t.filterHTMLTags(g,a.htmlDecode),this.markdownTextarea.text(l),s.save(),a.saveHTMLToTextarea&&this.htmlTextarea.text(g),a.watch||!a.watch&&n.preview){if(c.html(g),this.previewCodeHighlight(),a.toc){var p=""===a.tocContainer?c:e(a.tocContainer),m=p.find("."+this.classPrefix+"toc-menu");p.attr("previewContainer",""===a.tocContainer?"true":"false"),""!==a.tocContainer&&m.length>0&&m.remove(),t.markdownToCRenderer(d,p,a.tocDropdown,a.tocStartLevel),(a.tocDropdown||p.find("."+this.classPrefix+"toc-menu").length>0)&&t.tocDropdownMenu(p,""!==a.tocTitle?a.tocTitle:this.lang.tocTitle),""!==a.tocContainer&&c.find(".markdown-toc").css("border","none")}a.tex&&(!t.kaTeXLoaded&&a.autoLoadModules?t.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,r.katexRender()}):(t.$katex=katex,this.katexRender())),(a.flowChart||a.sequenceDiagram)&&(o=setTimeout(function(){clearTimeout(o),r.flowChartAndSequenceDiagramRender(),o=null},10)),n.loaded&&e.proxy(a.onchange,this)()}return this},focus:function(){return this.cm.focus(),this},setCursor:function(e){return this.cm.setCursor(e),this},getCursor:function(){return this.cm.getCursor()},setSelection:function(e,t){return this.cm.setSelection(e,t),this},getSelection:function(){return this.cm.getSelection()},setSelections:function(e){return this.cm.setSelections(e),this},getSelections:function(){return this.cm.getSelections()},replaceSelection:function(e){return this.cm.replaceSelection(e),this},insertValue:function(e){return this.replaceSelection(e),this},appendMarkdown:function(e){var t=(this.settings,this.cm);return t.setValue(t.getValue()+e),this},setMarkdown:function(e){return this.cm.setValue(e||this.settings.markdown),this},getMarkdown:function(){return this.cm.getValue()},getValue:function(){return this.cm.getValue()},setValue:function(e){return this.cm.setValue(e),this},clear:function(){return this.cm.setValue(""),this},getHTML:function(){return this.settings.saveHTMLToTextarea?this.htmlTextarea.val():(alert("Error: settings.saveHTMLToTextarea == false"),!1)},getTextareaSavedHTML:function(){return this.getHTML()},getPreviewedHTML:function(){return this.settings.watch?this.previewContainer.html():(alert("Error: settings.watch == false"),!1)},watch:function(t){var o=this.settings;if(e.inArray(o.mode,["gfm","markdown"])<0)return this;if(this.state.watching=o.watch=!0,this.preview.show(),this.toolbar){var r=o.toolbarIconsClass.watch,n=o.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",o.lang.toolbar.watch),a.removeClass(n).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),i=0,this.save().resize(),o.onwatch||(o.onwatch=t||function(){}),e.proxy(o.onwatch,this)(),this},unwatch:function(t){var i=this.settings;if(this.state.watching=i.watch=!1,this.preview.hide(),this.toolbar){var o=i.toolbarIconsClass.watch,r=i.toolbarIconsClass.unwatch,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",i.lang.toolbar.unwatch),n.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=t||function(){}),e.proxy(i.onunwatch,this)(),this},show:function(t){t=t||function(){};var i=this;return this.editor.show(0,function(){e.proxy(t,i)()}),this},hide:function(t){t=t||function(){};var i=this;return this.editor.hide(0,function(){e.proxy(t,i)()}),this},previewing:function(){var i=this,o=this.editor,r=this.preview,n=this.toolbar,a=this.settings,s=this.codeMirror,l=this.previewContainer;if(e.inArray(a.mode,["gfm","markdown"])<0)return this;a.toolbar&&n&&(n.toggle(),n.find(".fa[name=preview]").toggleClass("active")),s.toggle();var c=function(e){e.shiftKey&&27===e.keyCode&&i.previewed()};"none"===s.css("display")?(this.state.preview=!0,this.state.fullscreen&&r.css("background","#fff"),o.find("."+this.classPrefix+"preview-close-btn").show().bind(t.mouseOrTouch("click","touchend"),function(){i.previewed()}),a.watch?l.css("padding",""):this.save(),l.addClass(this.classPrefix+"preview-active"),r.show().css({position:"",top:0,width:o.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":o.height()}),this.state.loaded&&e.proxy(a.onpreviewing,this)(),e(window).bind("keyup",c)):(e(window).unbind("keyup",c),this.previewed())},previewed:function(){var i=this.editor,o=this.preview,r=this.toolbar,n=this.settings,a=this.previewContainer,s=i.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),n.toolbar&&r.show(),o[n.watch?"show":"hide"](),s.hide().unbind(t.mouseOrTouch("click","touchend")),a.removeClass(this.classPrefix+"preview-active"),n.watch&&a.css("padding","20px"),o.css({background:null,position:"absolute",width:i.width()/2,height:n.autoHeight&&!this.state.fullscreen?"auto":i.height()-r.height(),top:n.toolbar?r.height():0}),this.state.loaded&&e.proxy(n.onpreviewed,this)(),this},fullscreen:function(){var t=this,i=this.state,o=this.editor,r=(this.preview,this.toolbar),n=this.settings,a=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()};return o.hasClass(a)?(e(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,e("html,body").css("overflow","hidden"),o.css({width:e(window).width(),height:e(window).height()}).addClass(a),this.resize(),e.proxy(n.onfullscreen,this)(),e(window).bind("keyup",s)),this},fullscreenExit:function(){var t=this.editor,i=this.settings,o=this.toolbar,r=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,o&&o.find(".fa[name=fullscreen]").parent().removeClass("active"),e("html,body").css("overflow",""),t.css({width:t.data("oldWidth"),height:t.data("oldHeight")}).removeClass(r),this.resize(),e.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(i,o){var r=this,n=this.cm,a=this.settings;return o=a.pluginPath+o,"function"==typeof define?"undefined"==typeof this[i]?(alert("Error: "+i+" plugin is not found, you are not load this plugin."),this):(this[i](n),this):(e.inArray(o,t.loadFiles.plugin)<0?t.loadPlugin(o,function(){t.loadPlugins[i]=r[i],r[i](n)}):e.proxy(t.loadPlugins[i],this)(n),this)},search:function(e){var t=this.settings;return t.searchReplace?(t.readOnly||this.cm.execCommand(e||"find"),this):(alert("Error: settings.searchReplace == false"),this)},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},t.fn.init.prototype=t.fn,t.dialogLockScreen=function(){var t=this.settings||{dialogLockScreen:!0};t.dialogLockScreen&&(e("html,body").css("overflow","hidden"),this.resize())},t.dialogShowMask=function(t){var i=this.editor,o=this.settings||{dialogShowMask:!0};t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(t.css("z-index"))-1).show()},t.toolbarHandlers={undo:function(){this.cm.undo()},redo:function(){this.cm.redo()},bold:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("**"+i+"**"),""===i&&e.setCursor(t.line,t.ch+2)},del:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("~~"+i+"~~"),""===i&&e.setCursor(t.line,t.ch+2)},italic:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("*"+i+"*"),""===i&&e.setCursor(t.line,t.ch+1)},quote:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("> "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("> "+i)},ucfirst:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.firstUpperCase(i)),e.setSelections(o)},ucwords:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.wordsFirstUpperCase(i)),e.setSelections(o)},uppercase:function(){var e=this.cm,t=e.getSelection(),i=e.listSelections();e.replaceSelection(t.toUpperCase()),e.setSelections(i)},lowercase:function(){var e=this.cm,t=(e.getCursor(),e.getSelection()),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("# "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("# "+i)},h2:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0), +e.replaceSelection("## "+i),e.setCursor(t.line,t.ch+3)):e.replaceSelection("## "+i)},h3:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("### "+i),e.setCursor(t.line,t.ch+4)):e.replaceSelection("### "+i)},h4:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("#### "+i),e.setCursor(t.line,t.ch+5)):e.replaceSelection("#### "+i)},h5:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("##### "+i),e.setCursor(t.line,t.ch+6)):e.replaceSelection("##### "+i)},h6:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("###### "+i),e.setCursor(t.line,t.ch+7)):e.replaceSelection("###### "+i)},"list-ul":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;r>o;o++)i[o]=""===i[o]?"":"- "+i[o];e.replaceSelection(i.join("\n"))}},"list-ol":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("1. "+t);else{for(var i=t.split("\n"),o=0,r=i.length;r>o;o++)i[o]=""===i[o]?"":o+1+". "+i[o];e.replaceSelection(i.join("\n"))}},hr:function(){{var e=this.cm,t=e.getCursor();e.getSelection()}e.replaceSelection((0!==t.ch?"\n\n":"\n")+"------------\n\n")},tex:function(){if(!this.settings.tex)return alert("settings.tex === false"),this;var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("$$"+i+"$$"),""===i&&e.setCursor(t.line,t.ch+2)},link:function(){this.executePlugin("linkDialog","link-dialog/link-dialog")},"reference-link":function(){this.executePlugin("referenceLinkDialog","reference-link-dialog/reference-link-dialog")},pagebreak:function(){if(!this.settings.pageBreak)return alert("settings.pageBreak === false"),this;{var e=this.cm;e.getSelection()}e.replaceSelection("\r\n[========]\r\n")},image:function(){this.executePlugin("imageDialog","image-dialog/image-dialog")},code:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("`"+i+"`"),""===i&&e.setCursor(t.line,t.ch+1)},"code-block":function(){this.executePlugin("codeBlockDialog","code-block-dialog/code-block-dialog")},"preformatted-text":function(){this.executePlugin("preformattedTextDialog","preformatted-text-dialog/preformatted-text-dialog")},table:function(){this.executePlugin("tableDialog","table-dialog/table-dialog")},datetime:function(){var e=this.cm,i=(e.getSelection(),new Date,this.settings.lang.name),o=t.dateFormat()+" "+t.dateFormat("zh-cn"===i||"zh-tw"===i?"cn-week-day":"week-day");e.replaceSelection(o)},emoji:function(){this.executePlugin("emojiDialog","emoji-dialog/emoji-dialog")},"html-entities":function(){this.executePlugin("htmlEntitiesDialog","html-entities-dialog/html-entities-dialog")},"goto-line":function(){this.executePlugin("gotoLineDialog","goto-line-dialog/goto-line-dialog")},watch:function(){this[this.settings.watch?"unwatch":"watch"]()},preview:function(){this.previewing()},fullscreen:function(){this.fullscreen()},clear:function(){this.clear()},search:function(){this.search()},help:function(){this.executePlugin("helpDialog","help-dialog/help-dialog")},info:function(){this.showInfoDialog()}},t.keyMaps={"Ctrl-1":"h1","Ctrl-2":"h2","Ctrl-3":"h3","Ctrl-4":"h4","Ctrl-5":"h5","Ctrl-6":"h6","Ctrl-B":"bold","Ctrl-D":"datetime","Ctrl-E":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();return this.settings.emoji?(e.replaceSelection(":"+i+":"),void(""===i&&e.setCursor(t.line,t.ch+1))):void alert("Error: settings.emoji == false")},"Ctrl-Alt-G":"goto-line","Ctrl-H":"hr","Ctrl-I":"italic","Ctrl-K":"code","Ctrl-L":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+1)},"Ctrl-U":"list-ul","Shift-Ctrl-A":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();return this.settings.atLink?(e.replaceSelection("@"+i),void(""===i&&e.setCursor(t.line,t.ch+1))):void alert("Error: settings.atLink == false")},"Shift-Ctrl-C":"code","Shift-Ctrl-Q":"quote","Shift-Ctrl-S":"del","Shift-Ctrl-K":"tex","Shift-Alt-C":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection(["```",i,"```"].join("\n")),""===i&&e.setCursor(t.line,t.ch+3)},"Shift-Ctrl-Alt-C":"code-block","Shift-Ctrl-H":"html-entities","Shift-Alt-H":"help","Shift-Ctrl-E":"emoji","Shift-Ctrl-U":"uppercase","Shift-Alt-U":"ucwords","Shift-Ctrl-Alt-U":"ucfirst","Shift-Alt-L":"lowercase","Shift-Ctrl-I":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("!["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+4)},"Shift-Ctrl-Alt-I":"image","Shift-Ctrl-L":"link","Shift-Ctrl-O":"list-ol","Shift-Ctrl-P":"preformatted-text","Shift-Ctrl-T":"table","Shift-Alt-P":"pagebreak",F9:"watch",F10:"preview",F11:"fullscreen"};var r=function(e){return String.prototype.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};t.trim=r;var n=function(e){return e.toLowerCase().replace(/\b(\w)|\s(\w)/g,function(e){return e.toUpperCase()})};t.ucwords=t.wordsFirstUpperCase=n;var a=function(e){return e.toLowerCase().replace(/\b(\w)/,function(e){return e.toUpperCase()})};return t.firstUpperCase=t.ucfirst=a,t.urls={atLinkBase:"https://github.com/"},t.regexs={atLink:/@(\w+)/g,email:/(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,emailLink:/(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,emoji:/:([\w\+-]+):/g,emojiDatetime:/(\d{2}:\d{2}:\d{2})/g,twemoji:/:(tw-([\w]+)-?(\w+)?):/g,fontAwesome:/:(fa-([\w]+)(-(\w+)){0,}):/g,editormdLogo:/:(editormd-logo-?(\w+)?):/g,pageBreak:/^\[[=]{8,}\]$/},t.emoji={path:"http://www.emoji-cheat-sheet.com/graphics/emojis/",ext:".png"},t.twemoji={path:"http://twemoji.maxcdn.com/36x36/",ext:".png"},t.markedRenderer=function(i,o){var n={toc:!0,tocm:!1,tocStartLevel:1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1},a=e.extend(n,o||{}),s=t.$marked,l=new s.Renderer;i=i||[];var c=t.regexs,h=c.atLink,d=c.emoji,u=c.email,f=c.emailLink,g=c.twemoji,p=c.fontAwesome,m=c.editormdLogo,w=c.pageBreak;return l.emoji=function(e){e=e.replace(t.regexs.emojiDatetime,function(e){return e.replace(/:/g,":")});var i=e.match(d);if(!i||!a.emoji)return e;for(var o=0,r=i.length;r>o;o++)":+1:"===i[o]&&(i[o]=":\\+1:"),e=e.replace(new RegExp(i[o]),function(e,i){var o=e.match(p),r=e.replace(/:/g,"");if(o)for(var n=0,a=o.length;a>n;n++){var s=o[n].replace(/:/g,"");return''}else{var l=e.match(m),c=e.match(g);if(l)for(var h=0,d=l.length;d>h;h++){var u=l[h].replace(/:/g,"");return''}else{if(!c){var f="+1"===r?"plus1":r;return f="black_large_square"===f?"black_square":f,f="moon"===f?"waxing_gibbous_moon":f,':'+r+':'}for(var w=0,v=c.length;v>w;w++){var k=c[w].replace(/:/g,"").replace("tw-","");return'twemoji-'+k+''}}}});return e},l.atLink=function(i){return h.test(i)?(a.atLink&&(i=i.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(h,function(e,i){return''+e+""}).replace(/_#_@_#_/g,"@")),a.emailLink&&(i=i.replace(f,function(t,i,o,r,n){return!i&&e.inArray(n,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?''+t+"":t})),i):i},l.link=function(e,t,i){if(this.options.sanitize){try{var o=decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(r){return""}if(0===o.indexOf("javascript:"))return""}var n=''+i.replace(/@/g,"@")+""):(t&&(n+=' title="'+t+'"'),n+=">"+i+"")},l.heading=function(e,t,o){var n=e,a=/\s*\]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var s=[];e=e.split(/\]+)\>([^\>]*)\<\/a\>/);for(var l=0,c=e.length;c>l;l++)s.push(e[l].replace(/\s*href\=\"(.*)\"\s*/g,""));e=s.join(" ")}e=r(e);var h=e.toLowerCase().replace(/[^\w]+/g,"-"),d={text:e,level:t,slug:h},u=/^[\u4e00-\u9fa5]+$/.test(e),f=u?escape(e).replace(/\%/g,""):e.toLowerCase().replace(/[^\w]+/g,"-");i.push(d);var g="';return g+='',g+='',g+=this.atLink(a?this.emoji(n):this.emoji(e)),g+=""},l.pageBreak=function(e){return w.test(e)&&a.pageBreak&&(e='
                  '),e},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",n=a.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return''+i.replace(/\$/g,"")+""}):o?e.replace(/\$/g,""):e;var l='
                  '+e+"
                  ";return n?s?'
                  '+l+"

                  ":l:w.test(e)?this.pageBreak(e):""+this.atLink(this.emoji(e))+"

                  \n"},l.code=function(e,i,o){return"seq"===i||"sequence"===i?'
                  '+e+"
                  ":"flow"===i?'
                  '+e+"
                  ":"math"===i||"latex"===i||"katex"===i?'

                  '+e+"

                  ":s.Renderer.prototype.code.apply(this,arguments)},l.tablecell=function(e,t){var i=t.header?"th":"td",o=t.align?"<"+i+' style="text-align:'+t.align+'">':"<"+i+">";return o+this.atLink(this.emoji(e))+"\n"},l.listitem=function(e){return a.taskList&&/^\s*\[[x\s]\]\s*/.test(e)?(e=e.replace(/^\s*\[\s\]\s*/,' ').replace(/^\s*\[x\]\s*/,' '),'
                • '+this.atLink(this.emoji(e))+"
                • "):"
                • "+this.atLink(this.emoji(e))+"
                • "},l},t.markdownToCRenderer=function(e,t,i,o){var r="",n=0,a=this.classPrefix;o=o||1;for(var s=0,l=e.length;l>s;s++){var c=e[s].text,h=e[s].level;o>h||(r+=h>n?"":n>h?new Array(n-h+2).join("
              • "):"",r+='
              • '+c+"