From 04d1eb79ba0266d031e2b6985ace82f61f65509c Mon Sep 17 00:00:00 2001 From: zovjsra <110753121@nccu.edu.tw> Date: Fri, 24 Feb 2023 04:21:14 +0000 Subject: [PATCH] =?UTF-8?q?=E8=A9=B2=E9=A1=8F=E8=89=B2=E3=80=81=E6=95=B8?= =?UTF-8?q?=E5=AD=97=E6=95=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/main.css | 4 +++- static/js/generalText.js | 19 +++++++++++++------ templates/generalTxt.html | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/static/css/main.css b/static/css/main.css index b38b365..d97cfb7 100755 --- a/static/css/main.css +++ b/static/css/main.css @@ -186,6 +186,7 @@ li a { from { opacity: 0; } + to { opacity: 1; } @@ -202,6 +203,7 @@ li a { from { opacity: 1; } + to { opacity: 0; } @@ -260,7 +262,7 @@ li a { #vis { display: inline-block; - background-color: aliceblue; + background-color: transparent; position: relative; border-radius: 30px; resize: both; diff --git a/static/js/generalText.js b/static/js/generalText.js index 180c3ce..6d6de75 100644 --- a/static/js/generalText.js +++ b/static/js/generalText.js @@ -15,7 +15,7 @@ function addStopWord() { } else { stopwords.push(newsw) - $('#sweContainer').append($('
  • ').attr('class', 'w3-display-container').append($('').append(newsw)).append($('').attr('class', 'w3-button w3-hover-red w3-transparent w3-display-right').click(function(e) { + $('#sweContainer').append($('
  • ').attr('class', 'w3-display-container').append($('').append(newsw)).append($('').attr('class', 'w3-button w3-hover-red w3-transparent w3-display-right').click(function (e) { var index = $(this).parent().index() console.log(stopwords[index]) stopwords.splice(index, 1) @@ -33,14 +33,14 @@ function addStopWord() { function showStopwordEditor() { console.log(stopwords) $(window).unbind('keydown') - $(window).keydown(function(event) { + $(window).keydown(function (event) { if (event.keyCode == 13) { addStopWord() } }) $('#sweContainer').empty() for (word of stopwords) { - $('#sweContainer').append($('
  • ').attr('class', 'w3-display-container').append($('').append(word)).append($('').attr('class', 'w3-button w3-hover-red w3-transparent w3-display-right').click(function(e) { + $('#sweContainer').append($('
  • ').attr('class', 'w3-display-container').append($('').append(word)).append($('').attr('class', 'w3-button w3-hover-red w3-transparent w3-display-right').click(function (e) { var index = $(this).parent().index() console.log(stopwords[index]) stopwords.splice(index, 1) @@ -53,7 +53,7 @@ function showStopwordEditor() { function hideStopWordEditor() { $(window).unbind('keydown') - $(window).keydown(function(event) { + $(window).keydown(function (event) { if (event.keyCode == 13) { event.preventDefault() sendRequest() @@ -74,7 +74,7 @@ function submit() { stopwords: stopwords }), contentType: 'application/json', - success: function(data) { + success: function (data) { tsvPath = data.Result.path destroyCurrentGraph() d3.select('#graph').append('div').attr('id', 'vis') @@ -102,7 +102,7 @@ function buildSentetree() { gapBetweenGraph: 10 }); tree.data(model.getRenderedGraphs(2)) - new ResizeSensor(jQuery('#d3kitRoot'), function() { + new ResizeSensor(jQuery('#d3kitRoot'), function () { var scale, origin; scale = Math.min(2, ($('#graph').outerWidth()) / ($('#d3kitRoot').outerWidth() + 60)) @@ -125,4 +125,11 @@ function switchMessageBox() { } else { $('#toggleTextBox').html('隱藏文字輸入區') } +} + +function countWords() { + text = $("#rawTextBox").val() + let wordCount = text.split(new RegExp("[\u4e00-\u9fa5]")).length - 1 + console.log(wordCount) + $("#wordcount").html('字數:' + wordCount) } \ No newline at end of file diff --git a/templates/generalTxt.html b/templates/generalTxt.html index b592e28..e0c2c24 100644 --- a/templates/generalTxt.html +++ b/templates/generalTxt.html @@ -48,8 +48,9 @@ onclick="showStopwordEditor()">編輯停用詞
    +
    字數:0
    +換行為斷句" onchange="countWords()">