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. <span id="allwordnumber"></span> 词
  289. </p>
  290. <div class="main" id="stop_word_table">
  291. <!-- <div class="one">
  292. <div>{{ item }}</div>
  293. <div class="right">
  294. <span style="margin-right: 24px" @click="edit(item)">编辑</span>
  295. <span @click="deleteOne(item, i)">删除</span>
  296. </div>
  297. </div> -->
  298. </div>
  299. <div class="bottom">
  300. <button class="close" id="emptyWord">清空</button>
  301. <button class="add" id="addWord">添加</button>
  302. </div>
  303. </div>
  304. <div class="stop_word_table" id="addwordDom" style="display: none;">
  305. <div class="title">
  306. <span>添加</span>
  307. <img id="closeWordadd" src="./img/close.png" alt="">
  308. </div>
  309. <div class="top">
  310. <input style="width: 100%;" type="" name="" value="" id="addwordContent" />
  311. </div>
  312. <div class="bottom">
  313. <button class="close" id="canceladd">取消</button>
  314. <button class="add" id="addSubmit">确定</button>
  315. </div>
  316. </div>
  317. <div class="stop_word_table" id="editwordDom" style="display: none;">
  318. <div class="title">
  319. <span>添加</span>
  320. <img id="closeWordedit" src="./img/close.png" alt="">
  321. </div>
  322. <div class="top">
  323. <input style="width: 100%;" type="" name="" value="" id="editwordContent" />
  324. </div>
  325. <div class="bottom">
  326. <button class="close" id="canceledit">取消</button>
  327. <button class="add" id="editSubmit">确定</button>
  328. </div>
  329. </div>
  330. </div>
  331. </div>
  332. <script src="./js/d3.min.js"></script>
  333. <script src="./js/cloud.min.js"></script>
  334. <script type="text/javascript">
  335. var stopWordList = null;
  336. var oldstopWordList = [];
  337. $(function() {
  338. initStopWords();
  339. jiekouData();
  340. })
  341. let query = location.href.split("?");
  342. let arr = query[1].split("&");
  343. var articleId = null;
  344. var searchType = null;
  345. var old_searchType = null
  346. var W_stopWordStatus = null
  347. var prefix = 'HM21St_User_Token='
  348. var start = document.cookie.indexOf(prefix)
  349. var end = document.cookie.indexOf(";", start + prefix.length)
  350. if (end == -1) {
  351. end = document.cookie.length;
  352. }
  353. var AccessToken = JSON.parse(unescape(document.cookie.substring(start + prefix.length, end))).access_token
  354. arr.forEach((item) => {
  355. if (item.split("=")[0] == "articleId") {
  356. articleId = item.split("=")[1];
  357. }
  358. if (item.split("=")[0] == "searchType") {
  359. searchType = item.split("=")[1];
  360. old_searchType = item.split("=")[1];
  361. }
  362. });
  363. // 如果是词汇 默认选中词
  364. if (old_searchType == 2) {
  365. $(".danwei div").removeClass("radio-active");
  366. $(".danwei").find("div").eq(1).addClass("radio-active")
  367. }
  368. if (old_searchType == 0) {
  369. $("#font").attr("value", "Arial");
  370. $(".danwei div").removeClass("radio-active");
  371. searchType = 3
  372. $(".danwei").find("div").eq(1).addClass("radio-active")
  373. for (let i = 0; i < $("#fontSel").children().length; i++) {
  374. if ($("#fontSel").children().eq(i)[0].value == "Arial") {
  375. $("#fontSel").children().eq(i)[0].selected = true;
  376. } else {
  377. $("#fontSel").children().eq(i)[0].selected = false;
  378. }
  379. }
  380. } else {
  381. $("#font").attr("value", "Arial");
  382. for (let i = 0; i < $("#fontSel").children().length; i++) {
  383. if ($("#fontSel").children().eq(i)[0].value == "Arial") {
  384. $("#fontSel").children().eq(i)[0].selected = true;
  385. } else {
  386. $("#fontSel").children().eq(i)[0].selected = false;
  387. }
  388. }
  389. }
  390. function getdata() {
  391. let data = {
  392. type: 0,
  393. id: articleId,
  394. stopWordStatus: W_stopWordStatus,
  395. }
  396. $.ajax({
  397. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud?AccessToken=" + AccessToken,
  398. // url: "/i21st-newspaper-management-test/api/article/detail/wordCloud",
  399. data: JSON.stringify(data),
  400. contentType: "application/json",
  401. dataType: "json",
  402. type: "post",
  403. success: function(res) {
  404. let str = ''
  405. res.data.forEach(item => {
  406. if (item.word.indexOf(" ") != -1) {
  407. item.word = item.word.replace(" ", "")
  408. }
  409. str += item.word + " "
  410. })
  411. ciyunData = res.data
  412. text = str
  413. $("#text").val(text);
  414. $("#go").trigger("click");
  415. console.log("2022-11-09 14点55分");
  416. }
  417. })
  418. }
  419. function initContent() {
  420. var dataType = $("#dataType").val();
  421. var ruleType = $("#rule").val();
  422. var fileId = "${fileId}";
  423. // $.ajax({
  424. // url: "${ctx}/bc/textKeyWords/wordCloud",
  425. // data: { "fileId": fileId, "ruleType": ruleType },
  426. // dataType: "JSON",
  427. // Type: "POST",
  428. // success: function (data) {
  429. let data = {
  430. count: 0,
  431. flag: true,
  432. jsonObject: null,
  433. listStr: [{
  434. frequency: 3,
  435. level: "L1",
  436. posStr: "[\"noun\"]",
  437. rate: "2762.15",
  438. word: "mine",
  439. }, {
  440. frequency: 2,
  441. level: "L0",
  442. posStr: "[\"adj\"]",
  443. rate: "996.51",
  444. word: "nice",
  445. }, {
  446. frequency: 3,
  447. level: "L0",
  448. posStr: "[\"noun\"]",
  449. rate: "340.09",
  450. word: "house",
  451. }, {
  452. frequency: 2,
  453. level: "L0",
  454. posStr: "[\"noun\"]",
  455. rate: "251.11",
  456. word: "friend",
  457. }],
  458. message: null,
  459. objects: null,
  460. userList: null,
  461. 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']
  462. }
  463. if (data.flag) {
  464. var $stop = $(".stop");
  465. var stopFlag = $stop.hasClass("checkbox-active"); //选择了停用
  466. // if (!stopFlag) {
  467. // stopWordLists = null;
  468. // }
  469. // if (ruleType == 1) {
  470. // var themeList = data.listStr;
  471. // text = themeDeal(themeList, stopWordLists);
  472. // } else {
  473. // var object = data.jsonObject;
  474. // var words = "";
  475. // if (dataType == "Word") {
  476. // words = object['wordList'];
  477. // } else {
  478. // words = object['lemmaList'];
  479. // }
  480. let str = ''
  481. data.arr.forEach(item => {
  482. str += item + " "
  483. })
  484. // text = replaceStop(words, stopWordLists);
  485. // }
  486. text = str
  487. $("#text").val(text);
  488. $("#go").trigger("click");
  489. } else {
  490. layer.alert(data.message);
  491. }
  492. // }, error: function (jqXHR, textStatus, errorThrown) {
  493. // if (jqXHR.status == 401) {
  494. // var url = jqXHR.responseText;
  495. // layer.alert('会话已过期,请重新登陆。', function (index) {
  496. // layer.close(index);
  497. // location.reload();
  498. // });
  499. // } else {
  500. // layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  501. // }
  502. // }
  503. // })
  504. }
  505. function initStopWords() {
  506. $.ajax({
  507. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud_stopWordList?AccessToken=" + AccessToken,
  508. // url: "/i21st-newspaper-management-test/api/user/stopVocab/get",
  509. data: JSON.stringify({}),
  510. contentType: "application/json;charset=UTF-8",
  511. dataType: "json",
  512. type: "post",
  513. success: function(res) {
  514. let arr = []
  515. res.data.result.forEach(item => {
  516. arr.push(item.word)
  517. })
  518. oldstopWordList = JSON.parse(JSON.stringify(arr))
  519. stopWordList = JSON.parse(JSON.stringify(arr))
  520. $("#allwordnumber").text(oldstopWordList.length)
  521. changeWordData()
  522. },
  523. error: function(jqXHR, textStatus, errorThrown) {
  524. if (jqXHR.status == 401) {
  525. var url = jqXHR.responseText;
  526. layer.alert('会话已过期,请重新登陆。', function(index) {
  527. layer.close(index);
  528. location.reload();
  529. });
  530. } else {
  531. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  532. }
  533. }
  534. });
  535. }
  536. $(".rule div").click(function() {
  537. $(".rule div").removeClass("radio-active");
  538. $(this).addClass("radio-active");
  539. $("#rule").attr("value", $(this).attr("value"))
  540. initContent();
  541. })
  542. $(".styleType div").click(function() {
  543. $(".styleType div").removeClass("radio-active");
  544. $(this).addClass("radio-active");
  545. $("#spiral").attr("value", $(this).attr("value"));
  546. $("#go").trigger("click");
  547. })
  548. // 切换单位
  549. $(".danwei div").click(function() {
  550. $(".danwei div").removeClass("radio-active");
  551. $(this).addClass("radio-active");
  552. var value = $(this).attr("value");
  553. let newvalue = null
  554. if (old_searchType == 0) { //拼音
  555. if (value == 'zi') {
  556. newvalue = 0
  557. } else {
  558. newvalue = 3
  559. }
  560. } else if (old_searchType == 2) {
  561. if (value == 'zi') {
  562. newvalue = 1
  563. } else {
  564. newvalue = 2
  565. }
  566. } else {
  567. if (value == 'zi') {
  568. newvalue = 1
  569. } else {
  570. newvalue = 4
  571. }
  572. }
  573. searchType = newvalue
  574. getdata()
  575. })
  576. $(".fontDriect div").click(function() {
  577. $(".fontDriect div").removeClass("radio-active");
  578. $(this).addClass("radio-active");
  579. var value = $(this).attr("value");
  580. if (value == 1) {
  581. $("#angle-from").val(0);
  582. $("#angle-to").val(0);
  583. $("#angle-count").val(1);
  584. inChange();
  585. $("#go").click();
  586. $("#angles svg").remove();
  587. } else if (value == 2) {
  588. $("#angle-from").val(90)
  589. $("#angle-to").val(90)
  590. $("#angle-count").val(1);
  591. inChange();
  592. $("#go").click();
  593. $("#angles svg").remove();
  594. } else if (value == 3) {
  595. $("#angle-from").val(0)
  596. $("#angle-to").val(90)
  597. $("#angle-count").val(2);
  598. inChange();
  599. $("#go").click();
  600. $("#angles svg").remove();
  601. }
  602. })
  603. $(".scaleSel div").click(function() {
  604. $(".scaleSel div").removeClass("radio-active");
  605. $(this).addClass("radio-active");
  606. var value = $(this).attr("value");
  607. $("#scale").attr("value", value);
  608. $("#go").trigger("click");
  609. })
  610. $("#fontSel").change(function() {
  611. var value = $(this).children('option:selected').val();
  612. $("#font").attr("value", value);
  613. $("#go").trigger("click");
  614. })
  615. $("#download-png").click(function() {
  616. var el = d3.select("#cloudDiv").node().children[0];
  617. saveSvgAsPng(el, "词云.png");
  618. })
  619. // $(".stopWordList").click(function () {
  620. // var openy = layer.open({
  621. // title: '停用词表'
  622. // , title: false
  623. // , content: '${ctx}/bc/textKeyWords/stopWordListHtml?fileId=${fileId}'
  624. // , area: ['440px', '595px']
  625. // , type: 2
  626. // , closeBtn: 0
  627. // });
  628. // initStopWords();
  629. // })
  630. $("#dataTypeSel").change(function() {
  631. var selvalue = $(this).children('option:selected').val();
  632. // var ruleVlue = $("#rule").attr("value");
  633. // $("#dataType").attr("value", selvalue);
  634. // initContent();
  635. jiekouData()
  636. });
  637. $(".stop").click(function() {
  638. var $stop = $(".stop");
  639. if ($stop.hasClass("checkbox-active")) {
  640. $stop.removeClass("checkbox-active");
  641. } else {
  642. $stop.addClass("checkbox-active");
  643. }
  644. jiekouData()
  645. })
  646. $(".biglittle").click(function() {
  647. var $stop = $(".biglittle");
  648. if ($stop.hasClass("checkbox-active")) {
  649. $stop.removeClass("checkbox-active");
  650. } else {
  651. $stop.addClass("checkbox-active");
  652. }
  653. jiekouData()
  654. })
  655. function jiekouData() {
  656. var $biglittle = $(".biglittle");
  657. var $stop = $(".stop");
  658. let isSelectCaseSensitive = false
  659. let isSelectLemma = false
  660. let stopWordStatus = false
  661. if ($biglittle.hasClass("checkbox-active")) {
  662. isSelectCaseSensitive = true
  663. } else {
  664. isSelectCaseSensitive = false
  665. }
  666. if ($stop.hasClass("checkbox-active")) {
  667. stopWordStatus = 1
  668. } else {
  669. stopWordStatus = 0
  670. }
  671. var selvalue = $("#dataTypeSel").children('option:selected').val();
  672. if (selvalue == 'Lemma') {
  673. isSelectLemma = true;
  674. } else {
  675. isSelectLemma = false;
  676. }
  677. W_stopWordStatus = stopWordStatus
  678. getdata()
  679. }
  680. function replaceStop(words, stopWordList) {
  681. var text = "";
  682. var wordListLow = new Array();
  683. if (stopWordList != null) {
  684. for (var i = 0; i < stopWordList.length; i++) {
  685. wordListLow.push(stopWordList[i].toLowerCase());
  686. }
  687. }
  688. for (var i = 0; i < words.length; i++) {
  689. var wordList = words[i];
  690. var word = wordList[0];
  691. var count = wordList[1];
  692. if (wordListLow.indexOf(word) < 0) {
  693. for (var j = 0; j < count; j++) {
  694. text += word + " ";
  695. }
  696. }
  697. }
  698. return text;
  699. }
  700. function themeDeal(theme, stopWordList) {
  701. var text = "";
  702. var wordListLow = new Array();
  703. if (stopWordList != null) {
  704. for (var i = 0; i < stopWordList.length; i++) {
  705. wordListLow.push(stopWordList[i].toLowerCase());
  706. }
  707. }
  708. for (var i = 0; i < theme.length; i++) {
  709. var themeWord = theme[i];
  710. var word = themeWord['word'];
  711. var flag = false;
  712. if (wordListLow.indexOf(word.toLowerCase()) > -1) {
  713. flag = true;
  714. }
  715. if (!flag) {
  716. var rate = Math.round(themeWord['rate']);
  717. for (var j = 0; j < rate; j++) {
  718. text += word + " ";
  719. }
  720. }
  721. }
  722. return text;
  723. }
  724. // 停用词表
  725. $("#stop").click(function() {
  726. $("#shadow").show()
  727. changeWordData()
  728. })
  729. // 处理词表数据
  730. var editOldVal = ""
  731. function changeWordData(msg, arr) {
  732. if (arr) {
  733. stopWordList = JSON.parse(JSON.stringify(arr));
  734. } else {
  735. stopWordList = JSON.parse(JSON.stringify(oldstopWordList));
  736. }
  737. $("#stop_word_table").empty()
  738. for (let i = 0; i < stopWordList.length; i++) {
  739. let node = ` <div class="one">
  740. <div>${stopWordList[i]}</div>
  741. <div class="right">
  742. <span style="margin-right: 24px" id="edit${i}" @click="edit(item)">编辑</span>
  743. <span @click="deleteOne(item, i)" id="delete${i}">删除</span>
  744. </div>
  745. </div>`
  746. $("#stop_word_table").append(node)
  747. $(`#edit${i}`).click(function() {
  748. $("#editwordDom").show()
  749. $("#wordTable").hide()
  750. $("#editwordContent").val(stopWordList[i])
  751. editOldVal = stopWordList[i]
  752. })
  753. $(`#delete${i}`).click(function() {
  754. oldstopWordList.forEach((item, i) => {
  755. if (stopWordList[i] == item) {
  756. oldstopWordList.splice(i, 1)
  757. }
  758. })
  759. updatawordData()
  760. })
  761. }
  762. if (msg) {
  763. layer.msg("成功")
  764. }
  765. }
  766. function updatawordData() {
  767. let userStopVocab = JSON.parse(JSON.stringify(oldstopWordList));
  768. $.ajax({
  769. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud_stopWordSave?AccessToken=" + AccessToken,
  770. // url: "/i21st-newspaper-management-test/api/user/stopVocab/update",
  771. data: JSON.stringify({
  772. tenantId: "",
  773. wordList: userStopVocab
  774. }),
  775. contentType: "application/json;charset=UTF-8",
  776. dataType: "json",
  777. type: "post",
  778. success: function(data) {
  779. let val = $("#wordContent").val()
  780. if (val != "") {
  781. $("#seekWordBtn").click()
  782. } else {
  783. changeWordData("msg")
  784. }
  785. },
  786. error: function(jqXHR, textStatus, errorThrown) {
  787. if (jqXHR.status == 401) {
  788. var url = jqXHR.responseText;
  789. layer.alert('会话已过期,请重新登陆。', function(index) {
  790. layer.close(index);
  791. location.reload();
  792. });
  793. } else {
  794. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  795. }
  796. }
  797. })
  798. }
  799. // 搜索
  800. $("#seekWordBtn").click(function() {
  801. let val = $("#wordContent").val()
  802. let arr = []
  803. if (val == "") {
  804. stopWordList = JSON.parse(JSON.stringify(oldstopWordList))
  805. changeWordData("msg")
  806. } else {
  807. oldstopWordList.forEach((item, i) => {
  808. if (item.indexOf(val) != -1) {
  809. arr.push(item);
  810. }
  811. })
  812. // stopWordList = JSON.parse(JSON.stringify(arr))
  813. changeWordData("msg", arr)
  814. }
  815. })
  816. // 清空
  817. $("#emptyWord").click(function() {
  818. oldstopWordList = []
  819. updatawordData()
  820. })
  821. // 关闭
  822. $("#closeWord").click(function() {
  823. $("#shadow").hide()
  824. getdata()
  825. })
  826. // 新增 addWord
  827. $("#addWord").click(function() {
  828. $("#addwordDom").show()
  829. $("#wordTable").hide()
  830. $("#addwordContent").val("")
  831. })
  832. // 确定新增 addSubmit
  833. $("#addSubmit").click(function() {
  834. let val = $("#addwordContent").val()
  835. if (val == '') {
  836. layer.msg("请输入内容")
  837. return
  838. } else {
  839. let flag = false;
  840. oldstopWordList.forEach(item => {
  841. if (item == val) {
  842. flag = true
  843. }
  844. })
  845. if (flag) {
  846. layer.msg("该词已经存在,请勿重复添加")
  847. return
  848. }
  849. oldstopWordList.unshift(val)
  850. stopWordList.unshift(val)
  851. $("#wordTable").show()
  852. $("#addwordDom").hide()
  853. updatawordData()
  854. }
  855. })
  856. // 确定修改
  857. $('#editSubmit').click(function() {
  858. let val = $("#editwordContent").val()
  859. if (val == '') {
  860. layer.msg("请输入内容")
  861. return
  862. } else {
  863. let flag = false;
  864. oldstopWordList.forEach(item => {
  865. if (item == val) {
  866. flag = true
  867. }
  868. })
  869. if (flag) {
  870. layer.msg("该词已经存在,请勿重复添加")
  871. return
  872. }
  873. let arr = JSON.parse(JSON.stringify(oldstopWordList))
  874. let index = null
  875. arr.forEach((item, i) => {
  876. if (item == editOldVal) {
  877. index = i
  878. }
  879. })
  880. arr[index] = val
  881. oldstopWordList = JSON.parse(JSON.stringify(arr))
  882. stopWordList = JSON.parse(JSON.stringify(arr))
  883. $("#wordTable").show()
  884. $("#editwordDom").hide()
  885. updatawordData()
  886. }
  887. })
  888. // 关闭新增词
  889. $("#closeWordadd").click(function() {
  890. $("#wordTable").show()
  891. $("#addwordDom").hide()
  892. })
  893. $("#canceladd").click(function() {
  894. $("#wordTable").show()
  895. $("#addwordDom").hide()
  896. })
  897. // 关闭编辑
  898. $("#closeWordedit").click(function() {
  899. $("#wordTable").show()
  900. $("#editwordDom").hide()
  901. })
  902. $("#canceledit").click(function() {
  903. $("#wordTable").show()
  904. $("#editwordDom").hide()
  905. })
  906. </script>
  907. </body>
  908. </html>