mail4one/jsdev/index.html

137 lines
4.7 KiB
HTML

<!doctype html>
<html>
<head>
<title>Mail4one Web config</title>
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<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">
var matches_table
var match_row_template
function main() {
matches_table = document.getElementById("web-cfg-matches")
match_row_template = document.getElementById("web-cfg-matches-row")
const config = JSON.parse(document.getElementById('m41config').text);
matches_table = document.getElementById("web-cfg-matches")
for (match of config["matches"]) {
let vals = []
let matchType = ""
const {
"name": match_name,
"addrs" : addrs,
"addr_rexs" : addr_rexs,
} = match
if (addrs != undefined) {
vals = addrs
matchType = "addrs"
} else {
vals = addr_rexs
matchType = "addr_rexs"
}
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")
}
}
function addMatchRow() {
row_copy = match_row_template.content.cloneNode(true)
tb = matches_table.tBodies[0]
tb.appendChild(row_copy)
}
</script>
</head>
<body onload="main()">
<template id="web-cfg-matches-row">
<tr>
<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>
</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>