forked from cadar/lithium
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Two new apps, counter and calculator
- Loading branch information
cadar
committed
Apr 20, 2009
1 parent
3687666
commit a9cceae
Showing
7 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(define-module web_calc | ||
(export all)) | ||
|
||
(include-file "lfeweb/wf.lfe") | ||
|
||
(defun main () (make-template file '"./wwwroot/template.html")) | ||
|
||
(defun title () '"Web calculator") | ||
|
||
(defun body () | ||
(list | ||
(make-textbox id 'number1 text '"") | ||
(make-br) | ||
(make-textbox id 'number2 text '"") | ||
(make-br) | ||
(make-button id 'add text '"+" postback 'add_button) | ||
(make-button text '"c" postback 'clear_button) | ||
(make-panel id 'res1) | ||
(make-hr) | ||
(make-link url '"viewsource?module=web_calc" text '"source"))) | ||
|
||
(defun event | ||
(('add_button) | ||
(let* ((s1 (: wf q 'number1)) | ||
(s2 (: wf q 'number2)) | ||
(n1 (list_to_integer (: lists flatten s1))) | ||
(n2 (list_to_integer (: lists flatten s2))) | ||
(sum1 (+ n1 n2))) | ||
(: wf update 'res1 (integer_to_list sum1))) | ||
'ok) | ||
(('clear_button) | ||
(: wf wire '"obj('number1').value=''; obj('number2').value='';") 'ok) | ||
((all) (: wf flash (: wf f '"no match, ~p~n" (list all))) 'ok)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(define-module web_counter | ||
(export all)) | ||
|
||
(include-file "lfeweb/wf.lfe") | ||
|
||
(defun main () (make-template file '"./wwwroot/template.html")) | ||
|
||
(defun title () '"Counter") | ||
|
||
(defun body () | ||
(list | ||
(make-panel id 'counter_and_hvalue body (list '"0" | ||
(make-hidden id 'value1 text '"0"))) | ||
(make-br) | ||
(make-button text '"++" postback (tuple 'inc1 1)) | ||
(make-button text '"--" postback (tuple 'inc1 -1)) | ||
(make-hr) | ||
(make-link url '"viewsource?module=web_counter" text '"source"))) | ||
|
||
(defun event | ||
(((tuple 'inc1 d)) (let ((next_value (integer_to_list (+ d (list_to_integer (hd (: wf q 'value1))))))) | ||
(: wf update 'counter_and_hvalue | ||
(make-panel body (list next_value | ||
(make-hidden id 'value1 text next_value))))) | ||
'ok) | ||
((all) (: wf flash (: wf f '"no match, ~p~n" (list all))) | ||
'ok)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(define-module web_piki | ||
(export all)) | ||
|
||
(include-file "lfeweb/wf.lfe") | ||
|
||
(defun main () (make-template file '"./wwwroot/template.html")) | ||
|
||
(defun title () '"Piki") | ||
|
||
(defun body () | ||
(list | ||
|
||
(make-p body '"Text") | ||
(make-textarea id 'area1 text '"non"))) | ||
|
||
(defun event | ||
(('checkbox_clicked) (: wf flash (list '"Clicked, " (: wf q 'check1))) 'ok) | ||
(('box1) (: wf flash (list '"box1 is " (: wf q 'box1))) 'ok) | ||
(('save) (: wf flash (list (: wf q 'inbox1) | ||
'" Saved " | ||
(: wf q 'area1))) 'ok) | ||
(('clear) (: wf wire '"obj('area1').value=''") 'ok) | ||
((all) (: wf flash (: wf f '"no match, ~p~n" (list all))) 'ok)) | ||
|
||
(defun inplace_textbox_event (tag value) | ||
(: io format '"~s~n" (list value)) | ||
value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters