add all event from ocaml
This commit is contained in:
parent
01e62889e2
commit
ad460ee549
8 changed files with 52 additions and 15 deletions
|
|
@ -225,12 +225,9 @@ let parse_image image =
|
||||||
(* make up random name if no name was given *)
|
(* make up random name if no name was given *)
|
||||||
Uuidm.to_string (Uuidm.v4_gen random_state ())
|
Uuidm.to_string (Uuidm.v4_gen random_state ())
|
||||||
in
|
in
|
||||||
if not (is_valid_image content) then
|
if not (is_valid_image content) then Error "invalid image"
|
||||||
Error "invalid image"
|
else if String.length alt > 1000 then Error "Image description too long"
|
||||||
else if String.length alt > 1000 then
|
else Ok (Some (name, content, alt))
|
||||||
Error "Image description too long"
|
|
||||||
else
|
|
||||||
Ok (Some (name, content, alt))
|
|
||||||
|
|
||||||
(*TODO switch to markdown !*)
|
(*TODO switch to markdown !*)
|
||||||
(* insert html into the comment, and keep tracks of citations :
|
(* insert html into the comment, and keep tracks of citations :
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ let f request =
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<br />
|
<br />
|
||||||
<button class="btn btn-primary" onclick="geolocalize()">Geolocalize me</button>
|
<button class="btn btn-primary" id="geolocalize">Geolocalize me</button>
|
||||||
% if Option.is_some @@ Dream.session "nick" request then begin
|
% if Option.is_some @@ Dream.session "nick" request then begin
|
||||||
<a class="btn btn-primary" href="/babillard/new_thread">New Thread</a>
|
<a class="btn btn-primary" href="/babillard/new_thread">New Thread</a>
|
||||||
% end;
|
% end;
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,26 @@ blockquote.blockquote {
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quoteLink {
|
||||||
|
background-color: #FCE4EC;
|
||||||
|
padding: 2px;
|
||||||
|
text-align: center;
|
||||||
|
color: #5a5a5a;
|
||||||
|
font-size: 10px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 2px solid DodgerBlue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quoteLink:focus {
|
||||||
|
background-color: #FCE4EC;
|
||||||
|
padding: 2px;
|
||||||
|
text-align: center;
|
||||||
|
color: #5a5a5a;
|
||||||
|
font-size: 10px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 2px solid DodgerBlue;
|
||||||
|
}
|
||||||
|
|
||||||
.postForm {
|
.postForm {
|
||||||
background-color: #FCE4EC;
|
background-color: #FCE4EC;
|
||||||
margin: 5px 5px 5px 5px;
|
margin: 5px 5px 5px 5px;
|
||||||
|
|
|
||||||
|
|
@ -101,12 +101,16 @@ module Geolocalize = struct
|
||||||
in
|
in
|
||||||
ignore @@ Jv.call Leaflet.map "setView" [| latlng; Jv.of_int 13 |]
|
ignore @@ Jv.call Leaflet.map "setView" [| latlng; Jv.of_int 13 |]
|
||||||
|
|
||||||
let geolocalize () =
|
let geolocalize _ =
|
||||||
log "geolocalize@.";
|
log "geolocalize@.";
|
||||||
let l = Brr_io.Geolocation.of_navigator Brr.G.navigator in
|
let l = Brr_io.Geolocation.of_navigator Brr.G.navigator in
|
||||||
ignore @@ Fut.await (Brr_io.Geolocation.get l) update_location
|
ignore @@ Fut.await (Brr_io.Geolocation.get l) update_location
|
||||||
|
|
||||||
let () = Jv.set Jv.global "geolocalize" (Jv.repr geolocalize)
|
let () =
|
||||||
|
let button = Jv.get Jv.global "geolocalize" in
|
||||||
|
ignore
|
||||||
|
@@ Jv.call button "addEventListener"
|
||||||
|
[| Jv.of_string "click"; Jv.repr geolocalize |]
|
||||||
end
|
end
|
||||||
|
|
||||||
module Marker = struct
|
module Marker = struct
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ let log = Format.printf
|
||||||
|
|
||||||
(* called by clicking post_id *)
|
(* called by clicking post_id *)
|
||||||
(* insert id into reply form *)
|
(* insert id into reply form *)
|
||||||
let insert_quote post_id =
|
let insert_quote post_id _event =
|
||||||
log "quote@.";
|
log "quote@.";
|
||||||
Option.iter
|
Option.iter
|
||||||
(fun comment_textarea ->
|
(fun comment_textarea ->
|
||||||
|
|
@ -15,7 +15,23 @@ let insert_quote post_id =
|
||||||
Jv.(find global "replyComment");
|
Jv.(find global "replyComment");
|
||||||
Jv.undefined
|
Jv.undefined
|
||||||
|
|
||||||
let () = Jv.set Jv.global "insert_quote" (Jv.repr insert_quote)
|
let () =
|
||||||
|
log "add inser_quote event on post links@.";
|
||||||
|
let document = Jv.get Jv.global "document" in
|
||||||
|
let quote_links =
|
||||||
|
Jv.to_jv_list
|
||||||
|
@@ Jv.call document "getElementsByClassName" [| Jv.of_string "quoteLink" |]
|
||||||
|
in
|
||||||
|
log "quote_links leng %d@." (List.length quote_links);
|
||||||
|
let add_click quote_link =
|
||||||
|
let post_id =
|
||||||
|
Jv.call quote_link "getAttribute" [| Jv.of_string "data-id" |]
|
||||||
|
in
|
||||||
|
ignore
|
||||||
|
@@ Jv.call quote_link "addEventListener"
|
||||||
|
[| Jv.of_string "click"; Jv.repr (insert_quote post_id) |]
|
||||||
|
in
|
||||||
|
List.iter add_click quote_links
|
||||||
|
|
||||||
(* make image description field visible when a file is selected*)
|
(* make image description field visible when a file is selected*)
|
||||||
let make_visible el _event =
|
let make_visible el _event =
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ let render_time date_span =
|
||||||
in
|
in
|
||||||
ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date)
|
ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date)
|
||||||
|
|
||||||
let make_pretty _ =
|
let make_pretty _event =
|
||||||
log "make pretty@.";
|
log "make pretty@.";
|
||||||
let document = Jv.get Jv.global "document" in
|
let document = Jv.get Jv.global "document" in
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ let f request =
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<br />
|
<br />
|
||||||
<button class="btn btn-primary" onclick="geolocalize()">Geolocalize me</button>
|
<button class="btn btn-primary" id="geolocalize">Geolocalize me</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6" id="newthread-form">
|
<div class="col-md-6" id="newthread-form">
|
||||||
<div class="postForm">
|
<div class="postForm">
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,8 @@ let view_post ?is_thread_preview post_id =
|
||||||
Format.fprintf fmt
|
Format.fprintf fmt
|
||||||
{|
|
{|
|
||||||
<span class=postNo>
|
<span class=postNo>
|
||||||
<a href="#%s" title="Link to this post">#</a>
|
<a href="#%s" title="Link to this post" class="quote">#</a>
|
||||||
<a href="javascript:insert_quote('%s')" class="quoteLink" title="Reply to this post">%s</a>
|
<button data-id="%s" class="quoteLink" title="Reply to this post">%s</button>
|
||||||
</span>
|
</span>
|
||||||
%a
|
%a
|
||||||
|}
|
|}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue