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.
222 lines
7.0 KiB
JavaScript
222 lines
7.0 KiB
JavaScript
var hint,
|
|
hintAncor = null,
|
|
hintData = null,
|
|
hintX = -1,
|
|
hintY = -1;
|
|
|
|
document.on("ready", function() {
|
|
document.append(<popup id="hint"></popup>);
|
|
hint = $("#hint");
|
|
});
|
|
|
|
function prepareHint() {
|
|
function checkField(field) {
|
|
return field != "" ? <b>{field}</b> : {_("Unknown")}>;
|
|
}
|
|
|
|
if (typeof hintData === "string") hintData = CommonNative.GetContactData(hintData);
|
|
|
|
if (hintData.kind == NODE_GROUP && cldata) {
|
|
var total = cldata.getTotalGroupCount(hintData.group);
|
|
var onoffline = [];
|
|
if (CommonNative.IsOnline()) {
|
|
var online = cldata.getGroupCount(hintData.group, 0);
|
|
var offline = cldata.getGroupCount(hintData.group, 1) + cldata.getGroupCount(hintData.group, 4);
|
|
var unknown = cldata.getGroupCount(hintData.group, 2) + cldata.getGroupCount(hintData.group, 3);
|
|
onoffline.push(<div key="hintonline">{_("Online")}: <b>{online}</b></div>);
|
|
onoffline.push(<div key="hintoffline">{_("Offline")}: <b>{offline}</b></div>);
|
|
onoffline.push(<div key="hintunknown">{_("Unknown")}: <b>{unknown}</b></div>);
|
|
}
|
|
|
|
hint.patch(<popup id="hint">
|
|
<div key="hinttotal">{_("Total")}: <b>{total}</b></div>
|
|
{onoffline}
|
|
</popup>);
|
|
return;
|
|
}
|
|
|
|
if (hintData.kind != NODE_CONTACT) return;
|
|
|
|
var texts = {
|
|
hintstatusmsg: "Message",
|
|
hintidle: "Idle time",
|
|
hintimportant: "Important",
|
|
hintofficial: "Official contact",
|
|
hintbot: "Bot contact",
|
|
hintbirth: "Birthday",
|
|
hintgroup: "Group",
|
|
hintnoclient: "Client was closed",
|
|
hintclientdesc: "Client",
|
|
hintclientonline: "Online since",
|
|
hintclientoffline: "Last time seen online",
|
|
hintignored: "Being ignored",
|
|
hintauth: "Authorization required",
|
|
hintstatus: "Status",
|
|
hintxstatus: "XStatus",
|
|
hintnick: "Nick",
|
|
hintfirst: "First name",
|
|
hintlast: "Last name"
|
|
};
|
|
var ttexts = CommonNative.GetTranslations(texts);
|
|
|
|
var desc = [];
|
|
if (hintData.status.desc != "")
|
|
desc = <div key="hintstatusmsg">{ttexts["hintstatusmsg"]}: <span class="limited"><b>{hintData.status.desc}</b></span></div>;
|
|
|
|
var idle = [];
|
|
var idleTime = CommonNative.GetContactIdle(hintData.uid);
|
|
if (idleTime > 0)
|
|
idle = <div key="hintidle">{ttexts["hintidle"]}: <b>{String.printf("%d:%02d", (idleTime % 3600) / 60, idleTime % 60)}</b></div>;
|
|
|
|
var important = [];
|
|
var importantText = CommonNative.GetContactImportant(hintData.uid, false);
|
|
if (importantText != "")
|
|
important = <div key="hintimportant">{ttexts["hintimportant"]}: <span class="limited"><b>{importantText}</b></span></div>;
|
|
|
|
var importantLocal = [];
|
|
importantText = CommonNative.GetContactImportant(hintData.uid, true);
|
|
if (importantText != "")
|
|
importantLocal = <div key="hintimportantlocal">{ttexts["hintimportant"]}: <span class="limited"><b>{importantText}</b></span></div>;
|
|
|
|
var official = [];
|
|
if (hintData.status.official)
|
|
official = <div key="hintofficial"><b>{ttexts["hintofficial"]}</b></div>;
|
|
|
|
var bot = [];
|
|
if (hintData.status.bot)
|
|
bot = <div key="hintbot"><b>{ttexts["hintbot"]}</b></div>;
|
|
|
|
var birth = [];
|
|
if (hintData.birthLocal != '')
|
|
birth = <div key="hintbirth">{ttexts["hintbirth"]}: <b>{hintData.birthLocal}</b></div>;
|
|
// else if (hintData.birth != '')
|
|
// birth = |
|
|
|
var group = [];
|
|
var groupName = CommonNative.GetGroupName(hintData.group);
|
|
if (groupName != "")
|
|
group = <div key="hintgroup">{ttexts["hintgroup"]}: <b>{groupName}</b></div>;
|
|
|
|
var noClient = [];
|
|
if (hintData.noClient)
|
|
noClient = <div key="hintnoclient">{ttexts["hintnoclient"]}: <b>{hintData.clientClosed}</b></div>;
|
|
|
|
var client = [];
|
|
if (hintData.status.code != 1 && hintData.status.code != 2) { // is online
|
|
if (hintData.clientDesc != "")
|
|
client.push(<div key="hintclientdesc">{ttexts["hintclientdesc"]}: <b>{hintData.clientDesc}</b></div>);
|
|
if (hintData.onlineSince != "")
|
|
client.push(<div key="hintclientonline">{ttexts["hintclientonline"]}: <b>{hintData.onlineSince}</b></div>);
|
|
} else {
|
|
if (hintData.lastTimeSeenOnline != "")
|
|
client.push(<div key="hintclientoffline">{ttexts["hintclientoffline"]}: <b>{hintData.lastTimeSeenOnline}</b></div>);
|
|
}
|
|
|
|
var ignored = [];
|
|
var isIgnored = CommonNative.GetContactIgnored(hintData.uid);
|
|
if (isIgnored)
|
|
ignored = <div key="hintignored"><b>{ttexts["hintignored"]}</b></div>;
|
|
|
|
var needAuth = [];
|
|
if (hintData.needAuth)
|
|
needAuth = <div key="hintauth"><b>{ttexts["hintauth"]}</b></div>;
|
|
|
|
var avatar = [];
|
|
if (View.share.commonSettings.supportAvatars && View.share.commonSettings.avatarShowInHint && hintData.hasAvatar)
|
|
avatar = <div key="hintavatar" class="hintheader2"><img src={"miniavatar:" + hintData.uid} /></div>;
|
|
|
|
var xstatus = [];
|
|
var xstatustext = [];
|
|
if (hintData.xstatus.status != "") {
|
|
xstatus = <span key="xstatus" class="xstatus">{hintData.xstatus.status}</span>;
|
|
xstatustext = <div key="hintxstatus">{ttexts["hintxstatus"]}: <b>{hintData.xstatus.text}</b></div>
|
|
}
|
|
|
|
hint.patch(<popup id="hint">
|
|
<div class="hintheader">
|
|
<div class="hintheader1">
|
|
<div><div id="hinticon"></div>{xstatus}<span>UIN </span><span key="hintuin"><b>{hintData.uid2show}</b></span></div>
|
|
<div key="hintstatus">{ttexts["hintstatus"]}: <b>{hintData.status.name}</b></div>
|
|
{xstatustext}
|
|
</div>
|
|
{avatar}
|
|
</div>
|
|
{desc}
|
|
{idle}
|
|
<hr/>
|
|
{important}
|
|
{importantLocal}
|
|
{official}
|
|
{bot}
|
|
<div key="hintnick">{ttexts["hintnick"]}: {checkField(hintData.nick)}</div>
|
|
<div key="hintfirst">{ttexts["hintfirst"]}: {checkField(hintData.first)}</div>
|
|
<div key="hintlast">{ttexts["hintlast"]}: {checkField(hintData.last)}</div>
|
|
{birth}
|
|
{group}
|
|
{noClient}
|
|
{client}
|
|
{ignored}
|
|
{needAuth}
|
|
</popup>);
|
|
hint.$("#hinticon").applySprite(hintData.status.statusimg);
|
|
hint.$("#hinticon").requestPaint();
|
|
}
|
|
|
|
function showHintFunc() {
|
|
if (!hintAncor) hintAncor = window.hintAncor;
|
|
if (!hintData) hintData = window.hintData;
|
|
if (!hintX) hintX = window.hintX;
|
|
if (!hintY) hintY = window.hintY;
|
|
|
|
if (!hintAncor || !hintAncor.tag || document.state.ownspopup) return;
|
|
if (view.uniqueid != "main") { // check for menu in main
|
|
var main = findWindow("main");
|
|
if (main && main.document.state.ownspopup) return;
|
|
}
|
|
|
|
var gap = 0;
|
|
if (hintX == -1 && hintY == -1) {
|
|
var [hintX, hintY] = view.box("position", "cursor");
|
|
gap = 10dip.valueOf();
|
|
}
|
|
|
|
prepareHint();
|
|
|
|
var pos = 7;
|
|
if (hintData.kind == NODE_CONTACT) {
|
|
var [pos, hintX, hintY] = getPopupPosition(hintX, hintY, null, gap, gap);
|
|
} else {
|
|
hintX += gap;
|
|
hintY += gap;
|
|
}
|
|
|
|
hintAncor.popup(hint, {
|
|
//anchorAt: 7,
|
|
popupAt: pos,
|
|
x: hintX,
|
|
y: hintY
|
|
});
|
|
}
|
|
|
|
function showHint(ancor, data, x = -1, y = -1) {
|
|
if (!hint) return;
|
|
document.timer(0, hideHint);
|
|
var wasPresent = hint.state.popup;
|
|
hideHint();
|
|
hintAncor = ancor;
|
|
hintData = data;
|
|
hintX = x;
|
|
hintY = y;
|
|
var delay = wasPresent ? 100 : 1000;
|
|
document.timer(delay, showHintFunc);
|
|
}
|
|
|
|
function hideHint() {
|
|
document.timer(0, showHintFunc);
|
|
hintX = -1;
|
|
hintY = -1;
|
|
if (hint) {
|
|
hint.state.popup = false;
|
|
hint.requestPaint();
|
|
}
|
|
} |