1 |
fab7ff44
|
Bill Marquette
|
<?php
|
2 |
6b07c15a
|
Matthew Grooms
|
/*
|
3 |
|
|
headjs.php
|
4 |
|
|
|
5 |
|
|
Redistribution and use in source and binary forms, with or without
|
6 |
|
|
modification, are permitted provided that the following conditions are met:
|
7 |
|
|
|
8 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
9 |
|
|
this list of conditions and the following disclaimer.
|
10 |
|
|
|
11 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
12 |
|
|
notice, this list of conditions and the following disclaimer in the
|
13 |
|
|
documentation and/or other materials provided with the distribution.
|
14 |
|
|
|
15 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
16 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
17 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
18 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
19 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
20 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
21 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
22 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
23 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
24 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
25 |
|
|
*/
|
26 |
7ac5a4cb
|
Scott Ullrich
|
/*
|
27 |
|
|
pfSense_MODULE: header
|
28 |
|
|
*/
|
29 |
6b07c15a
|
Matthew Grooms
|
|
30 |
|
|
##|+PRIV
|
31 |
|
|
##|*IDENT=page-requiredforjavascript
|
32 |
|
|
##|*NAME=Required for javascript page
|
33 |
|
|
##|*DESCR=Allow access to the 'Required for javascript' page.
|
34 |
|
|
##|*MATCH=headjs.php*
|
35 |
|
|
##|-PRIV
|
36 |
|
|
|
37 |
fd4151a9
|
Ermal
|
require_once("guiconfig.inc");
|
38 |
|
|
|
39 |
fab7ff44
|
Bill Marquette
|
function getHeadJS() {
|
40 |
|
|
global $_SERVER, $HTTP_SERVER_VARS, $g, $use_loader_tab_gif;
|
41 |
|
|
|
42 |
|
|
if(!$use_loader_tab_gif)
|
43 |
|
|
$loader_gif = "/themes/{$g['theme']}/images/misc/loader.gif";
|
44 |
|
|
else
|
45 |
|
|
$loader_gif = "/themes/{$g['theme']}/images/misc/loader_tab.gif";
|
46 |
|
|
|
47 |
|
|
$headjs = "
|
48 |
|
|
var input_errors = '';
|
49 |
ea0d4171
|
Vinicius Coque
|
jQuery(document).ready(init);
|
50 |
fab7ff44
|
Bill Marquette
|
";
|
51 |
|
|
$_SESSION['NO_AJAX'] == "True" ? $noajax = "var noAjaxOnSubmit = true;" : $noajax = "var noAjaxOnSubmit = false;";
|
52 |
|
|
|
53 |
|
|
$headjs .= "
|
54 |
|
|
{$noajax}
|
55 |
|
|
|
56 |
|
|
function init() {
|
57 |
ea0d4171
|
Vinicius Coque
|
if(jQuery('#submit') && ! noAjaxOnSubmit) {
|
58 |
fab7ff44
|
Bill Marquette
|
// debugging helper
|
59 |
|
|
//alert('adding observe event for submit button');
|
60 |
|
|
|
61 |
ea0d4171
|
Vinicius Coque
|
jQuery(\"#submit\").click(submit_form);
|
62 |
|
|
jQuery('#submit').click(function() {return false;});
|
63 |
fab7ff44
|
Bill Marquette
|
var to_insert = \"<div style='visibility:hidden' id='loading' name='loading'><img src='{$loader_gif}' \/><\/div>\";
|
64 |
ea0d4171
|
Vinicius Coque
|
jQuery('#submit').before(to_insert);
|
65 |
fab7ff44
|
Bill Marquette
|
}
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
function submit_form(e){
|
69 |
|
|
// debugging helper
|
70 |
|
|
//alert(Form.serialize($('iform')));
|
71 |
ea0d4171
|
Vinicius Coque
|
|
72 |
|
|
if(jQuery('#inputerrors'))
|
73 |
|
|
jQuery('#inputerrors').html('<center><b><i>Loading...</i></b></center>');
|
74 |
fab7ff44
|
Bill Marquette
|
|
75 |
|
|
/* dsh: Introduced because pkg_edit tries to set some hidden fields
|
76 |
52860a44
|
Bill Marquette
|
* if executing submit's onclick event. The click gets deleted
|
77 |
fab7ff44
|
Bill Marquette
|
* by Ajax. Hence using onkeydown instead.
|
78 |
|
|
*/
|
79 |
ea0d4171
|
Vinicius Coque
|
if(jQuery('#submit').prop('keydown')) {
|
80 |
|
|
jQuery('#submit').keydown();
|
81 |
|
|
jQuery('#submit').css('visibility','hidden');
|
82 |
|
|
}
|
83 |
|
|
if(jQuery('#cancelbutton'))
|
84 |
|
|
jQuery('#cancelbutton').css('visibility','hidden');
|
85 |
|
|
jQuery('#loading').css('visibility','visible');
|
86 |
fab7ff44
|
Bill Marquette
|
// submit the form using Ajax
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
function formSubmitted(resp) {
|
90 |
|
|
var responseText = resp.responseText;
|
91 |
|
|
|
92 |
|
|
// debugging helper
|
93 |
be23be5a
|
Scott Ullrich
|
// alert(responseText);
|
94 |
fab7ff44
|
Bill Marquette
|
|
95 |
|
|
if(responseText.indexOf('html') > 0) {
|
96 |
|
|
/* somehow we have been fed an html page! */
|
97 |
|
|
//alert('Somehow we have been fed an html page! Forwarding to /.');
|
98 |
|
|
document.location.href = '/';
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
eval(responseText);
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
/* this function will be called if an HTTP error will be triggered */
|
105 |
|
|
function formFailure(resp) {
|
106 |
950f0f9e
|
Scott Ullrich
|
showajaxmessage(resp.responseText);
|
107 |
ea0d4171
|
Vinicius Coque
|
if(jQuery('#submit'))
|
108 |
|
|
jQuery('#submit').css('visibility','visible');
|
109 |
|
|
if(jQuery('#cancelbutton'))
|
110 |
|
|
jQuery('#cancelbutton').css('visibility','visible');
|
111 |
|
|
if(jQuery('#loading'))
|
112 |
|
|
jQuery('#loading').css('visibility','hidden');
|
113 |
950f0f9e
|
Scott Ullrich
|
|
114 |
fab7ff44
|
Bill Marquette
|
}
|
115 |
|
|
|
116 |
|
|
function showajaxmessage(message) {
|
117 |
|
|
var message_html;
|
118 |
|
|
|
119 |
|
|
if (message == '') {
|
120 |
|
|
NiftyCheck();
|
121 |
|
|
Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\");
|
122 |
|
|
Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\");
|
123 |
|
|
|
124 |
ea0d4171
|
Vinicius Coque
|
if(jQuery('#submit'))
|
125 |
|
|
jQuery('#submit').css('visibility','visible');
|
126 |
|
|
if(jQuery('#cancelbutton'))
|
127 |
|
|
jQuery('#cancelbutton').css('visibility','visible');
|
128 |
|
|
if(jQuery('#loading'))
|
129 |
|
|
jQuery('#loading').css('visibility','hidden');
|
130 |
fab7ff44
|
Bill Marquette
|
|
131 |
|
|
return;
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
message_html = '<table height=\"32\" width=\"100%\"><tr><td>';
|
135 |
|
|
message_html += '<div style=\"background-color:#990000\" id=\"redbox\">';
|
136 |
|
|
message_html += '<table width=\"100%\"><tr><td width=\"8%\">';
|
137 |
859e12ed
|
Scott Ullrich
|
message_html += '<img style=\"vertical-align:center\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\" width=\"28\" height=\"32\" \/>';
|
138 |
fab7ff44
|
Bill Marquette
|
message_html += '<\/td><td width=\"70%\"><font color=\"white\">';
|
139 |
|
|
message_html += '<b>' + message + '<\/b><\/font><\/td>';
|
140 |
|
|
|
141 |
|
|
if(message.indexOf('apply') > 0) {
|
142 |
|
|
message_html += '<td>';
|
143 |
|
|
message_html += '<input name=\"apply\" type=\"submit\" class=\"formbtn\" id=\"apply\" value=\"" . gettext("Apply changes") . "\" \/>';
|
144 |
|
|
message_html += '<\/td>';
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
message_html += '<\/tr><\/table><\/div><\/td><\/table><br \/>';
|
148 |
ea0d4171
|
Vinicius Coque
|
jQuery('#inputerrors').html(message_html);
|
149 |
fab7ff44
|
Bill Marquette
|
|
150 |
|
|
NiftyCheck();
|
151 |
|
|
Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\");
|
152 |
|
|
Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\");
|
153 |
|
|
|
154 |
ea0d4171
|
Vinicius Coque
|
if(jQuery('#submit'))
|
155 |
|
|
jQuery('#submit').css('visibility','visible');
|
156 |
|
|
if(jQuery('#cancelbutton'))
|
157 |
|
|
jQuery('#cancelbutton').css('visibility','visible');
|
158 |
|
|
if(jQuery('#loading'))
|
159 |
|
|
jQuery('#loading').css('visibility','hidden');
|
160 |
|
|
if(jQuery('#inputerrors'))
|
161 |
fab7ff44
|
Bill Marquette
|
window.scrollTo(0, 0);
|
162 |
|
|
}
|
163 |
|
|
";
|
164 |
|
|
|
165 |
|
|
return $headjs;
|
166 |
|
|
}
|
167 |
|
|
|
168 |
fd4151a9
|
Ermal
|
?>
|