... | ... | @@ -2,11 +2,35 @@ I'll use this to list some of the stuff I've done with pikey. |
|
|
|
|
|
First off, a couple of simple macros.
|
|
|
|
|
|
Probably one of the most useful so far that I've found.
|
|
|
Some of the most useful so far that I've written.
|
|
|
|
|
|
``` common-lisp
|
|
|
(defmacro+ps -> (name function &rest args)
|
|
|
`((@ ,name ,function) ,@args))
|
|
|
|
|
|
(defpsmacro with-document-ready (&rest body)
|
|
|
`(progn
|
|
|
((@ ($ document) ready) (lambda ()
|
|
|
,@body))))
|
|
|
|
|
|
(defpsmacro ajax (&key url (data nil) (on-success nil) (on-error nil))
|
|
|
`(-> $ ajax (create url ,url
|
|
|
method "POST"
|
|
|
data-type "json"
|
|
|
,@(when data `(data ,data))
|
|
|
,@(when on-success `(success ,on-success))
|
|
|
,@(when on-error `(error ,on-error)))))
|
|
|
|
|
|
(defpsmacro and-property (element prop action)
|
|
|
`(when ((@ ,element has-own-property) ,prop)
|
|
|
,action))
|
|
|
|
|
|
;; And my personal favorite...
|
|
|
(defpsmacro map (func list)
|
|
|
`(do ((i 0 (incf i)))
|
|
|
((>= i (@ ,list length)))
|
|
|
(funcall ,func (aref ,list i))))
|
|
|
|
|
|
```
|
|
|
|
|
|
``` common-lisp
|
... | ... | |