Ur/Web Examples
Check-in [f85bb74c6b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:- make jsMove more concise
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f85bb74c6b45f851e6fddfa2929c618998b299a7
User & Date: beyert 2015-02-23 03:42:22
Context
2015-02-23
05:17
- in jsMove switch back to signal-based instructions check-in: d033bf1632 user: beyert tags: trunk
03:42
- make jsMove more concise check-in: f85bb74c6b user: beyert tags: trunk
01:41
- slight revisions to formatting check-in: 5a1c5eea69 user: beyert tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jsMove/jsMove.ur.

1
2
3
4


5
6
7
8
9
10
11
..
69
70
71
72
73
74
75






76
77
78
79
80
81
82

83
84
85
86
87
88
89
..
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
(* jsMove *)

type point = (int * int)
type point' = (source int * source int)



val minPt : point = (0, 0)
val maxPt : point = (640, 480)
val initPt : point = (20, 20)

val show_list_int : show (list int) =
  let fun joinReverse' (lst: list int) (acc: string) : string = case lst of
................................................................................
      (True, True, True) => "or a mouse click"
    | (True, True, False) => " or a mouse movement"
    | (True, _, _) => ""
    | (False, True, True) => "a " ^ device ^ " click"
    | (False, True, False) => "a " ^ device ^ " movement"
    | _ => "clicking on one of the buttons to reactivate input" end







fun main_touch () : transaction page =
  x <- source (initPt.1: int); y <- source (initPt.2: int);
  i <- source ("": string);
  keyOn <- source (False: bool);
  touchOn <- source (True: bool);
  mouseOn <- source (True: bool);
  clickToMove <- source (False: bool);

  return
    <xml><body onload={
    setMouseEvents (s touchOn) (s mouseOn) (s clickToMove) (x, y) minPt maxPt}>
  <dyn signal={(JsMoveJs.initCanvas minPt maxPt (x, y));
               return <xml></xml>}/>
  <p>Position: <dyn signal={x' <- signal x; y' <- signal y;
                            return <xml>{[show (x', y')]}</xml>}/></p>
................................................................................
  <p>Touchscreen on: <dyn signal={mouseOn <- signal mouseOn;
                                  return <xml>{[mouseOn]}</xml>}/>
  <button value="Toggle Touchscreen"
    onclick={fn _ => mouseOn' <- get mouseOn;
             set mouseOn (not mouseOn')}/></p>
  <p>Touch Click to move: <dyn signal={clickToMove <- signal clickToMove;
                                       return <xml>{[clickToMove]}</xml>}/>
    <button value="Toggle Touch Click"
      onclick={fn _ => clickToMove' <- get clickToMove;
               set clickToMove (not clickToMove');
               setMouseEvents (s touchOn) (s mouseOn) (s clickToMove) (x, y)
                 minPt maxPt}/></p>
      <p><dyn signal={touchOn' <- signal touchOn;
                      keyOn' <- signal keyOn;
                      mouseOn' <- signal mouseOn;
                      clickToMove' <- signal clickToMove;
                      return <xml>
                        {[instructions touchOn' keyOn' mouseOn'
                          clickToMove']}</xml>}/></p></body></xml>

fun main () : transaction page =
  x <- source (initPt.1: int); y <- source (initPt.2: int);
  keys <- source ([]: list int);
  i <- source ("": string);
  keyOn <- source (True: bool);
  touchOn <- source (False: bool);
  mouseOn <- source (True: bool);
  clickToMove <- source (False: bool);

  return
    <xml><body onload={
................................................................................
  <p>Mouse on: <dyn signal={mouseOn' <- signal mouseOn;
                            return <xml>{[mouseOn']}</xml>}/>
  <button value="Toggle Mouse"
    onclick={fn _ => mouseOn' <- get mouseOn;
             set mouseOn (not mouseOn')}/></p>
  <p>Click to move: <dyn signal={clickToMove <- signal clickToMove;
                                 return <xml>{[clickToMove]}</xml>}/>
    <button value="Toggle Click"
      onclick={fn _ => clickToMove' <- get clickToMove;
               set clickToMove (not clickToMove');
               setMouseEvents (s touchOn) (s mouseOn) (s clickToMove) (x, y)
                 minPt maxPt}/></p>
      <p><dyn signal={touchOn' <- signal touchOn;
                      keyOn' <- signal keyOn;
                      mouseOn' <- signal mouseOn;
                      clickToMove' <- signal clickToMove;
                      return <xml>
                        {[instructions touchOn' keyOn' mouseOn'
                          clickToMove']}</xml>}/></p></body></xml>




>
>







 







>
>
>
>
>
>


<




>







 







|
|
|
|
|
<
<
<
<
<
|
|




<







 







|
|
|
|
|
<
<
<
<
<
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93
94
95
96
97
..
98
99
100
101
102
103
104
105
106
107
108
109





110
111
112
113
114
115

116
117
118
119
120
121
122
...
137
138
139
140
141
142
143
144
145
146
147
148





149
150
(* jsMove *)

type point = (int * int)
type point' = (source int * source int)
(* this is supposed to be an immutable source *)
type dyn_signal = source

val minPt : point = (0, 0)
val maxPt : point = (640, 480)
val initPt : point = (20, 20)

val show_list_int : show (list int) =
  let fun joinReverse' (lst: list int) (acc: string) : string = case lst of
................................................................................
      (True, True, True) => "or a mouse click"
    | (True, True, False) => " or a mouse movement"
    | (True, _, _) => ""
    | (False, True, True) => "a " ^ device ^ " click"
    | (False, True, False) => "a " ^ device ^ " movement"
    | _ => "clicking on one of the buttons to reactivate input" end

fun xinstructions (touchOn: dyn_signal bool) (keyOn: dyn_signal bool)
  (mouseOn: dyn_signal bool) (clickMove: dyn_signal bool) : signal xbody =
  touchOn' <- signal touchOn; keyOn' <- signal keyOn;
  mouseOn' <- signal mouseOn; clickMove' <- signal clickMove;
  return <xml>{[instructions touchOn' keyOn' mouseOn' clickMove']}</xml>

fun main_touch () : transaction page =
  x <- source (initPt.1: int); y <- source (initPt.2: int);

  keyOn <- source (False: bool);
  touchOn <- source (True: bool);
  mouseOn <- source (True: bool);
  clickToMove <- source (False: bool);

  return
    <xml><body onload={
    setMouseEvents (s touchOn) (s mouseOn) (s clickToMove) (x, y) minPt maxPt}>
  <dyn signal={(JsMoveJs.initCanvas minPt maxPt (x, y));
               return <xml></xml>}/>
  <p>Position: <dyn signal={x' <- signal x; y' <- signal y;
                            return <xml>{[show (x', y')]}</xml>}/></p>
................................................................................
  <p>Touchscreen on: <dyn signal={mouseOn <- signal mouseOn;
                                  return <xml>{[mouseOn]}</xml>}/>
  <button value="Toggle Touchscreen"
    onclick={fn _ => mouseOn' <- get mouseOn;
             set mouseOn (not mouseOn')}/></p>
  <p>Touch Click to move: <dyn signal={clickToMove <- signal clickToMove;
                                       return <xml>{[clickToMove]}</xml>}/>
     <button value="Toggle Touch Click"
       onclick={fn _ => clickToMove' <- get clickToMove;
                set clickToMove (not clickToMove');
                setMouseEvents (s touchOn) (s mouseOn) (s clickToMove) (x, y)
                  minPt maxPt}/></p>





  <p><dyn signal={xinstructions touchOn keyOn mouseOn clickToMove}/></p>
  </body></xml>

fun main () : transaction page =
  x <- source (initPt.1: int); y <- source (initPt.2: int);
  keys <- source ([]: list int);

  keyOn <- source (True: bool);
  touchOn <- source (False: bool);
  mouseOn <- source (True: bool);
  clickToMove <- source (False: bool);

  return
    <xml><body onload={
................................................................................
  <p>Mouse on: <dyn signal={mouseOn' <- signal mouseOn;
                            return <xml>{[mouseOn']}</xml>}/>
  <button value="Toggle Mouse"
    onclick={fn _ => mouseOn' <- get mouseOn;
             set mouseOn (not mouseOn')}/></p>
  <p>Click to move: <dyn signal={clickToMove <- signal clickToMove;
                                 return <xml>{[clickToMove]}</xml>}/>
  <button value="Toggle Click"
    onclick={fn _ => clickToMove' <- get clickToMove;
             set clickToMove (not clickToMove');
             setMouseEvents (s touchOn) (s mouseOn) (s clickToMove) (x, y)
               minPt maxPt}/></p>





  <p><dyn signal={xinstructions touchOn keyOn mouseOn clickToMove}/></p>
  </body></xml>