diff --git a/Modules/Context.js b/Modules/Context.js deleted file mode 100644 index 3d5f250..0000000 --- a/Modules/Context.js +++ /dev/null @@ -1,37 +0,0 @@ -var Observable = require("FuseJS/Observable"); -var Backend = require("./Backend"); - -var hikes = Observable(); - -Backend.getHikes() - .then(function(newHikes) { - hikes.replaceAll(newHikes); - }) - .catch(function(error) { - console.log("Couldn't get hikes: " + error); - }); - -function updateHike(id, name, location, distance, rating, comments) { - for (var i = 0; i < hikes.length; i++) { - var hike = hikes.getAt(i); - if (hike.id == id) { - hike.name = name; - hike.location = location; - hike.distance = distance; - hike.rating = rating; - hike.comments = comments; - hikes.replaceAt(i, hike); - break; - } - } - Backend.updateHike(id, name, location, distance, rating, comments) - .catch(function(error) { - console.log("Couldn't update hike: " + id); - }); -} - -module.exports = { - hikes: hikes, - - updateHike: updateHike -}; \ No newline at end of file diff --git a/Pages/EditHikePage.js b/Pages/EditHikePage.js deleted file mode 100644 index e33b3e6..0000000 --- a/Pages/EditHikePage.js +++ /dev/null @@ -1,31 +0,0 @@ -var Context = require("Modules/Context"); - -var hike = this.Parameter; - -var name = hike.map(function(x) { return x.name; }); -var location = hike.map(function(x) { return x.location; }); -var distance = hike.map(function(x) { return x.distance; }); -var rating = hike.map(function(x) { return x.rating; }); -var comments = hike.map(function(x) { return x.comments; }); - -function cancel() { - // Refresh hike value to reset dependent Observables' values - hike.value = hike.value; - router.goBack(); -} - -function save() { - Context.updateHike(hike.value.id, name.value, location.value, distance.value, rating.value, comments.value); - router.goBack(); -} - -module.exports = { - name: name, - location: location, - distance: distance, - rating: rating, - comments: comments, - - cancel: cancel, - save: save -}; \ No newline at end of file diff --git a/.gitignore b/chapter-1/.gitignore similarity index 100% rename from .gitignore rename to chapter-1/.gitignore diff --git a/LICENSE b/chapter-1/LICENSE similarity index 100% rename from LICENSE rename to chapter-1/LICENSE diff --git a/chapter-1/MainView.ux b/chapter-1/MainView.ux new file mode 100644 index 0000000..e5dcdf1 --- /dev/null +++ b/chapter-1/MainView.ux @@ -0,0 +1,42 @@ + + + + var Observable = require("FuseJS/Observable"); + + var name = Observable("Tricky Trails"); + var location = Observable("Lakebed, Utah"); + var distance = Observable(10.4); + var rating = Observable(4); + var comments = Observable("This hike was nice and hike-like. Glad I didn't bring a bike."); + + module.exports = { + name: name, + location: location, + distance: distance, + rating: rating, + comments: comments + }; + + + + + + + Name: + + + Location: + + + Distance (km): + + + Rating: + + + Comments: + + + + + diff --git a/README.md b/chapter-1/README.md similarity index 100% rename from README.md rename to chapter-1/README.md diff --git a/hikr.gif b/chapter-1/hikr.gif similarity index 100% rename from hikr.gif rename to chapter-1/hikr.gif diff --git a/chapter-1/hikr.unoproj b/chapter-1/hikr.unoproj new file mode 100644 index 0000000..36acee3 --- /dev/null +++ b/chapter-1/hikr.unoproj @@ -0,0 +1,10 @@ +{ + "RootNamespace":"", + "Packages": [ + "Fuse", + "FuseJS" + ], + "Includes": [ + "*" + ] +} diff --git a/chapter-2/.gitignore b/chapter-2/.gitignore new file mode 100644 index 0000000..a0ada99 --- /dev/null +++ b/chapter-2/.gitignore @@ -0,0 +1,2 @@ +build/ +.uno/ diff --git a/chapter-2/LICENSE b/chapter-2/LICENSE new file mode 100644 index 0000000..3ad225c --- /dev/null +++ b/chapter-2/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Fuse + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/chapter-2/MainView.ux b/chapter-2/MainView.ux new file mode 100644 index 0000000..5528cc6 --- /dev/null +++ b/chapter-2/MainView.ux @@ -0,0 +1,89 @@ + + + + var Observable = require("FuseJS/Observable"); + + var hikes = [ + { + id: 0, + name: "Tricky Trails", + location: "Lakebed, Utah", + distance: 10.4, + rating: 4, + comments: "This hike was nice and hike-like. Glad I didn't bring a bike." + }, + { + id: 1, + name: "Mondo Mountains", + location: "Black Hills, South Dakota", + distance: 20.86, + rating: 3, + comments: "Not the best, but would probably do again. Note to self: don't forget the sandwiches next time." + }, + { + id: 2, + name: "Pesky Peaks", + location: "Bergenhagen, Norway", + distance: 8.2, + rating: 5, + comments: "Short but SO sweet!!" + }, + { + id: 3, + name: "Rad Rivers", + location: "Moriyama, Japan", + distance: 12.3, + rating: 4, + comments: "Took my time with this one. Great view!" + }, + { + id: 4, + name: "Dangerous Dirt", + location: "Cactus, Arizona", + distance: 19.34, + rating: 2, + comments: "Too long, too hot. Also that snakebite wasn't very fun." + } + ]; + + var hike = Observable(); + + function chooseHike(arg) { + hike.value = arg.data; + } + + module.exports = { + hikes: hikes, + + hike: hike, + + chooseHike: chooseHike + }; + + + + + +