Skip to content

Commit

Permalink
refactor: fixed category navigation + eslint + version bumped to offi…
Browse files Browse the repository at this point in the history
…cial
  • Loading branch information
NickIliev committed Apr 17, 2018
1 parent 1b18187 commit d6eb679
Show file tree
Hide file tree
Showing 48 changed files with 181 additions and 190 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"curly": "error",
"default-case": "error",
"dot-location": [
"error",
"warn",
"property"
],
"dot-notation": "error",
Expand All @@ -54,6 +54,7 @@
}
],
"no-caller": "error",
"no-case-declarations": "warn",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-console": "off",
Expand Down
2 changes: 1 addition & 1 deletion app/application/application-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const navigationLinks = [
];
function onNavigatingTo(args) {
const page = args.object;
if((platformModule.isIOS) && (navigationLinks.filter(e => e.title === 'iOS Notification Observer').length < 1)){
if ((platformModule.isIOS) && (navigationLinks.filter((e) => e.title === "iOS Notification Observer").length < 1)) {
navigationLinks.push(new link("iOS Notification Observer", "/application/ios-notification-observer/ios-notification-observer-page"));
}
page.bindingContext = new ListViewLinksModel({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ListViewLinksModel = require("../../links-view-model");
const link = require("../../link");
const navigationLinks = [
new link("Basics", "/data/observable-array//basics/basics-page")
new link("Basics", "/data-category/observable-array//basics/basics-page")
];
function onNavigatingTo(args) {
const page = args.object;
Expand Down
10 changes: 5 additions & 5 deletions app/data-category/observable/observable-page.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const ListViewLinksModel = require("../../links-view-model");
const link = require("../../link");
const navigationLinks = [
new link("Basics", "/data/observable//basics/basics-page"),
new link("Two-Way Binding", "/data/observable/two-way/two-way-page"),
new link("MVVM Pattern", "/data/observable/mvvm-pattern/mvvm-pattern-page"),
new link("Parents Binding", "/data/observable/parent-binding/parent-binding-page"),
new link("Plain Object Binding", "/data/observable/plain-object-binding/plain-object-binding-page")
new link("Basics", "/data-category/observable//basics/basics-page"),
new link("Two-Way Binding", "/data-category/observable/two-way/two-way-page"),
new link("MVVM Pattern", "/data-category/observable/mvvm-pattern/mvvm-pattern-page"),
new link("Parents Binding", "/data-category/observable/parent-binding/parent-binding-page"),
new link("Plain Object Binding", "/data-category/observable/plain-object-binding/plain-object-binding-page")
];
function onNavigatingTo(args) {
const page = args.object;
Expand Down
2 changes: 1 addition & 1 deletion app/data-category/virtual-array/virtual-array-page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ListViewLinksModel = require("../../links-view-model");
const link = require("../../link");
const navigationLinks = [
new link("Basics", "/data/virtual-array//basics/basics-page")
new link("Basics", "/data-category/virtual-array//basics/basics-page")
];
function onNavigatingTo(args) {
const page = args.object;
Expand Down
32 changes: 12 additions & 20 deletions app/fetch/get/get-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,21 @@ function onButtonTap(args) {
}
switch (!status) {
case true:
vm.set(id + "ResultButton", `Hide ${id} result`);
vm.set(`${id}ResultVisible`, `Hide ${id} result`);
break;
case false:
vm.set(id + "ResultButton", `Show ${id} result`);
vm.set(`${id}ResultVisible`, `Show ${id} result`);
break;
default:
break;
}
vm.set(id + "ResultVisible", !status);
vm.set(`${id}ResultVisible`, !status);
}

function getStringExample(viewModel) {
// >> get-string-code-fetch
fetch("https://httpbin.org/get")
.then((response) => {
return response.text();
})
.then((response) => response.text())
.then((r) => {
viewModel.set("getStringResult", r);
}).catch((e) => {
Expand All @@ -83,20 +81,18 @@ function getStringExample(viewModel) {
function getJSONExample(viewModel) {
// >> get-json-code-fetch
fetch("https://httpbin.org/get")
.then((response) => {
return response.json();
})
.then((response) => response.json())
.then((r) => {
// >> (hide)
viewModel.set("host", r.headers.Host);
viewModel.set("userAgent", r.headers["User-Agent"]);
viewModel.set("origin", r.origin);
viewModel.set("url", r.url);
// << (hide)
}).catch((e) => {
}).catch((err) => {
// >> (hide)
console.log("Error: ");
console.log(e);
console.log(err);
// << (hide)
});
// << get-json-code-fetch
Expand All @@ -109,10 +105,10 @@ function getResponseStatusCodeExample(viewModel) {
const status = response.status;
viewModel.set("statusCodeResult", status);
// << (hide)
}).catch((e) => {
}).catch((err) => {
// >> (hide)
console.log("Error: ");
console.log(e);
console.log(err);
// << (hide)
});
// << request-status-code-fetch
Expand All @@ -122,16 +118,14 @@ function getResponseHeadersExample(viewModel) {
console.log("getResponseHeadersExample");
// >> request-response-header-fetch
fetch("https://httpbin.org/get")
.then((r) => {
return r.json();
})
.then((r) => r.json())
.then((response) => {
// >> (hide)
console.log("Header");
console.log(response);
viewModel.set("acceptEncoding", response.headers["Accept-Encoding"]);
viewModel.set("userAgent", response.headers["User-Agent"]);
viewModel.set("host", response.headers["Host"]);
viewModel.set("host", response.headers.Host);
// << (hide)
}).catch((e) => {
// >> (hide)
Expand All @@ -145,9 +139,7 @@ function getResponseHeadersExample(viewModel) {
function getResponseFormDataExample(viewModel) {
// >> request-response-form-data
fetch("https://httpbin.org/get")
.then((result) => {
return result.formData();
})
.then((result) => result.formData())
.then((response) => {
// >> (hide)
viewModel.set("responseFormDataResult", response);
Expand Down
20 changes: 8 additions & 12 deletions app/fetch/post/post-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@ function makePostRequest(args) {
const page = args.object.page;
const vm = page.bindingContext;
// >> fetch-post
fetch("https://httpbin.org/post", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
username: vm.get("user"),
password: vm.get("pass")
})
})
.then((r) => {
return r.json();
fetch("https://httpbin.org/post", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
username: vm.get("user"),
password: vm.get("pass")
})
}).then((r) => r.json())
.then((response) => {
const result = response.json;
// >> (hide)
vm.set("isItemVisible", true);
vm.set("message", result.username);
// << (hide)
})
.catch((e) => {
}).catch((e) => {
// >> (hide)
console.log("Error: ");
console.log(e);
Expand Down
4 changes: 2 additions & 2 deletions app/file-system/create/create-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ function onCreateFile(args) {
// >> fs-create-all-code
const documents = fileSystemModule.knownFolders.documents();
const folder = documents.getFolder(vm.get("folderName") || "testFolder");
const file = folder.getFile((vm.get("fileName") || "testFile") + ".txt");
const file = folder.getFile(`${(vm.get("fileName") || "testFile")}`.txt);

file.writeText(vm.get("fileTextContent") || "some random content")
.then((result) => {
file.readText()
.then((res) => {
vm.set("successMessage", "Successfully saved in " + file.path);
vm.set("successMessage", `Successfully saved in${file.path}`);
vm.set("writtenContent", res);
vm.set("isItemVisible", true);
});
Expand Down
2 changes: 1 addition & 1 deletion app/file-system/paths/paths-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function onNavigatingTo(args) {
const vm = new Observable();

// >> fs-paths-normalize-code
const documentsFolder = fileSystemModule.knownFolders.documents();
let documentsFolder = fileSystemModule.knownFolders.documents();
const currentAppFolder = fileSystemModule.knownFolders.currentApp();
const tempFolder = fileSystemModule.knownFolders.temp();

Expand Down
8 changes: 4 additions & 4 deletions app/file-system/read/read-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ function onNavigatingTo(args) {
"Open source framework for building truly native mobile apps" +
"with Angular, TypeScript or JavaScript.";

const documents = fileSystemModule.knownFolders.documents();
let documents = fileSystemModule.knownFolders.documents();
const folder = documents.getFolder(folderName);
const file = folder.getFile(fileName);

file.writeText(fileTextContent)
.then((result) => {
// >> fs-read-text-code
file.readText()
.then(res => {
.then((res) => {
vm.set("writtenContent", res);
}).catch(err => {
}).catch((err) => {
console.log(err.stack);
});
// << fs-read-text-code
Expand Down Expand Up @@ -81,7 +81,7 @@ function onReadSync(args) {
if (saved) {
const imageFile = fileSystemModule.File.fromPath(path);
const binarySource = imageFile.readSync((err) => {
console.log("Error:" + err);
console.log(err);
});
console.log(this.binarySource);
// << fs-read-sync-code
Expand Down
2 changes: 1 addition & 1 deletion app/file-system/update/update-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function onFileRename(args) {
const vm = page.bindingContext;
// >> fs-update-rename-file-code
const fileName = vm.get("fileName");
file.rename(fileName + ".txt")
file.rename(`${fileName}.txt`)
.then((res) => {
// File Successfully Renamed.
vm.set("fileSuccessMessage", `File renamed to: ${fileName}.txt`);
Expand Down
6 changes: 3 additions & 3 deletions app/http/get/get-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ function onButtonTap(args) {
}
switch (!status) {
case true:
vm.set(id + "ResultButton", `Hide ${id} result`);
vm.set(`${id}ResultButton`, `Hide ${id} result`);
break;
case false:
vm.set(id + "ResultButton", `Show ${id} result`);
vm.set(`${id}ResultButton`, `Show ${id} result`);
break;
default:
break;
}
vm.set(id + "ResultVisible", !status);
vm.set(`${id}ResultButton`, !status);
}

function getStringExample(viewModel) {
Expand Down
2 changes: 1 addition & 1 deletion app/image-source/load-image/load-image-page.js

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions app/main-page.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
const ListViewLinksModel = require("./links-view-model");
const link = require("./link");
const navigationLinks = [
new link("Observable", "/data/observable/observable-page"),
new link("Observable Array", "/data/observable-array/observable-array-page"),
new link("Virtual Array", "/data/virtual-array/virtual-array-page"),
new link("Observable", "/data-category/observable/observable-page"),
new link("Observable Array", "/data-category/observable-array/observable-array-page"),
new link("Virtual Array", "/data-category/virtual-array/virtual-array-page"),
new link("Application", "/application/application-page"),
new link("Application Settings", "/application-settings/application-settings-page"),
new link("Action Bar", "ui/action-bar/action-bar-page"),
new link("ActivityIndicator", "ui/activity-indicator/activity-indicator-page"),
new link("Animations", "ui/animations/animations-page"),
new link("Button", "ui/button/button-page"),
new link("Borders", "ui/borders/borders-page"),
new link("Color", "color/color-page"),
new link("Action Bar", "/ui-category/action-bar/action-bar-page"),
new link("ActivityIndicator", "/ui-category/activity-indicator/activity-indicator-page"),
new link("Animations", "/ui-category/animations/animations-page"),
new link("Button", "/ui-category/button/button-page"),
new link("Borders", "/ui-category/borders/borders-page"),
new link("Color", "/color/color-page"),
new link("Connectivity", "/connectivity/connectivity-page"),
new link("Console", "/console/console-page"),
new link("DatePicker", "ui/date-picker/date-picker-page"),
new link("Dialogs", "ui/dialogs/dialogs-page"),
new link("Gestures", "ui/gestures/gestures-page"),
new link("HtmlView", "ui/html-view/html-view-page"),
new link("Image", "ui/image/image-page"),
new link("Image Cache", "ui/image-cache/image-cache-page"),
new link("Layouts", "ui/layouts/layouts-page"),
new link("TimePicker", "ui/time-picker/time-picker-page"),
new link("ScrollView", "/ui/scroll-view/scroll-view-page"),
new link("SearchBar", "/ui/search-bar/search-bar-page"),
new link("SegmentedBar", "/ui/segmented-bar/segmented-bar-page"),
new link("Slider", "/ui/slider/slider-page"),
new link("Switch", "/ui/switch/switch-page"),
new link("TabView", "/ui/tab-view/tab-view-page"),
new link("TextField", "ui/text-field/text-field-page"),
new link("TextView", "/ui/text-view/text-view-page"),
new link("WebView", "/ui/web-view/web-view-page"),
new link("Style", "/ui/styling/styling-page"),
new link("Label", "/ui/label/label-page"),
new link("ListPicker", "/ui/list-picker/list-picker-page"),
new link("ListView", "/ui/list-view/list-view-page"),
new link("Progress", "/ui/progress/progress-page"),
new link("Formatted String", "/ui/formatted-string/formatted-string-page"),
new link("DatePicker", "/ui-category/date-picker/date-picker-page"),
new link("Dialogs", "/ui-category/dialogs/dialogs-page"),
new link("Gestures", "/ui-category/gestures/gestures-page"),
new link("HtmlView", "/ui-category/html-view/html-view-page"),
new link("Image", "/ui-category/image/image-page"),
new link("Image Cache", "/ui-category/image-cache/image-cache-page"),
new link("Layouts", "/ui-category/layouts/layouts-page"),
new link("TimePicker", "/ui-category/time-picker/time-picker-page"),
new link("ScrollView", "/ui-category/scroll-view/scroll-view-page"),
new link("SearchBar", "/ui-category/search-bar/search-bar-page"),
new link("SegmentedBar", "/ui-category/segmented-bar/segmented-bar-page"),
new link("Slider", "/ui-category/slider/slider-page"),
new link("Switch", "/ui-category/switch/switch-page"),
new link("TabView", "/ui-category/tab-view/tab-view-page"),
new link("TextField", "/ui-category/text-field/text-field-page"),
new link("TextView", "/ui-category/text-view/text-view-page"),
new link("WebView", "/ui-category/web-view/web-view-page"),
new link("Style", "/ui-category/styling/styling-page"),
new link("Label", "/ui-category/label/label-page"),
new link("ListPicker", "/ui-category/list-picker/list-picker-page"),
new link("ListView", "/ui-category/list-view/list-view-page"),
new link("Progress", "/ui-category/progress/progress-page"),
new link("Formatted String", "/ui-category/formatted-string/formatted-string-page"),
new link("Trace Module", "/trace/trace-page"),
new link("Timer Module", "/timer/timer-page"),
new link("Placeholder", "/ui/placeholder/placeholder-page"),
new link("Repeater", "/ui/repeater/repeater-page"),
new link("Placeholder", "/ui-category/placeholder/placeholder-page"),
new link("Repeater", "/ui-category/repeater/repeater-page"),
new link("Platform Module", "/platform/platform-page"),
new link("FPS Meter", "/fps-meter/fps-meter-page"),
new link("HTTP Module", "/http/http-page"),
Expand Down
4 changes: 2 additions & 2 deletions app/ui-category/action-bar/action-bar-page.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const ListViewLinksModel = require("../../links-view-model");
const link = require("../../link");
const navigationLinks = [
new link("Basics", "/ui/action-bar/basics/basics-page"),
new link("Code-Behind", "/ui/action-bar/code-behind/code-behind-page")
new link("Basics", "/ui-category/action-bar/basics/basics-page"),
new link("Code-Behind", "/ui-category/action-bar/code-behind/code-behind-page")
];
function onNavigatingTo(args) {
const page = args.object;
Expand Down
6 changes: 3 additions & 3 deletions app/ui-category/activity-indicator/activity-indicator-page.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const ListViewLinksModel = require("../../links-view-model");
const link = require("../../link");
const navigationLinks = [
new link("Basics", "/ui/activity-indicator/basics/basics-page"),
new link("Styling", "/ui/activity-indicator/styling/styling-page"),
new link("Code-Behind", "/ui/activity-indicator/code-behind/code-behind-page")
new link("Basics", "/ui-category/activity-indicator/basics/basics-page"),
new link("Styling", "/ui-category/activity-indicator/styling/styling-page"),
new link("Code-Behind", "/ui-category/activity-indicator/code-behind/code-behind-page")
];

function onNavigatingTo(args) {
Expand Down
6 changes: 3 additions & 3 deletions app/ui-category/animations/animations-page.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const ListViewLinksModel = require("../../links-view-model");
const link = require("../../link");
const navigationLinks = [
new link("Animated Properties", "/ui/animations/animating-properties/animating-properties-page"),
new link("Chained Animations", "/ui/animations/chaining-animations/chaining-animations-page"),
new link("Animating Multiple Views", "/ui/animations/multiple-views/multiple-views-page")
new link("Animated Properties", "/ui-category/animations/animating-properties/animating-properties-page"),
new link("Chained Animations", "/ui-category/animations/chaining-animations/chaining-animations-page"),
new link("Animating Multiple Views", "/ui-category/animations/multiple-views/multiple-views-page")
];

// >> animations-imports
Expand Down
Loading

0 comments on commit d6eb679

Please sign in to comment.