ciyunPrint.html 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Access-Control-Allow-Origin" content="*">
  5. <meta charset="utf-8" />
  6. <title>词云</title>
  7. <link rel="stylesheet" href="./layui/css/layui.css">
  8. <script src="./js/jquery-1.11.3.js"></script>
  9. <script type="text/javascript" src="./js/saveSvgAsPng.js"></script>
  10. <script type="text/javascript" src="./layer/layer.js"></script>
  11. <script type="text/javascript" src="./layui/layui.js"></script>
  12. <link rel="stylesheet" href="./css/common.css">
  13. <link rel="stylesheet" href="./css/jiaocai.css">
  14. <link rel="stylesheet" href="./css/font/font.css">
  15. <script src="../config.js"></script>
  16. <style type="text/css">
  17. body,
  18. html {
  19. min-width: 870px;
  20. }
  21. #stop:hover {
  22. text-decoration: underline;
  23. color: #FF0000;
  24. }
  25. .shadow {
  26. position: absolute;
  27. width: 100%;
  28. height: 100%;
  29. left: 0;
  30. top: 0;
  31. background: rgba(0, 0, 0, 0.3);
  32. }
  33. .stop_word_table {
  34. width: 413px;
  35. position: fixed;
  36. top: 5%;
  37. left: 37%;
  38. background: #FFFFFF;
  39. border: 1px solid rgba(0, 0, 0, 0.1);
  40. padding: 24px;
  41. }
  42. .stop_word_table .title {
  43. display: flex;
  44. justify-content: space-between;
  45. align-items: center;
  46. font-weight: bold;
  47. font-size: 16px;
  48. color: #000000;
  49. padding-bottom: 16px;
  50. border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  51. }
  52. .stop_word_table .title img {
  53. width: 24px;
  54. height: 24px;
  55. cursor: pointer;
  56. }
  57. .stop_word_table .top {
  58. display: flex;
  59. align-items: center;
  60. margin-top: 16px;
  61. }
  62. .stop_word_table .top input {
  63. width: 278px;
  64. height: 40px;
  65. border: 1px solid #000000;
  66. outline: none;
  67. }
  68. .stop_word_table .top button {
  69. width: 87px;
  70. height: 40px;
  71. background: #000000;
  72. text-align: center;
  73. font-weight: bold;
  74. font-size: 16px;
  75. line-height: 40px;
  76. color: #ffffff;
  77. cursor: pointer;
  78. border: none;
  79. }
  80. .stop_word_table .main {
  81. margin-top: 16px;
  82. max-height: 340px;
  83. overflow: hidden;
  84. overflow-y: scroll;
  85. }
  86. .stop_word_table .one {
  87. display: flex;
  88. justify-content: space-between;
  89. font-size: 16px;
  90. color: #000000;
  91. height: 34px;
  92. line-height: 34px;
  93. padding: 0 8px;
  94. }
  95. .stop_word_table .right span {
  96. cursor: pointer;
  97. }
  98. .stop_word_table .main> :nth-child(2n) {
  99. background: #ffffff;
  100. }
  101. .stop_word_table .main> :nth-child(2n-1) {
  102. background: #f8f8f8;
  103. }
  104. .stop_word_table .bottom {
  105. display: flex;
  106. justify-content: space-between;
  107. margin-top: 16px;
  108. }
  109. .stop_word_table .bottom button {
  110. width: 173.5px;
  111. height: 48px;
  112. font-weight: bold;
  113. font-size: 16px;
  114. border: none;
  115. cursor: pointer;
  116. }
  117. .stop_word_table .bottom .close {
  118. background: #ebebeb;
  119. color: #000000;
  120. }
  121. .stop_word_table .bottom .add {
  122. background: #000000;
  123. color: #ffffff;
  124. }
  125. </style>
  126. </head>
  127. <body>
  128. <div class="wraps">
  129. <div class="contents">
  130. <div class="content-inner" style="padding: 0;width: 870px;">
  131. <div class="cloudDiv">
  132. <!-- <div class="cloud-copyright">Copyright © Jason Davies</div> -->
  133. <div class="cloud-con-div" id="cloudDiv"></div>
  134. </div>
  135. <form id="form" style="height: 0;overflow: hidden;">
  136. <div class="cloud-box">
  137. <!-- <div class="cloud-rule clear">
  138. <div class="rule-item fl">
  139. <p class="fl">规则:</p>
  140. <input type="text" hidden="" id="rule" value="1">
  141. <div class="rule-radio rule fl">
  142. <div name="radio" class="radio-con fl ruleType radio-active" value='1'><i
  143. class="radio-icon fl"></i>主题性
  144. </div>
  145. <div name="radio" class="radio-con fl ruleType" value='2'><i
  146. class="radio-icon fl"></i>频次</div>
  147. </div>
  148. </div>
  149. <div class="rule-item fl">
  150. <p class="fl">数据类型:</p>
  151. <input type="text" hidden="" id="dataType" value="Word">
  152. <select name="selectDataType" class="selectOp fl" id="dataTypeSel">
  153. <option value="Word">Word</option>
  154. <option value="Lemma">Lemma</option>
  155. </select>
  156. </div>
  157. <div class="rule-item fl">
  158. <div class="checkbox-con fl biglittle" style="margin-right: 0px;"><i
  159. class="checkbox-icon fl"></i></div>
  160. <div class="checkbox-con fl stopWordList"><span id="biglittle"
  161. style="color: #0079FF;">区分大小写</span></div>
  162. </div>
  163. </div> -->
  164. <div class="cloud-rule clear" style="border:0;">
  165. <div class="rule-item fl">
  166. <p class="fl">样式:</p>
  167. <input type="text" hidden="" id="spiral" value="archimedean">
  168. <div class="rule-radio styleType fl">
  169. <div name="radio" class="radio-con radio-active fl" value='archimedean'><i class="radio-icon fl"></i>螺线
  170. </div>
  171. <div name="radio" class="radio-con fl" value='rectangular'><i class="radio-icon fl"></i>矩形</div>
  172. </div>
  173. </div>
  174. <div class="rule-item fl">
  175. <p class="fl">字体:</p>
  176. <!-- 方正书宋 FZSS
  177. 兰亭黑 FZLTH
  178. 方正楷体 FZKT-GBK
  179. 方正拼音 FZPY
  180. -->
  181. <input type="radio" hidden="" id="font" value="">
  182. <select name="selectFont" class="selectOp fl" id="fontSel">
  183. <option value="Impact">Impact</option>
  184. <option value="Georgia">Georgia</option>
  185. <option value="Arial">Arial</option>
  186. <option value="Constantia">Constantia</option>
  187. <option value="Century">Century</option>
  188. <option value="Berlin Sans FB">Berlin Sans FB</option>
  189. <option value="Cooper Black">Cooper Black</option>
  190. <option value="Elephant">Elephant</option>
  191. <option value="FZSS">方正书宋</option>
  192. <option value="FZLTH">方正兰亭黑</option>
  193. <option value="FZKT-GBK">方正楷体</option>
  194. <option value="FZPY">方正拼音</option>
  195. </select>
  196. </div>
  197. <div class="rule-item fl">
  198. <p class="fl">文字方向:</p>
  199. <input type="text" hidden="" id="fontdir" value="1">
  200. <div class="rule-radio fontDriect fl">
  201. <div name="orientations" class="radio-con radio-active fl" value='1'><i class="radio-icon fl"></i>水平
  202. </div>
  203. <div name="orientations" class="radio-con fl" value='2'><i class="radio-icon fl"></i>垂直</div>
  204. <div name="orientations" class="radio-con fl" value='3'><i class="radio-icon fl"></i>垂直和水平</div>
  205. </div>
  206. </div>
  207. <!-- <div class="rule-item fl">
  208. <p class="fl">单位:</p>
  209. <input type="text" hidden="" id="danwei" value="zi">
  210. <div class="rule-radio danwei fl">
  211. <div name="danwei" class="radio-con radio-active fl" value='zi'><i class="radio-icon fl"></i>字
  212. </div>
  213. <div name="danwei" class="radio-con fl" value='ci'><i class="radio-icon fl"></i>词
  214. </div>
  215. </div>
  216. </div> -->
  217. <div id="angles" style="float: left" hidden="">
  218. <p>
  219. <input type="number" id="angle-count" value="5" min="1"><label for="angle-count">
  220. <font style="vertical-align: inherit;"></font>
  221. </label>
  222. <font style="vertical-align: inherit;"><label for="angle-from">
  223. <font style="vertical-align: inherit;">来自的</font>
  224. </label><label for="angle-count">
  225. <font style="vertical-align: inherit;">方向</font>
  226. </label></font><label for="angle-from">
  227. <font style="vertical-align: inherit;"></font>
  228. </label><input type="number" id="angle-from" value="0" min="-90" max="90">
  229. <font style="vertical-align: inherit;">
  230. <font style="vertical-align: inherit;">°
  231. </font>
  232. </font><label for="angle-to">
  233. <font style="vertical-align: inherit;">
  234. <font style="vertical-align: inherit;">到</font>
  235. </font>
  236. </label><input type="number" id="angle-to" value="0" min="-90" max="90">
  237. <font style="vertical-align: inherit;">
  238. <font style="vertical-align: inherit;"> °
  239. </font>
  240. </font>
  241. </p>
  242. </div>
  243. <div class="rule-item fl">
  244. <p class="fl">缩放:</p>
  245. <input type="text" hidden="" id="scale" value="sqrt">
  246. <div class="rule-radio scaleSel fl">
  247. <div name="radio" class="radio-con fl" value="log"><i class="radio-icon fl"></i>log n
  248. </div>
  249. <div name="radio" class="radio-con radio-active fl" value="sqrt"><i class="radio-icon fl"></i>✓n</div>
  250. <div name="radio" class="radio-con fl" value="linear"><i class="radio-icon fl"></i>n
  251. </div>
  252. </div>
  253. </div>
  254. <div class="rule-item fl">
  255. <p class="fl">下载:</p>
  256. <div class="download-type fl">
  257. <span class="dType" id="download-svg">SVG</span>
  258. <span class="line2">|</span>
  259. <span class="dType" id="download-png">PNG</span>
  260. </div>
  261. </div>
  262. <div class="rule-item fl">
  263. <!-- <div class="checkbox-con checkbox-active fl hide"><i class="checkbox-icon fl"></i>区分大小写 -->
  264. <!-- </div> -->
  265. <div class="checkbox-con fl stop" style="margin-right: 0px;"><i class="checkbox-icon fl"></i></div>
  266. <div class="checkbox-con fl stopWordList"><span id="stop" style="color: #0079FF;">停用词表</span></div>
  267. </div>
  268. </div>
  269. <textarea rows="" cols="" id="text" name="text" hidden=""></textarea>
  270. </div>
  271. <div class="cloud-footer">
  272. <button class="produce" type="submit" id="go">生成</button>
  273. </div>
  274. </form>
  275. </div>
  276. </div>
  277. <div class="shadow" id="shadow" style="display: none;">
  278. <div class="stop_word_table" id="wordTable">
  279. <div class="title">
  280. <span>停用词表</span>
  281. <img id="closeWord" src="./img/close.png" alt="">
  282. </div>
  283. <div class="top">
  284. <input type="" name="" value="" id="wordContent" />
  285. <button id="seekWordBtn">检索</button>
  286. </div>
  287. <p style="text-align: right; margin-top: 16px; font-size: 16px; color: #000000">
  288. 共
  289. <span id="allwordnumber"></span> 词
  290. </p>
  291. <div class="main" id="stop_word_table">
  292. <!-- <div class="one">
  293. <div>{{ item }}</div>
  294. <div class="right">
  295. <span style="margin-right: 24px" @click="edit(item)">编辑</span>
  296. <span @click="deleteOne(item, i)">删除</span>
  297. </div>
  298. </div> -->
  299. </div>
  300. <div class="bottom">
  301. <button class="close" id="emptyWord">清空</button>
  302. <button class="add" id="addWord">添加</button>
  303. </div>
  304. </div>
  305. <div class="stop_word_table" id="addwordDom" style="display: none;">
  306. <div class="title">
  307. <span>添加</span>
  308. <img id="closeWordadd" src="./img/close.png" alt="">
  309. </div>
  310. <div class="top">
  311. <input style="width: 100%;" type="" name="" value="" id="addwordContent" />
  312. </div>
  313. <div class="bottom">
  314. <button class="close" id="canceladd">取消</button>
  315. <button class="add" id="addSubmit">确定</button>
  316. </div>
  317. </div>
  318. <div class="stop_word_table" id="editwordDom" style="display: none;">
  319. <div class="title">
  320. <span>添加</span>
  321. <img id="closeWordedit" src="./img/close.png" alt="">
  322. </div>
  323. <div class="top">
  324. <input style="width: 100%;" type="" name="" value="" id="editwordContent" />
  325. </div>
  326. <div class="bottom">
  327. <button class="close" id="canceledit">取消</button>
  328. <button class="add" id="editSubmit">确定</button>
  329. </div>
  330. </div>
  331. </div>
  332. </div>
  333. <script src="./js/d3.min.js"></script>
  334. <script src="./js/cloud.min.js"></script>
  335. <script type="text/javascript">
  336. var stopWordList = null;
  337. var oldstopWordList = [];
  338. $(function() {
  339. initStopWords();
  340. jiekouData();
  341. })
  342. let query = location.href.split("?");
  343. let arr = query[1].split("&");
  344. var articleId = null;
  345. var searchType = null;
  346. var old_searchType = null
  347. var W_stopWordStatus = null
  348. var prefix = 'HM21St_User_Token='
  349. var start = document.cookie.indexOf(prefix)
  350. var end = document.cookie.indexOf(";", start + prefix.length)
  351. if (end == -1) {
  352. end = document.cookie.length;
  353. }
  354. var AccessToken = JSON.parse(unescape(document.cookie.substring(start + prefix.length, end))).access_token
  355. arr.forEach((item) => {
  356. if (item.split("=")[0] == "articleId") {
  357. articleId = item.split("=")[1];
  358. }
  359. if (item.split("=")[0] == "searchType") {
  360. searchType = item.split("=")[1];
  361. old_searchType = item.split("=")[1];
  362. }
  363. });
  364. // 如果是词汇 默认选中词
  365. if (old_searchType == 2) {
  366. $(".danwei div").removeClass("radio-active");
  367. $(".danwei").find("div").eq(1).addClass("radio-active")
  368. }
  369. if (old_searchType == 0) {
  370. $("#font").attr("value", "Arial");
  371. $(".danwei div").removeClass("radio-active");
  372. searchType = 3
  373. $(".danwei").find("div").eq(1).addClass("radio-active")
  374. for (let i = 0; i < $("#fontSel").children().length; i++) {
  375. if ($("#fontSel").children().eq(i)[0].value == "Arial") {
  376. $("#fontSel").children().eq(i)[0].selected = true;
  377. } else {
  378. $("#fontSel").children().eq(i)[0].selected = false;
  379. }
  380. }
  381. } else {
  382. $("#font").attr("value", "Arial");
  383. for (let i = 0; i < $("#fontSel").children().length; i++) {
  384. if ($("#fontSel").children().eq(i)[0].value == "Arial") {
  385. $("#fontSel").children().eq(i)[0].selected = true;
  386. } else {
  387. $("#fontSel").children().eq(i)[0].selected = false;
  388. }
  389. }
  390. }
  391. function getdata() {
  392. let data = {
  393. type: 0,
  394. id: articleId,
  395. stopWordStatus: W_stopWordStatus,
  396. }
  397. $.ajax({
  398. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud?AccessToken=" + AccessToken,
  399. // url: "/i21st-newspaper-management-test/api/article/detail/wordCloud",
  400. data: JSON.stringify(data),
  401. contentType: "application/json",
  402. dataType: "json",
  403. type: "post",
  404. success: function(res) {
  405. let str = ''
  406. res.data.forEach(item => {
  407. if (item.word.indexOf(" ") != -1) {
  408. item.word = item.word.replace(" ", "")
  409. }
  410. str += item.word + " "
  411. })
  412. ciyunData = res.data
  413. text = str
  414. $("#text").val(text);
  415. $("#go").trigger("click");
  416. console.log("2022-11-09 14点55分");
  417. }
  418. })
  419. }
  420. function initContent() {
  421. var dataType = $("#dataType").val();
  422. var ruleType = $("#rule").val();
  423. var fileId = "${fileId}";
  424. // $.ajax({
  425. // url: "${ctx}/bc/textKeyWords/wordCloud",
  426. // data: { "fileId": fileId, "ruleType": ruleType },
  427. // dataType: "JSON",
  428. // Type: "POST",
  429. // success: function (data) {
  430. let data = {
  431. count: 0,
  432. flag: true,
  433. jsonObject: null,
  434. listStr: [{
  435. frequency: 3,
  436. level: "L1",
  437. posStr: "[\"noun\"]",
  438. rate: "2762.15",
  439. word: "mine",
  440. }, {
  441. frequency: 2,
  442. level: "L0",
  443. posStr: "[\"adj\"]",
  444. rate: "996.51",
  445. word: "nice",
  446. }, {
  447. frequency: 3,
  448. level: "L0",
  449. posStr: "[\"noun\"]",
  450. rate: "340.09",
  451. word: "house",
  452. }, {
  453. frequency: 2,
  454. level: "L0",
  455. posStr: "[\"noun\"]",
  456. rate: "251.11",
  457. word: "friend",
  458. }],
  459. message: null,
  460. objects: null,
  461. userList: null,
  462. arr: ['5', '6', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'a', 'Hi', 'Is', 'It', 'My', 'am', 'is', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'my', 'my', 'my', 'my', 'my', 'my', 'Are', 'She', 'are', 'big', 'you', 'you', 'you', 'you', 'you', 'They', 'This', 'mine', 'mine', 'mine', 'name', 'nice', 'tall', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'very', 'very', 'very', 'very', 'you', 'you', 'you', 'you', 'you', 'Giant', 'Kendo', 'These', 'funny', 'house', 'house', 'house', 'nicer', 'think', 'think', 'three', 'yours', 'yours', 'yours', 'bigger', 'meters', 'school', 'school', 'taller', 'friends', 'funnier', 'teacher', 'teacher', 'younger', 'friendly', 'nineteen', 'friendlier', 'qinpeng']
  463. }
  464. if (data.flag) {
  465. var $stop = $(".stop");
  466. var stopFlag = $stop.hasClass("checkbox-active"); //选择了停用
  467. // if (!stopFlag) {
  468. // stopWordLists = null;
  469. // }
  470. // if (ruleType == 1) {
  471. // var themeList = data.listStr;
  472. // text = themeDeal(themeList, stopWordLists);
  473. // } else {
  474. // var object = data.jsonObject;
  475. // var words = "";
  476. // if (dataType == "Word") {
  477. // words = object['wordList'];
  478. // } else {
  479. // words = object['lemmaList'];
  480. // }
  481. let str = ''
  482. data.arr.forEach(item => {
  483. str += item + " "
  484. })
  485. // text = replaceStop(words, stopWordLists);
  486. // }
  487. text = str
  488. $("#text").val(text);
  489. $("#go").trigger("click");
  490. } else {
  491. layer.alert(data.message);
  492. }
  493. // }, error: function (jqXHR, textStatus, errorThrown) {
  494. // if (jqXHR.status == 401) {
  495. // var url = jqXHR.responseText;
  496. // layer.alert('会话已过期,请重新登陆。', function (index) {
  497. // layer.close(index);
  498. // location.reload();
  499. // });
  500. // } else {
  501. // layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  502. // }
  503. // }
  504. // })
  505. }
  506. function initStopWords() {
  507. $.ajax({
  508. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud_stopWordList?AccessToken=" + AccessToken,
  509. // url: "/i21st-newspaper-management-test/api/user/stopVocab/get",
  510. data: JSON.stringify({}),
  511. contentType: "application/json;charset=UTF-8",
  512. dataType: "json",
  513. type: "post",
  514. success: function(res) {
  515. let arr = []
  516. res.data.result.forEach(item => {
  517. arr.push(item.word)
  518. })
  519. oldstopWordList = JSON.parse(JSON.stringify(arr))
  520. stopWordList = JSON.parse(JSON.stringify(arr))
  521. $("#allwordnumber").text(oldstopWordList.length)
  522. changeWordData()
  523. },
  524. error: function(jqXHR, textStatus, errorThrown) {
  525. if (jqXHR.status == 401) {
  526. var url = jqXHR.responseText;
  527. layer.alert('会话已过期,请重新登陆。', function(index) {
  528. layer.close(index);
  529. location.reload();
  530. });
  531. } else {
  532. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  533. }
  534. }
  535. });
  536. }
  537. $(".rule div").click(function() {
  538. $(".rule div").removeClass("radio-active");
  539. $(this).addClass("radio-active");
  540. $("#rule").attr("value", $(this).attr("value"))
  541. initContent();
  542. })
  543. $(".styleType div").click(function() {
  544. $(".styleType div").removeClass("radio-active");
  545. $(this).addClass("radio-active");
  546. $("#spiral").attr("value", $(this).attr("value"));
  547. $("#go").trigger("click");
  548. })
  549. // 切换单位
  550. $(".danwei div").click(function() {
  551. $(".danwei div").removeClass("radio-active");
  552. $(this).addClass("radio-active");
  553. var value = $(this).attr("value");
  554. let newvalue = null
  555. if (old_searchType == 0) { //拼音
  556. if (value == 'zi') {
  557. newvalue = 0
  558. } else {
  559. newvalue = 3
  560. }
  561. } else if (old_searchType == 2) {
  562. if (value == 'zi') {
  563. newvalue = 1
  564. } else {
  565. newvalue = 2
  566. }
  567. } else {
  568. if (value == 'zi') {
  569. newvalue = 1
  570. } else {
  571. newvalue = 4
  572. }
  573. }
  574. searchType = newvalue
  575. getdata()
  576. })
  577. $(".fontDriect div").click(function() {
  578. $(".fontDriect div").removeClass("radio-active");
  579. $(this).addClass("radio-active");
  580. var value = $(this).attr("value");
  581. if (value == 1) {
  582. $("#angle-from").val(0);
  583. $("#angle-to").val(0);
  584. $("#angle-count").val(1);
  585. inChange();
  586. $("#go").click();
  587. $("#angles svg").remove();
  588. } else if (value == 2) {
  589. $("#angle-from").val(90)
  590. $("#angle-to").val(90)
  591. $("#angle-count").val(1);
  592. inChange();
  593. $("#go").click();
  594. $("#angles svg").remove();
  595. } else if (value == 3) {
  596. $("#angle-from").val(0)
  597. $("#angle-to").val(90)
  598. $("#angle-count").val(2);
  599. inChange();
  600. $("#go").click();
  601. $("#angles svg").remove();
  602. }
  603. })
  604. $(".scaleSel div").click(function() {
  605. $(".scaleSel div").removeClass("radio-active");
  606. $(this).addClass("radio-active");
  607. var value = $(this).attr("value");
  608. $("#scale").attr("value", value);
  609. $("#go").trigger("click");
  610. })
  611. $("#fontSel").change(function() {
  612. var value = $(this).children('option:selected').val();
  613. $("#font").attr("value", value);
  614. $("#go").trigger("click");
  615. })
  616. $("#download-png").click(function() {
  617. var el = d3.select("#cloudDiv").node().children[0];
  618. saveSvgAsPng(el, "词云.png");
  619. })
  620. // $(".stopWordList").click(function () {
  621. // var openy = layer.open({
  622. // title: '停用词表'
  623. // , title: false
  624. // , content: '${ctx}/bc/textKeyWords/stopWordListHtml?fileId=${fileId}'
  625. // , area: ['440px', '595px']
  626. // , type: 2
  627. // , closeBtn: 0
  628. // });
  629. // initStopWords();
  630. // })
  631. $("#dataTypeSel").change(function() {
  632. var selvalue = $(this).children('option:selected').val();
  633. // var ruleVlue = $("#rule").attr("value");
  634. // $("#dataType").attr("value", selvalue);
  635. // initContent();
  636. jiekouData()
  637. });
  638. $(".stop").click(function() {
  639. var $stop = $(".stop");
  640. if ($stop.hasClass("checkbox-active")) {
  641. $stop.removeClass("checkbox-active");
  642. } else {
  643. $stop.addClass("checkbox-active");
  644. }
  645. jiekouData()
  646. })
  647. $(".biglittle").click(function() {
  648. var $stop = $(".biglittle");
  649. if ($stop.hasClass("checkbox-active")) {
  650. $stop.removeClass("checkbox-active");
  651. } else {
  652. $stop.addClass("checkbox-active");
  653. }
  654. jiekouData()
  655. })
  656. function jiekouData() {
  657. var $biglittle = $(".biglittle");
  658. var $stop = $(".stop");
  659. let isSelectCaseSensitive = false
  660. let isSelectLemma = false
  661. let stopWordStatus = false
  662. if ($biglittle.hasClass("checkbox-active")) {
  663. isSelectCaseSensitive = true
  664. } else {
  665. isSelectCaseSensitive = false
  666. }
  667. if ($stop.hasClass("checkbox-active")) {
  668. stopWordStatus = 1
  669. } else {
  670. stopWordStatus = 0
  671. }
  672. var selvalue = $("#dataTypeSel").children('option:selected').val();
  673. if (selvalue == 'Lemma') {
  674. isSelectLemma = true;
  675. } else {
  676. isSelectLemma = false;
  677. }
  678. W_stopWordStatus = stopWordStatus
  679. getdata()
  680. }
  681. function replaceStop(words, stopWordList) {
  682. var text = "";
  683. var wordListLow = new Array();
  684. if (stopWordList != null) {
  685. for (var i = 0; i < stopWordList.length; i++) {
  686. wordListLow.push(stopWordList[i].toLowerCase());
  687. }
  688. }
  689. for (var i = 0; i < words.length; i++) {
  690. var wordList = words[i];
  691. var word = wordList[0];
  692. var count = wordList[1];
  693. if (wordListLow.indexOf(word) < 0) {
  694. for (var j = 0; j < count; j++) {
  695. text += word + " ";
  696. }
  697. }
  698. }
  699. return text;
  700. }
  701. function themeDeal(theme, stopWordList) {
  702. var text = "";
  703. var wordListLow = new Array();
  704. if (stopWordList != null) {
  705. for (var i = 0; i < stopWordList.length; i++) {
  706. wordListLow.push(stopWordList[i].toLowerCase());
  707. }
  708. }
  709. for (var i = 0; i < theme.length; i++) {
  710. var themeWord = theme[i];
  711. var word = themeWord['word'];
  712. var flag = false;
  713. if (wordListLow.indexOf(word.toLowerCase()) > -1) {
  714. flag = true;
  715. }
  716. if (!flag) {
  717. var rate = Math.round(themeWord['rate']);
  718. for (var j = 0; j < rate; j++) {
  719. text += word + " ";
  720. }
  721. }
  722. }
  723. return text;
  724. }
  725. // 停用词表
  726. $("#stop").click(function() {
  727. $("#shadow").show()
  728. changeWordData()
  729. })
  730. // 处理词表数据
  731. var editOldVal = ""
  732. function changeWordData(msg, arr) {
  733. if (arr) {
  734. stopWordList = JSON.parse(JSON.stringify(arr));
  735. } else {
  736. stopWordList = JSON.parse(JSON.stringify(oldstopWordList));
  737. }
  738. $("#stop_word_table").empty()
  739. for (let i = 0; i < stopWordList.length; i++) {
  740. let node = ` <div class="one">
  741. <div>${stopWordList[i]}</div>
  742. <div class="right">
  743. <span style="margin-right: 24px" id="edit${i}" @click="edit(item)">编辑</span>
  744. <span @click="deleteOne(item, i)" id="delete${i}">删除</span>
  745. </div>
  746. </div>`
  747. $("#stop_word_table").append(node)
  748. $(`#edit${i}`).click(function() {
  749. $("#editwordDom").show()
  750. $("#wordTable").hide()
  751. $("#editwordContent").val(stopWordList[i])
  752. editOldVal = stopWordList[i]
  753. })
  754. $(`#delete${i}`).click(function() {
  755. oldstopWordList.forEach((item, i) => {
  756. if (stopWordList[i] == item) {
  757. oldstopWordList.splice(i, 1)
  758. }
  759. })
  760. updatawordData()
  761. })
  762. }
  763. if (msg) {
  764. layer.msg("成功")
  765. }
  766. }
  767. function updatawordData() {
  768. let userStopVocab = JSON.parse(JSON.stringify(oldstopWordList));
  769. $.ajax({
  770. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud_stopWordSave?AccessToken=" + AccessToken,
  771. // url: "/i21st-newspaper-management-test/api/user/stopVocab/update",
  772. data: JSON.stringify({
  773. tenantId: "",
  774. wordList: userStopVocab
  775. }),
  776. contentType: "application/json;charset=UTF-8",
  777. dataType: "json",
  778. type: "post",
  779. success: function(data) {
  780. let val = $("#wordContent").val()
  781. if (val != "") {
  782. $("#seekWordBtn").click()
  783. } else {
  784. changeWordData("msg")
  785. }
  786. },
  787. error: function(jqXHR, textStatus, errorThrown) {
  788. if (jqXHR.status == 401) {
  789. var url = jqXHR.responseText;
  790. layer.alert('会话已过期,请重新登陆。', function(index) {
  791. layer.close(index);
  792. location.reload();
  793. });
  794. } else {
  795. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  796. }
  797. }
  798. })
  799. }
  800. // 搜索
  801. $("#seekWordBtn").click(function() {
  802. let val = $("#wordContent").val()
  803. let arr = []
  804. if (val == "") {
  805. stopWordList = JSON.parse(JSON.stringify(oldstopWordList))
  806. changeWordData("msg")
  807. } else {
  808. oldstopWordList.forEach((item, i) => {
  809. if (item.indexOf(val) != -1) {
  810. arr.push(item);
  811. }
  812. })
  813. // stopWordList = JSON.parse(JSON.stringify(arr))
  814. changeWordData("msg", arr)
  815. }
  816. })
  817. // 清空
  818. $("#emptyWord").click(function() {
  819. oldstopWordList = []
  820. updatawordData()
  821. })
  822. // 关闭
  823. $("#closeWord").click(function() {
  824. $("#shadow").hide()
  825. getdata()
  826. })
  827. // 新增 addWord
  828. $("#addWord").click(function() {
  829. $("#addwordDom").show()
  830. $("#wordTable").hide()
  831. $("#addwordContent").val("")
  832. })
  833. // 确定新增 addSubmit
  834. $("#addSubmit").click(function() {
  835. let val = $("#addwordContent").val()
  836. if (val == '') {
  837. layer.msg("请输入内容")
  838. return
  839. } else {
  840. let flag = false;
  841. oldstopWordList.forEach(item => {
  842. if (item == val) {
  843. flag = true
  844. }
  845. })
  846. if (flag) {
  847. layer.msg("该词已经存在,请勿重复添加")
  848. return
  849. }
  850. oldstopWordList.unshift(val)
  851. stopWordList.unshift(val)
  852. $("#wordTable").show()
  853. $("#addwordDom").hide()
  854. updatawordData()
  855. }
  856. })
  857. // 确定修改
  858. $('#editSubmit').click(function() {
  859. let val = $("#editwordContent").val()
  860. if (val == '') {
  861. layer.msg("请输入内容")
  862. return
  863. } else {
  864. let flag = false;
  865. oldstopWordList.forEach(item => {
  866. if (item == val) {
  867. flag = true
  868. }
  869. })
  870. if (flag) {
  871. layer.msg("该词已经存在,请勿重复添加")
  872. return
  873. }
  874. let arr = JSON.parse(JSON.stringify(oldstopWordList))
  875. let index = null
  876. arr.forEach((item, i) => {
  877. if (item == editOldVal) {
  878. index = i
  879. }
  880. })
  881. arr[index] = val
  882. oldstopWordList = JSON.parse(JSON.stringify(arr))
  883. stopWordList = JSON.parse(JSON.stringify(arr))
  884. $("#wordTable").show()
  885. $("#editwordDom").hide()
  886. updatawordData()
  887. }
  888. })
  889. // 关闭新增词
  890. $("#closeWordadd").click(function() {
  891. $("#wordTable").show()
  892. $("#addwordDom").hide()
  893. })
  894. $("#canceladd").click(function() {
  895. $("#wordTable").show()
  896. $("#addwordDom").hide()
  897. })
  898. // 关闭编辑
  899. $("#closeWordedit").click(function() {
  900. $("#wordTable").show()
  901. $("#editwordDom").hide()
  902. })
  903. $("#canceledit").click(function() {
  904. $("#wordTable").show()
  905. $("#editwordDom").hide()
  906. })
  907. </script>
  908. </body>
  909. </html>