<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Session.Timeout = 60
’Response.Write( IP )
Dim Action
Action = Request.Form("Action")
‘User Login
If Action = "UserLogin" Then
Call UserLogin()
Response.Redirect("WashingRoom.asp")
End If
Response.Write( "Welcome You, " & Session("UserName") & "<br>" )
‘Name Action
Sub UserLogin()
Dim UserIP
UserIP = Request.ServerVariables("REMOTE_ADDR")
Dim UserName
UserName = Request.Form("UserName")
If UserName = Empty Then
UserName = "No Named User"
End If
Session("UserName") = UserName
Session("UserIP") = UserIP
End Sub
Dim arrQueue
If Application("Queue") = Empty Then
reDim arrQueue(0)
Else
arrQueue = Split( Application("Queue"), "/" )
End If
Sub JoinInQueue()
If Application("Queue") <> Empty Then
If Instr( Application("Queue"), Session("UserName") ) > 0 Then
Else
Application("Queue") = Application("Queue") + Session("UserName") + "/"
End If
Else
Application("Queue") = Session("UserName") + "/"
End If
End Sub
Sub ExitFromQueue()
If Instr(Application("Queue"), Session("UserName")) > 0 Then
Application("Queue") = Replace( Application("Queue"), Session("UserName") + "/", "")
End If
End Sub
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>WashingRoom Queue System 1.0</title>
</head>
<body>
<%
Sub ShowQueue()
Dim iterator, counter
iterator = 0
counter = 0
Response.Write( "<ol>" )
For iterator = 0 To Ubound( arrQueue ) – 1
If arrQueue(i) <> Empty Then
If counter = 0 Then
Response.Write( "<li><font color=’red’>" & arrQueue(iterator) & "</font></li>" )
Else
Response.Write( "<li>" & arrQueue(iterator) & "</li>" )
End If
counter = counter + 1
End If
Next
Response.Write( "</ol>" )
If counter = 0 Then
Response.Write( "The WashingRoom is Empty Now" )
End If
End Sub
If Session("UserName") = Empty Then
Response.Write( "<h1> Enter Your Name to Continue </h1>" )
Response.Write( "<form method = ‘post’ action = ‘washingRoom.asp’>" )
Response.Write( "Input Your Name Please : <input type=’text’ size = ‘20′ name = ‘UserName’>" )
Response.Write( "<input type=’hidden’ name=’action’ value=’UserLogin’>" )
Response.Write( "<input type=’submit’ name = ’submit’ value = ‘Go on’>" )
Response.Write( "</form>" )
Else
If Application("Queue") <> Empty Then
ShowQueue
If Request.Form("submit") = "Join-In-The-Queue" Then
JoinInQueue
Response.Redirect("WashingRoom.asp")
ElseIf Request.Form("submit") = "Have-Finished-Washing" Then
ExitFromQueue
Response.Redirect("WashingRoom.asp")
ElseIf Request.Form("submit") = "I-am-Busy" Then
ExitFromQueue
JoinInQueue
Response.Redirect("WashingRoom.asp")
End If
Else
Response.Write( "No one in the washingRoom now!" )
If Request.Form("submit") = "Join-In-The-Queue" Then
JoinInQueue
Response.Redirect("WashingRoom.asp")
ElseIf Request.Form("submit") = "Have-Finished-Washing" Then
ExitFromQueue
Response.Redirect("WashingRoom.asp")
ElseIf Request.Form("submit") = "I-am-Busy" Then
ExitFromQueue
JoinInQueue
Response.Redirect("WashingRoom.asp")
End If
End If
Response.Write( "<form method=’post’ action=’WashingRoom.asp’>" )
Response.Write( "<input type=’submit’ name=’submit’ value=’Join-In-The-Queue’>")
Response.Write( "<input type=’submit’ name=’submit’ value=’Have-Finished-Washing’>")
Response.Write( "<input type=’submit’ name=’submit’ value=’I-am-Busy’>")
Response.Write( "</form>" )
End If
‘Response.Write( Application("Queue") )
%>
<hr />
<font color="#0000FF">Notice</font>
<ol>
<li>If you want to use washing room, please press "Join-In-The-Queue" button.</li>
<li>If you have finished washing your hand, please press "Have-Finished-Washing" button.</li>
<li>If it’s your turn and you are busy at the moment, you can press "I-am-Busy" button in order to re queue and let other body use the washing room first.</li>
</ol>
</body>
</html>