X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=jappixmini%2Flib.js;h=31302732874ea9c6bf186c4e981442f34ec2cd57;hb=d9330e3b05c71bbd172293fb223271033d3b19f7;hp=ca0130a90aeb96966537e7613371b0d2ca233e5c;hpb=2fef298b3e08bc4a332dc53976ca2e69547ad318;p=friendica-addons.git diff --git a/jappixmini/lib.js b/jappixmini/lib.js index ca0130a9..31302732 100644 --- a/jappixmini/lib.js +++ b/jappixmini/lib.js @@ -1,3 +1,9 @@ +// +// Copyright 2012 "Leberwurscht" +// +// This file is dual-licensed under the MIT license (see MIT.txt) and the AGPL license (see jappix/COPYING). +// + function jappixmini_addon_xor(str1, str2) { if (str1.length != str2.length) throw "not same length"; @@ -34,7 +40,7 @@ function jappixmini_addon_get_client_secret(callback) { var div = document.getElementById("#jappixmini-password-query-div"); if (!div) { - div = $('
Retype your Friendica password for chatting:
'); + div = $('
Retype your Friendica password for chatting:
'); var input = $('') div.append(input); @@ -132,7 +138,7 @@ function jappixmini_manage_roster(contacts, contacts_hash, autoapprove, autosubs if (!name) name = xid; acceptSubscribe(xid, name); - console.log("Accepted "+xid+" for chat."); + console.log("Accepted "+xid+" ("+name+") for chat."); } }); @@ -162,17 +168,21 @@ function jappixmini_manage_roster(contacts, contacts_hash, autoapprove, autosubs // ignore accounts that are not in the list if (contacts[xid]===undefined) return; - // add to Friendica group if necessary + // add to Friendica group or change name if necessary var groups = []; + var group_missing = false; node.find('group').each(function() { var group_text = $(this).text(); if (group_text) groups.push(group_text); }); - if ($.inArray("Friendica", groups)==-1) { + group_missing = true; groups.push("Friendica"); - sendRoster(xid, null, null, groups); - console.log("Added "+xid+" to Friendica group."); + } + + if (group_missing || name!=contacts[xid]) { + sendRoster(xid, null, contacts[xid], groups); + console.log("Added "+xid+" to Friendica group and set name to "+contacts[xid]+"."); } // authorize if necessary @@ -207,7 +217,7 @@ function jappixmini_manage_roster(contacts, contacts_hash, autoapprove, autosubs item.setAttribute('name', contacts[xid]); item.appendChild(iq.buildNode('group', {'xmlns': NS_ROSTER}, "Friendica")); con.send(iq); - console.log("Added "+xid+" to roster."); + console.log("Added "+xid+" ("+contacts[xid]+") to roster."); } setPersistent("jappix-mini", "contacts-hash", contacts_hash); @@ -226,7 +236,7 @@ function jappixmini_addon_subscribe() { sendSubscribe(xid, "subscribe"); } -function jappixmini_addon_start(server, username, proxy, bosh, encrypted, password, nickname, contacts, contacts_hash, autoapprove, autosubscribe) { +function jappixmini_addon_start(server, username, proxy, bosh, encrypted, password, nickname, contacts, contacts_hash, autoapprove, autosubscribe, groupchats) { var handler = function(password){ // check if settings have changed, reinitialize jappix mini if this is the case var settings_identifier = str_sha1(server); @@ -251,6 +261,7 @@ function jappixmini_addon_start(server, username, proxy, bosh, encrypted, passwo HOST_BOSH = bosh; // start jappix mini + MINI_GROUPCHATS = groupchats; MINI_NICKNAME = nickname; LOCK_HOST = "off"; launchMini(true, false, server, username, password);