[freeside-commits] freeside/httemplate/elements logout.html, NONE, 1.1 rs_init_object.html, NONE, 1.1 header.html, 1.36, 1.37 xmlhttp.html, 1.10, 1.11

Jeff Finucane,420,, jeff at wavetail.420.am
Fri Jan 8 08:05:06 PST 2010


Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv32137/httemplate/elements

Modified Files:
	header.html xmlhttp.html 
Added Files:
	logout.html rs_init_object.html 
Log Message:
add a logout link (RT 1330 & 5518)

--- NEW FILE: logout.html ---
<%doc>

Example:

  include( '/elements/logout.html');
  This is the <a href="javascript:void()" onClick="logout();">logout</a> link.

</%doc>
<SCRIPT TYPE="text/javascript">

  function logout() {
    // count args; build URL
    var url = "<% $fsurl. 'loginout/logout.html' %>";

    var xmlhttp = rs_init_object();
    xmlhttp.open("GET", url, false, "magic", "notyet");
    xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
    xmlhttp.send(null);

    if (xmlhttp.readyState != 4) {
      alert("Logout failed: readyState is " + xmlhttp.readyState);
      return;
    }

    if (xmlhttp.status != 200) {
      alert("Logout failed: status is " + xmlhttp.status);
    } else {
      var data = xmlhttp.responseText;
      // alert('received response: ' + data);
      if ( data.indexOf("<b>System error</b>") > -1 ) {
        var w;
        if ( w = window.open("about:blank") ) {
          w.document.write(data);
        } else {
          // popup blocking?  should use an overlib popup instead 
          alert("Error popup disabled; try disabling popup blocking to see");
        }
      } else {
        window.location = "<% $fsurl. 'loginout/logout.html' %>";
      }
    }
  }

</SCRIPT>

--- NEW FILE: rs_init_object.html ---
<%doc>

Example:

  include( '/elements/rs_init_object.html' );

</%doc>
<SCRIPT TYPE="text/javascript">

  function rs_init_object() {
    var A;
    try {
      A=new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        A=new ActiveXObject("Microsoft.XMLHTTP");
      } catch (oc) {
        A=null;
      }
    }
    if(!A && typeof XMLHttpRequest != "undefined")
      A = new XMLHttpRequest();
    if (!A)
      alert("Can't create XMLHttpRequest object");
    return A;

  }

</SCRIPT>

Index: xmlhttp.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/xmlhttp.html,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- xmlhttp.html	8 May 2008 12:45:59 -0000	1.10
+++ xmlhttp.html	8 Jan 2010 16:05:04 -0000	1.11
@@ -14,26 +14,9 @@
   );
 
 </%doc>
+<% include( '/elements/rs_init_object.html' ) %>
 <SCRIPT TYPE="text/javascript">
 
-  function rs_init_object() {
-    var A;
-    try {
-      A=new ActiveXObject("Msxml2.XMLHTTP");
-    } catch (e) {
-      try {
-        A=new ActiveXObject("Microsoft.XMLHTTP");
-      } catch (oc) {
-        A=null;
-      }
-    }
-    if(!A && typeof XMLHttpRequest != "undefined")
-      A = new XMLHttpRequest();
-    if (!A)
-      alert("Can't create XMLHttpRequest object");
-    return A;
-
-  }
 % foreach my $func ( @{$opt{'subs'}} ) { 
 %
 %       my $furl = $url;

Index: header.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/header.html,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- header.html	28 Dec 2009 19:18:19 -0000	1.36
+++ header.html	8 Jan 2010 16:05:04 -0000	1.37
@@ -37,6 +37,8 @@
     %>
 
     <% include('init_overlib.html') |n %>
+    <% include('rs_init_object.html') |n %>
+    <% include('logout.html') |n %>
 
     <SCRIPT TYPE="text/javascript">
 
@@ -82,7 +84,7 @@
         <td align=left BGCOLOR="#ffffff"> <!-- valign="top" -->
           <font size=6><% $company_name || 'ExampleCo' %></font>
         </td>
-        <td align=right valign=top BGCOLOR="#ffffff"><FONT SIZE="-1">Logged in as <b><% getotaker %>&nbsp;</b><br></FONT><FONT SIZE="-2"><a href="<%$fsurl%>pref/pref.html" STYLE="color: #000000">Preferences</a>
+        <td align=right valign=top BGCOLOR="#ffffff"><FONT SIZE="-1">Logged in as <b><% getotaker %>&nbsp;</b> <FONT SIZE="-2">[ <a href="javascript:void(0);" onClick="logout();">logout</a> ]</FONT><br></FONT><FONT SIZE="-2"><a href="<%$fsurl%>pref/pref.html" STYLE="color: #000000">Preferences</a>
 %         if ( $conf->config("ticket_system")
 %              && FS::TicketSystem->access_right(\%session, 'ModifySelf') ) {
             | <a href="<%$fsurl%>rt/User/Prefs.html" STYLE="color: #000000">Ticketing preferences</a>



More information about the freeside-commits mailing list