Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/PhieF/CarnetElectron.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2020-11-05 01:16:03 +0300
committerPhie <phie@phie.ovh>2020-11-05 01:16:03 +0300
commit8d6f7e4fb641d8b333363fe2a8811e38b750c2fa (patch)
tree76f57d8cc8d9efa7c881719d501e0d3bf3ed9f80 /importer
parentbeac1617efb1325675e5b72bcd7341a225e2aaed (diff)
ability to send a complete note archive for carnet + adding translations to importer
Diffstat (limited to 'importer')
-rw-r--r--importer/importer.html46
-rw-r--r--importer/importer.js47
2 files changed, 78 insertions, 15 deletions
diff --git a/importer/importer.html b/importer/importer.html
index 4cec903..885a55d 100644
--- a/importer/importer.html
+++ b/importer/importer.html
@@ -27,6 +27,11 @@
<script src="../recent/recent_db_manager.js"></script>
<script src="../keywords/keywords_db_manager.js"></script>
+
+
+ <!-- localization -->
+ <script src="../libs/jquery_i18n/CLDRPluralRuleParser.js"></script>
+ <script src="../libs/jquery_i18n/jquery.i18n.js"></script>
</head>
<body>
@@ -48,6 +53,10 @@
.mdl-data-table {
white-space: normal;
}
+
+ #archive-or-notes-selection {
+ display: none;
+ }
</style>
<div class="mdl-layout mdl-js-layout
mdl-layout--fixed-header">
@@ -56,7 +65,7 @@
<button id="back_arrow" class="mdl-button mdl-js-button mdl-button--icon" style="left: -55px;">
<i class="material-icons">arrow_back</i>
</button>
- <span class="mdl-layout-title">Importer</span>
+ <span class="mdl-layout-title" data-i18n="importer">Importer</span>
</div>
</header>
<div class="centered-container" id="select-folder">
@@ -64,7 +73,7 @@
Google provides a way to export all of your Google Keep notes.
<br />
<a onclick="compatibility.openUrl('https://takeout.google.com/settings/takeout'); return false;"
- href="#">Follow
+ href="https://takeout.google.com/settings/takeout">Follow
this link</a>
<br />
<br /> Find Google Keep
@@ -77,16 +86,30 @@
<input type="radio" name="archive-type" value="1">
Carnet<br>
<br>
- <button class="mdl-button mdl-js-button mdl-button--raised" id="select-folder-button">
+ <button class="mdl-button mdl-js-button mdl-button--raised" id="select-folder-button"
+ data-i18n="select_archive">
Select archive
</button>
</div>
+ <div id="archive-or-notes-selection" class="centered-container">
+ <span data-i18n="send_whole_archive_or_select">Send the whole archive or select specific notes to
+ import.</span> <br />
+ <br />
+ <button style="margin-right:10px" class="mdl-button mdl-js-button mdl-button--raised"
+ id="send-archive-button" data-i18n="send_archive">
+ Send archive
+ </button>
+ <button class="mdl-button mdl-js-button mdl-button--raised" id="select-notes-button"
+ data-i18n="select_notes">
+ Select Notes
+ </button>
+ </div>
<div id="note-selection-view">
<div class="centered-container">
<button class="mdl-button mdl-js-button mdl-button--raised import-button" style="width:370px"
- id="import-button1">
+ id="import-button1" data-i18n="import">
Import
</button>
<br />
@@ -94,12 +117,12 @@
<label id="add-to-recent" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect"
for="add-to-recent-cb">
<input type="checkbox" id="add-to-recent-cb" class="mdl-checkbox__input">
- <span class="mdl-checkbox__label">Add to recent</span>
+ <span class="mdl-checkbox__label" data-i18n="add_to_recent">Add to recent</span>
</label>
</div>
<div class="centered-container" id="progress-view">
<div>
- <span>Loading notes list</span>
+ <span data-i18n="loading_notes_list">Loading notes list</span>
<div id="p2" style="margin:auto" class="mdl-progress mdl-js-progress mdl-progress__indeterminate">
</div>
</div>
@@ -109,7 +132,7 @@
</div>
<div class="centered-container" style="margin-bottom:10px;">
<button class="mdl-button mdl-js-button mdl-button--raised import-button" style="width:370px"
- id="import-button2">
+ id="import-button2" data-i18n="import">
Import
</button>
</div>
@@ -118,8 +141,9 @@
<div id="importing-view">
<div class="centered-container" id="importing-progress-view">
<div>
- Importing notes
- <div id="p2" style="margin:auto" class="mdl-progress mdl-js-progress mdl-progress__indeterminate">
+ <span data-i18n="importing_notes">Importing notes</span>
+ <div id="progress-bar" style="margin:auto"
+ class="mdl-progress mdl-js-progress mdl-progress__indeterminate">
</div>
</div>
<span id="importing"></span>
@@ -135,7 +159,7 @@
<div id="import-finished">
<div class="centered-container" id="import-finished-view">
- <div>
+ <div data-i18n="import_finished">
Import finished
</div>
<span id="import-report"></span>
@@ -146,7 +170,7 @@
</div>
</div>
- <input type="file" id="input_file" style="display: none;" />
+ <input type="file" id="input_file" name="archive" style="display: none;" />
</div>
</body>
diff --git a/importer/importer.js b/importer/importer.js
index acd300a..3979dfa 100644
--- a/importer/importer.js
+++ b/importer/importer.js
@@ -97,28 +97,63 @@ Importer.prototype.importNext = function (callback) {
}
Importer.prototype.onArchiveSelected = function (archive) {
+ this.archive = archive
var importer = this
importer.archiveName = archive.name;
console.log("$(input[name='archive-type']:checked).val() " + $("input[name='archive-type']:checked").val())
switch (parseInt($("input[name='archive-type']:checked").val())) {
case 0:
importer.converter = new GoogleConverter(this);
+ importer.loadNoteList()
break;
default:
importer.converter = new CarnetConverter(this);
+ importer.displayChooseWholeArchiveOrSelectNotes()
}
importer.destPath = importer.converter.getDestPath()
- JSZip.loadAsync(archive).then(function (zip) {
+ $("#select-folder").hide()
+ document.getElementById("folder-picker").style.display = "none"
+}
+
+Importer.prototype.displayChooseWholeArchiveOrSelectNotes = function () {
+ var files = []
+ files.push(this.archive)
+ $("#archive-or-notes-selection").show()
+ document.getElementById("select-notes-button").onclick = () => {
+ $("#archive-or-notes-selection").hide()
+ this.loadNoteList()
+ }
+ document.getElementById("send-archive-button").onclick = () => {
+ let progressBar = document.getElementById("progress-bar");
+ RequestBuilder.sRequestBuilder.postFiles("/note/import_archive", {
+
+ }, files, function (error, data) {
+ console.log("send " + error)
+
+ }, function (percentComplete) {
+
+ progressBar.classList.remove("mdl-progress__indeterminate")
+ progressBar.MaterialProgress.setProgress(percentComplete)
+ $("#archive-or-notes-selection").hide()
+ console.log("sending " + percentComplete)
+ $("#importing-view").show();
+ document.getElementById("importing").innerHTML = percentComplete + "%"
+
+ })
+ }
+}
+
+Importer.prototype.loadNoteList = function () {
+ JSZip.loadAsync(this.archive).then(function (zip) {
importer.currentZip = zip
importer.converter.getListOfNotesFromZip(zip, (list) => {
- document.getElementById("folder-picker").style.display = "none"
- $("#select-folder").hide()
+
+
$("#note-selection-view").show()
importer.fillNoteList(function () { }, list)
})
})
-
}
Importer.prototype.fillNoteList = function (callback, list) {
@@ -287,4 +322,8 @@ Importer.prototype.sendNote = function (blob, metadata, filename, isPinned, path
var importer;
$(document).ready(function () {
importer = new Importer("/Keep");
+ $.i18n().locale = navigator.language;
+ compatibility.loadLang(function () {
+ $('body').i18n();
+ })
})