let frontend_resource_types : enum_type list = [
mk_enum_type
~enum_prefix:"Button"
~type_name:"user_buttons"
[
"Logout", FtUserLogin;
"ChangePasswordShowDialog", FtUserSettings;
"ChangePasswordComplete", FtUserSettings;
];
...
]
type user_buttons =
| ButtonLogout
| ButtonChangePasswordShowDialog
| ButtonChangePasswordComplete
let all_user_buttons = [
ButtonLogout;
ButtonChangePasswordShowDialog;
ButtonChangePasswordComplete;
]
let user_button_to_name =
function
| ButtonLogout -> "Logout"
| ButtonChangePasswordShowDialog -> "Change password"
| ButtonChangePasswordComplete -> "Password change complete"
...
let user_button_to_html
?(enabled = true)
?(data_id = "")
?(custom_callback = _blank_custom_callback)
(btn: user_buttons) =
...
let default_template () =
Printf.sprintf {|
<a %s data-class="%s" data-tag="%s" onclick="callbacks.onButtonClick(this, '%s', '%s')"
class="waves-effect waves-light btn %s">%s</a>
|} maybe_id btn_id data_id btn_id data_id disabled_class name
in
match btn with
| ButtonLikeMessage ->
Printf.sprintf {|
<a data-class="%s" data-tag="%s" href="#!" onclick="callbacks.onButtonClick(this, '%s', '%s')" class="%s">%s</a>
|} btn_id data_id btn_id data_id disabled_class name
let on_button_click (dom_elem: Js_of_ocaml.Dom_html.element Js.t) the_btn the_id = (
...
match the_btn with
| ButtonLogout -> (
clear_session_cookies_and_refresh ()
)
str_gen_basic (fun append_string ->
user_button_to_html ButtonLogout |> append_string
)
| name | height | weight | smelliness |
|-------+--------+--------+------------|
| alice | 0.6 | 0.4 | 0.8 |
| bob | 0.8 | 0.6 | 0.5 |
| name | height | weight | speed | accuracy | quick thinking |
|-------+--------+--------+-------+----------+----------------|
| bob | 1.0 | 0.5 | 0.3 | 0.1 | 0.2 |
| roy | 0.8 | 0.9 | 0.1 | 0.7 | 0.4 |
| dylan | 0.8 | 0.4 | 0.9 | 0.9 | 0.8 |
| name | typesafety | conciseness | syntax sugar | performance | memory usage | metaprogramming capabilities | total language power as sum of all |
|-------+------------+-------------+--------------+-------------+--------------+------------------------------+------------------------------------|
| lua | 0.0 | 0.6 | 0.1 | 0.4 | 0.8 | 0.0 | 1.9 |
| ruby | 0.0 | 0.9 | 0.8 | 0.1 | 0.2 | 0.5 | 2.5 |
| lisp | 0.0 | 0.6 | 0.2 | 0.3 | 0.5 | 0.6 | 2.2 |
| rust | 1.0 | 0.3 | 0.4 | 1.0 | 1.0 | 0.7 | 4.4 |
| ocaml | 1.0 | 0.8 | 0.2 | 0.9 | 0.8 | 0.3 | 4.0 |
| go | 0.6 | 0.2 | 0.0 | 0.8 | 0.8 | 0.0 | 2.4 |
| java | 0.5 | 0.2 | 0.2 | 0.7 | 0.0 | 0.0 | 1.6 |
| attribute name | importance |
|------------------------------+------------|
| typesafety | 1.0 |
| conciseness | 0.6 |
| syntax sugar | 0.0 |
| performance | 0.5 |
| memory usage | 0.7 |
| metaprogramming capabilities | 0.0 |
| name | typesafety | conciseness | syntax sugar | performance | memory usage | metaprogramming capabilities | total language power as sum of all |
|-------+------------+-------------+--------------+-------------+--------------+------------------------------+------------------------------------|
| lua | 0.0 * 1.0 | 0.6 * 0.6 | 0.1 * 0.0 | 0.4 * 0.5 | 0.8 * 0.7 | 0.0 * 0.0 | 1.12 |
| ruby | 0.0 * 1.0 | 0.9 * 0.6 | 0.8 * 0.0 | 0.1 * 0.5 | 0.2 * 0.7 | 0.5 * 0.0 | 0.73 |
| lisp | 0.0 * 1.0 | 0.6 * 0.6 | 0.2 * 0.0 | 0.3 * 0.5 | 0.5 * 0.7 | 0.6 * 0.0 | 0.86 |
| rust | 1.0 * 1.0 | 0.3 * 0.6 | 0.4 * 0.0 | 1.0 * 0.5 | 1.0 * 0.7 | 0.7 * 0.0 | 2.38 |
| ocaml | 1.0 * 1.0 | 0.8 * 0.6 | 0.2 * 0.0 | 0.9 * 0.5 | 0.8 * 0.7 | 0.3 * 0.0 | 2.49 |
| go | 0.6 * 1.0 | 0.2 * 0.6 | 0.0 * 0.0 | 0.8 * 0.5 | 0.8 * 0.7 | 0.0 * 0.0 | 1.68 |
| java | 0.5 * 1.0 | 0.2 * 0.6 | 0.2 * 0.0 | 0.7 * 0.5 | 0.0 * 0.7 | 0.0 * 0.0 | 0.97 |