You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
5.1 KiB
HTML
163 lines
5.1 KiB
HTML
<html window-icon="themepicsingle:db">
|
|
<head>
|
|
<include src="common.htm" />
|
|
<style src="contactsdb.css" />
|
|
<script src="libs/dayjs.min.js" />
|
|
<script>
|
|
const VTable = importModule("vlist.mjs").VTable;
|
|
|
|
var contactsDB, data, report,
|
|
main = $("#main"),
|
|
dbmenu = $("#dbmenu"),
|
|
title = view.caption;
|
|
|
|
view.minSize = [400, 120];
|
|
translateWindow("span, checkbox, button");
|
|
|
|
function recordView(record, isCurrent, isSelected) {
|
|
var cls = record.inCL ? " incl" : "";
|
|
return <tr key={record.UID} class={cls} state-current={isCurrent}>
|
|
<td>{record.UID}</td>
|
|
<td>{record.name}</td>
|
|
<td>{record.messages == 0 ? "" : record.messages}</td>
|
|
<td>{record.important}</td>
|
|
<td>{record.lastseen ? dayjs(record.lastseen).format("DD.MM.YYYY HH:mm") : ""}</td>
|
|
<td>{record.bday ? dayjs(record.bday).format("DD.MM.YYYY") : ""}</td>
|
|
<td>{record.days2bday >= 0 && record.days2bday < 1000 ? record.days2bday : ""}</td>
|
|
</tr>;
|
|
}
|
|
|
|
function viewInfoCurrent() {
|
|
if (contactsDB.vtbody.value)
|
|
openViewInfo(contactsDB.vtbody.value.UID, contactsDB.vtbody.value.name);
|
|
}
|
|
|
|
function deleteCurrent() {
|
|
if (contactsDB.vtbody.value)
|
|
if (CommonNative.DeleteContactFromDB(contactsDB.vtbody.value.UID)) {
|
|
data = data.filter((item) => item !== contactsDB.vtbody.value);
|
|
contactsDB.componentUpdate({ recordset: data });
|
|
updateContactCount();
|
|
}
|
|
}
|
|
|
|
function addAll2CL() {
|
|
if (createDialog(
|
|
"question",
|
|
_("Confirm"),
|
|
_("Are you sure you want to add entire DB to contact list?"),
|
|
false, ["mbYes", "mbNo"], "mbNo", "mbNo"
|
|
) === "mbYes") CommonNative.AddAllDB2CL();
|
|
}
|
|
|
|
function updateList() {
|
|
data = CommonNative.GetContactsDB();
|
|
contactsDB.componentUpdate({ recordset: data });
|
|
updateContactCount();
|
|
}
|
|
|
|
function updateContactCount() {
|
|
view.caption = title + " (" + data.length + ")";
|
|
}
|
|
|
|
data = CommonNative.GetContactsDB();
|
|
updateContactCount();
|
|
|
|
main.clear();
|
|
main.append(<VTable class="contacts" recordview={recordView} recordset={data} sortable>
|
|
<columns>
|
|
<th field="UID" as="integer">UIN</th>
|
|
<th field="name">{_("Nickname")}</th>
|
|
<th field="messages" as="integer">{_("History")}</th>
|
|
<th field="important">{_("Important")}</th>
|
|
<th field="lastseen" as="date">{_("Last seen")}</th>
|
|
<th field="bday" as="date">{_("Birthday")}</th>
|
|
<th field="days2bday" as="integer">{_("Days to Bd")}</th>
|
|
</columns>
|
|
</VTable>);
|
|
contactsDB = $(".contacts");
|
|
contactsDB.init();
|
|
contactsDB.vtbody
|
|
.on("dblclick", () => viewInfoCurrent())
|
|
.on("keydown", (e) => {
|
|
if (e.keyCode == Event.VK_DELETE) deleteCurrent();
|
|
else if (e.keyCode == Event.VK_RETURN) viewInfoCurrent();
|
|
}).on("contextmenu", (e) => {
|
|
if (!contactsDB.vtbody.value) return false;
|
|
$("#madd2cl").state.disabled = contactsDB.vtbody.value.inCL;
|
|
e.source = dbmenu;
|
|
return true;
|
|
});
|
|
|
|
renderGroupLists($("#mgrouplist"), true);
|
|
|
|
setMenuListener(dbmenu, function() {
|
|
if (this.parent)
|
|
switch (this.parent.id) {
|
|
case "mgrouplist":
|
|
if (contactsDB.vtbody.value)
|
|
View.share.MainNative.AddContact(contactsDB.vtbody.value.UID, parseInt(this.attr["groupid"]));
|
|
return;
|
|
}
|
|
|
|
if (contactsDB.vtbody.value)
|
|
switch (this.id) {
|
|
case "mviewinfo": viewInfoCurrent(); break;
|
|
case "maddall2cl": addAll2CL(); break;
|
|
case "mopenchat": View.share.MainNative.OpenChatWith(contactsDB.vtbody.value.UID); break;
|
|
case "mdelete": deleteCurrent(); break;
|
|
}
|
|
});
|
|
|
|
$("#refresh").on("click", () => updateList());
|
|
|
|
$("#clean").on("click", () => {
|
|
var removeHist = $("#removehist").value;
|
|
var action = createDialog(
|
|
"question",
|
|
_("Confirm"),
|
|
_("Are you sure you want to delete all contacts that are not in contact list?") +
|
|
(removeHist ? "\n" + _("History with them will be removed too!") : ""),
|
|
false, [
|
|
"mbYes",
|
|
["mbPartial", _("Yes, only with empty history")],
|
|
"mbNo"
|
|
], "mbNo", "mbNo"
|
|
);
|
|
if (action === "mbNo") return;
|
|
report = CommonNative.CleanContactsDB(removeHist, action === "mbPartial");
|
|
$("#report").state.disabled = false;
|
|
updateList();
|
|
});
|
|
|
|
$("#report").on("click", () => {
|
|
openTextWindow("report", _("Report"), report, true);
|
|
});
|
|
|
|
$("#close").on("click", () => view.close());
|
|
|
|
document.on("keydown", (e) => {
|
|
if (e.keyCode == Event.VK_ESCAPE || (e.ctrlKey && e.keyCode == Event.VK_W)) view.close();
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="main">
|
|
<div id="loading"><span>Loading contacts...</span></div>
|
|
</div>
|
|
<checkbox small id="removehist">Delete history together with the contacts</checkbox>
|
|
<div class="buttonPanel">
|
|
<button uwp id="refresh">Refresh</button>
|
|
<button uwp id="clean">Clean</button>
|
|
<button uwp id="report" disabled>View report</button>
|
|
<button uwp right id="close">Close</button>
|
|
</div>
|
|
<menu id="dbmenu" class="context custom">
|
|
<li id="mviewinfo"><div auto pic="info"></div><span>View info</span></li>
|
|
<li id="madd2cl"><div auto pic="add.contact"></div><span>Add to contact list</span><menu id="mgrouplist"></menu></li>
|
|
<li id="maddall2cl"><div auto pic="db"></div><span>Add ALL contacts to the list</span></li>
|
|
<li id="mopenchat"><div auto pic="msg"></div><span>Open chat</span></li>
|
|
<li id="mdelete"><div auto pic="delete"></div><span>Delete</span></li>
|
|
</menu>
|
|
</body>
|
|
</html> |