/examples/render-update.lisp

http://github.com/mtravers/wuwei · Lisp · 56 lines · 47 code · 9 blank · 0 comment · 1 complexity · 16cd37f3b177d2342887db6e47f71c49 MD5 · raw file

  1. (in-package :wu)
  2. (publish-code)
  3. (publish :path "/render-update-demo"
  4. :content-type "text/html"
  5. :function 'render-update-demo)
  6. (defun render-update-demo (req ent)
  7. (with-http-response-and-body (req ent)
  8. (html (:head
  9. (javascript-includes "prototype.js" "effects.js" "dragdrop.js")
  10. (css-includes "wuwei.css"))
  11. (:body
  12. (example-header #.(this-pathname))
  13. (:h1 "WuWei render-update demo")
  14. ((:div :id "FOO")
  15. (link-to-remote
  16. "Click me and I will be replaced"
  17. (ajax-continuation ()
  18. (render-update
  19. (:update "FOO" (html (:i (:princ "I have been replaced"))))))))
  20. :hr
  21. ((:div :id "notdragme" :style "background:#FFBBAD; border: 1px solid; margin: 5px; padding: 5x; width: 50px; height: 50px;"))
  22. (link-to-remote "Click me" (ajax-continuation ()
  23. (render-update
  24. (:visual-effect :fade "notdragme"))))
  25. " for a disappearing act"
  26. :hr
  27. (let ((n 1) (acc 1))
  28. (link-to-remote "A hand-cranked factorial engine."
  29. (ajax-continuation (:keep t)
  30. (render-update
  31. (:insert :after "bar" (html ((:div :style "background:#FFFFAD; border 1px solid; margin 5px; padding 5x")
  32. (setq acc (* acc (incf n)))
  33. (:princ (format nil "~A! = ~A" n acc))
  34. )))
  35. ))))
  36. ((:div :id "bar"))
  37. :hr
  38. "Some drag-n-drop"
  39. ((:div :id "dragme" :style "background:#BBFFAD; border: 1px solid; margin: 5px; padding: 5x; width: 100px; height: 50px;")
  40. "Drag me")
  41. ((:div :id "target" :style "background:#BBFAFD; border: 1px solid; margin: 5px; padding: 5x; width: 100px; height: 50px;")
  42. "Drop it here")
  43. (render-scripts
  44. (:draggable "dragme")
  45. (:drop-target "target"
  46. :|onDrop| `(:raw "function (elt) {alert('thanks!');}")))
  47. ))))