mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-16 12:19:45 +00:00
misc
This commit is contained in:
parent
ac13586591
commit
a99d95af7d
4 changed files with 1 additions and 120 deletions
|
@ -1,25 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Chapter Editor</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Chapter Editor</h1>
|
|
||||||
<div>
|
|
||||||
<ol id="chapters">
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
<div class="">
|
|
||||||
<button id="closeButton" type="button" name="button">Cancel</button>
|
|
||||||
<button id="saveButton" type="button" name="button">Save</button>
|
|
||||||
</div>
|
|
||||||
<script src="jquery.js" charset="utf-8"></script>
|
|
||||||
<script src="filesaver.js" charset="utf-8"></script>
|
|
||||||
<script src="jszip.js" charset="utf-8"></script>
|
|
||||||
<script src="jszip-utils.js" charset="utf-8"></script>
|
|
||||||
<script src="utils.js" charset="utf-8"></script>
|
|
||||||
<script src="saveEbook.js" charset="utf-8"></script>
|
|
||||||
<script src="editor.js" charset="utf-8"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,30 +0,0 @@
|
||||||
// var chapterHolder = document.getElementById('chapters');
|
|
||||||
var list = document.getElementById('chapters');
|
|
||||||
var allPages = getEbookPages();
|
|
||||||
|
|
||||||
console.log(allPages.length);
|
|
||||||
|
|
||||||
for (var i = 0; i < allPages.length; i++) {
|
|
||||||
if (!allPages[i]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var listItem = document.createElement('li');
|
|
||||||
var label = document.createElement('span');
|
|
||||||
label.innerHTML = allPages[i].title;
|
|
||||||
listItem.appendChild(label);
|
|
||||||
list.appendChild(listItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
document.getElementById('closeButton').onclick = function () {
|
|
||||||
window.open(window.location, '_self').close();
|
|
||||||
};
|
|
||||||
|
|
||||||
document.getElementById('saveButton').onclick = function () {
|
|
||||||
try {
|
|
||||||
buildEbook();
|
|
||||||
// window.open(window.location, '_self').close();
|
|
||||||
} catch (e) {
|
|
||||||
alert(e);
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,24 +1,5 @@
|
||||||
var win = null;
|
|
||||||
|
|
||||||
document.getElementById("editChapters").onclick = function() {
|
document.getElementById("editChapters").onclick = function() {
|
||||||
// win = window.open(chrome.extension.getURL('chapter-editor/editor.html'), '_blank');
|
|
||||||
// win.focus();
|
|
||||||
|
|
||||||
// chrome.tabs.create({url:"editor.html"});
|
|
||||||
|
|
||||||
// var list = document.getElementById('chapters');
|
|
||||||
// var allPages = getEbookPages();
|
|
||||||
//
|
|
||||||
// for (var i = 0; i < allPages.length; i++) {
|
|
||||||
// var listItem = document.createElement('li');
|
|
||||||
// var label = document.createElement('span');
|
|
||||||
// label.innerHTML = allPages[i].title;
|
|
||||||
// label.class = 'menu-item-full';
|
|
||||||
// listItem.appendChild(label);
|
|
||||||
// list.appendChild(listItem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
chrome.tabs.query({
|
chrome.tabs.query({
|
||||||
currentWindow: true,
|
currentWindow: true,
|
||||||
active: true
|
active: true
|
||||||
|
@ -35,27 +16,8 @@ document.getElementById("editChapters").onclick = function() {
|
||||||
chrome.tabs.executeScript(tab[0].id, {file: '/chapter-editor/saveEbook.js'});
|
chrome.tabs.executeScript(tab[0].id, {file: '/chapter-editor/saveEbook.js'});
|
||||||
|
|
||||||
chrome.tabs.executeScript(tab[0].id, {
|
chrome.tabs.executeScript(tab[0].id, {
|
||||||
file: '/chapter-editor/inlined.js'
|
file: '/chapter-editor/chapterEditor.js'
|
||||||
});
|
});
|
||||||
|
|
||||||
// chrome.tabs.executeScript(tab[0].id, {
|
|
||||||
// file: 'extractHtml.js'
|
|
||||||
// }, function() {
|
|
||||||
// // if (chrome.runtime.lastError) {
|
|
||||||
// // alert(JSON.stringify(chrome.runtime.lastError));
|
|
||||||
// // throw Error("Unable to inject script into tab " + tabId);
|
|
||||||
// // }
|
|
||||||
// chrome.tabs.sendMessage(tab[0].id, {
|
|
||||||
// type: action
|
|
||||||
// }, function(response) {
|
|
||||||
// var allPages = getEbookPages();
|
|
||||||
// allPages.push(response);
|
|
||||||
// saveEbookPages(allPages);
|
|
||||||
// if (!justAddToBuffer) {
|
|
||||||
// buildEbook();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,21 +32,6 @@ function dispatch(action, justAddToBuffer) {
|
||||||
active: true
|
active: true
|
||||||
}, function(tab) {
|
}, function(tab) {
|
||||||
|
|
||||||
// chrome.tabs.sendMessage(
|
|
||||||
// tab[0].id, {
|
|
||||||
// type: action
|
|
||||||
// },
|
|
||||||
// function(response) {
|
|
||||||
// alert('nnn 3' + response);
|
|
||||||
// var allPages = getEbookPages();
|
|
||||||
// allPages.push(response);
|
|
||||||
// saveEbookPages(allPages);
|
|
||||||
// if (!justAddToBuffer) {
|
|
||||||
// buildEbook();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
|
|
||||||
chrome.tabs.executeScript(tab[0].id, {file: '/chapter-editor/jquery.js'});
|
chrome.tabs.executeScript(tab[0].id, {file: '/chapter-editor/jquery.js'});
|
||||||
chrome.tabs.executeScript(tab[0].id, {file: '/chapter-editor/filesaver.js'});
|
chrome.tabs.executeScript(tab[0].id, {file: '/chapter-editor/filesaver.js'});
|
||||||
chrome.tabs.executeScript(tab[0].id, {file: '/chapter-editor/jszip.js'});
|
chrome.tabs.executeScript(tab[0].id, {file: '/chapter-editor/jszip.js'});
|
||||||
|
@ -94,20 +41,9 @@ function dispatch(action, justAddToBuffer) {
|
||||||
chrome.tabs.executeScript(tab[0].id, {
|
chrome.tabs.executeScript(tab[0].id, {
|
||||||
file: 'extractHtml.js'
|
file: 'extractHtml.js'
|
||||||
}, function() {
|
}, function() {
|
||||||
// if (chrome.runtime.lastError) {
|
|
||||||
// alert(JSON.stringify(chrome.runtime.lastError));
|
|
||||||
// throw Error("Unable to inject script into tab " + tabId);
|
|
||||||
// }
|
|
||||||
chrome.tabs.sendMessage(tab[0].id, {
|
chrome.tabs.sendMessage(tab[0].id, {
|
||||||
type: action
|
type: action
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
// var allPages = getEbookPages();
|
|
||||||
// allPages.push(response);
|
|
||||||
// saveEbookPages(allPages);
|
|
||||||
// if (!justAddToBuffer) {
|
|
||||||
// buildEbook();
|
|
||||||
// }
|
|
||||||
|
|
||||||
getEbookPages(function (allPages) {
|
getEbookPages(function (allPages) {
|
||||||
allPages.push(response);
|
allPages.push(response);
|
||||||
saveEbookPages(allPages);
|
saveEbookPages(allPages);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue