Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

Commit

Permalink
🎨 Fetch route function comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sundowndev committed Mar 27, 2018
1 parent c5f359f commit 85b5a7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions lib/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Router.js
*
* @author SundownDEV https://github.com/SundownDEV
* @version 1.2.0
* @version 1.4.2
* @description Simple front based mono-page router
* @license MIT
*/
Expand Down Expand Up @@ -98,18 +98,21 @@ var router = function () {
};

/**
* @function setRoute
* @function fetchRoute
*
* @param routeName string
*/
this.setRoute = function (routeName) {
this.fetchRoute = function (routeName, params) {
let targetRoute = parent.routes.find(function (route) {
return route.name === routeName;
});

if (targetRoute.route !== undefined) {
new RouterRequest().setURI(parent.FormatPath(targetRoute.route));
}
if (targetRoute.route !== undefined && !targetRoute.paramsEnabled) {
new RouterRequest().setURI(targetRoute.route);
} else if (targetRoute.paramsEnabled) {
// TODO: fetch route with parameters handling
console.log(targetRoute);
};
};

/**
Expand Down Expand Up @@ -149,7 +152,7 @@ var router = function () {
this.handle = function (routes) {
let URI = parent.getCurrentURI();

routes.forEach(function(Route){
routes.forEach(function (Route) {
let RouteArray = Route.split('/');
let URIarray = URI.split('/');

Expand Down Expand Up @@ -241,7 +244,7 @@ let RouterRequest = function () {

/**
* Set the new URI
* @param route string Must match "#/{name}"
* @param route string
*/
this.setURI = function (route) {
location.hash = route;
Expand Down Expand Up @@ -271,9 +274,9 @@ let BeforeMiddleware = function (route, callback) {
};

if (this.callback != null) {
if (this.route == '*') {
if (this.route === '*') {
this.callback.apply();
}else if (this.route == this.URI) {
}else if (this.route === this.URI) {
this.callback.apply();
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/router/router.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 85b5a7f

Please sign in to comment.