Commits

Rhys ! committed 7081e69

validating booklist search form

Comments (0)

Files changed (4)

site/booklist_404.shpaml

+{{inherit "wrapper.tmpl"}}
+{{py: global left_insert; left_insert = {} }}
+{{def title}}Booklists{{enddef}}
+{{def stylesheet}}booklists{{enddef}}
+{{def script}}booklists{{enddef}}
+ul.breadcrumb
+    li
+        >
+        a href=index.php | Bookshop
+    li
+        >
+        a href=booklists.php | Booklists
+    li
+        >
+        a href=# | Not found
+div.error
+    p | Could not find that booklist.
+form.block method=get action=booklist_hit2316.php
+    fieldset
+        legend | Year
+        > input type=radio name=year value=2010 id=year-2010
+        label for=year-2010 | 2010
+        > input type=radio name=year value=2011 id=year-2011 checked=checked
+        label for=year-2011 | 2011
+    fieldset
+        legend | Semester
+        > input type=radio name=semester value=summer id=semester-summer
+        label for=semester-summer | Summer
+        > input type=radio name=semester value=one id=semester-one
+        label for=semester-one | One
+        > input type=radio name=semester value=two id=semester-two checked=checked
+        label for=semester-two | Two
+        > input type=radio name=semester value=three id=semester-three
+        label for=semester-three | Three
+    fieldset
+        legend | Campus
+        > input type=radio name=campus value=Hawthorn id=campus-Hawthorn checked=checked
+        label for=campus-Hawthorn | Hawthorn
+        > input type=radio name=campus value=Lilydale id=campus-Lilydale
+        label for=campus-Lilydale | Lilydale
+        > input type=radio name=campus value=Prahran id=campus-Prahran
+        label for=campus-Prahran | Prahran
+        > input type=radio name=campus value=Wantirna id=campus-Wantirna
+        label for=campus-Wantirna | Wantirna
+        > input type=radio name=campus value=Croydon id=campus-Croydon
+        label for=campus-Croydon | Croydon
+    fieldset
+        legend | Unit code
+        > input type=text name=query placeholder="Enter unit code"
+    > input type=submit value=Search

site/booklists.coffee

+$ ->
+    $('form').submit ->
+        form = $(this).serializeArray()
+        if form[0].value is "2011" and form[1].value is "two" and form[2].value is "Hawthorn" and form[3].value.toUpperCase() is "HIT2316"
+            document.location = 'booklist_hit2316.php'
+        else
+            document.location = 'booklist_404.php'
+        return false

site/booklists.shpaml

 {{py: global left_insert; left_insert = {} }}
 {{def title}}Booklists{{enddef}}
 {{def stylesheet}}booklists{{enddef}}
+{{def script}}booklists{{enddef}}
 ul.breadcrumb
     li
         >
     td.number
         text-align: right
 
+div.error
+    background-color: #ebb
+    padding: 10px
+    +border-radius(0.5em)
+    margin-bottom: 1em
+
 form.block
     display: block
     background-color: #e7dfd1
     color: #663333
-    padding: 10px 10px
+    padding: 10px
     margin: 0 auto 3em
     +border-radius(0.5em)
     input[type="text"]