webbuild interface: add cookie support to maintain user session

This commit is contained in:
Silvan Calarco 2013-05-21 00:30:35 +02:00
parent 3927887baf
commit b84e90b7db

View File

@ -1,4 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head> <html><head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<!-- styles needed by jScrollPane --> <!-- styles needed by jScrollPane -->
<link type="text/css" href="/scripts/jquery.jscrollpane.css" rel="stylesheet" media="all" > <link type="text/css" href="/scripts/jquery.jscrollpane.css" rel="stylesheet" media="all" >
<!-- latest jQuery direct from google's CDN --> <!-- latest jQuery direct from google's CDN -->
@ -36,12 +38,45 @@ window.onbeforeunload = function (e) {
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
var user = "silvan"; var user = "silvan";
var user_email = "silvan.calarco@gmail.com"; var user_email = "silvan.calarco@mambasoft.it";
var secret = ""; var secret = "";
var lastupdate = 0; var lastupdate = 0;
var reloadtime = 15000; var reloadtime = 15000;
var editor; var editor;
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name)
{
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1)
{
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1)
{
c_value = null;
}
else
{
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1)
{
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start,c_end));
}
return c_value;
}
function clearid(id) { function clearid(id) {
document.getElementById(id).innerHTML = ''; document.getElementById(id).innerHTML = '';
} }
@ -56,6 +91,9 @@ function editorChanged() {
function ajax_getvalues(request,confirm) { function ajax_getvalues(request,confirm) {
var url = "/cgi-bin/webbuild" var url = "/cgi-bin/webbuild"
if (!secret) {
secret=getCookie("webbuild");
}
if (confirm) { if (confirm) {
document.getElementById("status").innerHTML = document.getElementById("status").innerHTML =
'<div class=screencontainer><div class=opaquebackground></div>'+ '<div class=screencontainer><div class=opaquebackground></div>'+
@ -98,10 +136,9 @@ function ajax_getvalues(request,confirm) {
for (var i = 0; i < nodes.length; i++) { for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeName == "title") { if (nodes[i].nodeName == "title") {
document.title = nodes[i].childNodes[0].nodeValue; document.title = nodes[i].childNodes[0].nodeValue;
} else if (nodes[i].nodeName == "cookie") {
setCookie("webbuild", nodes[i].childNodes[0].nodeValue, 1);
} else if (document.getElementById(nodes[i].nodeName) != undefined) { } else if (document.getElementById(nodes[i].nodeName) != undefined) {
// var node = document.getElementById(nodes[i].nodeName)
//alert("replace " + node.nodeValue + "with " + nodes[i].childNodes[0].nodeValue);
// node = replaceHTML(node, nodes[i].childNodes[0].nodeValue);
$("#"+nodes[i].nodeName).html(nodes[i].childNodes[0].nodeValue); $("#"+nodes[i].nodeName).html(nodes[i].childNodes[0].nodeValue);
spectext = document.getElementById("spectext"); spectext = document.getElementById("spectext");
if ((nodes[i].nodeName == "editor") && (spectext != undefined) && (spectext.parentNode != undefined)) if ((nodes[i].nodeName == "editor") && (spectext != undefined) && (spectext.parentNode != undefined))
@ -157,9 +194,9 @@ function ajax_getvalues(request,confirm) {
</head><body> </head><body>
<table width="100%"><tr><td> <table width="100%"><tr><td>
<tr><td valign="middle"> <tr><td valign="middle">
<table align="center"><tr> <table align="left"><tr>
<td><img src="/images/community-gr.png" alt="build automatici"></td> <td><img src="/images/webbuild.png" alt="build automatici"></td>
<td class="toptitle">Interfaccia Web per lo sviluppo di openmamba (alpha testing)</td> <td>&nbsp;&nbsp;&nbsp;<b>- Webbuild - Interfaccia Web per lo sviluppo di openmamba</b></td>
</tr></table> </tr></table>
</td></tr> </td></tr>
<tr><td> <tr><td>