Skip to content

Commit

Permalink
backup for linebreak
Browse files Browse the repository at this point in the history
  • Loading branch information
shiku committed Jan 20, 2019
1 parent d69f189 commit 5039d30
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 188 deletions.
15 changes: 13 additions & 2 deletions background.js
Expand Up @@ -14,9 +14,15 @@ chrome.contextMenus.onClicked.addListener(function(info, tab){
chrome.storage.local.get(function(obj) {
var summary_number = 3;
var minimum_length = 5;

var separator = [".","。"];
var lang = "en";
summary_number = obj.summary_number;
minimum_length = obj.minimum_length;
// group of separator is given by text split by " ".
// it is very bad hack...
separator = obj.separator.split(" ");
alert(separator);
lang = obj.lang;
// not so good solution ....
if(info.selectionText.length < 20){
if(tab.id>=0){
Expand All @@ -30,11 +36,16 @@ chrome.contextMenus.onClicked.addListener(function(info, tab){
//getinfo();

// summarize and push
summary = preproc_en(info.selectionText, summary_number, minimum_length);
if (lang == "ja"){
summary = preproc_ja(info.selectionText, summary_number, minimum_length, separator);
}else{
summary = preproc_en(info.selectionText, summary_number, minimum_length, separator);
}
summary_alert = "";
for(var i=0; i<summary.length; ++i){
summary_alert += "-> " + summary[i] +".\n\n";
}

alert(summary_alert);
if(tab.id>=0){
chrome.tabs.sendMessage(tab.id, {"command":"fill", "summary":summary});
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Expand Up @@ -17,11 +17,11 @@
},
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["jquery-3.3.1.min.js", "jquery.highlight-5.js", "imakita_body.js", "preproc_en.js", "content.js"]
"js": ["jquery-3.3.1.min.js", "jquery.highlight-5.js", "imakita_body.js", "preproc_en.js", "tiny_segmenter-0.2.js", "preproc_ja.js", "content.js"]
}],

"background": {
"scripts": ["jquery-3.3.1.min.js", "jquery.highlight-5.js", "imakita_body.js", "preproc_en.js", "background.js"],
"scripts": ["jquery-3.3.1.min.js", "jquery.highlight-5.js", "imakita_body.js", "preproc_en.js", "tiny_segmenter-0.2.js", "preproc_ja.js", "background.js"],
"persistent": false
}
}
14 changes: 14 additions & 0 deletions popup.html
Expand Up @@ -4,6 +4,20 @@ <h1>Imakita Summarizer</h1>
<!-- <p><label>Highlight Color: <input id="#highlight-color" type="color" name="color" value="#ffff00" /> </label></p> -->
<p><label>Number of summary sentence: <input type="number" name="summary_number" value="5" step="1"></label></p>
<p><label>Minimum length of sentence: <input type="number" name="minimum_length" value="1" step="1"> </label></p>

<p><label>Separator:
<select name="separator">
<option value=". 。 ." selected>Period</option>
<option value="n . 。 .">Period and Linebreak</option>
</select>
</label></p>

<p><label>Language:
<select name="lang">
<option value="en" selected>English</option>
<option value="ja">Japanese</option>
</select>
</label></p>
<!--
<p><label>Alert summary : <input type="checkbox" name="usealert"></label></p>
<p><label>Use line break as separator: <input type="checkbox" name="linebreak"></label></p>
Expand Down
9 changes: 9 additions & 0 deletions popup.js
Expand Up @@ -6,6 +6,13 @@ $(function () {
if ("minimum_length" in obj) {
$("input[name='minimum_length']").val(obj.minimum_length);
}
if ("lang" in obj) {
$("select[name='lang']").val(obj.lang);
}
if ("separator" in obj) {
$("select[name='separator']").val(obj.separator);
}

$("#register").on("click", function() {
update_settings();
});
Expand All @@ -17,6 +24,8 @@ function update_settings() {
let obj = {};
obj.summary_number = $("input[name='summary_number']").val();
obj.minimum_length = $("input[name='minimum_length']").val();
obj.lang = $("select[name='lang']").val();
obj.separator = $("select[name='separator']").val();
chrome.storage.local.set(obj, function(){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type: "update"}, null);
Expand Down
11 changes: 10 additions & 1 deletion preproc_en.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5039d30

Please sign in to comment.