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 *)
|
||||
Uuidm.to_string (Uuidm.v4_gen random_state ())
|
||||
in
|
||||
if not (is_valid_image content) then
|
||||
Error "invalid image"
|
||||
else if String.length alt > 1000 then
|
||||
Error "Image description too long"
|
||||
else
|
||||
Ok (Some (name, content, alt))
|
||||
if not (is_valid_image content) then Error "invalid image"
|
||||
else if String.length alt > 1000 then Error "Image description too long"
|
||||
else Ok (Some (name, content, alt))
|
||||
|
||||
(*TODO switch to markdown !*)
|
||||
(* insert html into the comment, and keep tracks of citations :
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ let f request =
|
|||
<div class="col-md-6">
|
||||
<div id="map"></div>
|
||||
<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
|
||||
<a class="btn btn-primary" href="/babillard/new_thread">New Thread</a>
|
||||
% end;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,26 @@ blockquote.blockquote {
|
|||
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 {
|
||||
background-color: #FCE4EC;
|
||||
margin: 5px 5px 5px 5px;
|
||||
|
|
|
|||
|
|
@ -101,12 +101,16 @@ module Geolocalize = struct
|
|||
in
|
||||
ignore @@ Jv.call Leaflet.map "setView" [| latlng; Jv.of_int 13 |]
|
||||
|
||||
let geolocalize () =
|
||||
let geolocalize _ =
|
||||
log "geolocalize@.";
|
||||
let l = Brr_io.Geolocation.of_navigator Brr.G.navigator in
|
||||
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
|
||||
|
||||
module Marker = struct
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ let log = Format.printf
|
|||
|
||||
(* called by clicking post_id *)
|
||||
(* insert id into reply form *)
|
||||
let insert_quote post_id =
|
||||
let insert_quote post_id _event =
|
||||
log "quote@.";
|
||||
Option.iter
|
||||
(fun comment_textarea ->
|
||||
|
|
@ -15,7 +15,23 @@ let insert_quote post_id =
|
|||
Jv.(find global "replyComment");
|
||||
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*)
|
||||
let make_visible el _event =
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ let render_time date_span =
|
|||
in
|
||||
ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date)
|
||||
|
||||
let make_pretty _ =
|
||||
let make_pretty _event =
|
||||
log "make pretty@.";
|
||||
let document = Jv.get Jv.global "document" in
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ let f request =
|
|||
<div class="col-md-6">
|
||||
<div id="map"></div>
|
||||
<br />
|
||||
<button class="btn btn-primary" onclick="geolocalize()">Geolocalize me</button>
|
||||
<button class="btn btn-primary" id="geolocalize">Geolocalize me</button>
|
||||
</div>
|
||||
<div class="col-md-6" id="newthread-form">
|
||||
<div class="postForm">
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ let view_post ?is_thread_preview post_id =
|
|||
Format.fprintf fmt
|
||||
{|
|
||||
<span class=postNo>
|
||||
<a href="#%s" title="Link to this post">#</a>
|
||||
<a href="javascript:insert_quote('%s')" class="quoteLink" title="Reply to this post">%s</a>
|
||||
<a href="#%s" title="Link to this post" class="quote">#</a>
|
||||
<button data-id="%s" class="quoteLink" title="Reply to this post">%s</button>
|
||||
</span>
|
||||
%a
|
||||
|}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue