-
-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathMainView.js
30 lines (25 loc) · 872 Bytes
/
MainView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var Observable = require("FuseJS/Observable");
var Storage = require("FuseJS/Storage");
var SAVENAME = "localStorage.json";
var welcomeText = Observable("Loading...");
var message = Observable("");
var hasStored = Observable(false);
debug_log("Js initialized");
Storage.read(SAVENAME).then(function(content) {
var data = JSON.parse(content);
welcomeText.value = "Stored data: " + data.message;
}, function(error) {
//For now, let's expect the error to be because of the file not being found.
welcomeText.value = "There is currently no local data stored";
});
function saveMessage() {
var storeObject = {message: message.value};
Storage.write(SAVENAME, JSON.stringify(storeObject));
hasStored.value = true;
}
module.exports = {
welcomeText: welcomeText,
message: message,
saveMessage: saveMessage,
hasStored: hasStored
};