Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enhanced config code to accept settings from outside

  • Loading branch information...
commit 3f01a73be00f6f7f91461a102ef341267fcff3bf 1 parent a64e972
@usarskyy authored
Showing with 23 additions and 5 deletions.
  1. +23 −2 scripts/filemanager.config.js.default
  2. +0 −3  scripts/filemanager.js
View
25 scripts/filemanager.config.js.default
@@ -2,6 +2,8 @@
Configuration
---------------------------------------------------------*/
+var urlVars = getUrlVars();
+
// Set culture to display localized messages
var culture = 'en';
@@ -21,16 +23,35 @@ var browseOnly = false;
// Set this to the server side language you wish to use.
var lang = 'php'; // options: php, jsp, lasso, asp, cfm, ashx, asp // we are looking for contributors for lasso, python connectors (partially developed)
+// Sets paths to connectors based on language selection.
+var fileConnector = urlVars["connectorUrl"] ? decodeURIComponent(urlVars["connectorUrl"]) : 'connectors/' + lang + '/filemanager.' + lang;
+
var am = document.location.pathname.substring(1, document.location.pathname.lastIndexOf('/') + 1);
// Set this to the directory you wish to manage.
-var fileRoot = '/' + am + 'userfiles/';
+var fileRoot = urlVars["fileRoot"] ? decodeURIComponent(urlVars["fileRoot"]) : '/' + am + 'userfiles/';
//Path to the manage directory on the HTTP server
-var relPath = window.location.protocol + '//' + document.domain;
+var relPath = urlVars["relPath"] ? decodeURIComponent(urlVars["relPath"]) : window.location.protocol + '//' + document.domain;
// Show image previews in grid views?
var showThumbs = true;
// Allowed image extensions when type is 'image'
var imagesExt = ['jpg', 'jpeg', 'gif', 'png'];
+
+// gets array of supplied URL parameters
+function getUrlVars()
@usarskyy Owner

Probably it is not the best approach to duplicate already existing code (in filemnager.js exists similar function) but I wanted to keep config file completely independent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+{
+ var vars = [], hash;
+ var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
+
+ for(var i = 0; i < hashes.length; i++)
+ {
+ hash = hashes[i].split('=');
+ vars.push(hash[0]);
+ vars[hash[0]] = hash[1];
+ }
+
+ return vars;
+}
View
3  scripts/filemanager.js
@@ -24,9 +24,6 @@ $.urlParam = function(name){
Setup, Layout, and Status Functions
---------------------------------------------------------*/
-// Sets paths to connectors based on language selection.
-var fileConnector = 'connectors/' + lang + '/filemanager.' + lang;
@usarskyy Owner

Had to move this variable into config file to keep everything close to each ither

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-
var capabilities = new Array('select', 'download', 'rename', 'delete');
// Get localized messages from file
@usarskyy

Had to move this variable into config file to keep everything close to each ither

@usarskyy

Probably it is not the best approach to duplicate already existing code (in filemnager.js exists similar function) but I wanted to keep config file completely independent

Please sign in to comment.
Something went wrong with that request. Please try again.