[0000619] Fixed javascript related timeout issues.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Thu, 21 Apr 2011 16:37:00 +0000 (18:37 +0200)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Thu, 21 Apr 2011 16:37:00 +0000 (18:37 +0200)
access/login.php
access/logout.php
includes/ui/ui_view.inc
js/login.js [new file with mode: 0644]

index c60819a90ea3fe5074281e9850fb089963329185..3bbf0060ec37fcab5ebe32d4a7ee4ad04be2267a 100644 (file)
        if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
                die(_("Restricted access"));
        include_once($path_to_root . "/includes/ui.inc");
-       
+       include_once($path_to_root . "/includes/page/header.inc");
+
        $js = "<script language='JavaScript' type='text/javascript'>
 function defaultCompany()
 {
        document.forms[0].company_login_name.options[".$_SESSION["wa_current_user"]->company."].selected = true;
 }
-".get_js_png_fix()."</script>";
-       $js2 = "<script language='JavaScript' type='text/javascript'>
-function set_fullmode() {
-       document.getElementById('ui_mode').value = 1;
-       document.loginform.submit();
-       return true;
-}
 </script>";
-
+       add_js_file('login.js');
        // Display demo user name and password within login form if "$allow_demo_mode" is true
        if ($allow_demo_mode == true)
        {
@@ -52,11 +46,11 @@ function set_fullmode() {
        echo "<head><title>$title</title>\n";
        echo "<meta http-equiv='Content-type' content='text/html; charset=$encoding' />\n";
        echo "<link href='$path_to_root/themes/$def_theme/default.css' rel='stylesheet' type='text/css'> \n";
+       send_scripts();
        if (!$login_timeout)
        {
                echo $js;
-       }       
-       echo $js2;
+       }
        echo "</head>\n";
 
        echo "<body id='loginscreen' $onload>\n";
@@ -88,7 +82,7 @@ function set_fullmode() {
 
        password_row(_("Password:"), 'password', $password);
 
-               if ($login_timeout) {
+       if ($login_timeout) {
                hidden('company_login_name', $_SESSION["wa_current_user"]->company);
        } else {
                if (isset($_SESSION['wa_current_user']->company))
@@ -114,6 +108,8 @@ function set_fullmode() {
                        echo "<input type='hidden' name='$p' value='$val'>";
        }
        end_form(1);
+       $Ajax->addScript(true, "document.forms[0].password.focus();");
+
     echo "<script language='JavaScript' type='text/javascript'>
     //<![CDATA[
             <!--
index 762fcd0e2953cce7a9b2427299ca0f822b94f706..6ea32fd7d6599775499e5427a0e9ea4dfff3d455 100644 (file)
 $page_security = 'SA_OPEN';
 $path_to_root="..";
 include($path_to_root . "/includes/session.inc");
+add_js_file('login.js');
 
 include($path_to_root . "/includes/page/header.inc");
-page_header(_("Logout"), true, false, '', get_js_png_fix());
+page_header(_("Logout"), true, false, '');
 
 echo "<table width='100%' border='0'>
   <tr>
index 0fa04330a7478483bf9eb5e207f25562d2da6b80..e2e5066ac0f4ee1ec6952b1aef6584b3565c4285 100644 (file)
@@ -808,31 +808,6 @@ function reset_focus()
        unset($_POST['_focus']);
 }
 
-function get_js_png_fix()
-{
-       $js = "function fixPNG(myImage)\n"
-               . "{\n"
-               . " var arVersion = navigator.appVersion.split(\"MSIE\")\n"
-               . " var version = parseFloat(arVersion[1])\n"
-       . " if ((version >= 5.5) && (version < 7) && (document.body.filters))\n"
-       . " {\n"
-               . "  var imgID = (myImage.id) ? \"id='\" + myImage.id + \"' \" : \"\"\n"
-               . "  var imgClass = (myImage.className) ? \"class='\" + myImage.className + \"' \" : \"\"\n"
-               . "  var imgTitle = (myImage.title) ?\n"
-               . "    \"title='\" + myImage.title  + \"' \" : \"title='\" + myImage.alt + \"' \"\n"
-               . "  var imgStyle = \"display:inline-block;\" + myImage.style.cssText\n"
-               . "  var strNewHTML = \"<span \" + imgID + imgClass + imgTitle\n"
-        . "    + \" style=\\\"\" + \"width:\" + myImage.width\n"
-        . "    + \"px; height:\" + myImage.height\n"
-        . "    + \"px;\" + imgStyle + \";\"\n"
-        . "    + \"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader\"\n"
-        . "    + \"(src=\'\" + myImage.src + \"\', sizingMethod='scale');\\\"></span>\"\n"
-               . "  myImage.outerHTML = strNewHTML\n"
-       . " }\n"
-               . "}\n";
-       return $js;
-}
-
 function get_js_date_picker()
 {
     global $go_debug;
diff --git a/js/login.js b/js/login.js
new file mode 100644 (file)
index 0000000..e4f0c68
--- /dev/null
@@ -0,0 +1,33 @@
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+function fixPNG(myImage)
+{
+       var arVersion = navigator.appVersion.split("MSIE")
+       var version = parseFloat(arVersion[1])
+       if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
+               var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
+               var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
+               var imgTitle = (myImage.title) ?
+                       "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
+               var imgStyle = "display:inline-block;" + myImage.style.cssText
+               var strNewHTML = "<span " + imgID + imgClass + imgTitle
+                       + " style=width:" + myImage.width + "px; height:" + myImage.height + "px;" 
+                       + imgStyle + ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+                       + "(src='" + myImage.src + "', sizingMethod='scale');></span>"
+               myImage.outerHTML = strNewHTML
+       }
+}
+
+function set_fullmode() {
+       document.getElementById('ui_mode').value = 1;
+       document.loginform.submit();
+       return true;
+}