void UpdateHeader(string color, string title) { string header = ""; header += "<div style='padding: 3px; background: " + color + "; '>"; header += "<b>" + title + "</b>"; header += "</div>"; StatusBrowser.SafeInvokeScript("SetElement", new String[] { "header", header }); }
public void ShowUser(ulong user, uint project) { CurrentMode = StatusModeType.User; UserID = user; ProjectID = project; string header = ""; string content = ""; // get trust info OpLink link = null, parent = null; if (Core.Trust != null) { link = Core.Trust.GetLink(user, project); if (link != null) { parent = link.GetHigher(false); } } // if loop root if (link != null && link.IsLoopRoot) { content = "<b>Order</b><br>"; content += "<div style='padding-left: 10;'>"; if (link.Downlinks.Count > 0) { foreach (OpLink downlink in link.Downlinks) { string entry = ""; if (downlink.UserID == Core.UserID) { entry += "<b>" + Core.GetName(downlink.UserID) + "</b> <i>trusts</i>"; } else { entry += Core.GetName(downlink.UserID) + " <i>trusts</i>"; } if (downlink.GetHigher(true) == null) { entry = "<font style='color: red;'>" + entry + "</font>"; } content += entry + "<br>"; } content += Core.GetName(link.Downlinks[0].UserID) + "<br>"; } content += "</div>"; UpdateHeader("MediumSlateBlue", "Trust Loop"); StatusBrowser.SafeInvokeScript("SetElement", new String[] { "content", content }); return; } // add icons on right content += "<div style='float: right;'>"; Func <string, string, string> getImgLine = (url, path) => "<a href='http://" + url + "'><img style='margin:2px;' src='" + path + "' border=0></a><br>"; if (UserID != Core.UserID && Core.GetService(ServiceIDs.IM) != null && Core.Locations.ActiveClientCount(UserID) > 0) { content += getImgLine("im", IMImg); } if (UserID != Core.UserID && Core.GetService(ServiceIDs.Mail) != null) { content += getImgLine("mail", MailImg); } content += getImgLine("buddy_who", BuddyWhoImg); if (UserID != Core.UserID && link != null) { OpLink local = Core.Trust.GetLink(Core.UserID, ProjectID); if (local != null && local.Uplink == link) { content += getImgLine("untrust", UntrustImg); } else { content += getImgLine("trust", TrustImg); } } content += "</div>"; // name string username = Core.GetName(user); header = "<a class='header' href='http://rename_user'>" + username + "</a>"; if (link != null) { // trust unconfirmed? if (parent != null && !parent.Confirmed.Contains(link.UserID)) { bool requested = parent.Requests.Any(r => r.KeyID == link.UserID); string msg = requested ? "Trust Requested" : "Trust Denied"; if (parent.UserID == Core.UserID) { msg = "<b><a class='untrusted' href='http://trust_accept'>" + msg + "</a></b>"; } msg = "<span class='untrusted'>" + msg + "</span>"; content += msg + "<br>"; } // title if (parent != null) { string title = parent.Titles.ContainsKey(UserID) ? parent.Titles[UserID] : "None"; if (parent.UserID == Core.UserID) { title = "<a href='http://change_title/" + title + "'>" + title + "</a>"; } content += "<b>Title: </b>" + title + "<br>"; } // projects string projects = ""; foreach (uint id in link.Trust.Links.Keys) { if (id != 0) { projects += "<a href='http://project/" + id.ToString() + "'>" + Core.Trust.GetProjectName(id) + "</a>, "; } } projects = projects.TrimEnd(new char[] { ' ', ',' }); if (projects != "") { content += "<b>Projects: </b>" + projects + "<br>"; } } if (Core.Buddies.IgnoreList.SafeContainsKey(user)) { content += "<span class='untrusted'><b><a class='untrusted' href='http://unignore'>Ignored</a></b></span><br>"; } //Locations: // Home: Online // Office: Away - At Home // Mobile: Online, Local Time 2:30pm // Server: Last Seen 10/2/2007 string aliases = ""; string locations = ""; foreach (ClientInfo info in Core.Locations.GetClients(user)) { string name = Core.Locations.GetLocationName(user, info.ClientID); bool local = Core.Network.Local.Equals(info); if (info.Data.Name != username) { aliases += AddAlias(info.Data.Name); } if (local) { name = "<a href='http://edit_location'>" + name + "</a>"; } locations += "<b>" + name + ": </b>"; string status = "Online"; if (local && Core.User.Settings.Invisible) { status = "Invisible"; } else if (info.Data.Away) { status = "Away - " + info.Data.AwayMessage; } if (local) { locations += "<a href='http://edit_status'>" + status + "</a>"; } else { locations += status; } if (info.Data.GmtOffset != System.TimeZone.CurrentTimeZone.GetUtcOffset(Core.TimeNow).TotalMinutes) { locations += ", Local Time " + Core.TimeNow.ToUniversalTime().AddMinutes(info.Data.GmtOffset).ToString("t"); } locations += "<br>"; } if (locations == "") { content += "<b>Offline</b><br>"; } else { content += "<b>Locations</b><br>"; content += "<div style='padding-left: 10; line-height: normal'>"; content += locations; content += "</div>"; } // add aliases if (Core.Trust != null) { OpTrust trust = Core.Trust.GetTrust(user); if (trust != null && trust.Name != username) { aliases += AddAlias(trust.Name); } } OpBuddy buddy; if (Core.Buddies.BuddyList.SafeTryGetValue(user, out buddy)) { if (buddy.Name != username) // should be equal unless we synced our buddy list with ourselves somewhere else { aliases += AddAlias(buddy.Name); } } if (aliases != "") { content += "<b>Aliases: </b>" + aliases.Trim(',', ' ') + "<br>"; } UpdateHeader("MediumSlateBlue", header); StatusBrowser.SafeInvokeScript("SetElement", new String[] { "content", content }); }
private void UpdateContent(string content) { StatusBrowser.SafeInvokeScript("SetElement", new String[] { "content", content }); }