entry validaton.
$ts = $thoseps[user_tho_sep()];
$ds = $decseps[user_dec_sep()];
- $js = "\n<script type=\"text/javascript\">\n"
- . "<!--\n"
+ $js = "\n"
. "var user = {\n"
- . "theme: '". $path_to_root . '/themes/'. 'default' /*user_theme()*/.'/'."',\n"
+ . "theme: '". $path_to_root . '/themes/'. user_theme().'/'."',\n"
. "loadtxt: '"._('Requesting data...')."',\n"
. "ts: '$ts',\n"
. "ds: '$ds',\n"
- . "pdec : " . user_price_dec() . "}\n--></script>";
+ . "pdec : " . user_price_dec() . "}\n";
add_js_source($js);
}
***********************************************************************/
function page_footer($no_menu=false, $is_index=false)
{
- global $path_to_root;
+ global $path_to_root, $js_lib;
if (in_ajax())
return;// just for speed up
include_once($path_to_root."/themes/".user_theme()."/renderer.php");
$rend = new renderer();
$rend->menu_footer($no_menu, $is_index);
+
+ add_user_js_data();
+ echo "\n<script type=\"text/javascript\"><!--\n";
+
+ foreach($js_lib as $text)
+ echo $text;
+
+ echo "\n--></script>\n";
echo "</body></html>\n";
}
global $js_lib, $js_static, $js_path, $js_userlib, $comp_path,
$path_to_root, $go_debug;
- add_user_js_data();
-
$js ='';
foreach($js_static as $jsfile)
{
$jsfile . '"></script>';
}
- foreach($js_lib as $text)
- {
- $js .= $text;
- }
echo $js;
}
if (in_ajax())
return; // just for speed up
+// $jsext = substr_replace($_SERVER['PHP_SELF'], '.js', -4);
+
+// if (file_exists($_SERVER['DOCUMENT_ROOT'].$jsext))
+// add_js_ufile($jsext);
+
$theme = user_theme();
$local_path_to_root = $path_to_root;
function get_js_open_window($width, $height)
{
- $js = "\n<script type=\"text/javascript\">\n"
- . "<!--\n"
- . "function openWindow(url, title)\n"
+ $js ="function openWindow(url, title)\n"
. "{\n"
. " var left = (screen.width - $width) / 2;\n"
. " var top = (screen.height - $height) / 2;\n"
. " return window.open(url, title, 'width=$width,height=$height,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes');\n"
- . "}\n"
- . "-->\n"
- . "</script>\n";
+ . "}\n";
return $js;
}
function get_js_png_fix()
{
- $js = "<script type=\"text/javascript\">\n"
- . "function fixPNG(myImage)\n"
+ $js = "function fixPNG(myImage)\n"
. "{\n"
. " var arVersion = navigator.appVersion.split(\"MSIE\")\n"
. " var version = parseFloat(arVersion[1])\n"
. " + \"(src=\'\" + myImage.src + \"\', sizingMethod='scale');\\\"></span>\"\n"
. " myImage.outerHTML = strNewHTML\n"
. " }\n"
- . "}\n"
- . "</script>\n";
+ . "}\n";
return $js;
}
'alt': false, // whether is the Alt key pressed
'focus': -1 // currently selected indeks of document.links
};
+var _validate = {}; // validation functions
function debug(msg) {
box = document.getElementById('msgbox')
box.innerHTML= box.innerHTML+'<br>'+msg
}
-function progbar() {
- box = document.getElementById('msgbox');
- box.innerHTML= "<center><table width='98%' border='1' cellpadding=3 "
- +"bordercolor='#007700' style='border-collapse: collapse'>"
- +"<tr><td align='center' bgcolor='#ccffcc' >"
- +"<img src='"+user.theme+"images/progressbar.gif' alt='"
- +user.loadtxt+"' /></td></tr></table></center><br>";
- box.style.display = 'block';
-}
-
function save_focus(e) {
_focus = e.name||e.id;
var h = document.getElementById('hints');
e.style.display = 'block';
},
// '.ajaxsubmit,.editbutton,.navibutton': // much slower on IE7
- 'button.ajaxsubmit,input.ajaxsubmit,input.editbutton,button.navibutton':
+ 'button.ajaxsubmit,input.ajaxsubmit,input.editbutton,button.editbutton,button.navibutton':
function(e) {
- e.onclick = function() {
- if (this.getAttribute('aspect') == 'process')
- progbar();
- save_focus(this);
- JsHttpRequest.request(this);
- return false;
- }
+ e.onclick = function() {
+ save_focus(e);
+ if (e.getAttribute('aspect') == 'process')
+ JsHttpRequest.request(this, null, 30000);
+ else
+ JsHttpRequest.request(this);
+ return false;
+ }
+ },
+ 'button': function(e) {
+ if (e.name) {
+ var func = eval("_validate."+e.name);
+ var old = e.onclick;
+ if(func) {
+ if (typeof old != 'function') {
+ e.onclick = func;
+ } else {
+ e.onclick = function() {
+ if(func())
+ { old(); return true;}
+ else
+ return false;
+ }
+ }
+ }
+ }
},
'.amount': function(e) {
if(e.onblur==undefined) {
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
+function set_mark(img) {
+ var box = document.getElementById('ajaxmark');
+ if(img) box.src = user.theme+'images/'+ img;
+ box.style.visibility = img ? 'visible' : 'hidden'
+}
+
//
// JsHttpRequest class extensions.
//
// if form parameter exists also form values are submited, otherwise
// request is directed to current location
//
- JsHttpRequest.request= function(trigger, form) {
- var mark = document.getElementById('ajaxmark');
- if(mark) mark.style.visibility = 'visible';
+JsHttpRequest.request= function(trigger, form, tout) {
+ tout = tout | 3000; // default timeout value
+ set_mark(tout>5000 ? 'progressbar.gif' : 'ajax-loader.gif');
+ JsHttpRequest._request(trigger, form, tout, 2);
+}
+
+JsHttpRequest._request = function(trigger, form, tout, retry) {
+
if (trigger.tagName=='A') {
var content = {};
var upload = 0;
if (!form) url = url.substring(0, url.indexOf('?'));
- if (!submitObj)
+ if (!submitObj) {
content[trigger] = 1;
-
+ }
}
// this is to avoid caching problems
content['_random'] = Math.random()*1234567;
+
+ var tcheck = setTimeout(
+ function() {
+ for(var id in JsHttpRequest.PENDING) {
+ var call = JsHttpRequest.PENDING[id];
+ if (call != false) {
+ if (call._ldObj.xr) // needed for gecko
+ call._ldObj.xr.onreadystatechange = function(){};
+ call.abort(); // why this doesn't kill request in firebug?
+// call._ldObj.xr.abort();
+ delete JsHttpRequest.PENDING[id];
+ }
+ }
+ set_mark(retry ? 'ajax-loader2.gif':'warning.png' );
+ if(retry)
+ JsHttpRequest._request(trigger, form, tout, retry-1);
+ }, tout );
JsHttpRequest.query(
(upload ? "form." : "")+"POST "+url, // force form loader
errors = errors+'<br>Unknown ajax function: '+cmd;
}
}
-
+ if(tcheck)
+ JsHttpRequest.clearTimeout(tcheck);
// Write errors to the debug div.
document.getElementById('msgbox').innerHTML = errors;
- var mark = document.getElementById('ajaxmark');
- if(mark) mark.style.visibility = 'hidden';
+ set_mark();
Behaviour.apply();
}
}
},
- false // do not disable caching
+ false // do not disable caching
);
- }
+ }
// collect all form input values plus inp trigger value
JsHttpRequest.formInputs = function(inp, objForm, upload)
{