|
|
@ -17,7 +17,7 @@ function init() {
|
|
|
|
type: 'POST',
|
|
|
|
type: 'POST',
|
|
|
|
url: '/init',
|
|
|
|
url: '/init',
|
|
|
|
dataType: 'json',
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(data) {
|
|
|
|
success: function (data) {
|
|
|
|
console.log(data)
|
|
|
|
console.log(data)
|
|
|
|
setDate(data.Result.startDate, data.Result.endDate)
|
|
|
|
setDate(data.Result.startDate, data.Result.endDate)
|
|
|
|
document.getElementById('keywordBox').value = data.Result.keyword
|
|
|
|
document.getElementById('keywordBox').value = data.Result.keyword
|
|
|
@ -39,44 +39,44 @@ function init() {
|
|
|
|
buildSentetree()
|
|
|
|
buildSentetree()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
$(document).ready(function() {
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(window).keydown(function(event) {
|
|
|
|
$(window).keydown(function (event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
event.preventDefault()
|
|
|
|
event.preventDefault()
|
|
|
|
sendRequest()
|
|
|
|
sendRequest()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$(window).on('mousemove', function(e) {
|
|
|
|
$(window).on('mousemove', function (e) {
|
|
|
|
$('#nodeTitle').css({
|
|
|
|
$('#nodeTitle').css({
|
|
|
|
left: e.pageX,
|
|
|
|
left: e.pageX,
|
|
|
|
top: e.pageY
|
|
|
|
top: e.pageY
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
$('#titleListContainer').hover(
|
|
|
|
$('#titleListContainer').hover(
|
|
|
|
function() { // Run on hover/mouseenter
|
|
|
|
function () { // Run on hover/mouseenter
|
|
|
|
$(this).css('overflow', 'auto')
|
|
|
|
$(this).css('overflow', 'auto')
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function() { // Run on mouseleave
|
|
|
|
function () { // Run on mouseleave
|
|
|
|
$(this).css('overflow', 'hidden')
|
|
|
|
$(this).css('overflow', 'hidden')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
$('#titleListLayer').click(function(e) {
|
|
|
|
$('#titleListLayer').click(function (e) {
|
|
|
|
if ($('#titleListLayer').is(e.target)) {
|
|
|
|
if ($('#titleListLayer').is(e.target)) {
|
|
|
|
hideTitles()
|
|
|
|
hideTitles()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
$('#stopWordEditorLayer').click(function(e) {
|
|
|
|
$('#stopWordEditorLayer').click(function (e) {
|
|
|
|
if ($('#stopWordEditorLayer').is(e.target)) {
|
|
|
|
if ($('#stopWordEditorLayer').is(e.target)) {
|
|
|
|
hideStopWordEditor()
|
|
|
|
hideStopWordEditor()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
$('#idfEditorLayer').click(function(e) {
|
|
|
|
$('#idfEditorLayer').click(function (e) {
|
|
|
|
if ($('#idfEditorLayer').is(e.target)) {
|
|
|
|
if ($('#idfEditorLayer').is(e.target)) {
|
|
|
|
hideIdfEditor()
|
|
|
|
hideIdfEditor()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
$('#pttPageWindow').click(function(e) {
|
|
|
|
$('#pttPageWindow').click(function (e) {
|
|
|
|
if ($('#pttPageWindow').is(e.target)) {
|
|
|
|
if ($('#pttPageWindow').is(e.target)) {
|
|
|
|
hidePTTPage()
|
|
|
|
hidePTTPage()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -88,23 +88,23 @@ function init() {
|
|
|
|
|
|
|
|
|
|
|
|
function loadTemplate(num) {
|
|
|
|
function loadTemplate(num) {
|
|
|
|
templates = [{
|
|
|
|
templates = [{
|
|
|
|
startDate: '2020-12-01',
|
|
|
|
startDate: '2020-12-01',
|
|
|
|
endDate: '2020-12-31',
|
|
|
|
endDate: '2020-12-31',
|
|
|
|
keyword: '',
|
|
|
|
keyword: '',
|
|
|
|
mode: 1
|
|
|
|
mode: 1
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
startDate: '2020-01-01',
|
|
|
|
startDate: '2020-01-01',
|
|
|
|
endDate: '2020-03-01',
|
|
|
|
endDate: '2020-03-01',
|
|
|
|
keyword: '衛生紙',
|
|
|
|
keyword: '衛生紙',
|
|
|
|
mode: 2
|
|
|
|
mode: 2
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
startDate: '2020-01-11',
|
|
|
|
startDate: '2020-01-11',
|
|
|
|
endDate: '2020-01-12',
|
|
|
|
endDate: '2020-01-12',
|
|
|
|
keyword: '',
|
|
|
|
keyword: '',
|
|
|
|
mode: 2
|
|
|
|
mode: 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
chosenTemp = templates[num]
|
|
|
|
chosenTemp = templates[num]
|
|
|
|
setDate(chosenTemp.startDate, chosenTemp.endDate)
|
|
|
|
setDate(chosenTemp.startDate, chosenTemp.endDate)
|
|
|
@ -127,7 +127,7 @@ function addStopWord() {
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stopwords.push(newsw)
|
|
|
|
stopwords.push(newsw)
|
|
|
|
$('#sweContainer').append($('<li>').attr('class', 'w3-display-container').append($('<span>').append(newsw)).append($('<span>').attr('class', 'w3-button w3-hover-red w3-transparent w3-display-right').click(function(e) {
|
|
|
|
$('#sweContainer').append($('<li>').attr('class', 'w3-display-container').append($('<span>').append(newsw)).append($('<span>').attr('class', 'w3-button w3-hover-red w3-transparent w3-display-right').click(function (e) {
|
|
|
|
var index = $(this).parent().index()
|
|
|
|
var index = $(this).parent().index()
|
|
|
|
console.log(stopwords[index])
|
|
|
|
console.log(stopwords[index])
|
|
|
|
stopwords.splice(index, 1)
|
|
|
|
stopwords.splice(index, 1)
|
|
|
@ -172,14 +172,14 @@ function scrollIdfList() {
|
|
|
|
|
|
|
|
|
|
|
|
function showStopwordEditor() {
|
|
|
|
function showStopwordEditor() {
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
$(window).keydown(function(event) {
|
|
|
|
$(window).keydown(function (event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
addStopWord()
|
|
|
|
addStopWord()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
$('#sweContainer').empty()
|
|
|
|
$('#sweContainer').empty()
|
|
|
|
for (word of stopwords) {
|
|
|
|
for (word of stopwords) {
|
|
|
|
$('#sweContainer').append($('<li>').append($('<span>').append(word)).append($('<span>').attr('class', 'w3-button w3-hover-red w3-transparent w3-display-right').click(function(e) {
|
|
|
|
$('#sweContainer').append($('<li>').append($('<span>').append(word)).append($('<span>').attr('class', 'w3-button w3-hover-red w3-transparent w3-display-right').click(function (e) {
|
|
|
|
var index = $(this).parent().index()
|
|
|
|
var index = $(this).parent().index()
|
|
|
|
console.log(stopwords[index])
|
|
|
|
console.log(stopwords[index])
|
|
|
|
stopwords.splice(index, 1)
|
|
|
|
stopwords.splice(index, 1)
|
|
|
@ -192,27 +192,27 @@ function showStopwordEditor() {
|
|
|
|
|
|
|
|
|
|
|
|
function showIdfEditor() {
|
|
|
|
function showIdfEditor() {
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
$(window).keydown(function(event) {
|
|
|
|
$(window).keydown(function (event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
scrollIdfList()
|
|
|
|
scrollIdfList()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
$('#ieContainer').empty().append(
|
|
|
|
$('#ieContainer').empty().append(
|
|
|
|
$('<thead>').append($('<tr>')
|
|
|
|
$('<thead>').append($('<tr>')
|
|
|
|
.append($('<th>')
|
|
|
|
.append($('<th>')
|
|
|
|
.attr('style', 'position: sticky; top: 0; background: white;')
|
|
|
|
.attr('style', 'position: sticky; top: 0; background: white;')
|
|
|
|
.append('單詞'))
|
|
|
|
.append('單詞'))
|
|
|
|
.append($('<th>')
|
|
|
|
.append($('<th>')
|
|
|
|
.attr('class', 'w3-center-align')
|
|
|
|
.attr('class', 'w3-center-align')
|
|
|
|
.attr('style', 'position: sticky; top: 0; background: white;')
|
|
|
|
.attr('style', 'position: sticky; top: 0; background: white;')
|
|
|
|
.append('操作'))
|
|
|
|
.append('操作'))
|
|
|
|
.append($('<th>')
|
|
|
|
.append($('<th>')
|
|
|
|
.attr('class', 'w3-right-align')
|
|
|
|
.attr('class', 'w3-right-align')
|
|
|
|
.attr('style', 'position: sticky; top: 0; background: white;')
|
|
|
|
.attr('style', 'position: sticky; top: 0; background: white;')
|
|
|
|
.append('單詞頻率')
|
|
|
|
.append('單詞頻率')
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
.append($('<tbody>'))
|
|
|
|
.append($('<tbody>'))
|
|
|
|
for (word of Object.entries(idfTable).sort((a, b) => { return (b[1] - a[1]) }).map((a) => { return a[0] }).slice(0, 1000)) {
|
|
|
|
for (word of Object.entries(idfTable).sort((a, b) => { return (b[1] - a[1]) }).map((a) => { return a[0] }).slice(0, 1000)) {
|
|
|
|
$('#ieContainer').find('tbody')
|
|
|
|
$('#ieContainer').find('tbody')
|
|
|
@ -226,7 +226,7 @@ function showIdfEditor() {
|
|
|
|
.append($('<button>')
|
|
|
|
.append($('<button>')
|
|
|
|
.attr('class', 'general-button')
|
|
|
|
.attr('class', 'general-button')
|
|
|
|
.html('設為最小')
|
|
|
|
.html('設為最小')
|
|
|
|
.click(function() {
|
|
|
|
.click(function () {
|
|
|
|
$(this)
|
|
|
|
$(this)
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
@ -236,7 +236,7 @@ function showIdfEditor() {
|
|
|
|
.append($('<button>')
|
|
|
|
.append($('<button>')
|
|
|
|
.attr('class', 'general-button')
|
|
|
|
.attr('class', 'general-button')
|
|
|
|
.html('設為最大')
|
|
|
|
.html('設為最大')
|
|
|
|
.click(function() {
|
|
|
|
.click(function () {
|
|
|
|
$(this)
|
|
|
|
$(this)
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
@ -248,7 +248,7 @@ function showIdfEditor() {
|
|
|
|
.append($('<button>')
|
|
|
|
.append($('<button>')
|
|
|
|
.attr('class', 'general-button')
|
|
|
|
.attr('class', 'general-button')
|
|
|
|
.html('重設')
|
|
|
|
.html('重設')
|
|
|
|
.click(function() {
|
|
|
|
.click(function () {
|
|
|
|
var _word = $($(this)
|
|
|
|
var _word = $($(this)
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
@ -275,7 +275,7 @@ function showIdfEditor() {
|
|
|
|
|
|
|
|
|
|
|
|
function hideStopWordEditor() {
|
|
|
|
function hideStopWordEditor() {
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
$(window).keydown(function(event) {
|
|
|
|
$(window).keydown(function (event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
event.preventDefault()
|
|
|
|
event.preventDefault()
|
|
|
|
sendRequest()
|
|
|
|
sendRequest()
|
|
|
@ -286,7 +286,7 @@ function hideStopWordEditor() {
|
|
|
|
|
|
|
|
|
|
|
|
function hideIdfEditor() {
|
|
|
|
function hideIdfEditor() {
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
$(window).keydown(function(event) {
|
|
|
|
$(window).keydown(function (event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
event.preventDefault()
|
|
|
|
event.preventDefault()
|
|
|
|
sendRequest()
|
|
|
|
sendRequest()
|
|
|
@ -369,7 +369,7 @@ function sendRequest() {
|
|
|
|
url: '/addRequest',
|
|
|
|
url: '/addRequest',
|
|
|
|
data: content,
|
|
|
|
data: content,
|
|
|
|
contentType: 'application/json',
|
|
|
|
contentType: 'application/json',
|
|
|
|
success: function(data) {
|
|
|
|
success: function (data) {
|
|
|
|
console.log(data)
|
|
|
|
console.log(data)
|
|
|
|
changeGraph(data.Result)
|
|
|
|
changeGraph(data.Result)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -460,16 +460,16 @@ function buildSentetree() {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
seqList = node.data.seq.DBs.map(function(n) {
|
|
|
|
seqList = node.data.seq.DBs.map(function (n) {
|
|
|
|
return n.rawText
|
|
|
|
return n.rawText
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
titleList = []
|
|
|
|
titleList = []
|
|
|
|
for (s of seqList) {
|
|
|
|
for (s of seqList) {
|
|
|
|
titleTemp = wordTitleList[s]
|
|
|
|
titleTemp = wordTitleList[s]
|
|
|
|
if ((titleList.map(function(n) {
|
|
|
|
if ((titleList.map(function (n) {
|
|
|
|
return n.title
|
|
|
|
return n.title
|
|
|
|
})).indexOf(titleTemp.title) == -1) {
|
|
|
|
})).indexOf(titleTemp.title) == -1) {
|
|
|
|
titleList.push(titleTemp)
|
|
|
|
titleList.push(titleTemp)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -508,7 +508,7 @@ function buildSentetree() {
|
|
|
|
globKeyword: globKeyword
|
|
|
|
globKeyword: globKeyword
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
contentType: 'application/json',
|
|
|
|
contentType: 'application/json',
|
|
|
|
success: function(data) {
|
|
|
|
success: function (data) {
|
|
|
|
console.log(data)
|
|
|
|
console.log(data)
|
|
|
|
$('#titleListKeywordInfo').html('單詞出現次數:' + data.Result.wordCount + ', 單詞出現的文章數:' + data.Result.postCount + ', 單詞頻率:' + (data.Result.postCount * 100 / totalPosts).toFixed(2) + '%')
|
|
|
|
$('#titleListKeywordInfo').html('單詞出現次數:' + data.Result.wordCount + ', 單詞出現的文章數:' + data.Result.postCount + ', 單詞頻率:' + (data.Result.postCount * 100 / totalPosts).toFixed(2) + '%')
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -517,26 +517,26 @@ function buildSentetree() {
|
|
|
|
for (i of titleList) {
|
|
|
|
for (i of titleList) {
|
|
|
|
$('#titleListContainer').append(
|
|
|
|
$('#titleListContainer').append(
|
|
|
|
$('<li>').attr('class', 'w3-panel')
|
|
|
|
$('<li>').attr('class', 'w3-panel')
|
|
|
|
.css('cursor', 'pointer').append(
|
|
|
|
.css('cursor', 'pointer').append(
|
|
|
|
$('<p>').attr('target', '_blank').append(
|
|
|
|
$('<p>').attr('target', '_blank').append(
|
|
|
|
$('<h4>').html(i.title)
|
|
|
|
$('<h4>').html(i.title)
|
|
|
|
).append(
|
|
|
|
).append(
|
|
|
|
$('<span>').attr('style', 'margin: 0px 10px').html(i.author)
|
|
|
|
$('<span>').attr('style', 'margin: 0px 10px').html(i.author)
|
|
|
|
).append(
|
|
|
|
).append(
|
|
|
|
$('<span>').attr('style', 'margin: 0px 10px').html(i.date)
|
|
|
|
$('<span>').attr('style', 'margin: 0px 10px').html(i.date)
|
|
|
|
).append(
|
|
|
|
).append(
|
|
|
|
$('<span>').attr('style', 'margin: 0px 10px').html('推文數:' + i.pushes)
|
|
|
|
$('<span>').attr('style', 'margin: 0px 10px').html('推文數:' + i.pushes)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
).click(function() {
|
|
|
|
).click(function () {
|
|
|
|
let indx = $(this).index()
|
|
|
|
let indx = $(this).index()
|
|
|
|
showPTTPage((titleList[indx].url).replace('www.ptt.cc', 'www.pttweb.cc'))
|
|
|
|
showPTTPage((titleList[indx].url).replace('www.ptt.cc', 'www.pttweb.cc'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.on('nodeMouseenter', node => {
|
|
|
|
.on('nodeMouseenter', node => {
|
|
|
|
console.log(node)
|
|
|
|
console.log(node)
|
|
|
|
titles = node.data.topEntries.map(function(x) {
|
|
|
|
titles = node.data.topEntries.map(function (x) {
|
|
|
|
return wordTitleList[x.rawText]
|
|
|
|
return wordTitleList[x.rawText]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
console.log(titles)
|
|
|
|
console.log(titles)
|
|
|
@ -564,7 +564,7 @@ function buildSentetree() {
|
|
|
|
}).on('linkMouseenter', link => {
|
|
|
|
}).on('linkMouseenter', link => {
|
|
|
|
console.log(link)
|
|
|
|
console.log(link)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
new ResizeSensor(jQuery('#d3kitRoot'), function() {
|
|
|
|
new ResizeSensor(jQuery('#d3kitRoot'), function () {
|
|
|
|
var scale, origin;
|
|
|
|
var scale, origin;
|
|
|
|
scale = Math.min(2, ($('#graph').outerWidth()) / ($('#d3kitRoot').outerWidth() + 60))
|
|
|
|
scale = Math.min(2, ($('#graph').outerWidth()) / ($('#d3kitRoot').outerWidth() + 60))
|
|
|
|
|
|
|
|
|
|
|
|