mail4one/jsdev/index.html

137 lines
4.7 KiB
HTML
Raw Normal View History

2023-07-02 23:48:04 -04:00
<!doctype html>
<html>
<head>
<title>Mail4one Web config</title>
2023-07-03 17:52:28 -04:00
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
2023-07-02 23:48:04 -04:00
<script type="application/json" id="m41config">
{
"matches": [
{
"name": "mydomain",
"addr_rexs": [
".*@mydomain.com",
".*@m.mydomain.com"
]
},
{
"name": "personal",
"addrs": [
"first.last@mydomain.com",
"secret.name@mydomain.com"
]
}
],
"boxes": [
{
"name": "spam",
"rules": [
{
"match_name": "mydomain",
"negate": true,
"stop_check": true
}
]
},
{
"name": "important",
"rules": [
{
"match_name": "personal"
}
]
},
{
"name": "all",
"rules": [
{
"match_name": "default_match_all"
}
]
}
],
"users": [
{
"username": "mymobile",
"password_hash": "AFTY5EVN7AX47ZL7UMH3BETYWFBTAV3XHR73CEFAJBPN2NIHPWDZHV2UQSMSPHSQQ2A2BFQBNC77VL7F2UKATQNJZGYLCSU6C43UQDAQXWXSWNGAEPGIMG2F3QDKBXL3MRHY6K2BPID64ZR6LABLPVSF",
"mbox": "important"
},
{
"username": "mydesk",
"password_hash": "AFTY5EVN7AX47ZL7UMH3BETYWFBTAV3XHR73CEFAJBPN2NIHPWDZHV2UQSMSPHSQQ2A2BFQBNC77VL7F2UKATQNJZGYLCSU6C43UQDAQXWXSWNGAEPGIMG2F3QDKBXL3MRHY6K2BPID64ZR6LABLPVSF",
"mbox": "all"
}
]
}
</script>
<script type="application/javascript">
2023-07-03 17:52:28 -04:00
var matches_table
var match_row_template
2023-07-02 23:48:04 -04:00
function main() {
matches_table = document.getElementById("web-cfg-matches")
2023-07-03 17:52:28 -04:00
match_row_template = document.getElementById("web-cfg-matches-row")
const config = JSON.parse(document.getElementById('m41config').text);
matches_table = document.getElementById("web-cfg-matches")
2023-07-02 23:48:04 -04:00
for (match of config["matches"]) {
2023-07-03 17:52:28 -04:00
let vals = []
let matchType = ""
const {
"name": match_name,
"addrs" : addrs,
"addr_rexs" : addr_rexs,
} = match
2023-07-02 23:48:04 -04:00
2023-07-03 17:52:28 -04:00
if (addrs != undefined) {
vals = addrs
2023-07-02 23:48:04 -04:00
matchType = "addrs"
2023-07-03 17:52:28 -04:00
} else {
vals = addr_rexs
matchType = "addr_rexs"
2023-07-02 23:48:04 -04:00
}
2023-07-03 17:52:28 -04:00
addMatchRow()
const rows = matches_table.tBodies[0].rows
const lrow = rows.item(rows.length -1 )
const [ nameCell, typeCell, valCell ] = lrow.cells
nameCell.innerText = match_name
typeCell.firstElementChild.value = matchType
valCell.firstElementChild.value = vals.join("\n")
2023-07-02 23:48:04 -04:00
}
}
function addMatchRow() {
2023-07-03 17:52:28 -04:00
row_copy = match_row_template.content.cloneNode(true)
2023-07-02 23:48:04 -04:00
tb = matches_table.tBodies[0]
tb.appendChild(row_copy)
}
</script>
</head>
<body onload="main()">
<template id="web-cfg-matches-row">
<tr>
2023-07-03 17:52:28 -04:00
<td contentEditable="true" >Name</td>
<td>
<select>
<option value="addrs">List of addresses</option>
<option value="addr_rexs">List of regexes for addresses</option>
</select>
</td>
<td>
<textarea></textarea>
</td>
2023-07-02 23:48:04 -04:00
</tr>
</template>
<h1>Mail4one Web config</h1>
<table id="web-cfg-matches">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Values</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<button onClick="addMatchRow()">Add Match</button>
</body>
</html>