mirror of
https://github.com/PirateBox-Dev/PirateBoxScripts_Webserver.git
synced 2023-12-14 07:22:58 +01:00
Get timestamp for Shoutbox from the client/browser
on systems with no real time clock
This commit is contained in:
parent
b1382377b9
commit
c8986663c8
|
@ -71,8 +71,8 @@ def read_data_file():
|
|||
#--------------
|
||||
# Function for saving new Shoubox-Content & Regenerate static HTML file -- usually called by HTML-Form
|
||||
#--------------
|
||||
def process_form( name , indata , color ):
|
||||
content = save_input( name , indata , color )
|
||||
def process_form( name , indata , color , time ):
|
||||
content = save_input( name , indata , color , time )
|
||||
|
||||
if broadcast_destination == False:
|
||||
generate_html_into_file ( content )
|
||||
|
@ -81,9 +81,9 @@ def process_form( name , indata , color ):
|
|||
#--------------
|
||||
# Acutally Saves SB-Content to datafile
|
||||
#--------------
|
||||
def save_input( name , indata , color ):
|
||||
def save_input( name , indata , color , time ):
|
||||
|
||||
content = prepare_line ( name, indata, color )
|
||||
content = prepare_line ( name, indata, color , time )
|
||||
|
||||
if broadcast_destination != False:
|
||||
return writeToNetwork( content , broadcast_destination )
|
||||
|
@ -109,7 +109,7 @@ def writeToDisk ( content ):
|
|||
return finalcontent
|
||||
|
||||
|
||||
def prepare_line ( name, indata, color ):
|
||||
def prepare_line ( name, indata, color , time ):
|
||||
datapass = re.sub("<", "<", indata)
|
||||
data = re.sub(">", ">", datapass)
|
||||
curdate = datetime.datetime.now()
|
||||
|
@ -117,7 +117,8 @@ def prepare_line ( name, indata, color ):
|
|||
# <div class="message">
|
||||
# <date>00:00:00</date> <name>Nickname:</name> <data class="def">Lorem ipsum dolor sit amet</data>
|
||||
# </div>
|
||||
content = "<div class='message'><date>" + curdate.strftime("%H:%M:%S") + "</date> <name>" + name + ":</name> <data class='" + color + "'>" + data + "</data></div>\n"
|
||||
#content = "<div class='message'><date>" + curdate.strftime("%H:%M:%S") + "</date> <name>" + name + ":</name> <data class='" + color + "'>" + data + "</data></div>\n"
|
||||
content = "<div class='message'><date>" + time + "</date> <name>" + name + ":</name> <data class='" + color + "'>" + data + "</data></div>\n"
|
||||
return content
|
||||
|
||||
#--------------
|
||||
|
|
|
@ -21,9 +21,10 @@ else:
|
|||
datapass = re.sub("<", "<", rawdata)
|
||||
data = re.sub(">", ">", datapass)
|
||||
color = values["color"].value
|
||||
time = values["time"].value
|
||||
curdate = datetime.datetime.now()
|
||||
|
||||
process_form( name , rawdata , color )
|
||||
process_form( name , rawdata , color , time )
|
||||
|
||||
print """<html><body>ok</body></html>"""
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<div id="chat" class="card">
|
||||
<h2>Chat</h2>
|
||||
<div id="shoutbox" class="shoutbox_content"></div>
|
||||
<form method="POST" name="psowrte" id="sb_form" >
|
||||
<form method="POST" name="psowrte" id="sb_form" onsubmit='getTime();'>
|
||||
<div id="shoutbox-input">
|
||||
<input class="nickname" type="text" name="name" value="Anonymous" placeholder="Nickname">
|
||||
<input class="message" type="text" name="data" placeholder="Message...">
|
||||
|
@ -65,6 +65,21 @@
|
|||
<label for="orange" class="bg-orange"> <input name="color" type="radio" value="orange" id="orange" >Orange</label>
|
||||
<label for="red" class="bg-red"> <input name="color" type="radio" value="red" id="red" >Red</label>
|
||||
</div>
|
||||
<input type="hidden" name="time" id="time">
|
||||
<script language='JavaScript'>
|
||||
function getTime(){
|
||||
var date = new Date();
|
||||
var h = date.getUTCHours();
|
||||
var hour = (h < 10) ? '0' + h : h;
|
||||
var mi = date.getUTCMinutes();
|
||||
var minute = (mi < 10) ? '0' + mi : mi;
|
||||
var sc = date.getUTCSeconds();
|
||||
var second = (sc < 10) ? '0' + sc : sc;
|
||||
var loctime = hour + "." + minute + "." + second;
|
||||
|
||||
document.getElementById('time').value = loctime;
|
||||
}
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue