diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock b/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock
index 940b293..7babce5 100644
Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock and b/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock differ
diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin b/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin
index c9a83d8..84b4326 100644
Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin and b/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin differ
diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin b/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin
index 4d9ab42..e9c4e09 100644
Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin and b/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin differ
diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin b/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin
index 6d41466..04125ff 100644
Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin and b/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin differ
diff --git a/platforms/android/assets/www/js/home.js b/platforms/android/assets/www/js/location.js
similarity index 67%
rename from platforms/android/assets/www/js/home.js
rename to platforms/android/assets/www/js/location.js
index 507117e..f05c7f9 100644
--- a/platforms/android/assets/www/js/home.js
+++ b/platforms/android/assets/www/js/location.js
@@ -174,7 +174,7 @@ function pingServer() {
$.get(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude);
}
}
-;
+
function onError(error) {
$('#loading-error').text("Check your device's network and location settings, and ensure a clear view of the sky.");
}
@@ -207,153 +207,4 @@ setInterval(pingServer, 5000);
// Show error if it's taking too long
setTimeout(function () {
onError();
-}, 15 * 1000);
-
-
-//////////////////////////////////////////////
-// Profile, stats, and chat stuff
-//////////////////////////////////////////////
-
-
-/*
- * Handles general server communication.
- */
-
-/**
- * Syncs the user's stats with the server and calls refreshStats().
- */
-function syncStats() {
- $.getJSON(mkApiUrl('getstats'), {
- user: username
- }, function (data) {
- if (data.status === 'OK') {
- maxenergy = data.stats.maxenergy;
- energy = data.stats.energy;
- level = data.stats.level;
- refreshStats();
- }
- });
-}
-
-/**
- * Display the current stats on the home screen.
- */
-function refreshStats() {
- energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0;
- $('#energybar').css('width', String(energypercent) + '%');
-}
-
-function getChat() {
- if (lockGot) {
- $.getJSON(mkApiUrl('chat', 'cs'), {
- lat: latitude,
- long: longitude
- }, function (data) {
- data = sortResults(data, 'time', true);
- var content = "";
- data.forEach(function (msg) {
- content += "" + msg.username + " " + msg.message + "
";
- });
- $('#chatmsgs').html(content);
- });
- }
-}
-
-
-syncStats();
-setInterval(function () {
- syncStats();
-}, 10 * 1000);
-setInterval(function () {
- getChat();
-}, 2000);
-// Send chat messages
-$("#chatsendform").submit(function (event) {
- message = $('#chatbox-input').val();
- if (message !== '') {
- $.post(mkApiUrl('chat', 'cs'), {
- user: username,
- lat: latitude,
- long: longitude,
- msg: message
- }, function (data) {
- if (data.status === 'OK') {
- $('#chatbox-input').val("");
- $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
- }
- }, "json");
- }
- event.preventDefault();
- return false;
-});
-function toggleChat() {
- if ($('#chatmsgs').css('display') === 'none') {
- openChat();
- } else {
- closeChat();
- }
-}
-
-function closeChat() {
- $('#chatmsgs').css('display', 'none');
- $('#chatbox').css('height', 'auto');
-}
-
-function openChat() {
- $('#chatbox').css('height', '50%');
- $('#chatmsgs').css('display', 'block');
- $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
-}
-
-function openProfile(user) {
- user = typeof user !== 'undefined' ? user : username;
- $('#main-content').load("screens/profile.html", null, function (x) {
- $('#overlay-main').css('display', 'block');
- loadProfile(user);
- });
-}
-
-function openRules() {
- openmodal('rules', '#rules-modal');
-}
-
-function openIntro() {
- openmodal('intro', '#intro-modal');
-}
-
-function openMenu(topage) {
- topage = typeof topage !== 'undefined' ? topage : "";
- $('#main-content').load("screens/menu.html", null, function (x) {
- $('#overlay-main').css('display', 'block');
- if (topage !== '') {
- $('#' + topage + '-tab').tab('show');
- }
- });
-}
-
-
-
-//////////////////////////////////////////////
-// Other things
-//////////////////////////////////////////////
-
-function closeMain() {
- $('#overlay-main').slideDown(100, function () {
- $('#overlay-main').css('display', 'none');
- $('#main-content').html("");
- });
-}
-
-// Handle back button to close things
-document.addEventListener("backbutton", function (event) {
- if ($('#overlay-main').css('display') !== 'none') {
- closeMain();
- } else if ($('#chatmsgs').css('display') !== 'none') {
- toggleChat();
- }
-}, false);
-// Show the rules
-if (localStorage.getItem("seenintro") !== 'yes') {
- openIntro();
- localStorage.setItem("seenintro", 'yes');
-}
\ No newline at end of file
+}, 15 * 1000);
\ No newline at end of file
diff --git a/platforms/android/assets/www/js/main.js b/platforms/android/assets/www/js/main.js
index 12ef656..1e13190 100644
--- a/platforms/android/assets/www/js/main.js
+++ b/platforms/android/assets/www/js/main.js
@@ -91,9 +91,36 @@ function scanCode() {
}
function sortResults(array, prop, asc) {
- array = array.sort(function(a, b) {
- if (asc) return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0);
- else return (b[prop] > a[prop]) ? 1 : ((b[prop] < a[prop]) ? -1 : 0);
+ array = array.sort(function (a, b) {
+ if (asc)
+ return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0);
+ else
+ return (b[prop] > a[prop]) ? 1 : ((b[prop] < a[prop]) ? -1 : 0);
});
return array;
+}
+
+//////////////////////////////////////////////
+// Other things
+//////////////////////////////////////////////
+
+function closeMain() {
+ $('#overlay-main').slideDown(100, function () {
+ $('#overlay-main').css('display', 'none');
+ $('#main-content').html("");
+ });
+}
+
+// Handle back button to close things
+document.addEventListener("backbutton", function (event) {
+ if ($('#overlay-main').css('display') !== 'none') {
+ closeMain();
+ } else if ($('#chatmsgs').css('display') !== 'none') {
+ toggleChat();
+ }
+}, false);
+// Show the rules
+if (localStorage.getItem("seenintro") !== 'yes') {
+ openIntro();
+ localStorage.setItem("seenintro", 'yes');
}
\ No newline at end of file
diff --git a/platforms/android/assets/www/js/user.js b/platforms/android/assets/www/js/user.js
new file mode 100644
index 0000000..d82001f
--- /dev/null
+++ b/platforms/android/assets/www/js/user.js
@@ -0,0 +1,120 @@
+//////////////////////////////////////////////
+// Profile, stats, and chat stuff
+//////////////////////////////////////////////
+
+
+/*
+ * Handles general server communication.
+ */
+
+/**
+ * Syncs the user's stats with the server and calls refreshStats().
+ */
+function syncStats() {
+ $.getJSON(mkApiUrl('getstats'), {
+ user: username
+ }, function (data) {
+ if (data.status === 'OK') {
+ maxenergy = data.stats.maxenergy;
+ energy = data.stats.energy;
+ level = data.stats.level;
+ refreshStats();
+ }
+ });
+}
+
+/**
+ * Display the current stats on the home screen.
+ */
+function refreshStats() {
+ energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0;
+ $('#energybar').css('width', String(energypercent) + '%');
+}
+
+function getChat() {
+ if (lockGot) {
+ $.getJSON(mkApiUrl('chat', 'cs'), {
+ lat: latitude,
+ long: longitude
+ }, function (data) {
+ data = sortResults(data, 'time', true);
+ var content = "";
+ data.forEach(function (msg) {
+ content += "" + msg.username + " " + msg.message + "
";
+ });
+ $('#chatmsgs').html(content);
+ });
+ }
+}
+
+
+syncStats();
+setInterval(function () {
+ syncStats();
+}, 10 * 1000);
+setInterval(function () {
+ getChat();
+}, 2000);
+// Send chat messages
+$("#chatsendform").submit(function (event) {
+ message = $('#chatbox-input').val();
+ if (message !== '') {
+ $.post(mkApiUrl('chat', 'cs'), {
+ user: username,
+ lat: latitude,
+ long: longitude,
+ msg: message
+ }, function (data) {
+ if (data.status === 'OK') {
+ $('#chatbox-input').val("");
+ $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
+ }
+ }, "json");
+ }
+ event.preventDefault();
+ return false;
+});
+function toggleChat() {
+ if ($('#chatmsgs').css('display') === 'none') {
+ openChat();
+ } else {
+ closeChat();
+ }
+}
+
+function closeChat() {
+ $('#chatmsgs').css('display', 'none');
+ $('#chatbox').css('height', 'auto');
+}
+
+function openChat() {
+ $('#chatbox').css('height', '50%');
+ $('#chatmsgs').css('display', 'block');
+ $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
+}
+
+function openProfile(user) {
+ user = typeof user !== 'undefined' ? user : username;
+ $('#main-content').load("screens/profile.html", null, function (x) {
+ $('#overlay-main').css('display', 'block');
+ loadProfile(user);
+ });
+}
+
+function openRules() {
+ openmodal('rules', '#rules-modal');
+}
+
+function openIntro() {
+ openmodal('intro', '#intro-modal');
+}
+
+function openMenu(topage) {
+ topage = typeof topage !== 'undefined' ? topage : "";
+ $('#main-content').load("screens/menu.html", null, function (x) {
+ $('#overlay-main').css('display', 'block');
+ if (topage !== '') {
+ $('#' + topage + '-tab').tab('show');
+ }
+ });
+}
diff --git a/platforms/android/assets/www/screens/home.html b/platforms/android/assets/www/screens/home.html
index 397805e..d9f9502 100644
--- a/platforms/android/assets/www/screens/home.html
+++ b/platforms/android/assets/www/screens/home.html
@@ -54,4 +54,5 @@
$('#namedisp').text(username);
navigator.splashscreen.hide();
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/platforms/android/assets/www/screens/inventory.html b/platforms/android/assets/www/screens/inventory.html
index 262b022..753bc71 100644
--- a/platforms/android/assets/www/screens/inventory.html
+++ b/platforms/android/assets/www/screens/inventory.html
@@ -1,3 +1,10 @@
-
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/platforms/android/assets/www/screens/settings.html b/platforms/android/assets/www/screens/settings.html
index 13281eb..4c16596 100644
--- a/platforms/android/assets/www/screens/settings.html
+++ b/platforms/android/assets/www/screens/settings.html
@@ -1,5 +1,8 @@
diff --git a/platforms/browser/www/js/home.js b/platforms/browser/www/js/location.js
similarity index 67%
rename from platforms/browser/www/js/home.js
rename to platforms/browser/www/js/location.js
index 507117e..f05c7f9 100644
--- a/platforms/browser/www/js/home.js
+++ b/platforms/browser/www/js/location.js
@@ -174,7 +174,7 @@ function pingServer() {
$.get(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude);
}
}
-;
+
function onError(error) {
$('#loading-error').text("Check your device's network and location settings, and ensure a clear view of the sky.");
}
@@ -207,153 +207,4 @@ setInterval(pingServer, 5000);
// Show error if it's taking too long
setTimeout(function () {
onError();
-}, 15 * 1000);
-
-
-//////////////////////////////////////////////
-// Profile, stats, and chat stuff
-//////////////////////////////////////////////
-
-
-/*
- * Handles general server communication.
- */
-
-/**
- * Syncs the user's stats with the server and calls refreshStats().
- */
-function syncStats() {
- $.getJSON(mkApiUrl('getstats'), {
- user: username
- }, function (data) {
- if (data.status === 'OK') {
- maxenergy = data.stats.maxenergy;
- energy = data.stats.energy;
- level = data.stats.level;
- refreshStats();
- }
- });
-}
-
-/**
- * Display the current stats on the home screen.
- */
-function refreshStats() {
- energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0;
- $('#energybar').css('width', String(energypercent) + '%');
-}
-
-function getChat() {
- if (lockGot) {
- $.getJSON(mkApiUrl('chat', 'cs'), {
- lat: latitude,
- long: longitude
- }, function (data) {
- data = sortResults(data, 'time', true);
- var content = "";
- data.forEach(function (msg) {
- content += "" + msg.username + " " + msg.message + "
";
- });
- $('#chatmsgs').html(content);
- });
- }
-}
-
-
-syncStats();
-setInterval(function () {
- syncStats();
-}, 10 * 1000);
-setInterval(function () {
- getChat();
-}, 2000);
-// Send chat messages
-$("#chatsendform").submit(function (event) {
- message = $('#chatbox-input').val();
- if (message !== '') {
- $.post(mkApiUrl('chat', 'cs'), {
- user: username,
- lat: latitude,
- long: longitude,
- msg: message
- }, function (data) {
- if (data.status === 'OK') {
- $('#chatbox-input').val("");
- $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
- }
- }, "json");
- }
- event.preventDefault();
- return false;
-});
-function toggleChat() {
- if ($('#chatmsgs').css('display') === 'none') {
- openChat();
- } else {
- closeChat();
- }
-}
-
-function closeChat() {
- $('#chatmsgs').css('display', 'none');
- $('#chatbox').css('height', 'auto');
-}
-
-function openChat() {
- $('#chatbox').css('height', '50%');
- $('#chatmsgs').css('display', 'block');
- $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
-}
-
-function openProfile(user) {
- user = typeof user !== 'undefined' ? user : username;
- $('#main-content').load("screens/profile.html", null, function (x) {
- $('#overlay-main').css('display', 'block');
- loadProfile(user);
- });
-}
-
-function openRules() {
- openmodal('rules', '#rules-modal');
-}
-
-function openIntro() {
- openmodal('intro', '#intro-modal');
-}
-
-function openMenu(topage) {
- topage = typeof topage !== 'undefined' ? topage : "";
- $('#main-content').load("screens/menu.html", null, function (x) {
- $('#overlay-main').css('display', 'block');
- if (topage !== '') {
- $('#' + topage + '-tab').tab('show');
- }
- });
-}
-
-
-
-//////////////////////////////////////////////
-// Other things
-//////////////////////////////////////////////
-
-function closeMain() {
- $('#overlay-main').slideDown(100, function () {
- $('#overlay-main').css('display', 'none');
- $('#main-content').html("");
- });
-}
-
-// Handle back button to close things
-document.addEventListener("backbutton", function (event) {
- if ($('#overlay-main').css('display') !== 'none') {
- closeMain();
- } else if ($('#chatmsgs').css('display') !== 'none') {
- toggleChat();
- }
-}, false);
-// Show the rules
-if (localStorage.getItem("seenintro") !== 'yes') {
- openIntro();
- localStorage.setItem("seenintro", 'yes');
-}
\ No newline at end of file
+}, 15 * 1000);
\ No newline at end of file
diff --git a/platforms/browser/www/js/main.js b/platforms/browser/www/js/main.js
index 12ef656..1e13190 100644
--- a/platforms/browser/www/js/main.js
+++ b/platforms/browser/www/js/main.js
@@ -91,9 +91,36 @@ function scanCode() {
}
function sortResults(array, prop, asc) {
- array = array.sort(function(a, b) {
- if (asc) return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0);
- else return (b[prop] > a[prop]) ? 1 : ((b[prop] < a[prop]) ? -1 : 0);
+ array = array.sort(function (a, b) {
+ if (asc)
+ return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0);
+ else
+ return (b[prop] > a[prop]) ? 1 : ((b[prop] < a[prop]) ? -1 : 0);
});
return array;
+}
+
+//////////////////////////////////////////////
+// Other things
+//////////////////////////////////////////////
+
+function closeMain() {
+ $('#overlay-main').slideDown(100, function () {
+ $('#overlay-main').css('display', 'none');
+ $('#main-content').html("");
+ });
+}
+
+// Handle back button to close things
+document.addEventListener("backbutton", function (event) {
+ if ($('#overlay-main').css('display') !== 'none') {
+ closeMain();
+ } else if ($('#chatmsgs').css('display') !== 'none') {
+ toggleChat();
+ }
+}, false);
+// Show the rules
+if (localStorage.getItem("seenintro") !== 'yes') {
+ openIntro();
+ localStorage.setItem("seenintro", 'yes');
}
\ No newline at end of file
diff --git a/platforms/browser/www/js/user.js b/platforms/browser/www/js/user.js
new file mode 100644
index 0000000..d82001f
--- /dev/null
+++ b/platforms/browser/www/js/user.js
@@ -0,0 +1,120 @@
+//////////////////////////////////////////////
+// Profile, stats, and chat stuff
+//////////////////////////////////////////////
+
+
+/*
+ * Handles general server communication.
+ */
+
+/**
+ * Syncs the user's stats with the server and calls refreshStats().
+ */
+function syncStats() {
+ $.getJSON(mkApiUrl('getstats'), {
+ user: username
+ }, function (data) {
+ if (data.status === 'OK') {
+ maxenergy = data.stats.maxenergy;
+ energy = data.stats.energy;
+ level = data.stats.level;
+ refreshStats();
+ }
+ });
+}
+
+/**
+ * Display the current stats on the home screen.
+ */
+function refreshStats() {
+ energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0;
+ $('#energybar').css('width', String(energypercent) + '%');
+}
+
+function getChat() {
+ if (lockGot) {
+ $.getJSON(mkApiUrl('chat', 'cs'), {
+ lat: latitude,
+ long: longitude
+ }, function (data) {
+ data = sortResults(data, 'time', true);
+ var content = "";
+ data.forEach(function (msg) {
+ content += "" + msg.username + " " + msg.message + "
";
+ });
+ $('#chatmsgs').html(content);
+ });
+ }
+}
+
+
+syncStats();
+setInterval(function () {
+ syncStats();
+}, 10 * 1000);
+setInterval(function () {
+ getChat();
+}, 2000);
+// Send chat messages
+$("#chatsendform").submit(function (event) {
+ message = $('#chatbox-input').val();
+ if (message !== '') {
+ $.post(mkApiUrl('chat', 'cs'), {
+ user: username,
+ lat: latitude,
+ long: longitude,
+ msg: message
+ }, function (data) {
+ if (data.status === 'OK') {
+ $('#chatbox-input').val("");
+ $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
+ }
+ }, "json");
+ }
+ event.preventDefault();
+ return false;
+});
+function toggleChat() {
+ if ($('#chatmsgs').css('display') === 'none') {
+ openChat();
+ } else {
+ closeChat();
+ }
+}
+
+function closeChat() {
+ $('#chatmsgs').css('display', 'none');
+ $('#chatbox').css('height', 'auto');
+}
+
+function openChat() {
+ $('#chatbox').css('height', '50%');
+ $('#chatmsgs').css('display', 'block');
+ $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
+}
+
+function openProfile(user) {
+ user = typeof user !== 'undefined' ? user : username;
+ $('#main-content').load("screens/profile.html", null, function (x) {
+ $('#overlay-main').css('display', 'block');
+ loadProfile(user);
+ });
+}
+
+function openRules() {
+ openmodal('rules', '#rules-modal');
+}
+
+function openIntro() {
+ openmodal('intro', '#intro-modal');
+}
+
+function openMenu(topage) {
+ topage = typeof topage !== 'undefined' ? topage : "";
+ $('#main-content').load("screens/menu.html", null, function (x) {
+ $('#overlay-main').css('display', 'block');
+ if (topage !== '') {
+ $('#' + topage + '-tab').tab('show');
+ }
+ });
+}
diff --git a/platforms/browser/www/screens/home.html b/platforms/browser/www/screens/home.html
index 397805e..d9f9502 100644
--- a/platforms/browser/www/screens/home.html
+++ b/platforms/browser/www/screens/home.html
@@ -54,4 +54,5 @@
$('#namedisp').text(username);
navigator.splashscreen.hide();
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/platforms/browser/www/screens/inventory.html b/platforms/browser/www/screens/inventory.html
index 262b022..753bc71 100644
--- a/platforms/browser/www/screens/inventory.html
+++ b/platforms/browser/www/screens/inventory.html
@@ -1,3 +1,10 @@
-
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/platforms/browser/www/screens/settings.html b/platforms/browser/www/screens/settings.html
index 13281eb..4c16596 100644
--- a/platforms/browser/www/screens/settings.html
+++ b/platforms/browser/www/screens/settings.html
@@ -1,5 +1,8 @@
diff --git a/www/js/home.js b/www/js/location.js
similarity index 67%
rename from www/js/home.js
rename to www/js/location.js
index 507117e..f05c7f9 100644
--- a/www/js/home.js
+++ b/www/js/location.js
@@ -174,7 +174,7 @@ function pingServer() {
$.get(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude);
}
}
-;
+
function onError(error) {
$('#loading-error').text("Check your device's network and location settings, and ensure a clear view of the sky.");
}
@@ -207,153 +207,4 @@ setInterval(pingServer, 5000);
// Show error if it's taking too long
setTimeout(function () {
onError();
-}, 15 * 1000);
-
-
-//////////////////////////////////////////////
-// Profile, stats, and chat stuff
-//////////////////////////////////////////////
-
-
-/*
- * Handles general server communication.
- */
-
-/**
- * Syncs the user's stats with the server and calls refreshStats().
- */
-function syncStats() {
- $.getJSON(mkApiUrl('getstats'), {
- user: username
- }, function (data) {
- if (data.status === 'OK') {
- maxenergy = data.stats.maxenergy;
- energy = data.stats.energy;
- level = data.stats.level;
- refreshStats();
- }
- });
-}
-
-/**
- * Display the current stats on the home screen.
- */
-function refreshStats() {
- energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0;
- $('#energybar').css('width', String(energypercent) + '%');
-}
-
-function getChat() {
- if (lockGot) {
- $.getJSON(mkApiUrl('chat', 'cs'), {
- lat: latitude,
- long: longitude
- }, function (data) {
- data = sortResults(data, 'time', true);
- var content = "";
- data.forEach(function (msg) {
- content += "" + msg.username + " " + msg.message + "
";
- });
- $('#chatmsgs').html(content);
- });
- }
-}
-
-
-syncStats();
-setInterval(function () {
- syncStats();
-}, 10 * 1000);
-setInterval(function () {
- getChat();
-}, 2000);
-// Send chat messages
-$("#chatsendform").submit(function (event) {
- message = $('#chatbox-input').val();
- if (message !== '') {
- $.post(mkApiUrl('chat', 'cs'), {
- user: username,
- lat: latitude,
- long: longitude,
- msg: message
- }, function (data) {
- if (data.status === 'OK') {
- $('#chatbox-input').val("");
- $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
- }
- }, "json");
- }
- event.preventDefault();
- return false;
-});
-function toggleChat() {
- if ($('#chatmsgs').css('display') === 'none') {
- openChat();
- } else {
- closeChat();
- }
-}
-
-function closeChat() {
- $('#chatmsgs').css('display', 'none');
- $('#chatbox').css('height', 'auto');
-}
-
-function openChat() {
- $('#chatbox').css('height', '50%');
- $('#chatmsgs').css('display', 'block');
- $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
-}
-
-function openProfile(user) {
- user = typeof user !== 'undefined' ? user : username;
- $('#main-content').load("screens/profile.html", null, function (x) {
- $('#overlay-main').css('display', 'block');
- loadProfile(user);
- });
-}
-
-function openRules() {
- openmodal('rules', '#rules-modal');
-}
-
-function openIntro() {
- openmodal('intro', '#intro-modal');
-}
-
-function openMenu(topage) {
- topage = typeof topage !== 'undefined' ? topage : "";
- $('#main-content').load("screens/menu.html", null, function (x) {
- $('#overlay-main').css('display', 'block');
- if (topage !== '') {
- $('#' + topage + '-tab').tab('show');
- }
- });
-}
-
-
-
-//////////////////////////////////////////////
-// Other things
-//////////////////////////////////////////////
-
-function closeMain() {
- $('#overlay-main').slideDown(100, function () {
- $('#overlay-main').css('display', 'none');
- $('#main-content').html("");
- });
-}
-
-// Handle back button to close things
-document.addEventListener("backbutton", function (event) {
- if ($('#overlay-main').css('display') !== 'none') {
- closeMain();
- } else if ($('#chatmsgs').css('display') !== 'none') {
- toggleChat();
- }
-}, false);
-// Show the rules
-if (localStorage.getItem("seenintro") !== 'yes') {
- openIntro();
- localStorage.setItem("seenintro", 'yes');
-}
\ No newline at end of file
+}, 15 * 1000);
\ No newline at end of file
diff --git a/www/js/main.js b/www/js/main.js
index 12ef656..1e13190 100644
--- a/www/js/main.js
+++ b/www/js/main.js
@@ -91,9 +91,36 @@ function scanCode() {
}
function sortResults(array, prop, asc) {
- array = array.sort(function(a, b) {
- if (asc) return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0);
- else return (b[prop] > a[prop]) ? 1 : ((b[prop] < a[prop]) ? -1 : 0);
+ array = array.sort(function (a, b) {
+ if (asc)
+ return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0);
+ else
+ return (b[prop] > a[prop]) ? 1 : ((b[prop] < a[prop]) ? -1 : 0);
});
return array;
+}
+
+//////////////////////////////////////////////
+// Other things
+//////////////////////////////////////////////
+
+function closeMain() {
+ $('#overlay-main').slideDown(100, function () {
+ $('#overlay-main').css('display', 'none');
+ $('#main-content').html("");
+ });
+}
+
+// Handle back button to close things
+document.addEventListener("backbutton", function (event) {
+ if ($('#overlay-main').css('display') !== 'none') {
+ closeMain();
+ } else if ($('#chatmsgs').css('display') !== 'none') {
+ toggleChat();
+ }
+}, false);
+// Show the rules
+if (localStorage.getItem("seenintro") !== 'yes') {
+ openIntro();
+ localStorage.setItem("seenintro", 'yes');
}
\ No newline at end of file
diff --git a/www/js/user.js b/www/js/user.js
new file mode 100644
index 0000000..d82001f
--- /dev/null
+++ b/www/js/user.js
@@ -0,0 +1,120 @@
+//////////////////////////////////////////////
+// Profile, stats, and chat stuff
+//////////////////////////////////////////////
+
+
+/*
+ * Handles general server communication.
+ */
+
+/**
+ * Syncs the user's stats with the server and calls refreshStats().
+ */
+function syncStats() {
+ $.getJSON(mkApiUrl('getstats'), {
+ user: username
+ }, function (data) {
+ if (data.status === 'OK') {
+ maxenergy = data.stats.maxenergy;
+ energy = data.stats.energy;
+ level = data.stats.level;
+ refreshStats();
+ }
+ });
+}
+
+/**
+ * Display the current stats on the home screen.
+ */
+function refreshStats() {
+ energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0;
+ $('#energybar').css('width', String(energypercent) + '%');
+}
+
+function getChat() {
+ if (lockGot) {
+ $.getJSON(mkApiUrl('chat', 'cs'), {
+ lat: latitude,
+ long: longitude
+ }, function (data) {
+ data = sortResults(data, 'time', true);
+ var content = "";
+ data.forEach(function (msg) {
+ content += "" + msg.username + " " + msg.message + "
";
+ });
+ $('#chatmsgs').html(content);
+ });
+ }
+}
+
+
+syncStats();
+setInterval(function () {
+ syncStats();
+}, 10 * 1000);
+setInterval(function () {
+ getChat();
+}, 2000);
+// Send chat messages
+$("#chatsendform").submit(function (event) {
+ message = $('#chatbox-input').val();
+ if (message !== '') {
+ $.post(mkApiUrl('chat', 'cs'), {
+ user: username,
+ lat: latitude,
+ long: longitude,
+ msg: message
+ }, function (data) {
+ if (data.status === 'OK') {
+ $('#chatbox-input').val("");
+ $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
+ }
+ }, "json");
+ }
+ event.preventDefault();
+ return false;
+});
+function toggleChat() {
+ if ($('#chatmsgs').css('display') === 'none') {
+ openChat();
+ } else {
+ closeChat();
+ }
+}
+
+function closeChat() {
+ $('#chatmsgs').css('display', 'none');
+ $('#chatbox').css('height', 'auto');
+}
+
+function openChat() {
+ $('#chatbox').css('height', '50%');
+ $('#chatmsgs').css('display', 'block');
+ $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000);
+}
+
+function openProfile(user) {
+ user = typeof user !== 'undefined' ? user : username;
+ $('#main-content').load("screens/profile.html", null, function (x) {
+ $('#overlay-main').css('display', 'block');
+ loadProfile(user);
+ });
+}
+
+function openRules() {
+ openmodal('rules', '#rules-modal');
+}
+
+function openIntro() {
+ openmodal('intro', '#intro-modal');
+}
+
+function openMenu(topage) {
+ topage = typeof topage !== 'undefined' ? topage : "";
+ $('#main-content').load("screens/menu.html", null, function (x) {
+ $('#overlay-main').css('display', 'block');
+ if (topage !== '') {
+ $('#' + topage + '-tab').tab('show');
+ }
+ });
+}
diff --git a/www/screens/home.html b/www/screens/home.html
index 397805e..d9f9502 100644
--- a/www/screens/home.html
+++ b/www/screens/home.html
@@ -54,4 +54,5 @@
$('#namedisp').text(username);
navigator.splashscreen.hide();
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/www/screens/inventory.html b/www/screens/inventory.html
index d6694d0..753bc71 100644
--- a/www/screens/inventory.html
+++ b/www/screens/inventory.html
@@ -1,3 +1,10 @@
-
-
-
\ No newline at end of file
+
+
+
\ No newline at end of file