Commit 7b81d515 authored by Kristopher Ruzic's avatar Kristopher Ruzic

remove contacts

doesn't refresh contact list on removal, so they will still appear (until refresh)
parent 3e3900e4
......@@ -134,9 +134,9 @@
<script src="gadget_jabberclient.js"></script>\n
\n
<!-- emoji -->\n
<link rel="stylesheet" type="text/css" href="gadget_jabberemoji.css">\n
<script type="text/javascript" src="gadget_jabberemoji_data.js"></script>\n
<script type="text/javascript" src="gadget_jabberemoji.js"></script>\n
<!--<link rel="stylesheet" type="text/css" href="gadget_jabberemoji.css">-->\n
<!--<script type="text/javascript" src="gadget_jabberemoji_data.js"></script>-->\n
<!--<script type="text/javascript" src="gadget_jabberemoji.js"></script>-->\n
\n
\n
\n
......@@ -144,9 +144,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
......@@ -168,6 +168,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
......@@ -226,6 +227,22 @@
</form>\n
</div>\n
</script>\n
\n
<script class="remove-contact-template" type="text/x-handlebars-template">\n
<div class="ui-grid-b ui-responsive">\n
<div class="ui-block-a"></div>\n
<div class="ui-block-b">\n
<form class="remove-contact-form">\n
<div class="ui-field-contain">\n
<label>Contact to remove</label>\n
<input type="text" name="remove" placeholder="Jabber ID" required value="{{contact}}" disabled>\n
</div>\n
<input data-inline="true" type="submit" value="Remove" data-theme="b">\n
</form>\n
</div>\n
<div class="ui-block-c"></div>\n
</div>\n
</script>\n
\n
<script class="reset-password-template" type="text/x-handlebars-template">\n
<div class="ui-grid-b ui-responsive">\n
......@@ -427,7 +444,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58531.43538.31607</string> </value>
<value> <string>945.62493.12341.2286</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -445,7 +462,7 @@
</tuple>
<state>
<tuple>
<float>1442849581.82</float>
<float>1443087193.8</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -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
......@@ -342,9 +343,11 @@
for (key2 in contact_dict) {\n
parameter.contact.push({\n
jid: key2,\n
list_id: key2.split("@")[0],\n
url: result_list[i],\n
new_message: !contact_dict[key2].read,\n
status: !contact_dict[key2].offline\n
status: !contact_dict[key2].offline,\n
remove_url: result_list[i].replace("dialog", "remove")\n
});\n
i += 1;\n
}\n
......@@ -361,7 +364,7 @@
$(gadget.props.element).trigger("create");\n
});\n
}\n
\n
\n
function updateConversation(gadget, jid, text, is_incoming) {\n
initializeContact(gadget, jid);\n
\n
......@@ -451,6 +454,53 @@
$(gadget.props.element).trigger("create");\n
});\n
}\n
\n
function renderRemovePage(gadget, connection_gadget) {\n
var contact_url, jid;\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.aq_pleasePublishMyState({page: PAGE_CONTACT});\n
})\n
.push(function (contact) {\n
contact_url = contact;\n
jid = gadget.props.options.jid;\n
gadget.props.header_element.innerHTML = gadget.props.header_template({\n
left_url: contact_url,\n
left_title: "carat-l",\n
title: "Delete Contact"\n
});\n
gadget.props.content_element.innerHTML =\n
gadget.props.remove_contact_template({\n
contact: jid\n
});\n
$(gadget.props.element).trigger("create");\n
\n
gadget.props.content_element.querySelector("input[type=text]")\n
.focus();\n
gadget.props.content_element.querySelector("input[type=text]")\n
.select();\n
return promiseEventListener(\n
gadget.props.content_element.querySelector(\'form.remove-contact-form\'),\n
\'submit\',\n
false\n
);\n
})\n
// XXX need to remove contact from list after removal\n
.push(function (submit_event) {\n
gadget.props.content_element.querySelector("input[type=submit]")\n
.disabled = true;\n
connection_gadget.requestUnsubscribe(\n
submit_event.target[0].value\n
);\n
// unsubscribe and remove do different things, but let\'s do both to make sure\n
return connection_gadget.removeContact(\n
submit_event.target[0].value\n
);\n
})\n
.push(function () {\n
return redirectToDefaultPage(gadget);\n
});\n
}\n
\n
function renderDialogPage(gadget, connection_gadget) {\n
var jid, message_box,\n
......@@ -621,10 +671,6 @@
return redirectToDefaultPage(gadget);\n
});\n
}\n
\n
function renderOptionsPage(gadget, connection_gadget, display_message) {\n
\n
}\n
\n
function renderResetPasswordPage(gadget, connection_gadget, display_message) {\n
var new_password = \'\';\n
......@@ -720,6 +766,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
......@@ -752,7 +801,7 @@
.push(function() {\n
return redirectToDefaultPage(gadget);\n
}, function (error) {\n
var error_text = "Contact List Update Failed. Please login again.";\n
var error_text = " List Update Failed. Please login again.";\n
return renderConnectPage(gadget, error_text);\n
});\n
})\n
......@@ -804,13 +853,13 @@
type = argument_list[2];\n
\n
initializeContact(gadget, from);\n
if ((type === "unavailable") || (type === "unsubscribed")) {\n
if (type === "unavailable") {\n
// Bye dear contact\n
gadget.props.contact_dict[from].offline = true;\n
} else {\n
// Hello dear contact\n
gadget.props.contact_dict[from].offline = false;\n
}\n
} \n
if ((gadget.props.options !== undefined) &&\n
(gadget.props.options.page === PAGE_CONTACT)) {\n
return gadget.getDeclaredGadget(CONNECTION_GADGET_SCOPE)\n
......@@ -893,7 +942,6 @@
gadget = this;\n
\n
gadget.props.options = options;\n
\n
if (options.page === undefined) {\n
result = redirectToDefaultPage(this);\n
} else if (options.page === PAGE_CONNECTION) {\n
......@@ -909,6 +957,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
......@@ -1071,7 +1121,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58365.12330.28757</string> </value>
<value> <string>945.62672.60033.17749</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -1089,7 +1139,7 @@
</tuple>
<state>
<tuple>
<float>1442839765.51</float>
<float>1443097975.82</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -251,15 +251,6 @@
// 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
......@@ -423,10 +414,10 @@
var result = [],\n
type = domElt.getAttribute(\'type\');\n
if(type === "result") {\n
result.push("Contact Delete Success.");\n
result.push("Contact Remove Success.");\n
}\n
else {\n
throw new Error("Contact Delete Failure.");\n
throw new Error("Contact Remove Failure.");\n
}\n
defer.resolve(result);\n
} catch (error) {\n
......@@ -597,7 +588,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>normie</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -611,7 +602,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.42491.2610.14711</string> </value>
<value> <string>945.62671.21661.2525</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -629,7 +620,7 @@
</tuple>
<state>
<tuple>
<float>1441889236.74</float>
<float>1443097880.51</float>
<string>UTC</string>
</tuple>
</state>
......
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