Commit 1b4e7a76 authored by Kristopher Ruzic's avatar Kristopher Ruzic

add ability to remove contacts

list isn't updated after removal, and requires a page refresh (and therefore relogin) to reflect changes
parent 4b5c52d4
......@@ -137,9 +137,9 @@
<div class="ui-grid-b ui-responsive">\n
<div class="ui-block-a"></div>\n
<div class="ui-block-b">\n
<ul data-role="listview" data-inset="true">\n
<ul data-role="listview" data-inset="true" data-split-icon="delete" data-split-theme="c">\n
{{#each contact}}\n
<li>\n
<li class="ui-li-has-alt" id="{{list_id}}">\n
{{#if status}}\n
{{#if url}}\n
<a href="{{url}}" class="ui-btn ui-btn-icon-left ui-icon-check">\n
......@@ -161,6 +161,7 @@
{{jid}}\n
{{/if}}\n
{{/if}}\n
<a href="{{remove_url}}" class="ui-btn ui-btn-icon-notext ui-icon-delete ui-btn-c" title="Remove"></a>\n
</li>\n
{{/each}}\n
</ul>\n
......
......@@ -125,6 +125,7 @@
PAGE_HISTORY = "history",\n
PAGE_NEW_CONTACT = "subscribe",\n
PAGE_PASSWORD = "password",\n
PAGE_REMOVE_CONTACT = "remove",\n
DEFAULT_PAGE = PAGE_CONTACT,\n
CONNECTION_GADGET_URL = "./gadget_jabberconnection.html",\n
CONNECTION_GADGET_SCOPE = "connection",\n
......@@ -698,6 +699,9 @@
g.props.header_template = Handlebars.compile(\n
document.querySelector(".header-template").innerHTML\n
);\n
g.props.remove_contact_template = Handlebars.compile(\n
document.querySelector(".remove-contact-template").innerHTML\n
);\n
});\n
})\n
// Configure jIO storage\n
......@@ -887,6 +891,8 @@
method = renderHistoryPage;\n
} else if (options.page === PAGE_PASSWORD) {\n
method = renderResetPasswordPage;\n
} else if (options.page == PAGE_REMOVE_CONTACT) {\n
method = renderRemovePage; \n
} else {\n
throw new Error("not implemented page " + options.page);\n
}\n
......
......@@ -232,7 +232,7 @@
\n
function deferServerDisconnection(gadget) {\n
enqueueDefer(gadget, function () {\n
// Try to auto connection\n
// Try to auto connect\n
if (gadget.props.connection !== undefined) {\n
gadget.props.connection.disconnect();\n
delete gadget.props.connection;\n
......@@ -248,18 +248,9 @@
}\n
\n
enqueueDefer(gadget, function () {\n
// Try to auto connection\n
// Try to auto connect\n
if (gadget.props.server !== undefined) {\n
gadget.props.connection = new Strophe.Connection(gadget.props.server);\n
\n
// gadget.props.connection.rawInput = function (data) {\n
// console.log("RECEIVING SOMETHING");\n
// console.log(data);\n
// };\n
// gadget.props.connection.rawOutput = function (data) {\n
// console.log("SENDING SOMETHING");\n
// console.log(data);\n
// };\n
\n
gadget.props.connection.connect(\n
gadget.props.jid,\n
......@@ -415,6 +406,34 @@
$pres().tree()\n
);\n
})\n
\n
.declareMethod(\'removeContact\', function (jid) {\n
var defer = RSVP.defer();\n
function jsonifyResponse(domElt) {\n
try {\n
var result = [],\n
type = domElt.getAttribute(\'type\');\n
if(type === "result") {\n
result.push("Contact Remove Success.");\n
}\n
else {\n
throw new Error("Contact Remove Failure.");\n
}\n
defer.resolve(result);\n
} catch (error) {\n
defer.reject(error);\n
}\n
}\n
var uid = this.props.jid.split(\'@\')[0];\n
this.props.connection.sendIQ(\n
$iq({type: "set"})\n
.c("query", {xmlns: Strophe.NS.ROSTER})\n
.c("item", {jid: jid, subscription: "remove"}),\n
jsonifyResponse,\n
defer.reject\n
);\n
return defer.promise;\n
})\n
\n
.declareMethod(\'requestSubscribe\', function (jid) {\n
this.props.connection.send(\n
......@@ -601,8 +620,8 @@
</tuple>
<state>
<tuple>
<float>1436191748.38</float>
<string>GMT</string>
<float>1443097880.51</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment