-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbda.compconfig.js
119 lines (110 loc) · 2.95 KB
/
bda.compconfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
(function($) {
"use strict";
var BDA_COMP_CONFIG = {
isServiceConfigurationPage : false,
isPropertyPage:false,
build : function()
{
console.time("bdaCompConfig");
BDA_COMP_CONFIG.isServiceConfigurationPage = BDA_COMP_CONFIG.isServiceConfigurationPageFct();
BDA_COMP_CONFIG.isPropertyPage = BDA_COMP_CONFIG.isPropertyPage();
if (BDA_COMP_CONFIG.isServiceConfigurationPage)
BDA_COMP_CONFIG.setupServiceConfigurationPage();
if (BDA_COMP_CONFIG.isPropertyPage)
BDA_COMP_CONFIG.setupPropertyPage();
console.timeEnd("bdaCompConfig");
},
isServiceConfigurationPageFct : function()
{
return location.search.indexOf("propertyName=serviceConfiguration") != -1;
},
isPropertyPage : function()
{
return $('form[method=POST] > input[name=propertyName]').length === 1;
},
setupPropertyPage : function()
{
//Modify default textarea default POST ISO 8859 to XHR UTF-8 with reload
var pathname = $(location).attr('pathname');
var form = $('form[method=POST][action="' + pathname.replace( /(\/)/g, "\\$1" ) + '"]');
if($('textarea', form).length === 1)
{
//I made sure I tool the right form and it has textarea. Now searching for submit button
var submitBtn = form.find('input[type=submit]');
submitBtn.attr('type', 'button');
submitBtn.click(function()
{
$.post(
form.attr('action'),
form.serializeArray(),
function(data)
{
location.reload();
})
});
}
},
setupServiceConfigurationPage : function()
{
console.log("setupServiceConfigurationPage");
hljs.registerLanguage("properties",
function(hljs) {
console.log(hljs);
return {
cI: true,
c: [
{
cN: 'comment',
b: '#',
e: '$'
},
{
cN: 'setting',
b: /^[$a-z0-9\[\]_-]+\s*=\s*/,
e: '$',
c: [
{
cN: 'value',
eW: !0,
c: [
{
cN: 'number',
b: '\\b\\d+(\\.\\d+)?',
r: 10
},
{
cN: 'string',
b : /[./a-z0-9\[\]_-]+/,
e: '$',
r: 0
}
],
r: 0
}
]
}
]
};
});
$('pre').each(function() {
var txt = $(this).html();
$(this).text("");
$("<code class='properties' />").appendTo($(this)).html(txt);
});
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
},
};
// Reference to BDA
var BDA;
// Jquery plugin creation
$.fn.bdaCompConfig = function(pBDA)
{
console.log('Init plugin {0}'.format('bdaCompConfig'));
//settings = $.extend({}, defaults, options);
BDA = pBDA;
BDA_COMP_CONFIG.build();
return this;
};
})(jQuery);