Skip to content

Commit

Permalink
Item8885: allow deeplink to configure option
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@7146 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Apr 10, 2010
1 parent 16ba8e1 commit 6dbb085
Showing 1 changed file with 68 additions and 4 deletions.
72 changes: 68 additions & 4 deletions core/lib/Foswiki/Configure/resources/scripts.js
Expand Up @@ -4,9 +4,19 @@

var expertsMode = '';

function toggleExpertsMode() {
var antimode = expertsMode;
expertsMode = (antimode == 'none' ? '' : 'none');
function toggleExpertsMode( inMode ) {

if (inMode != undefined) {
/* convert value to a css value */
expertsMode = (inMode == 1 ? '' : 'none');
} else {
/* toggle */
expertsMode = (expertsMode == 'none' ? '' : 'none');
}

var antimode = (expertsMode == 'none' ? '' : 'none');


/* toggle table rows */
$('tr.configureExpert').each(function() {
$(this).css("display", expertsMode);
Expand Down Expand Up @@ -450,6 +460,59 @@ function imgOnDemand () {
}
}

/**
Javascript query string parsing.
Author: djohnson@ibsys.com {{djohnson}} - you may use this file as you wish but please keep this header with it thanks
@use
Pass location.search to the constructor:
<code>var myPageQuery = new PageQuery(location.search)</code>
Retrieve values
<code>var myValue = myPageQuery.getValue("param1")</code>
*/
var PageQuery;
PageQuery = function (q) {
if (q.length > 1) {
this.q = q.substring(1, q.length);
} else {
this.q = null;
}
this.keyValuePairs = new Array();
if (q) {
for(var i=0; i < this.q.split(/[&;]/).length; i++) {
this.keyValuePairs[i] = this.q.split(/[&;]/)[i];
}
}
}
PageQuery.prototype.getKeyValuePairs = function() {
return this.keyValuePairs;
}
/**
@return The query string value; if not found returns -1.
*/
PageQuery.prototype.getValue = function (s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split(/=/)[0] == s)
return this.keyValuePairs[j].split(/=/)[1];
}
return -1;
}
PageQuery.prototype.getParameters = function () {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split(/=/)[0];
}
return a;
}
PageQuery.prototype.getLength = function() {
return this.keyValuePairs.length;
}

function getUrlParam(inName) {
var myPageQuery = new PageQuery(location.search);
var param = myPageQuery.getValue(inName);
return (param == -1 ? undefined : param);
}

/**
* jquery init
*/
Expand Down Expand Up @@ -523,7 +586,8 @@ $(document).ready(function() {
$(row).removeClass('configureExpert');
}
});
toggleExpertsMode();

toggleExpertsMode( getUrlParam('expert') );
toggleInfoMode();
initSection();
$(window).scroll(function(){ imgOnDemand() });
Expand Down

0 comments on commit 6dbb085

Please sign in to comment.