barcode submission with hidden forms

This commit is contained in:
Astro 2015-07-21 01:28:05 +02:00
parent fafb1548cb
commit 5b444ce17e
5 changed files with 17 additions and 7 deletions

View file

@ -6,5 +6,8 @@ import qualified Data.Text as T
import Text.Blaze.Internal
import Text.Shakespeare.Text
getBarcodeR :: UserId -> Text -> Handler Html
getBarcodeR uId barcode = undefined
postHomeBarcodeR :: Handler Html
postHomeBarcodeR = return mempty
postSelectBarcodeR :: UserId -> Handler Html
postSelectBarcodeR uId = return mempty

View file

@ -30,4 +30,5 @@
/avatar/#AvatarId/modify ModifyAvatarR GET POST
/avatar/#AvatarId/delete AvatarDeleteR GET
/newavatar NewAvatarR GET POST
/user/#UserId/barcode/#Text BarcodeR GET
/barcode HomeBarcodeR POST
/user/#UserId/barcode SelectBarcodeR POST

View file

@ -11,9 +11,11 @@ function showBarcode(text) {
function barcodeKeyPress(event) {
var key = String.fromCharCode(event.charCode)
if (event.keyCode === 13) {
var uid = document.getElementById('uid').getAttribute('value')
if (uid) {
window.location = "/user/" + encodeURIComponent(uid) + "/barcode/" + encodeURIComponent(barcodeBuf)
var input = document.getElementById('barcodeInput')
if (input) {
input.setAttribute('value', barcodeBuf)
input.parentNode.submit()
return
}
barcodeBuf = ""
event.preventDefault()

View file

@ -23,3 +23,6 @@ $forall (Entity uId user) <- users
<article .article #func>
<a href=@{ReactivateR}>
<p>_{MsgReactivateOldUser}
<form action=@{HomeBarcodeR} method=POST>
<input type=hidden #barcodeInput name=barcode>

View file

@ -26,4 +26,5 @@ $forall (Entity bId bev) <- beverages
<a href=@{BuyR uId bId}>
<p>#{beverageIdent bev}
<input type=hidden id=uid value=#{toPathPiece uId}>
<form action=@{SelectBarcodeR uId} method=POST>
<input type=hidden #barcodeInput name=barcode>