Nevermind, don't use Babel
ebeveyn
0415de945f
işleme
8dd6a9872d
@ -1,13 +0,0 @@
|
||||
const presets = [
|
||||
[
|
||||
"@babel/env",
|
||||
{
|
||||
targets: {
|
||||
chrome: "33",
|
||||
},
|
||||
useBuiltIns: "usage",
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
module.exports = { presets };
|
@ -1,60 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
function finishSave(note, callback) {
|
||||
NOTES.fixAll();
|
||||
NOTES.sync(function () {
|
||||
app.toast.create({
|
||||
text: 'Note saved.',
|
||||
closeTimeout: 2000
|
||||
}).open();
|
||||
$("#orig_content").val(note.content);
|
||||
});
|
||||
|
||||
if (typeof callback == "function") {
|
||||
callback();
|
||||
function saveme(callback) {
|
||||
function finishSave(note, callback) {
|
||||
NOTES.fixAll();
|
||||
NOTES.sync(function () {
|
||||
app.toast.create({
|
||||
text: 'Note saved.',
|
||||
closeTimeout: 2000
|
||||
}).open();
|
||||
$("#orig_content").val(note.content);
|
||||
});
|
||||
if (typeof callback == "function") {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var noteid = $("#note_content").data("noteid");
|
||||
|
||||
if (noteid == "") {
|
||||
var note = {
|
||||
content: $("#note_content").val(),
|
||||
modified: Math.round(new Date().getTime() / 1000)
|
||||
};
|
||||
NOTES.add(note, function (n) {
|
||||
$("#note_content").data("noteid", n.noteid);
|
||||
finishSave(n, callback);
|
||||
});
|
||||
} else {
|
||||
var note = NOTES.get(noteid);
|
||||
note.content = $("#note_content").val();
|
||||
note.modified = Math.round(new Date().getTime() / 1000);
|
||||
NOTES.set(note);
|
||||
finishSave(note, callback);
|
||||
}
|
||||
var noteid = $("#note_content").data("noteid");
|
||||
if (noteid == "") {
|
||||
var note = {
|
||||
content: $("#note_content").val(),
|
||||
modified: Math.round((new Date()).getTime() / 1000)
|
||||
};
|
||||
NOTES.add(note, function (n) {
|
||||
$("#note_content").data("noteid", n.noteid);
|
||||
finishSave(n, callback);
|
||||
});
|
||||
} else {
|
||||
var note = NOTES.get(noteid);
|
||||
note.content = $("#note_content").val();
|
||||
note.modified = Math.round((new Date()).getTime() / 1000);
|
||||
NOTES.set(note);
|
||||
finishSave(note, 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
|
||||
});
|
||||
});
|
||||
}
|
||||
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});
|
||||
});
|
||||
}
|
||||
}
|
@ -1,105 +1,126 @@
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
|
||||
$(".view-main").on("ptr:refresh", ".ptr-content", function () {
|
||||
restartApplication();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
function editNote(id) {
|
||||
var note = NOTES.get(id);
|
||||
router.navigate("/editnote", {
|
||||
context: {
|
||||
noteid: id,
|
||||
content: note.content,
|
||||
notetitle: note.title
|
||||
}
|
||||
});
|
||||
console.log("Editing " + id);
|
||||
var note = NOTES.get(id);
|
||||
router.navigate("/editnote", {
|
||||
context: {
|
||||
noteid: id,
|
||||
content: note.content,
|
||||
notetitle: note.title,
|
||||
}
|
||||
});
|
||||
console.log("Editing " + id);
|
||||
}
|
||||
|
||||
function favoriteNote(id) {}
|
||||
function favoriteNote(id) {
|
||||
|
||||
function makeList(id) {}
|
||||
}
|
||||
|
||||
function makeList(id) {
|
||||
|
||||
}
|
||||
|
||||
function deleteNote(id) {
|
||||
app.dialog.confirm('Are you sure?', 'Delete Note', function () {
|
||||
NOTES.del(id, function () {
|
||||
app.ptr.refresh();
|
||||
app.dialog.confirm('Are you sure?', 'Delete Note', function () {
|
||||
NOTES.del(id, function () {
|
||||
app.ptr.refresh();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("#app").on("click", ".edit-note-btn", function () {
|
||||
editNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
editNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
});
|
||||
|
||||
$("#app").on("click", ".favorite-note-btn", function () {
|
||||
favoriteNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
favoriteNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
});
|
||||
|
||||
$("#app").on("click", ".listify-note-btn", function () {
|
||||
makeList($(this).data("note"));
|
||||
app.popover.close();
|
||||
makeList($(this).data("note"));
|
||||
app.popover.close();
|
||||
});
|
||||
|
||||
$("#app").on("click", ".delete-note-btn", function () {
|
||||
deleteNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
deleteNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
});
|
||||
|
||||
function openNoteActionMenu(notecard) {
|
||||
var noteid = notecard.data("id");
|
||||
|
||||
if (window.innerWidth < 768) {
|
||||
var actionsheet = app.actions.create({
|
||||
buttons: [{
|
||||
text: "Edit",
|
||||
bold: true,
|
||||
icon: '<i class="fas fa-edit fa-fw"></i>',
|
||||
onClick: function onClick() {
|
||||
editNote(noteid);
|
||||
}
|
||||
}, // {
|
||||
// text: "Favorite",
|
||||
// icon: '<i class="fas fa-star fa-fw"></i>',
|
||||
// onClick: function () {
|
||||
// favoriteNote(noteid);
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// text: "Make a List",
|
||||
// icon: '<i class="fas fa-tasks fa-fw"></i>',
|
||||
// onClick: function () {
|
||||
// makeList(noteid);
|
||||
// }
|
||||
// },
|
||||
{
|
||||
text: "Delete",
|
||||
icon: '<i class="fas fa-trash fa-fw"></i>',
|
||||
onClick: function onClick() {
|
||||
deleteNote(noteid);
|
||||
}
|
||||
}]
|
||||
});
|
||||
actionsheet.open();
|
||||
return false;
|
||||
} else {
|
||||
var contextPopover = app.popover.create({
|
||||
targetEl: notecard.children(".menubtn"),
|
||||
content: '<div class="popover">' + '<div class="popover-inner">' + '<div class="list">' + '<ul>' + '<li><a class="list-button item-link edit-note-btn" data-note="' + noteid + '"><i class="fas fa-edit fa-fw"></i> Edit</a></li>' + '<li><a class="list-button item-link favorite-note-btn" data-note="' + noteid + '"><i class="fas fa-star fa-fw"></i> Favorite</a></li>' + '<li><a class="list-button item-link listify-note-btn" data-note="' + noteid + '"><i class="fas fa-tasks fa-fw"></i> Make a List</a></li>' + '<li><a class="list-button item-link delete-note-btn" data-note="' + noteid + '"><i class="fas fa-trash fa-fw"></i> Delete</a></li>' + '</ul>' + '</div>' + '</div>' + '</div>'
|
||||
});
|
||||
contextPopover.open();
|
||||
}
|
||||
var noteid = notecard.data("id");
|
||||
if (window.innerWidth < 768) {
|
||||
var actionsheet = app.actions.create({
|
||||
buttons: [
|
||||
{
|
||||
text: "Edit",
|
||||
bold: true,
|
||||
icon: '<i class="fas fa-edit fa-fw"></i>',
|
||||
onClick: function () {
|
||||
editNote(noteid);
|
||||
}
|
||||
},
|
||||
// {
|
||||
// text: "Favorite",
|
||||
// icon: '<i class="fas fa-star fa-fw"></i>',
|
||||
// onClick: function () {
|
||||
// favoriteNote(noteid);
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// text: "Make a List",
|
||||
// icon: '<i class="fas fa-tasks fa-fw"></i>',
|
||||
// onClick: function () {
|
||||
// makeList(noteid);
|
||||
// }
|
||||
// },
|
||||
{
|
||||
text: "Delete",
|
||||
icon: '<i class="fas fa-trash fa-fw"></i>',
|
||||
onClick: function () {
|
||||
deleteNote(noteid);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
return false;
|
||||
actionsheet.open();
|
||||
return false;
|
||||
} else {
|
||||
var contextPopover = app.popover.create({
|
||||
targetEl: notecard.children(".menubtn"),
|
||||
content: '<div class="popover">' +
|
||||
'<div class="popover-inner">' +
|
||||
'<div class="list">' +
|
||||
'<ul>' +
|
||||
'<li><a class="list-button item-link edit-note-btn" data-note="' + noteid + '"><i class="fas fa-edit fa-fw"></i> Edit</a></li>' +
|
||||
'<li><a class="list-button item-link favorite-note-btn" data-note="' + noteid + '"><i class="fas fa-star fa-fw"></i> Favorite</a></li>' +
|
||||
'<li><a class="list-button item-link listify-note-btn" data-note="' + noteid + '"><i class="fas fa-tasks fa-fw"></i> Make a List</a></li>' +
|
||||
'<li><a class="list-button item-link delete-note-btn" data-note="' + noteid + '"><i class="fas fa-trash fa-fw"></i> Delete</a></li>' +
|
||||
'</ul>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
});
|
||||
contextPopover.open();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$(".view-main").on("click", ".notecard .menubtn", function () {
|
||||
return openNoteActionMenu($(this).parent());
|
||||
return openNoteActionMenu($(this).parent());
|
||||
});
|
||||
|
||||
$(".view-main").on("contextmenu", ".notecard", function () {
|
||||
return openNoteActionMenu($(this));
|
||||
return openNoteActionMenu($(this));
|
||||
});
|
@ -1,74 +1,70 @@
|
||||
"use strict";
|
||||
|
||||
require("core-js/modules/es6.array.find");
|
||||
|
||||
require("core-js/modules/es6.regexp.to-string");
|
||||
|
||||
/* 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/. */
|
||||
|
||||
var $$ = Dom7;
|
||||
|
||||
var app = new Framework7({
|
||||
root: "#app",
|
||||
name: "NotePost",
|
||||
id: "com.netsyms.NotePostApp",
|
||||
init: true,
|
||||
initOnDeviceReady: false,
|
||||
routes: routes
|
||||
root: "#app",
|
||||
name: "NotePost",
|
||||
id: "com.netsyms.NotePostApp",
|
||||
init: true,
|
||||
initOnDeviceReady: false,
|
||||
routes: routes
|
||||
});
|
||||
|
||||
var mainView = app.views.create('.view-main', {
|
||||
url: "/"
|
||||
url: "/"
|
||||
});
|
||||
|
||||
var router = mainView.router;
|
||||
|
||||
var NOTES = null;
|
||||
|
||||
var OFFLINE = false;
|
||||
|
||||
/**
|
||||
* Thanks to https://stackoverflow.com/a/13542669
|
||||
* @param {type} color
|
||||
* @param {type} percent
|
||||
* @returns {String}
|
||||
*/
|
||||
|
||||
function shadeColor2(color, percent) {
|
||||
var f = parseInt(color.slice(1), 16),
|
||||
t = percent < 0 ? 0 : 255,
|
||||
p = percent < 0 ? percent * -1 : percent,
|
||||
R = f >> 16,
|
||||
G = f >> 8 & 0x00FF,
|
||||
B = f & 0x0000FF;
|
||||
return "#" + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1);
|
||||
var f = parseInt(color.slice(1), 16), t = percent < 0 ? 0 : 255, p = percent < 0 ? percent * -1 : percent, R = f >> 16, G = f >> 8 & 0x00FF, B = f & 0x0000FF;
|
||||
return "#" + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1);
|
||||
}
|
||||
|
||||
function restartApplication() {
|
||||
window.location = "index.html";
|
||||
window.location = "index.html";
|
||||
}
|
||||
|
||||
router.on("pageInit", function (pagedata) {
|
||||
pagedata.$el.find('script').each(function (el) {
|
||||
if ($$(this).attr('src')) {
|
||||
var s = document.createElement('script');
|
||||
s.src = $$(this).attr('src');
|
||||
$$('head').append(s);
|
||||
} else {
|
||||
eval($$(this).text());
|
||||
pagedata.$el.find('script').each(function (el) {
|
||||
if ($$(this).attr('src')) {
|
||||
var s = document.createElement('script');
|
||||
s.src = $$(this).attr('src');
|
||||
$$('head').append(s);
|
||||
} else {
|
||||
eval($$(this).text());
|
||||
}
|
||||
});
|
||||
switch (pagedata.name) {
|
||||
case "settings":
|
||||
updateSettingsData();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
switch (pagedata.name) {
|
||||
case "settings":
|
||||
updateSettingsData();
|
||||
break;
|
||||
}
|
||||
}); // Run platform-specific setup code for Cordova or NW.js
|
||||
});
|
||||
|
||||
// Run platform-specific setup code for Cordova or NW.js
|
||||
initPlatform();
|
||||
|
||||
|
||||
if (localStorage.getItem("configured") == null) {
|
||||
// Open the setup page
|
||||
router.navigate("/setup/0");
|
||||
// Open the setup page
|
||||
router.navigate("/setup/0");
|
||||
} else {
|
||||
createNotesObject(function (n) {
|
||||
NOTES = n;
|
||||
router.navigate("/home");
|
||||
});
|
||||
createNotesObject(function (n) {
|
||||
NOTES = n;
|
||||
router.navigate("/home");
|
||||
});
|
||||
}
|
@ -1,39 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* 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 createNotesObject(callback) {
|
||||
if (localStorage.getItem("serverurl") == null) {
|
||||
callback(new Notes());
|
||||
} else {
|
||||
var checkurl = localStorage.getItem("serverurl") + "/api/ping";
|
||||
$.ajax({
|
||||
url: checkurl,
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
method: "POST",
|
||||
beforeSend: function beforeSend(xhr) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(localStorage.getItem("username") + ":" + localStorage.getItem("password")));
|
||||
},
|
||||
success: function success(data) {
|
||||
if (data.status == "OK") {
|
||||
callback(new NotePostNotes(localStorage.getItem("serverurl"), localStorage.getItem("username"), localStorage.getItem("password")));
|
||||
} else if (data.status == "ERROR") {
|
||||
app.dialog.alert(data.msg, "Error");
|
||||
OFFLINE = true;
|
||||
callback(new Notes());
|
||||
} else {
|
||||
OFFLINE = true;
|
||||
callback(new Notes());
|
||||
}
|
||||
},
|
||||
error: function error() {
|
||||
OFFLINE = true;
|
||||
if (localStorage.getItem("serverurl") == null) {
|
||||
callback(new Notes());
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
var checkurl = localStorage.getItem("serverurl") + "/api/ping";
|
||||
$.ajax({
|
||||
url: checkurl,
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
method: "POST",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(localStorage.getItem("username") + ":" + localStorage.getItem("password")));
|
||||
}, success: function (data) {
|
||||
if (data.status == "OK") {
|
||||
callback(new NotePostNotes(localStorage.getItem("serverurl"), localStorage.getItem("username"), localStorage.getItem("password")));
|
||||
} else if (data.status == "ERROR") {
|
||||
app.dialog.alert(data.msg, "Error");
|
||||
OFFLINE = true;
|
||||
callback(new Notes());
|
||||
} else {
|
||||
OFFLINE = true;
|
||||
callback(new Notes());
|
||||
}
|
||||
}, error: function () {
|
||||
OFFLINE = true;
|
||||
callback(new Notes());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,70 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
var platform_type = "";
|
||||
|
||||
var openBrowser = function openBrowser(url) {};
|
||||
var openBrowser = function (url) {
|
||||
|
||||
}
|
||||
|
||||
function initCordova() {
|
||||
platform_type = "cordova"; // Handle back button to close things
|
||||
platform_type = "cordova";
|
||||
|
||||
document.addEventListener("backbutton", function (event) {
|
||||
router.navigate("/home");
|
||||
}, false);
|
||||
document.addEventListener("deviceready", function () {
|
||||
if (cordova.platformId == 'android') {
|
||||
StatusBar.backgroundColorByHexString("#D32F2F");
|
||||
StatusBar.styleLightContent();
|
||||
}
|
||||
}, false);
|
||||
// Handle back button to close things
|
||||
document.addEventListener("backbutton", function (event) {
|
||||
router.navigate("/home");
|
||||
}, false);
|
||||
|
||||
document.addEventListener("deviceready", function () {
|
||||
if (cordova.platformId == 'android') {
|
||||
StatusBar.backgroundColorByHexString("#D32F2F");
|
||||
StatusBar.styleLightContent();
|
||||
}
|
||||
}, false);
|
||||
|
||||
openBrowser = function openBrowser(url) {
|
||||
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
||||
};
|
||||
openBrowser = function (url) {
|
||||
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
||||
}
|
||||
}
|
||||
|
||||
function initNW() {
|
||||
platform_type = "nw";
|
||||
platform_type = "nw";
|
||||
|
||||
openBrowser = function openBrowser(url) {
|
||||
nw.Window.open(url, {
|
||||
id: url
|
||||
}, function (browserwin) {
|
||||
// Add menubar so the user can navigate around if they click a link
|
||||
var browsermenu = new nw.Menu({
|
||||
type: 'menubar'
|
||||
});
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Back",
|
||||
click: function click() {
|
||||
browserwin.window.history.back();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Forward",
|
||||
click: function click() {
|
||||
browserwin.window.history.forward();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Home",
|
||||
click: function click() {
|
||||
browserwin.window.location.href = url;
|
||||
}
|
||||
}));
|
||||
browserwin.menu = browsermenu;
|
||||
});
|
||||
};
|
||||
openBrowser = function (url) {
|
||||
nw.Window.open(url, {
|
||||
id: url
|
||||
}, function (browserwin) {
|
||||
// Add menubar so the user can navigate around if they click a link
|
||||
var browsermenu = new nw.Menu({type: 'menubar'});
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Back",
|
||||
click: function () {
|
||||
browserwin.window.history.back();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Forward",
|
||||
click: function () {
|
||||
browserwin.window.history.forward();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Home",
|
||||
click: function () {
|
||||
browserwin.window.location.href = url;
|
||||
}
|
||||
}));
|
||||
browserwin.menu = browsermenu;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initPlatform() {
|
||||
if (typeof cordova !== 'undefined') {
|
||||
initCordova();
|
||||
} else if (typeof nw !== 'undefined') {
|
||||
initNW();
|
||||
}
|
||||
if (typeof cordova !== 'undefined') {
|
||||
initCordova();
|
||||
} else if (typeof nw !== 'undefined') {
|
||||
initNW();
|
||||
}
|
||||
}
|
@ -1,109 +1,103 @@
|
||||
"use strict";
|
||||
|
||||
require("core-js/modules/es6.regexp.replace");
|
||||
|
||||
require("core-js/modules/es6.string.starts-with");
|
||||
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
|
||||
netsymscomurl = "https://apps.netsyms.com/notepost";
|
||||
netsymsbizurl = "https://BIZID.netsyms.biz/notepost";
|
||||
|
||||
|
||||
$('#use-security-checkbox-li').click(function () {
|
||||
// Event fires before the checkbox is changed, so we need to do the opposite
|
||||
if ($("#use-security").prop("checked")) {
|
||||
$('#protocol-select').text("https://");
|
||||
} else {
|
||||
$('#protocol-select').text("http://");
|
||||
}
|
||||
// Event fires before the checkbox is changed, so we need to do the opposite
|
||||
if ($("#use-security").prop("checked")) {
|
||||
$('#protocol-select').text("https://");
|
||||
} else {
|
||||
$('#protocol-select').text("http://");
|
||||
}
|
||||
});
|
||||
/* Detect if the user typed "http[s]://" into the URL box and correct for it */
|
||||
|
||||
/* Detect if the user typed "http[s]://" into the URL box and correct for it */
|
||||
$("#url").blur(function () {
|
||||
if ($('#url').val().toLowerCase().startsWith("https://")) {
|
||||
$('#url').val($('#url').val().replace(/https\:\/\//ig, ""));
|
||||
$('#protocol-select').text("https://");
|
||||
$('#use-security').prop('checked', true);
|
||||
} else if ($('#url').val().toLowerCase().startsWith("http://")) {
|
||||
$('#url').val($('#url').val().replace(/http\:\/\//ig, ""));
|
||||
$('#protocol-select').text("http://");
|
||||
$('#use-security').prop('checked', false);
|
||||
}
|
||||
if ($('#url').val().toLowerCase().startsWith("https://")) {
|
||||
$('#url').val($('#url').val().replace(/https\:\/\//ig, ""));
|
||||
$('#protocol-select').text("https://");
|
||||
$('#use-security').prop('checked', true);
|
||||
} else if ($('#url').val().toLowerCase().startsWith("http://")) {
|
||||
$('#url').val($('#url').val().replace(/http\:\/\//ig, ""));
|
||||
$('#protocol-select').text("http://");
|
||||
$('#use-security').prop('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#username').on("keyup", function () {
|
||||
$('#username').val($('#username').val().toLowerCase());
|
||||
$('#username').val($('#username').val().toLowerCase());
|
||||
});
|
||||
|
||||
function checkAndSave(url, username, password, nextcloud) {
|
||||
app.preloader.show();
|
||||
app.preloader.show();
|
||||
|
||||
if (typeof nextcloud === 'undefined') {
|
||||
nextcloud = false;
|
||||
}
|
||||
|
||||
var checkurl = url + "/api/ping";
|
||||
|
||||
if (nextcloud) {// TODO
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: checkurl,
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
method: "POST",
|
||||
beforeSend: function beforeSend(xhr) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
|
||||
},
|
||||
success: function success(data) {
|
||||
app.preloader.hide();
|
||||
if (typeof nextcloud === 'undefined') {
|
||||
nextcloud = false;
|
||||
}
|
||||
|
||||
if (data.status == "OK") {
|
||||
localStorage.setItem("username", username);
|
||||
localStorage.setItem("password", password);
|
||||
localStorage.setItem("serverurl", url);
|
||||
localStorage.setItem("configured", true); // Restart the app to re-read the config
|
||||
var checkurl = url + "/api/ping";
|
||||
|
||||
restartApplication();
|
||||
} else if (data.status == "ERROR") {
|
||||
app.dialog.alert(data.msg, "Error");
|
||||
} else {
|
||||
app.dialog.alert("", "Error");
|
||||
}
|
||||
},
|
||||
error: function error() {
|
||||
app.preloader.hide();
|
||||
app.dialog.alert("Could not sign in. Check your credentials and connection.", "Error");
|
||||
if (nextcloud) {
|
||||
// TODO
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: checkurl,
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
method: "POST",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
|
||||
}, success: function (data) {
|
||||
app.preloader.hide();
|
||||
if (data.status == "OK") {
|
||||
localStorage.setItem("username", username);
|
||||
localStorage.setItem("password", password);
|
||||
localStorage.setItem("serverurl", url);
|
||||
localStorage.setItem("configured", true);
|
||||
// Restart the app to re-read the config
|
||||
restartApplication();
|
||||
} else if (data.status == "ERROR") {
|
||||
app.dialog.alert(data.msg, "Error");
|
||||
} else {
|
||||
app.dialog.alert("", "Error");
|
||||
}
|
||||
}, error: function () {
|
||||
app.preloader.hide();
|
||||
app.dialog.alert("Could not sign in. Check your credentials and connection.", "Error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setupAccount() {
|
||||
var type = $("#accttype").val();
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
|
||||
switch (type) {
|
||||
case "personal":
|
||||
checkAndSave(netsymscomurl, username, password);
|
||||
break;
|
||||
|
||||
case "business":
|
||||
var url = netsymsbizurl.replace("BIZID", $("#bizid").val());
|
||||
checkAndSave(url, username, password);
|
||||
break;
|
||||
|
||||
case "selfhosted":
|
||||
if (/^(https?:\/\/)/.test($('#url').val())) {
|
||||
var url = $('#url').val();
|
||||
} else {
|
||||
var url = $('#protocol-select').text() + $('#url').val();
|
||||
}
|
||||
|
||||
url = url.replace(/\/$/, ""); // Remove trailing slash
|
||||
|
||||
checkAndSave(url, username, password);
|
||||
break;
|
||||
}
|
||||
var type = $("#accttype").val();
|
||||
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
|
||||
switch (type) {
|
||||
case "personal":
|
||||
checkAndSave(netsymscomurl, username, password);
|
||||
break;
|
||||
case "business":
|
||||
var url = netsymsbizurl.replace("BIZID", $("#bizid").val());
|
||||
checkAndSave(url, username, password);
|
||||
break;
|
||||
case "selfhosted":
|
||||
if (/^(https?:\/\/)/.test($('#url').val())) {
|
||||
var url = $('#url').val();
|
||||
} else {
|
||||
var url = $('#protocol-select').text() + $('#url').val();
|
||||
}
|
||||
url = url.replace(/\/$/, ""); // Remove trailing slash
|
||||
checkAndSave(url, username, password);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* The code in this file is by StackOverflow user Juan Mendes.
|
||||
* License: Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0).
|
||||
* Source: https://stackoverflow.com/a/14966749
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Creates a map out of an array be choosing what property to key by
|
||||
* @param {object[]} array Array that will be converted into a map
|
||||
* @param {string} prop Name of property to key by
|
||||
* @return {object} The mapped array. Example:
|
||||
* mapFromArray([{a:1,b:2}, {a:3,b:4}], 'a')
|
||||
* returns {1: {a:1,b:2}, 3: {a:3,b:4}}
|
||||
*/
|
||||
function mapFromArray(array, prop) {
|
||||
var map = {};
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
map[ array[i][prop] ] = array[i];
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object[]} o old array of notes (local copy)
|
||||
* @param {object[]} n new array of notes (remote copy)
|
||||
* @param {object} An object with changes
|
||||
*/
|
||||
function getDelta(o, n) {
|
||||
var delta = {
|
||||
addedRemote: [],
|
||||
addedLocal: [],
|
||||
deletedRemote: [],
|
||||
deletedLocal: [],
|
||||
changedRemote: [],
|
||||
changedLocal: [],
|
||||
noChange: []
|
||||
};
|
||||
oSane = [];
|
||||
for (var i = 0; i < o.length; i++) {
|
||||
if (o[i].noteid == null) { // Note has no real `noteid`
|
||||
delta.addedLocal.push(o[i]);
|
||||
} else {
|
||||
oSane.push(o[i]);
|
||||
}
|
||||
}
|
||||
var local = mapFromArray(oSane, 'noteid');
|
||||
var remote = mapFromArray(n, 'noteid');
|
||||
|
||||
for (var id in local) {
|
||||
if (!remote.hasOwnProperty(id)) { // Notes that are only present locally
|
||||
delta.addedLocal.push(local[id]);
|
||||
// TODO: Figure out which notes were actually added locally and which were deleted on the server
|
||||
/*if (local[id].norealid) { // Note hasn't been synced to the remote yet
|
||||
delta.addedLocal.push(local[id]);
|
||||
} else { // Note has been synced to remote but isn't there anymore
|
||||
delta.deletedRemote.push(local[id]);
|
||||
}*/
|
||||
} else { // Notes that are present on both
|
||||
if (local[id].modified > remote[id].modified) { // Local copy is newer
|
||||
delta.changedLocal.push(local[id]);
|
||||
} else if (local[id].modified < remote[id].modified) { // Remote copy is newer
|
||||
delta.changedRemote.push(remote[id]);
|
||||
} else { // Modified date is same, let's check content
|
||||
if (local[id].content == remote[id].content) {
|
||||
delta.noChange.push(local[id]);
|
||||
} else if (local[id].content.length > remote[id].content.length) {
|
||||
delta.changedLocal.push(local[id]);
|
||||
} else {
|
||||
delta.changedRemote.push(remote[id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add notes that are only on the remote
|
||||
for (var id in remote) {
|
||||
if (!local.hasOwnProperty(id)) {
|
||||
delta.addedRemote.push(remote[id]);
|
||||
}
|
||||
}
|
||||
return delta;
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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) {
|
||||
function finishSave(note, callback) {
|
||||
NOTES.fixAll();
|
||||
NOTES.sync(function () {
|
||||
app.toast.create({
|
||||
text: 'Note saved.',
|
||||
closeTimeout: 2000
|
||||
}).open();
|
||||
$("#orig_content").val(note.content);
|
||||
});
|
||||
if (typeof callback == "function") {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
var noteid = $("#note_content").data("noteid");
|
||||
if (noteid == "") {
|
||||
var note = {
|
||||
content: $("#note_content").val(),
|
||||
modified: Math.round((new Date()).getTime() / 1000)
|
||||
};
|
||||
NOTES.add(note, function (n) {
|
||||
$("#note_content").data("noteid", n.noteid);
|
||||
finishSave(n, callback);
|
||||
});
|
||||
} else {
|
||||
var note = NOTES.get(noteid);
|
||||
note.content = $("#note_content").val();
|
||||
note.modified = Math.round((new Date()).getTime() / 1000);
|
||||
NOTES.set(note);
|
||||
finishSave(note, 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});
|
||||
});
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
|
||||
$(".view-main").on("ptr:refresh", ".ptr-content", function () {
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
function editNote(id) {
|
||||
var note = NOTES.get(id);
|
||||
router.navigate("/editnote", {
|
||||
context: {
|
||||
noteid: id,
|
||||
content: note.content,
|
||||
notetitle: note.title,
|
||||
}
|
||||
});
|
||||
console.log("Editing " + id);
|
||||
}
|
||||
|
||||
function favoriteNote(id) {
|
||||
|
||||
}
|
||||
|
||||
function makeList(id) {
|
||||
|
||||
}
|
||||
|
||||
function deleteNote(id) {
|
||||
app.dialog.confirm('Are you sure?', 'Delete Note', function () {
|
||||
NOTES.del(id, function () {
|
||||
app.ptr.refresh();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("#app").on("click", ".edit-note-btn", function () {
|
||||
editNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
});
|
||||
|
||||
$("#app").on("click", ".favorite-note-btn", function () {
|
||||
favoriteNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
});
|
||||
|
||||
$("#app").on("click", ".listify-note-btn", function () {
|
||||
makeList($(this).data("note"));
|
||||
app.popover.close();
|
||||
});
|
||||
|
||||
$("#app").on("click", ".delete-note-btn", function () {
|
||||
deleteNote($(this).data("note"));
|
||||
app.popover.close();
|
||||
});
|
||||
|
||||
function openNoteActionMenu(notecard) {
|
||||
var noteid = notecard.data("id");
|
||||
if (window.innerWidth < 768) {
|
||||
var actionsheet = app.actions.create({
|
||||
buttons: [
|
||||
{
|
||||
text: "Edit",
|
||||
bold: true,
|
||||
icon: '<i class="fas fa-edit fa-fw"></i>',
|
||||
onClick: function () {
|
||||
editNote(noteid);
|
||||
}
|
||||
},
|
||||
// {
|
||||
// text: "Favorite",
|
||||
// icon: '<i class="fas fa-star fa-fw"></i>',
|
||||
// onClick: function () {
|
||||
// favoriteNote(noteid);
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// text: "Make a List",
|
||||
// icon: '<i class="fas fa-tasks fa-fw"></i>',
|
||||
// onClick: function () {
|
||||
// makeList(noteid);
|
||||
// }
|
||||
// },
|
||||
{
|
||||
text: "Delete",
|
||||
icon: '<i class="fas fa-trash fa-fw"></i>',
|
||||
onClick: function () {
|
||||
deleteNote(noteid);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
actionsheet.open();
|
||||
return false;
|
||||
} else {
|
||||
var contextPopover = app.popover.create({
|
||||
targetEl: notecard.children(".menubtn"),
|
||||
content: '<div class="popover">' +
|
||||
'<div class="popover-inner">' +
|
||||
'<div class="list">' +
|
||||
'<ul>' +
|
||||
'<li><a class="list-button item-link edit-note-btn" data-note="' + noteid + '"><i class="fas fa-edit fa-fw"></i> Edit</a></li>' +
|
||||
'<li><a class="list-button item-link favorite-note-btn" data-note="' + noteid + '"><i class="fas fa-star fa-fw"></i> Favorite</a></li>' +
|
||||
'<li><a class="list-button item-link listify-note-btn" data-note="' + noteid + '"><i class="fas fa-tasks fa-fw"></i> Make a List</a></li>' +
|
||||
'<li><a class="list-button item-link delete-note-btn" data-note="' + noteid + '"><i class="fas fa-trash fa-fw"></i> Delete</a></li>' +
|
||||
'</ul>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
});
|
||||
contextPopover.open();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$(".view-main").on("click", ".notecard .menubtn", function () {
|
||||
return openNoteActionMenu($(this).parent());
|
||||
});
|
||||
|
||||
$(".view-main").on("contextmenu", ".notecard", function () {
|
||||
return openNoteActionMenu($(this));
|
||||
});
|
@ -1,70 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
var $$ = Dom7;
|
||||
|
||||
var app = new Framework7({
|
||||
root: "#app",
|
||||
name: "NotePost",
|
||||
id: "com.netsyms.NotePostApp",
|
||||
init: true,
|
||||
initOnDeviceReady: false,
|
||||
routes: routes
|
||||
});
|
||||
|
||||
var mainView = app.views.create('.view-main', {
|
||||
url: "/"
|
||||
});
|
||||
|
||||
var router = mainView.router;
|
||||
|
||||
var NOTES = null;
|
||||
|
||||
var OFFLINE = false;
|
||||
|
||||
/**
|
||||
* Thanks to https://stackoverflow.com/a/13542669
|
||||
* @param {type} color
|
||||
* @param {type} percent
|
||||
* @returns {String}
|
||||
*/
|
||||
function shadeColor2(color, percent) {
|
||||
var f = parseInt(color.slice(1), 16), t = percent < 0 ? 0 : 255, p = percent < 0 ? percent * -1 : percent, R = f >> 16, G = f >> 8 & 0x00FF, B = f & 0x0000FF;
|
||||
return "#" + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1);
|
||||
}
|
||||
|
||||
function restartApplication() {
|
||||
window.location = "index.html";
|
||||
}
|
||||
|
||||
router.on("pageInit", function (pagedata) {
|
||||
pagedata.$el.find('script').each(function (el) {
|
||||
if ($$(this).attr('src')) {
|
||||
var s = document.createElement('script');
|
||||
s.src = $$(this).attr('src');
|
||||
$$('head').append(s);
|
||||
} else {
|
||||
eval($$(this).text());
|
||||
}
|
||||
});
|
||||
switch (pagedata.name) {
|
||||
case "settings":
|
||||
updateSettingsData();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// Run platform-specific setup code for Cordova or NW.js
|
||||
initPlatform();
|
||||
|
||||
|
||||
if (localStorage.getItem("configured") == null) {
|
||||
// Open the setup page
|
||||
router.navigate("/setup/0");
|
||||
} else {
|
||||
createNotesObject(function (n) {
|
||||
NOTES = n;
|
||||
router.navigate("/home");
|
||||
});
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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 createNotesObject(callback) {
|
||||
if (localStorage.getItem("serverurl") == null) {
|
||||
callback(new Notes());
|
||||
} else {
|
||||
var checkurl = localStorage.getItem("serverurl") + "/api/ping";
|
||||
$.ajax({
|
||||
url: checkurl,
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
method: "POST",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(localStorage.getItem("username") + ":" + localStorage.getItem("password")));
|
||||
}, success: function (data) {
|
||||
if (data.status == "OK") {
|
||||
callback(new NotePostNotes(localStorage.getItem("serverurl"), localStorage.getItem("username"), localStorage.getItem("password")));
|
||||
} else if (data.status == "ERROR") {
|
||||
app.dialog.alert(data.msg, "Error");
|
||||
OFFLINE = true;
|
||||
callback(new Notes());
|
||||
} else {
|
||||
OFFLINE = true;
|
||||
callback(new Notes());
|
||||
}
|
||||
}, error: function () {
|
||||
OFFLINE = true;
|
||||
callback(new Notes());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
var platform_type = "";
|
||||
|
||||
var openBrowser = function (url) {
|
||||
|
||||
}
|
||||
|
||||
function initCordova() {
|
||||
platform_type = "cordova";
|
||||
|
||||
// Handle back button to close things
|
||||
document.addEventListener("backbutton", function (event) {
|
||||
router.navigate("/home");
|
||||
}, false);
|
||||
|
||||
document.addEventListener("deviceready", function () {
|
||||
if (cordova.platformId == 'android') {
|
||||
StatusBar.backgroundColorByHexString("#D32F2F");
|
||||
StatusBar.styleLightContent();
|
||||
}
|
||||
}, false);
|
||||
|
||||
openBrowser = function (url) {
|
||||
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
||||
}
|
||||
}
|
||||
|
||||
function initNW() {
|
||||
platform_type = "nw";
|
||||
|
||||
openBrowser = function (url) {
|
||||
nw.Window.open(url, {
|
||||
id: url
|
||||
}, function (browserwin) {
|
||||
// Add menubar so the user can navigate around if they click a link
|
||||
var browsermenu = new nw.Menu({type: 'menubar'});
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Back",
|
||||
click: function () {
|
||||
browserwin.window.history.back();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Forward",
|
||||
click: function () {
|
||||
browserwin.window.history.forward();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Home",
|
||||
click: function () {
|
||||
browserwin.window.location.href = url;
|
||||
}
|
||||
}));
|
||||
browserwin.menu = browsermenu;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initPlatform() {
|
||||
if (typeof cordova !== 'undefined') {
|
||||
initCordova();
|
||||
} else if (typeof nw !== 'undefined') {
|
||||
initNW();
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
|
||||
netsymscomurl = "https://apps.netsyms.com/notepost";
|
||||
netsymsbizurl = "https://BIZID.netsyms.biz/notepost";
|
||||
|
||||
|
||||
$('#use-security-checkbox-li').click(function () {
|
||||
// Event fires before the checkbox is changed, so we need to do the opposite
|
||||
if ($("#use-security").prop("checked")) {
|
||||
$('#protocol-select').text("https://");
|
||||
} else {
|
||||
$('#protocol-select').text("http://");
|
||||
}
|
||||
});
|
||||
|
||||
/* Detect if the user typed "http[s]://" into the URL box and correct for it */
|
||||
$("#url").blur(function () {
|
||||
if ($('#url').val().toLowerCase().startsWith("https://")) {
|
||||
$('#url').val($('#url').val().replace(/https\:\/\//ig, ""));
|
||||
$('#protocol-select').text("https://");
|
||||
$('#use-security').prop('checked', true);
|
||||
} else if ($('#url').val().toLowerCase().startsWith("http://")) {
|
||||
$('#url').val($('#url').val().replace(/http\:\/\//ig, ""));
|
||||
$('#protocol-select').text("http://");
|
||||
$('#use-security').prop('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#username').on("keyup", function () {
|
||||
$('#username').val($('#username').val().toLowerCase());
|
||||
});
|
||||
|
||||
function checkAndSave(url, username, password, nextcloud) {
|
||||
app.preloader.show();
|
||||
|
||||
if (typeof nextcloud === 'undefined') {
|
||||
nextcloud = false;
|
||||
}
|
||||
|
||||
var checkurl = url + "/api/ping";
|
||||
|
||||
if (nextcloud) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: checkurl,
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
method: "POST",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
|
||||
}, success: function (data) {
|
||||
app.preloader.hide();
|
||||
if (data.status == "OK") {
|
||||
localStorage.setItem("username", username);
|
||||
localStorage.setItem("password", password);
|
||||
localStorage.setItem("serverurl", url);
|
||||
localStorage.setItem("configured", true);
|
||||
// Restart the app to re-read the config
|
||||
restartApplication();
|
||||
} else if (data.status == "ERROR") {
|
||||
app.dialog.alert(data.msg, "Error");
|
||||
} else {
|
||||
app.dialog.alert("", "Error");
|
||||
}
|
||||
}, error: function () {
|
||||
app.preloader.hide();
|
||||
app.dialog.alert("Could not sign in. Check your credentials and connection.", "Error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setupAccount() {
|
||||
var type = $("#accttype").val();
|
||||
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
|
||||
switch (type) {
|
||||
case "personal":
|
||||
checkAndSave(netsymscomurl, username, password);
|
||||
break;
|
||||
case "business":
|
||||
var url = netsymsbizurl.replace("BIZID", $("#bizid").val());
|
||||
checkAndSave(url, username, password);
|
||||
break;
|
||||
case "selfhosted":
|
||||
if (/^(https?:\/\/)/.test($('#url').val())) {
|
||||
var url = $('#url').val();
|
||||
} else {
|
||||
var url = $('#protocol-select').text() + $('#url').val();
|
||||
}
|
||||
url = url.replace(/\/$/, ""); // Remove trailing slash
|
||||
checkAndSave(url, username, password);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,25 +1,16 @@
|
||||
{
|
||||
"name": "com.netsyms.NotePostApp",
|
||||
"scripts": {
|
||||
"build": "babel js_src -d js"
|
||||
},
|
||||
"displayName": "NotePost",
|
||||
"version": "1.0.0",
|
||||
"description": "A cross-platform client app for NotePost.",
|
||||
"author": "Netsyms Technologies",
|
||||
"license": "MPL-2.0",
|
||||
"dependencies": {
|
||||
"@babel/polyfill": "^7.2.5",
|
||||
"@fortawesome/fontawesome-free": "^5.6.3",
|
||||
"easymde": "^2.4.2",
|
||||
"framework7": "^3.6.5",
|
||||
"jquery": "^3.3.1",
|
||||
"marked": "^0.6.0",
|
||||
"shufflejs": "^5.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.2.3",
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/preset-env": "^7.2.3"
|
||||
}
|
||||
"name": "com.netsyms.NotePostApp",
|
||||
"displayName": "NotePost",
|
||||
"version": "1.0.0",
|
||||
"description": "A cross-platform client app for NotePost.",
|
||||
"author": "Netsyms Technologies",
|
||||
"license": "MPL-2.0",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.6.3",
|
||||
"easymde": "^2.4.2",
|
||||
"framework7": "^3.6.5",
|
||||
"jquery": "^3.3.1",
|
||||
"marked": "^0.6.0",
|
||||
"shufflejs": "^5.2.1"
|
||||
}
|
||||
}
|
||||
|
Dosya farkı çok büyük olduğundan ihmal edildi
Fark Yükle
Yükleniyor…
Yeni konuda referans