up-css:
@scp roles.css lahar.helm.cs.unibo.it:/projects/helm/public_html/lambdadelta/css/
-.PHONY: test up-css
+up-js:
+ @scp roles.js lahar.helm.cs.unibo.it:/projects/helm/public_html/lambdadelta/js/
+
+.PHONY: test up-css up-js
.count {
}
+.filter {
+}
+
+.hidden {
+ display: none;
+}
+
.selected {
border: 1pt solid;
}
--- /dev/null
+function filter(ptr) {
+ var query = document.getElementById('f.'+ptr).value;
+ var cl = document.getElementsByName(ptr);
+ for (i=0;i < cl.length; i++) {
+ if (cl[i].getAttribute('key').search(query) >= 0) {
+ cl[i].classList.remove('hidden')
+ } else {
+ cl[i].classList.add('hidden')
+ }
+ }
+}
let visit_r p r =
before r.ET.rx (r.ET.ro=[]) (r.ET.rn=[]);
if r.ET.rx then begin
- EU.list_visit before_t each_t visit_tw after_t EU.oobj_selected EU.string_of_oobj (1::p) r.ET.ro;
- EU.list_visit before_w each_w visit_tw after_w EU.nobj_selected EU.string_of_nobj (2::p) r.ET.rn
+ EU.list_visit before_t each_t visit_tw after_t EU.oobj_selected EU.key_of_oobj EU.string_of_oobj (1::p) r.ET.ro;
+ EU.list_visit before_w each_w visit_tw after_w EU.nobj_selected EU.key_of_nobj EU.string_of_nobj (2::p) r.ET.rn
end;
after r.ET.rx
in
- EU.list_visit before_r each_r visit_r after_r EU.robj_selected EU.string_of_robj [0] st.ET.sr;
+ EU.list_visit before_r each_r visit_r after_r EU.robj_selected EU.key_of_robj EU.string_of_robj [0] st.ET.sr;
stage (EU.string_of_stage st.ET.ss) st.ET.sm;
- EU.list_visit before_t each_t visit_tw after_t EU.oobj_selected EU.string_of_oobj [1] st.ET.so;
- EU.list_visit before_w each_w visit_tw after_w EU.nobj_selected EU.string_of_nobj [2] st.ET.sn
+ EU.list_visit before_t each_t visit_tw after_t EU.oobj_selected EU.key_of_oobj EU.string_of_oobj [1] st.ET.so;
+ EU.list_visit before_w each_w visit_tw after_w EU.nobj_selected EU.key_of_nobj EU.string_of_nobj [2] st.ET.sn
val print_status: unit -> unit
val visit_status:
- (string -> string -> unit) -> (string -> bool -> string -> unit) ->
+ (string -> string -> unit) -> RolesTypes.each ->
(bool -> bool -> bool -> unit) -> (bool -> unit) -> (unit -> unit) ->
(string -> bool -> unit) ->
- (string -> string -> unit) -> (string -> bool -> string -> unit) -> (unit -> unit) ->
- (string -> string -> unit) -> (string -> bool -> string -> unit) -> (unit -> unit) ->
+ (string -> string -> unit) -> RolesTypes.each -> (unit -> unit) ->
+ (string -> string -> unit) -> RolesTypes.each -> (unit -> unit) ->
unit
| EWrongRequest of string * string
exception Error of error
+
+type each = string -> string -> bool -> string -> string -> unit
ET.nb = false; ET.nn = name_of_string s;
}
+let key_of_nobj n = string_of_nobj n
+
let nobj_selected n = n.ET.nb
let nobj_select n =
| [ss;sn] -> {ET.ob = false; ET.os = stage_of_string ss; ET.on = name_of_string sn}
| _ -> failwith "oobj_of_string"
+let key_of_oobj o = string_of_name o.ET.on
+
let oobj_selected o = o.ET.ob
let oobj_select o =
let string_of_robj r =
string_of_oobj (oobj_of_robj r)
+let key_of_robj r = key_of_oobj (oobj_of_robj r)
+
let robj_selected r = r.ET.rb
let robj_select r =
let pointer_of_string = stage_of_string
-let list_visit before each visit after selected string_of p l =
+let list_visit before each visit after selected key_of string_of p l =
let ptr p = string_of_pointer (List.rev p) in
let rec aux i = function
| [] -> ()
| x :: tl ->
- each (ptr (i::p)) (selected x) (string_of x);
+ each (ptr p) (ptr (i::p)) (selected x) (key_of x) (string_of x);
visit (i::p) x;
aux (succ i) tl
in
val list_split: ('a -> bool) -> ('a -> unit) -> 'a list -> 'a list * 'a list
val list_visit:
- (string -> string -> unit) -> (string -> bool -> string -> unit) ->
+ (string -> string -> unit) -> RolesTypes.each ->
(RolesTypes.pointer -> 'a -> unit) -> (unit -> unit) ->
- ('a -> bool) -> ('a -> string) -> RolesTypes.pointer -> 'a list -> unit
+ ('a -> bool) -> ('a -> string) -> ('a -> string) -> RolesTypes.pointer -> 'a list -> unit
val string_of_stage: RolesTypes.stage -> string
val nobj_of_string: string -> RolesTypes.nobj
+val key_of_nobj: RolesTypes.nobj -> string
+
val nobj_selected: RolesTypes.nobj -> bool
val nobj_select: RolesTypes.nobj -> unit
val oobj_of_string: string -> RolesTypes.oobj
+val key_of_oobj: RolesTypes.oobj -> string
+
val oobj_selected: RolesTypes.oobj -> bool
val oobj_select: RolesTypes.oobj -> unit
val string_of_robj: RolesTypes.robj -> string
+val key_of_robj: RolesTypes.robj -> string
+
val robj_selected: RolesTypes.robj -> bool
val robj_select: RolesTypes.robj -> unit
let author = "λδ development binary: role manager" in
let description = "λδ development binary: role manager" in
let title = "Role Manager" in
- let css = Filename.concat !EG.base_url "css/roles.css" in
let icon = Filename.concat !EG.base_url "images/crux_32.ico" in
- WS.open_out_html author description title css icon
+ let css = Filename.concat !EG.base_url "css/roles.css" in
+ let js = Filename.concat !EG.base_url "js/roles.js" in
+ WS.open_out_html author description title icon css js
let close_out () =
WS.close_out_html ()
WS.string_of_request "roles" (["system-"^req, arg], "")
let status_out () =
+ let filter p =
+ KP.printf "<input class=\"filter\" type=\"text\" placeholder=\"Filter...\" \
+ onkeyup=\"filter('%s');\" id=\"f.%s\"\n/>" p p
+ in
let button_specs = [
"default", "Refresh";
"save", "Save";
let req = string_of_request "select" p in
KP.printf "<div class=\"roles-head role-color\">\n";
KP.printf "<a href=\"%s\">Roles:</a>\n" req;
- KP.printf "<span class=\"count\">%s</span>\n" count
+ KP.printf "<span class=\"count\">%s</span>\n" count;
+ filter p
in
- let each_role p b str =
+ let each_role n p b k str =
let req_x = string_of_request "expand" p in
let req_s = string_of_request "select" p in
let s = if b then " selected" else "" in
- KP.printf "<div class=\"role role-color%s\">" s;
+ KP.printf "<div class=\"role role-color%s\" name=%S key=%S>" s n k;
KP.printf "<a href=\"%s\">⮞</a> " req_x;
KP.printf "<a href=\"%s\">%s</a>" req_s str
in
KP.printf "<div class=\"atoms-head %s\">\n" c;
KP.printf "<a href=\"%s\">%s:</a>\n" req str;
KP.printf "<span class=\"count\">%s</span>\n" count;
+ filter p;
KP.printf "</div>\n";
KP.printf "<div class=\"atoms\"><table class=\"atoms-table\"><tr>\n"
in
- let each_atom a p b str =
+ let each_atom a n p b k str =
let c = if a then "object-color" else "name-color" in
let s = if b then " selected" else "" in
let req = string_of_request "select" p in
- KP.printf "<td class=\"atom %s%s\"><a href=\"%s\">%s</a></td>\n" c s req str
+ KP.printf "<td class=\"atom %s%s\" name=%S key=%S>\
+ <a href=\"%s\">%s</a></td>\n" c s n k req str
in
let after_atoms () =
KP.printf "</tr></table></div>\n"
KP.printf "<input form=\"%s\" type=\"hidden\" name=\"%s\" value=\"%s\"/>"
form "control-random" (get_random ())
-let open_out_html author description title css icon =
+let open_out_html author description title icon css js =
open_out "application/xhtml+xml" 0;
KP.printf "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
KP.printf "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
KP.printf " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n";
KP.printf " <meta http-equiv=\"Content-Language\" content=\"en-us\"/>\n";
KP.printf " <meta http-equiv=\"Content-Style-Type\" content=\"text/css\"/>\n";
+ KP.printf " <meta http-equiv=\"content-script-type\" content=\"text/javascript\"/>\n";
KP.printf " <meta name=\"author\" content=\"%s\"/>\n" author;
KP.printf " <meta name=\"description\" content=\"%s\"/>\n" description;
KP.printf " <title>%s</title>" title;
- KP.printf " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\"/>\n" css;
KP.printf " <link rel=\"shortcut icon\" href=\"%s\"/>\n" icon;
+ KP.printf " <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\"/>\n" css;
KP.printf "</head>\n";
- KP.printf "<body lang=\"en-US\">\n"
+ KP.printf "<body lang=\"en-US\">\n";
+ KP.printf "<script type=\"text/javascript\" src=\"%s\"/>\n" js
let close_out_html () =
KP.printf "</body>\n";
val control_input: string -> unit
-val open_out_html: string -> string -> string -> string -> string -> unit
+val open_out_html: string -> string -> string -> string -> string -> string -> unit
val close_out_html: unit -> unit