ciyunindex.html 40 KB

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