diff options
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/elements/header.html | 4 | ||||
-rw-r--r-- | httemplate/elements/logout.html | 44 | ||||
-rw-r--r-- | httemplate/elements/rs_init_object.html | 29 | ||||
-rw-r--r-- | httemplate/elements/xmlhttp.html | 19 |
4 files changed, 77 insertions, 19 deletions
diff --git a/httemplate/elements/header.html b/httemplate/elements/header.html index 495923c4d..5c4d736d2 100644 --- a/httemplate/elements/header.html +++ b/httemplate/elements/header.html @@ -37,6 +37,8 @@ Example: %> <% include('init_overlib.html') |n %> + <% include('rs_init_object.html') |n %> + <% include('logout.html') |n %> <SCRIPT TYPE="text/javascript"> @@ -82,7 +84,7 @@ Example: <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 %> </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 %> </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> diff --git a/httemplate/elements/logout.html b/httemplate/elements/logout.html new file mode 100644 index 000000000..313dbfaf1 --- /dev/null +++ b/httemplate/elements/logout.html @@ -0,0 +1,44 @@ +<%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> diff --git a/httemplate/elements/rs_init_object.html b/httemplate/elements/rs_init_object.html new file mode 100644 index 000000000..3bb0b4279 --- /dev/null +++ b/httemplate/elements/rs_init_object.html @@ -0,0 +1,29 @@ +<%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> diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index d0c799095..2df3c42c9 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -14,26 +14,9 @@ Example: ); </%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; |