Fixed FELIX-3014 : Have a way to "deep link" to a particular tab within Configuration Status
https://issues.apache.org/jira/browse/FELIX-3014

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1169749 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
index 2e96882..e000fac 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
@@ -19,6 +19,7 @@
 
 import java.io.*;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.text.DateFormat;
 import java.text.MessageFormat;
 import java.util.*;
@@ -218,7 +219,7 @@
             {
                 final String label = desc.label;
                 final String title = desc.title;
-                pw.print("<li><a href='" + pluginRoot + label + ".nfo'>" + title + "</a></li>" );
+                pw.print("<li><a href='" + pluginRoot + URLEncoder.encode(label) + ".nfo'>" + title + "</a></li>" );
             }
         }
         pw.println("</ul> <!-- end tabs on top -->");
diff --git a/webconsole/src/main/resources/res/ui/configurationrender.js b/webconsole/src/main/resources/res/ui/configurationrender.js
index 49039cc..96c28c1 100644
--- a/webconsole/src/main/resources/res/ui/configurationrender.js
+++ b/webconsole/src/main/resources/res/ui/configurationrender.js
@@ -14,6 +14,8 @@
  * See the License for the specific language governing permissions and

  * limitations under the License.

  */

+var _tabs = false;

+

 function pad(value) {

 	if ( value < 10 ) {

 		return "0" + value;

@@ -21,6 +23,20 @@
 	return "" + value;

 }

 

+function setSelectedTab() {

+	var anchor =  window.location.hash;

+	if (anchor) {

+		anchor = pluginRoot + '/' + anchor.substring(1) + '.nfo';

+		_tabs.find('ul > li > a').each( function(index, element) {

+			if (anchor == $(element).data('href.tabs')) {

+				_tabs.tabs('select', index);

+				return false;

+			}

+			return true;

+		});

+	}

+}

+

 function downloadDump(ext) {

 	var now = new Date();

 	var name = "configuration-status-" + now.getUTCFullYear() + pad(now.getUTCMonth() + 1) + pad(now.getUTCDate()) + "-" + pad(now.getUTCHours()) + pad(now.getUTCMinutes()) + pad(now.getUTCSeconds()) + ".";

@@ -28,6 +44,7 @@
 }

 

 $(document).ready(function() {

+	$(window).bind( 'hashchange', setSelectedTab);

 	var dlg = $('#waitDlg').dialog({

 		modal    : true,

 		autoOpen : false,

@@ -36,11 +53,13 @@
 		closeOnEscape: false

 	});

 

-	$('#tabs').tabs({ajaxOptions: {

+	_tabs = $('#tabs').tabs({ajaxOptions: {

 		beforeSend : function() { dlg.dialog('open') },

-		complete   : function() { dlg.dialog('close')}

+		complete   : function() { dlg.dialog('close')},

 	}}).tabs('paging');

 

+	setTimeout(setSelectedTab, 1000);

+

 	$('.downloadTxt').click(function() { downloadDump('txt')});

 	$('.downloadZip').click(function() { downloadDump('zip')});

 });
\ No newline at end of file