Finished the WebCit screen for the Global Alias Table.
[citadel] / webcit / static / t / aide / display_aliases.html
1 <?=("head")><?%("COND:LOGGEDIN", 1, 1, 1, "", ="paging")>
2 <div id="banner">
3 <h1><a href="javascript:load_aliases()">&#8635;</a>
4 <?_("Global email aliases")></h1>
5 </div>
6 <div id="content" class="service">
7 <?!("COND:AIDE", 1)><?_("You need to be aide to view this.")><?!("X", 1)>
8 <??("COND:AIDE", 2)>
9
10 <div id="wc_easterbunny77">
11 </div>
12
13 <form method="POST" action="do_generic">
14         <input type="hidden" name="return_to" value="do_template?template=aide_display_menu">
15         <input type="hidden" name="g_cmd" value="conf putsys|global_alias_table">
16         <textarea name="g_input" id="g_input" rows="20" cols="80"  VALUE="" style="display:none;"></textarea>
17         <br><center>
18         <input type="submit" name="ok_button" onClick="javascript:add_alias();" value="<?_("Save")>">
19         <input type="submit" name="cancel_button" value="<?_("Cancel")>"></center>
20 </form>
21
22 <script type="text/javascript">
23
24 load_aliases = async() => {
25         response = await fetch("ajax_servcmd?g_cmd=conf getsys|global_alias_table");
26         data = await(response.text());
27         populate_aliases(data);
28 };
29
30 function delete_alias(rowid) {
31         var row = document.getElementById(rowid);
32         row.parentNode.removeChild(row);
33         repopulate_the_box();
34 }
35
36 function populate_aliases(data) {
37         var a = "<table id=killo9867>";
38         lines = data.split("\n");
39         for (var i=1; i<lines.length && lines[i] != "000"; ++i) {
40                 config_line = lines[i].split("|");
41                 lineid = randomString(10);
42                 a +=    "<tr id=" + lineid + ">" +
43                         "<td><a href=\"javascript:delete_alias('" + lineid + "');\">" +
44                         "<font color=\"#FF0000\">&#10060;</font></a></td>" +
45                         "<td>" + config_line[0] + "</td>" +
46                         "<td>" + config_line[1] + "</td>" +
47                         "</tr>";
48         }
49         a +=    "<tr id=\"newentry\">" +
50                 "<td><a href=\"javascript:add_alias();\">" +
51                 "<font color=\"#FF0000\">&#9989;</font></a></td>" +
52                 "<td><input id=\"newalias1\" name=\"newalias1\" width=\"40\"></td>" +
53                 "<td><input id=\"newalias2\" name=\"newalias2\" width=\"80\"></td>" +
54                 "</tr>";
55         a += "</table>";
56         document.getElementById("wc_easterbunny77").innerHTML = a;
57         repopulate_the_box();
58 }
59
60 function add_alias() {
61         a = document.getElementById("g_input").innerHTML;
62         if (a != "") {
63                 a += "\n";
64         }
65         a += document.getElementById("newentry").cells[1].firstChild.value + "|";
66         a += document.getElementById("newentry").cells[2].firstChild.value;
67         document.getElementById("g_input").innerHTML = a;
68         document.getElementById("newentry").cells[1].firstChild.value = "";
69         document.getElementById("newentry").cells[2].firstChild.value = "";
70         populate_aliases("100 \n" + a);
71         return true;
72 }
73
74 function repopulate_the_box() {
75         newbox = "";
76         t = document.getElementById("killo9867");
77         for (row of t.rows) {
78                 if (    (row.cells[1].innerHTML.trim() != "")
79                         && (row.cells[2].innerHTML.trim() != "")
80                         && (row.id != "newentry")
81                 ) {
82                         if (newbox != "") {
83                                 newbox += "\n";
84                         }
85                         newbox += row.cells[1].innerHTML.trim() + "|" + row.cells[2].innerHTML.trim();
86                 }
87         }
88         document.getElementById("g_input").innerHTML = newbox;
89 }
90
91 load_aliases();
92
93 </script>
94
95
96 <??("X", 2)>
97 </div>
98 </div>
99 <?=("trailing")>