-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a popup to load annotation data
- Loading branch information
Showing
9 changed files
with
154 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
textarea { | ||
width: 98%; | ||
height: 5rem; | ||
} | ||
input { | ||
margin-bottom: 0.5rem; | ||
} | ||
#buttons { | ||
display: flex; | ||
width: 100%; | ||
|
||
justify-content: center; | ||
} | ||
#buttons > input:first-child { | ||
margin-right: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<link rel="stylesheet" type="text/css" href="index.css"> | ||
</head> | ||
<body> | ||
<h3>YouTube Annotation Data</h3> | ||
<input id="youtube-file" type="file"> | ||
<textarea id="youtube-data" placeholder="YouTube Annotation Data..."></textarea> | ||
<h3>Converted YouTube Annotation Data</h3> | ||
<input id="converted-file" type="file"> | ||
<textarea id="converted-data" placeholder="Converted YouTube Annotation Data..."></textarea> | ||
|
||
<div id="buttons"> | ||
<input id="load-youtube" type="button" value="Load YouTube Data"> | ||
<input id="load-converted" type="button" value="Load Converted Data"> | ||
</div> | ||
|
||
<script type="text/javascript" src="index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const youtubeFile = document.getElementById("youtube-file"); | ||
const youtubeTextArea = document.getElementById("youtube-data"); | ||
|
||
const convertedFile = document.getElementById("converted-file"); | ||
const convertedTextArea = document.getElementById("converted-data"); | ||
|
||
const loadYoutube = document.getElementById("load-youtube"); | ||
const loadConverted = document.getElementById("load-converted"); | ||
|
||
loadYoutube.addEventListener("click", e => { | ||
const data = youtubeTextArea.value; | ||
sendLoadMessage("popup_load_youtube", data); | ||
}); | ||
loadConverted.addEventListener("click", e => { | ||
const data = convertedTextArea.value; | ||
sendLoadMessage("popup_load_converted", data); | ||
}); | ||
|
||
youtubeFile.addEventListener("change", e => loadFileData(youtubeFile.files[0], youtubeTextArea)); | ||
convertedFile.addEventListener("change", e => loadFileData(convertedFile.files[0], convertedTextArea)); | ||
|
||
function loadFileData(file, textarea) { | ||
const reader = new FileReader(); | ||
reader.addEventListener("load", e => { | ||
textarea.value = reader.result; | ||
}); | ||
reader.readAsText(file); | ||
} | ||
|
||
function sendLoadMessage(type, data) { | ||
if (!type || !data) return; | ||
console.log("sending load message:", type); | ||
chrome.tabs.query({currentWindow: true, active: true}, tabs => { | ||
if (tabs[0]) { | ||
const tab = tabs[0]; | ||
console.log(tab); | ||
chrome.tabs.sendMessage(tab.id, {type, data}); | ||
} | ||
}); | ||
} |