1 | /* |
---|
2 | Licensed to the Apache Software Foundation (ASF) under one or more |
---|
3 | contributor license agreements. See the NOTICE file distributed with |
---|
4 | this work for additional information regarding copyright ownership. |
---|
5 | The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
6 | (the "License"); you may not use this file except in compliance with |
---|
7 | the License. You may obtain a copy of the License at |
---|
8 | |
---|
9 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
10 | |
---|
11 | Unless required by applicable law or agreed to in writing, software |
---|
12 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
14 | See the License for the specific language governing permissions and |
---|
15 | limitations under the License. |
---|
16 | */ |
---|
17 | |
---|
18 | // #/~java-properties |
---|
19 | sammy.get |
---|
20 | ( |
---|
21 | /^#\/(~java-properties)$/, |
---|
22 | function( context ) |
---|
23 | { |
---|
24 | var core_basepath = $( 'li[data-basepath]', app.menu_element ).attr( 'data-basepath' ); |
---|
25 | var content_element = $( '#content' ); |
---|
26 | |
---|
27 | content_element |
---|
28 | .html( '<div id="java-properties"></div>' ); |
---|
29 | |
---|
30 | $.ajax |
---|
31 | ( |
---|
32 | { |
---|
33 | url : core_basepath + '/admin/properties?wt=json', |
---|
34 | dataType : 'json', |
---|
35 | context : $( '#java-properties', content_element ), |
---|
36 | beforeSend : function( xhr, settings ) |
---|
37 | { |
---|
38 | this |
---|
39 | .html( '<div class="loader">Loading ...</div>' ); |
---|
40 | }, |
---|
41 | success : function( response, text_status, xhr ) |
---|
42 | { |
---|
43 | var system_properties = response['system.properties']; |
---|
44 | var properties_data = {}; |
---|
45 | var properties_content = []; |
---|
46 | var properties_order = []; |
---|
47 | |
---|
48 | var workaround = xhr.responseText.match( /"(line\.separator)"\s*:\s*"(.+?)"/ ); |
---|
49 | if( workaround && workaround[2] ) |
---|
50 | { |
---|
51 | system_properties[workaround[1]] = workaround[2]; |
---|
52 | } |
---|
53 | |
---|
54 | for( var key in system_properties ) |
---|
55 | { |
---|
56 | var displayed_key = key.replace( /\./g, '.​' ); |
---|
57 | var displayed_value = [ system_properties[key] ]; |
---|
58 | var item_class = 'clearfix'; |
---|
59 | |
---|
60 | if( -1 !== key.indexOf( '.path' ) || -1 !== key.indexOf( '.dirs' ) ) |
---|
61 | { |
---|
62 | displayed_value = system_properties[key].split( system_properties['path.separator'] ); |
---|
63 | if( 1 < displayed_value.length ) |
---|
64 | { |
---|
65 | item_class += ' multi'; |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | var item_content = '<li><dl class="' + item_class + '">' + "\n" |
---|
70 | + '<dt>' + displayed_key.esc() + '</dt>' + "\n"; |
---|
71 | |
---|
72 | for( var i in displayed_value ) |
---|
73 | { |
---|
74 | item_content += '<dd>' + displayed_value[i].esc() + '</dd>' + "\n"; |
---|
75 | } |
---|
76 | |
---|
77 | item_content += '</dl></li>'; |
---|
78 | |
---|
79 | properties_data[key] = item_content; |
---|
80 | properties_order.push( key ); |
---|
81 | } |
---|
82 | |
---|
83 | properties_order.sort(); |
---|
84 | for( var i in properties_order ) |
---|
85 | { |
---|
86 | properties_content.push( properties_data[properties_order[i]] ); |
---|
87 | } |
---|
88 | |
---|
89 | this |
---|
90 | .html( '<ul>' + properties_content.join( "\n" ) + '</ul>' ); |
---|
91 | |
---|
92 | $( 'li:odd', this ) |
---|
93 | .addClass( 'odd' ); |
---|
94 | |
---|
95 | $( '.multi dd:odd', this ) |
---|
96 | .addClass( 'odd' ); |
---|
97 | }, |
---|
98 | error : function( xhr, text_status, error_thrown) |
---|
99 | { |
---|
100 | }, |
---|
101 | complete : function( xhr, text_status ) |
---|
102 | { |
---|
103 | } |
---|
104 | } |
---|
105 | ); |
---|
106 | } |
---|
107 | ); |
---|