diff --git a/Handler/Barcode.hs b/Handler/Barcode.hs index 460419f..47d928a 100644 --- a/Handler/Barcode.hs +++ b/Handler/Barcode.hs @@ -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 diff --git a/config/routes b/config/routes index 0a6fa2e..4fa5645 100644 --- a/config/routes +++ b/config/routes @@ -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 diff --git a/static/js/barcode.js b/static/js/barcode.js index d7a533f..c73aff3 100644 --- a/static/js/barcode.js +++ b/static/js/barcode.js @@ -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() diff --git a/templates/home.hamlet b/templates/home.hamlet index 621dc28..d08643b 100644 --- a/templates/home.hamlet +++ b/templates/home.hamlet @@ -23,3 +23,6 @@ $forall (Entity uId user) <- users

_{MsgReactivateOldUser} + +

+ diff --git a/templates/select.hamlet b/templates/select.hamlet index 073d285..0779342 100644 --- a/templates/select.hamlet +++ b/templates/select.hamlet @@ -26,4 +26,5 @@ $forall (Entity bId bev) <- beverages

#{beverageIdent bev} - + +