Source

confjoke / templates / main.html

{% extends "layout.html" %}

{% block title %} - 首頁{% endblock %}

{% block nav %} - Index{% endblock %}

{% block head %}
<!-- include jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="JavaScript">
<!--
var secs;
var timeout;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    timeout = 20;
    secs = timeout;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        secs = timeout;
        //StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        //alert("You have just wasted 10 seconds of your life.")
        GetJoke();
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function SentJoke(){
    /* Sent JW */
}
function GetJoke(){
    //Get JW
    var url = '/get';
    $.getJSON(url,'',function(d){
            $('#MyJoke').empty();
            var html="";
            $.each(d,function(i,item){
              html+="<b>「"+item['jWhat']+"」</b>by "+item['jWho'] + " at " + item['jWhere']+"<br />";
            });
            $('#MyJoke').append(html);
    });
}

$(function(){
        GetJoke();
        InitializeTimer();
});
//-->
</script>


{% endblock %}

{% block menu %}
{% endblock %}

{% block content %}
<form action="save" method="post" accept-charset="utf-8">
	<table width="80%" align="center">
		<tr>
			<td align="center" valign="middle" class="bg1">
                <p>
                出處: <input type="text" name="txtWho" id="txtWho" />
                哪天: <input type="text" name="txtWhen" id="txtWhen" />
				哪場: <input type="text" name="txtWhere" id="txtWhere" />
                <input type="submit" value="送出" class="button">
                </p>
                <p>梗: <textarea name="txtWhat" id="txtWhat" rows="2" cols="70"></textarea></p>
			</td>
		</tr>
        {% comment %}
		<tr>
			<td align="left" valign="middle" colspan=2>
			{% for show in jResult %}
			{% if show.jWhat %}
			    <p>
                "{{ show.jWhat|escape }}" by {{ show.jWho|escape }} at {{ show.jWhere|escape }}
                </p>
			{% endif %}
			{% endfor %}
				</p>
			</td>
		</tr>
        {% endcomment %}
        <tr>
            <td>
                <br />
                <div id='MyJoke' align='left'>來點新梗吧!!</div>
            </td>
        </tr>
	</table>
</form>
{% endblock %}