Make editor work, add support for syncing to NotePost, use ES6 classes for notes
parent
c32f985ec4
commit
d43cab8860
@ -0,0 +1,96 @@
|
|||||||
|
0 info it worked if it ends with ok
|
||||||
|
1 verbose cli [ '/usr/bin/node',
|
||||||
|
1 verbose cli '/usr/bin/npm',
|
||||||
|
1 verbose cli 'install',
|
||||||
|
1 verbose cli 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git',
|
||||||
|
1 verbose cli '--production',
|
||||||
|
1 verbose cli '--save' ]
|
||||||
|
2 info using npm@3.5.2
|
||||||
|
3 info using node@v8.10.0
|
||||||
|
4 silly loadCurrentTree Starting
|
||||||
|
5 silly install loadCurrentTree
|
||||||
|
6 silly install readLocalPackageData
|
||||||
|
7 silly fetchPackageMetaData https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
8 silly fetchOtherPackageData https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
9 silly cache add args [ 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git',
|
||||||
|
9 silly cache add null ]
|
||||||
|
10 verbose cache add spec https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
11 silly cache add parsed spec Result {
|
||||||
|
11 silly cache add raw: 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git',
|
||||||
|
11 silly cache add scope: null,
|
||||||
|
11 silly cache add name: null,
|
||||||
|
11 silly cache add rawSpec: 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git',
|
||||||
|
11 silly cache add spec: 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git',
|
||||||
|
11 silly cache add type: 'remote' }
|
||||||
|
12 silly mapToRegistry name https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
13 silly mapToRegistry using default registry
|
||||||
|
14 silly mapToRegistry registry https://registry.npmjs.org/
|
||||||
|
15 silly mapToRegistry uri https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
16 verbose addRemoteTarball https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git not in flight; adding
|
||||||
|
17 verbose addRemoteTarball [ 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git',
|
||||||
|
17 verbose addRemoteTarball null ]
|
||||||
|
18 info retry fetch attempt 1 at 10:07:53 PM
|
||||||
|
19 info attempt registry request try #1 at 10:07:53 PM
|
||||||
|
20 http fetch GET https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
21 verbose request id 9a59c3d4ecd0fe27
|
||||||
|
22 http fetch 404 https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
23 error fetch failed https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
24 warn retry will retry, error on last attempt: Error: fetch failed with status code 404
|
||||||
|
25 info retry fetch attempt 2 at 10:08:03 PM
|
||||||
|
26 info attempt registry request try #1 at 10:08:03 PM
|
||||||
|
27 http fetch GET https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
28 http fetch 404 https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
29 error fetch failed https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
30 warn retry will retry, error on last attempt: Error: fetch failed with status code 404
|
||||||
|
31 info retry fetch attempt 3 at 10:09:04 PM
|
||||||
|
32 info attempt registry request try #1 at 10:09:04 PM
|
||||||
|
33 http fetch GET https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
34 http fetch 404 https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
35 error fetch failed https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
|
||||||
|
36 silly fetchPackageMetaData Error: fetch failed with status code 404
|
||||||
|
36 silly fetchPackageMetaData at Request.<anonymous> (/usr/share/npm/node_modules/npm-registry-client/lib/fetch.js:51:14)
|
||||||
|
36 silly fetchPackageMetaData at emitOne (events.js:116:13)
|
||||||
|
36 silly fetchPackageMetaData at Request.emit (events.js:211:7)
|
||||||
|
36 silly fetchPackageMetaData at Request.onRequestResponse (/usr/share/npm/node_modules/request/request.js:998:10)
|
||||||
|
36 silly fetchPackageMetaData at emitOne (events.js:116:13)
|
||||||
|
36 silly fetchPackageMetaData at ClientRequest.emit (events.js:211:7)
|
||||||
|
36 silly fetchPackageMetaData at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:551:21)
|
||||||
|
36 silly fetchPackageMetaData at HTTPParser.parserOnHeadersComplete (_http_common.js:115:23)
|
||||||
|
36 silly fetchPackageMetaData at TLSSocket.socketOnData (_http_client.js:440:20)
|
||||||
|
36 silly fetchPackageMetaData at emitOne (events.js:116:13)
|
||||||
|
36 silly fetchPackageMetaData error for https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git Error: fetch failed with status code 404
|
||||||
|
36 silly fetchPackageMetaData at Request.<anonymous> (/usr/share/npm/node_modules/npm-registry-client/lib/fetch.js:51:14)
|
||||||
|
36 silly fetchPackageMetaData at emitOne (events.js:116:13)
|
||||||
|
36 silly fetchPackageMetaData at Request.emit (events.js:211:7)
|
||||||
|
36 silly fetchPackageMetaData at Request.onRequestResponse (/usr/share/npm/node_modules/request/request.js:998:10)
|
||||||
|
36 silly fetchPackageMetaData at emitOne (events.js:116:13)
|
||||||
|
36 silly fetchPackageMetaData at ClientRequest.emit (events.js:211:7)
|
||||||
|
36 silly fetchPackageMetaData at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:551:21)
|
||||||
|
36 silly fetchPackageMetaData at HTTPParser.parserOnHeadersComplete (_http_common.js:115:23)
|
||||||
|
36 silly fetchPackageMetaData at TLSSocket.socketOnData (_http_client.js:440:20)
|
||||||
|
36 silly fetchPackageMetaData at emitOne (events.js:116:13)
|
||||||
|
37 silly rollbackFailedOptional Starting
|
||||||
|
38 silly rollbackFailedOptional Finishing
|
||||||
|
39 silly runTopLevelLifecycles Starting
|
||||||
|
40 silly runTopLevelLifecycles Finishing
|
||||||
|
41 silly install printInstalled
|
||||||
|
42 verbose stack Error: fetch failed with status code 404
|
||||||
|
42 verbose stack at Request.<anonymous> (/usr/share/npm/node_modules/npm-registry-client/lib/fetch.js:51:14)
|
||||||
|
42 verbose stack at emitOne (events.js:116:13)
|
||||||
|
42 verbose stack at Request.emit (events.js:211:7)
|
||||||
|
42 verbose stack at Request.onRequestResponse (/usr/share/npm/node_modules/request/request.js:998:10)
|
||||||
|
42 verbose stack at emitOne (events.js:116:13)
|
||||||
|
42 verbose stack at ClientRequest.emit (events.js:211:7)
|
||||||
|
42 verbose stack at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:551:21)
|
||||||
|
42 verbose stack at HTTPParser.parserOnHeadersComplete (_http_common.js:115:23)
|
||||||
|
42 verbose stack at TLSSocket.socketOnData (_http_client.js:440:20)
|
||||||
|
42 verbose stack at emitOne (events.js:116:13)
|
||||||
|
43 verbose cwd /home/skylar/Documents/Projects/Sources/NotePostApp
|
||||||
|
44 error Linux 4.15.0-43-generic
|
||||||
|
45 error argv "/usr/bin/node" "/usr/bin/npm" "install" "https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git" "--production" "--save"
|
||||||
|
46 error node v8.10.0
|
||||||
|
47 error npm v3.5.2
|
||||||
|
48 error fetch failed with status code 404
|
||||||
|
49 error If you need help, you may report this error at:
|
||||||
|
49 error <https://github.com/npm/npm/issues>
|
||||||
|
50 verbose exit [ 1, true ]
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class NotePostNotes extends Notes {
|
||||||
|
|
||||||
|
constructor(server, username, password) {
|
||||||
|
super();
|
||||||
|
this.server = server;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
add(note, callback) {
|
||||||
|
note.norealid = true;
|
||||||
|
super.add(note, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
fix(note) {
|
||||||
|
super.fix(note);
|
||||||
|
note.id = note.noteid;
|
||||||
|
this.set(note);
|
||||||
|
}
|
||||||
|
|
||||||
|
load(callback) {
|
||||||
|
var self = this;
|
||||||
|
$.ajax({
|
||||||
|
url: this.server + "/api/getnotes",
|
||||||
|
dataType: "json",
|
||||||
|
cache: false,
|
||||||
|
method: "POST",
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader("Authorization", "Basic " + btoa(self.username + ":" + self.password));
|
||||||
|
}, success: function (val) {
|
||||||
|
if (val.status == "OK") {
|
||||||
|
self.notes = val.notes;
|
||||||
|
}
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
saveNote(note, callback) {
|
||||||
|
var self = this;
|
||||||
|
var data = {
|
||||||
|
text: note.content,
|
||||||
|
color: note.color,
|
||||||
|
modified: note.modified,
|
||||||
|
favorite: (note.favorite ? "1" : "0")
|
||||||
|
};
|
||||||
|
// Don't send ID if it's a locally-made note
|
||||||
|
if (note.norealid != true) {
|
||||||
|
data.id = note.id;
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: this.server + "/api/savenote",
|
||||||
|
dataType: "json",
|
||||||
|
method: "POST",
|
||||||
|
data: data,
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader("Authorization", "Basic " + btoa(self.username + ":" + self.password));
|
||||||
|
}
|
||||||
|
}).always(function () {
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
save(callback) {
|
||||||
|
this.fixAll();
|
||||||
|
super.save();
|
||||||
|
|
||||||
|
var ajaxcalls = [];
|
||||||
|
for (var i = 0; i < this.notes.length; i++) {
|
||||||
|
ajaxcalls.push(this.saveNote(this.notes[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$.when(ajaxcalls).always(function () {
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function saveme(callback) {
|
||||||
|
var noteid = $("#note_content").data("noteid");
|
||||||
|
if (noteid == "") {
|
||||||
|
// Make a very random ID number and check that it won't collide,
|
||||||
|
// in case the user is good at winning the lottery
|
||||||
|
do {
|
||||||
|
noteid = Math.floor(Math.random() * (9999999999 - 1000000000) + 1000000000);
|
||||||
|
console.log("Generating random note ID: " + noteid);
|
||||||
|
} while (notes.get(noteid) != null);
|
||||||
|
|
||||||
|
var note = {id: noteid};
|
||||||
|
note.content = $("#note_content").val();
|
||||||
|
note.modified = (new Date()).toISOString();
|
||||||
|
notes.add(note);
|
||||||
|
$("#note_content").data("noteid", noteid);
|
||||||
|
} else {
|
||||||
|
var note = notes.get(noteid);
|
||||||
|
note.content = $("#note_content").val();
|
||||||
|
note.modified = (new Date()).toISOString();
|
||||||
|
notes.set(note);
|
||||||
|
}
|
||||||
|
notes.fix(note);
|
||||||
|
notes.save(function () {
|
||||||
|
app.toast.create({
|
||||||
|
text: 'Note saved.',
|
||||||
|
closeTimeout: 2000
|
||||||
|
}).open();
|
||||||
|
$("#orig_content").val(note.content);
|
||||||
|
});
|
||||||
|
if (typeof callback == "function") {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function exiteditor() {
|
||||||
|
if ($("note_content").val() == "" || $("note_content").val() === $("orig_content").val()) {
|
||||||
|
router.back({force: true, ignoreCache: true, reload: true});
|
||||||
|
} else {
|
||||||
|
saveme(function () {
|
||||||
|
router.back({force: true, ignoreCache: true, reload: true});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue