From 8b5edbd369cf205c36092dc6f8c0b2744e5c2c4f Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 8 Nov 2018 21:20:33 -0700 Subject: [PATCH] Add setup for personal netsyms.com accounts (close #15) --- www/img/accounticons/personal.svg | 2 + www/js/main.js | 2 +- www/js/setup1.js | 35 +++++++++++++ www/pages/accounts.html | 6 +-- www/pages/setup0.html | 82 +++++++++++++++++++++++++++++++ www/pages/setup1.html | 36 +++++++++++++- www/routes.js | 7 ++- 7 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 www/img/accounticons/personal.svg create mode 100644 www/pages/setup0.html diff --git a/www/img/accounticons/personal.svg b/www/img/accounticons/personal.svg new file mode 100644 index 0000000..8faa19c --- /dev/null +++ b/www/img/accounticons/personal.svg @@ -0,0 +1,2 @@ + + diff --git a/www/js/main.js b/www/js/main.js index 4a13d26..c9d21a5 100644 --- a/www/js/main.js +++ b/www/js/main.js @@ -116,7 +116,7 @@ document.addEventListener("deviceready", function () { } else { // No account data found, open setup router.navigate({ - name: 'setup1' + name: 'setup0' }); } }) diff --git a/www/js/setup1.js b/www/js/setup1.js index b2e59da..239b313 100644 --- a/www/js/setup1.js +++ b/www/js/setup1.js @@ -10,6 +10,8 @@ setuppassword = ""; setupsynckey = ""; setupsyncurl = ""; +netsymscomurl = "http://skylar-desktop.home/accounthub/mobile/index.php"; + if (localStorage.getItem("firstrun") === null) { $("#setuptitle").text("Setup"); $(".firstrun-only").css("display", ""); @@ -74,11 +76,13 @@ function manualshow() { } function checkAndSave(syncurl, username, key) { + app.preloader.show(); $.post(syncurl, { username: username, key: key, action: "check_key" }, function (data) { + app.preloader.hide(); if (data.status === 'OK') { setupusername = username; setupsyncurl = syncurl; @@ -90,10 +94,41 @@ function checkAndSave(syncurl, username, key) { navigator.notification.alert(data.msg, null, "Error", 'Dismiss'); } }, "json").fail(function () { + app.preloader.hide(); navigator.notification.alert("Could not connect to the server. Try again.", null, "Error", 'Dismiss'); }); } +function personalsetup() { + app.preloader.show(); + var username = $("#personal_username").val(); + var password = $("#personal_password").val(); + + $.post(netsymscomurl, { + username: username, + password: password, + key: "NOKEY", + desc: device.platform + " " + device.model + " " + device.serial, + action: "generatesynccode" + }, function (result) { + app.preloader.hide(); + if (result.status == "OK") { + var code = result.code; + var accid = addaccount(username, password, netsymscomurl, code); + switchaccount(accid); + localStorage.setItem("firstrun", "1"); + navigator.notification.alert("Account connected!", null, "Success", 'Continue'); + restartApplication(); + } else if (result.status == "ERROR") { + navigator.notification.alert(result.message, null, "Error", 'Dismiss'); + } else { + navigator.notification.alert("Something went wrong, please try again.", null, "Error", 'Dismiss'); + } + }, "json").fail(function () { + app.preloader.hide(); + navigator.notification.alert("Something went wrong, please try again.", null, "Error", 'Dismiss'); + }); +} function scanCode() { try { diff --git a/www/pages/accounts.html b/www/pages/accounts.html index a56e32a..6fb3248 100644 --- a/www/pages/accounts.html +++ b/www/pages/accounts.html @@ -28,7 +28,7 @@
{{username}}
- + {{#if active}}
@@ -60,7 +60,7 @@
- + add
@@ -72,7 +72,7 @@ openAccountSwitcher(true); }); - $(".view-main").on("click", ".accountlist-item", function () { + $(".view-main").on("click", ".accountlist-item .item-content", function () { var id = $(this).data("id"); switchaccount(id); }); diff --git a/www/pages/setup0.html b/www/pages/setup0.html new file mode 100644 index 0000000..e550870 --- /dev/null +++ b/www/pages/setup0.html @@ -0,0 +1,82 @@ + + +
+ + + + + + +
\ No newline at end of file diff --git a/www/pages/setup1.html b/www/pages/setup1.html index 826817f..e2598ed 100644 --- a/www/pages/setup1.html +++ b/www/pages/setup1.html @@ -14,12 +14,46 @@
-

Open AccountHub on another device and go to Sync settings. Generate a mobile sync code, then press the button below to scan it.

+ {{#if personal}} +

Type your netsyms.com username and password.

+ +
+
    +
  • +
    +
    + + +
    +
    +
  • + +
  • +
    +
    + + +
    +
    +
  • +
+
+
+ Continue +
+ +
+ +

Or, scan a QR code with your phone camera. Open your account dashboard on another device (like a computer) and go to Sync settings. Generate a mobile sync code, then press the button below to scan it.

+ {{else}} +

Open AccountHub on another device and go to Sync settings. Generate a mobile sync code, then press the button below to scan it.

+ {{/if}}
+