2017-01-15 19:09:57 +00:00
|
|
|
(function () {
|
|
|
|
|
|
|
|
var laroute = (function () {
|
|
|
|
|
|
|
|
var routes = {
|
|
|
|
|
|
|
|
absolute: false,
|
|
|
|
rootUrl: 'http://pterodactyl.app',
|
2017-03-05 00:03:49 +00:00
|
|
|
routes : [{"host":null,"methods":["GET","HEAD"],"uri":"admin","name":"admin.index","action":"Pterodactyl\Http\Controllers\Admin\BaseController@getIndex"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/settings","name":"admin.settings","action":"Pterodactyl\Http\Controllers\Admin\BaseController@getSettings"},{"host":null,"methods":["POST"],"uri":"admin\/settings","name":null,"action":"Pterodactyl\Http\Controllers\Admin\BaseController@postSettings"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/users","name":"admin.users","action":"Pterodactyl\Http\Controllers\Admin\UserController@getIndex"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/users\/accounts.json","name":"admin.users.json","action":"Pterodactyl\Http\Controllers\Admin\UserController@getJson"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/users\/view\/{id}","name":"admin.users.view","action":"Pterodactyl\Http\Controllers\Admin\UserController@getView"},{"host":null,"methods":["POST"],"uri":"admin\/users\/view\/{id}","name":null,"action":"Pterodactyl\Http\Controllers\Admin\UserController@updateUser"},{"host":null,"methods":["DELETE"],"uri":"admin\/users\/view\/{id}","name":null,"action":"Pterodactyl\Http\Controllers\Admin\UserController@deleteUser"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/users\/new","name":"admin.users.new","action":"Pterodactyl\Http\Controllers\Admin\UserController@getNew"},{"host":null,"methods":["POST"],"uri":"admin\/users\/new","name":null,"action":"Pterodactyl\Http\Controllers\Admin\UserController@postNew"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers","name":"admin.servers","action":"Pterodactyl\Http\Controllers\Admin\ServersController@index"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/new","name":"admin.servers.new","action":"Pterodactyl\Http\Controllers\Admin\ServersController@new"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/new","name":null,"action":"Pterodactyl\Http\Controllers\Admin\ServersController@create"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/new\/nodes","name":"admin.servers.new.nodes","action":"Pterodactyl\Http\Controllers\Admin\ServersController@newServerNodes"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{id}","name":"admin.servers.view","action":"Pterodactyl\Http\Controllers\Admin\ServersController@viewIndex"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{id}\/details","name":"admin.servers.view.details","action":"Pterodactyl\Http\Controllers\Admin\ServersController@viewDetails"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{id}\/details","name":null,"action":"Pterodactyl\Http\Controllers\Admin\ServersController@setDetails"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{id}\/details\/container","name":"admin.servers.view.details.container","action":"Pterodactyl\Http\Controllers\Admin\ServersController@setContainer"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{id}\/build","name":"admin.servers.view.build","action":"Pterodactyl\Http\Controllers\Admin\ServersController@viewBuild"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{id}\/build","name":null,"action":"Pterodactyl\Http\Controllers\Admin\ServersController@updateBuild"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{id}\/startup","name":"admin.servers.view.startup","action":"Pterodactyl\Http\Controllers\Admin\ServersController@viewStartup"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{id}\/database","name":"admin.servers.view.database","action":"Pterodactyl\Http\Controllers\Admin\ServersController@viewDatabase"},{"host":null,"methods":["GET","HEAD"],"uri":"admin\/servers\/view\/{id}\/manage","name":"admin.servers.view.manage","action":"Pterodactyl\Http\Controllers\Admin\ServersController@viewManage"},{"host":null,"methods":["POST"],"uri":"admin\/servers\/view\/{id}\/manage\/toggle","name":"admin.servers.view.manage.toggle","action":"Pterodactyl\Http\Controllers\Admin\ServersController@toggleInstall"},{"host":nu
|
2017-01-15 19:09:57 +00:00
|
|
|
prefix: '',
|
|
|
|
|
|
|
|
route : function (name, parameters, route) {
|
|
|
|
route = route || this.getByName(name);
|
|
|
|
|
|
|
|
if ( ! route ) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.toRoute(route, parameters);
|
|
|
|
},
|
|
|
|
|
|
|
|
url: function (url, parameters) {
|
|
|
|
parameters = parameters || [];
|
|
|
|
|
|
|
|
var uri = url + '/' + parameters.join('/');
|
|
|
|
|
|
|
|
return this.getCorrectUrl(uri);
|
|
|
|
},
|
|
|
|
|
|
|
|
toRoute : function (route, parameters) {
|
|
|
|
var uri = this.replaceNamedParameters(route.uri, parameters);
|
|
|
|
var qs = this.getRouteQueryString(parameters);
|
|
|
|
|
|
|
|
return this.getCorrectUrl(uri + qs);
|
|
|
|
},
|
|
|
|
|
|
|
|
replaceNamedParameters : function (uri, parameters) {
|
|
|
|
uri = uri.replace(/\{(.*?)\??\}/g, function(match, key) {
|
|
|
|
if (parameters.hasOwnProperty(key)) {
|
|
|
|
var value = parameters[key];
|
|
|
|
delete parameters[key];
|
|
|
|
return value;
|
|
|
|
} else {
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Strip out any optional parameters that were not given
|
|
|
|
uri = uri.replace(/\/\{.*?\?\}/g, '');
|
|
|
|
|
|
|
|
return uri;
|
|
|
|
},
|
|
|
|
|
|
|
|
getRouteQueryString : function (parameters) {
|
|
|
|
var qs = [];
|
|
|
|
for (var key in parameters) {
|
|
|
|
if (parameters.hasOwnProperty(key)) {
|
|
|
|
qs.push(key + '=' + parameters[key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qs.length < 1) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '?' + qs.join('&');
|
|
|
|
},
|
|
|
|
|
|
|
|
getByName : function (name) {
|
|
|
|
for (var key in this.routes) {
|
|
|
|
if (this.routes.hasOwnProperty(key) && this.routes[key].name === name) {
|
|
|
|
return this.routes[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getByAction : function(action) {
|
|
|
|
for (var key in this.routes) {
|
|
|
|
if (this.routes.hasOwnProperty(key) && this.routes[key].action === action) {
|
|
|
|
return this.routes[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getCorrectUrl: function (uri) {
|
|
|
|
var url = this.prefix + '/' + uri.replace(/^\/?/, '');
|
|
|
|
|
|
|
|
if(!this.absolute)
|
|
|
|
return url;
|
|
|
|
|
|
|
|
return this.rootUrl.replace('/\/?$/', '') + url;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var getLinkAttributes = function(attributes) {
|
|
|
|
if ( ! attributes) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
var attrs = [];
|
|
|
|
for (var key in attributes) {
|
|
|
|
if (attributes.hasOwnProperty(key)) {
|
|
|
|
attrs.push(key + '="' + attributes[key] + '"');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return attrs.join(' ');
|
|
|
|
};
|
|
|
|
|
|
|
|
var getHtmlLink = function (url, title, attributes) {
|
|
|
|
title = title || url;
|
|
|
|
attributes = getLinkAttributes(attributes);
|
|
|
|
|
|
|
|
return '<a href="' + url + '" ' + attributes + '>' + title + '</a>';
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
// Generate a url for a given controller action.
|
|
|
|
// Router.action('HomeController@getIndex', [params = {}])
|
|
|
|
action : function (name, parameters) {
|
|
|
|
parameters = parameters || {};
|
|
|
|
|
|
|
|
return routes.route(name, parameters, routes.getByAction(name));
|
|
|
|
},
|
|
|
|
|
|
|
|
// Generate a url for a given named route.
|
|
|
|
// Router.route('routeName', [params = {}])
|
|
|
|
route : function (route, parameters) {
|
|
|
|
parameters = parameters || {};
|
|
|
|
|
|
|
|
return routes.route(route, parameters);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Generate a fully qualified URL to the given path.
|
|
|
|
// Router.route('url', [params = {}])
|
|
|
|
url : function (route, parameters) {
|
|
|
|
parameters = parameters || {};
|
|
|
|
|
|
|
|
return routes.url(route, parameters);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Generate a html link to the given url.
|
|
|
|
// Router.link_to('foo/bar', [title = url], [attributes = {}])
|
|
|
|
link_to : function (url, title, attributes) {
|
|
|
|
url = this.url(url);
|
|
|
|
|
|
|
|
return getHtmlLink(url, title, attributes);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Generate a html link to the given route.
|
|
|
|
// Router.link_to_route('route.name', [title=url], [parameters = {}], [attributes = {}])
|
|
|
|
link_to_route : function (route, title, parameters, attributes) {
|
|
|
|
var url = this.route(route, parameters);
|
|
|
|
|
|
|
|
return getHtmlLink(url, title, attributes);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Generate a html link to the given controller action.
|
|
|
|
// Router.link_to_action('HomeController@getIndex', [title=url], [parameters = {}], [attributes = {}])
|
|
|
|
link_to_action : function(action, title, parameters, attributes) {
|
|
|
|
var url = this.action(action, parameters);
|
|
|
|
|
|
|
|
return getHtmlLink(url, title, attributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}).call(this);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expose the class either via AMD, CommonJS or the global object
|
|
|
|
*/
|
|
|
|
if (typeof define === 'function' && define.amd) {
|
|
|
|
define(function () {
|
|
|
|
return laroute;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (typeof module === 'object' && module.exports){
|
|
|
|
module.exports = laroute;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.Router = laroute;
|
|
|
|
}
|
|
|
|
|
|
|
|
}).call(this);
|
|
|
|
|