Commit df83cd35 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 1b4e7a76
......@@ -109,6 +109,594 @@
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
<!doctype html>\n
<html manifest="./gadget_jabberclient.appcache">\n
<head>\n
<meta charset="utf-8">\n
<meta name="viewport" content="width=device-width, initial-scale=1">\n
\n
<title>Simple Jabber Client</title>\n
<link id="favicon" rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAADf8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAERAAAAAAAAEQEAAAAAAAEQARAAAAAAARAAEQAAAAARAAARAAAAABAAAAEQAAAAAAAAABEAAAAAAAAAEQAAAAAAAAABEAAAAAAAAAARAAAAAAAAABEAAAAAAAAAAQAAAAAAAAAAD//wAA//8AAP7/AAD8fwAA+X8AAPM/AADznwAA558AAO/PAAD/5wAA/+cAAP/zAAD/+QAA//kAAP/9AAD//wAA">\n
\n
<link rel="stylesheet" href="jquerymobile.css">\n
\n
\n
<!-- stylesheets for jabberclient -->\n
<link rel="stylesheet" type="text/css" href="gadget_jabberclient.css" />\n
\n
\n
<script src="jquery.js"></script>\n
<script src="jquerymobile.js"></script>\n
<script src="rsvp.js"></script>\n
<script src="renderjs.js"></script>\n
<script src="handlebars.js"></script>\n
<script src="gadget_global.js" ></script>\n
<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
\n
\n
\n
<script class="contact-list-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
<ul data-role="listview" data-inset="true" data-split-icon="delete" data-split-theme="c">\n
{{#each contact}}\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
{{#if new_message}}\n
<span class="ui-li-count">!</span>\n
{{/if}}\n
{{jid}}</a>\n
{{else}}\n
{{jid}}\n
{{/if}}\n
{{else}}\n
{{#if url}}\n
<a href="{{url}}" class="ui-btn ui-btn-icon-left ui-icon-forbidden">\n
{{#if new_message}}\n
<span class="ui-li-count">!</span>\n
{{/if}}\n
{{jid}}</a>\n
{{else}}\n
{{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
</div>\n
<div class="ui-block-c"></div>\n
</div>\n
</script>\n
\n
<script class="new-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="new-contact-form">\n
<div class="ui-field-contain">\n
<label>Jabber ID</label>\n
<input type="text" name="jid" placeholder="Jabber ID" value="" required>\n
</div>\n
<input data-inline="true" type="submit" value="Add" data-theme="b">\n
</form>\n
</div>\n
<div class="ui-block-c"></div>\n
</div>\n
</script>\n
\n
<script class="login-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
<h2>Jabber Client</h2>\n
<form class="login-form">\n
<div class="ui-field-contain">\n
<label>Server URL</label>\n
<input type="text" name="server" placeholder="Server URL" value="https://mail.tiolive.com/chat/http-bind/" required>\n
</div>\n
<div class="ui-field-contain">\n
<label>Jabber ID</label>\n
<input type="text" name="jid" placeholder="Jabber ID" value="" required>\n
</div>\n
<div class="ui-field-contain">\n
<label>Password</label>\n
<input type="password" name="passwd" placeholder="Password" value="" required>\n
</div>\n
<input data-inline="true" type="submit" value="Log In" data-theme="b">\n
</form>\n
<pre style="white-space: pre-wrap;">{{message}}</pre>\n
</div>\n
<div class="ui-block-c"></div>\n
</div>\n
</script>\n
\n
<script class="dialog-template" type="text/x-handlebars-template">\n
<div class="discussion-content"></div>\n
<div data-role="footer" data-position="fixed" data-tap-toggle="false" role="contentinfo" class="group-header ui-footer ui-bar-inherit ui-footer-fixed slideup">\n
<form class="message-form" style="width: 100%; margin-right: 0.6em;">\n
<textarea id="jabber-message" class="ui-input-text ui-shadow-inset ui-body-inherit ui-corner-all ui-textinput-autogrow" style="width: 100%; margin: 0px; resize: none; height: 50px;" placeholder="Write something..."></textarea>\n
</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
<div class="ui-block-a"></div>\n
<div class="ui-block-b">\n
<h2>Reset Password</h2>\n
<form class="reset-password-form">\n
<div class="ui-field-contain">\n
<label>Server URL</label>\n
<input type="text" name="server" placeholder="Server URL" value="tiolive.com" required>\n
</div>\n
<div class="ui-field-contain">\n
<label>New Password</label>\n
<input type="password" name="new_passwd" placeholder="New Password" value="" required>\n
</div>\n
<div class="ui-field-contain">\n
<label>Repeat Password</label>\n
<input type="password" name="repeat_passwd" placeholder="Repeat Password" value="" required>\n
</div>\n
<input data-inline="true" type="submit" value="Submit" data-theme="b">\n
</form>\n
<pre style="white-space: pre-wrap;">{{message}}</pre>\n
</div>\n
<div class="ui-block-c">\n
</div>\n
</div>\n
</script>\n
<script class="message-template" type="text/x-handlebars-template"><li data-theme="{{theme}}" class="{{msg_class}}" style=""><p style="white-space: pre-wrap; word-wrap: break-word; font-size: 14px;">{{{text}}}</p><label style="{{timestamp_style}}" class="{{sender}} {{timestamp_class}}">{{timestamp}}</label></li></script>\n
\n
<script class="history-template" type="text/x-handlebars-template"><pre style="white-space: pre-wrap;">{{text}}</pre></script>\n
\n
<script class="header-template" type="text/x-handlebars-template">\n
{{#if left_url}}\n
<a href="{{left_url}}" class="ui-btn-left ui-btn ui-btn-inline ui-mini ui-corner-all ui-btn-icon-notext ui-icon-{{left_title}}"></a>\n
{{/if}}\n
<h1 class="ui-title">{{title}}</h1>\n
{{#if right_url}}\n
<a href="{{right_url}}" class="ui-btn-right ui-btn ui-btn-inline ui-mini ui-corner-all ui-btn-icon-notext ui-icon-{{right_title}}"></a>\n
{{/if}}\n
</script>\n
</head>\n
\n
<body>\n
<div class="ui-hidden-accessible connection-gadget-container"></div>\n
\n
<div data-role="page">\n
\n
<div data-role="header" data-position="fixed" class="gadget-header" data-theme="b">\n
<h1></h1>\n
</div>\n
<div data-gadget-url="gadget_jio.html"\n
data-gadget-scope="jio_gadget"\n
data-gadget-sandbox="public"></div>\n
\n
<div role="main" class="ui-content gadget-content"></div>\n
</div>\n
</body>\n
</html>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>RenderJS Gadget JabberClient</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
<item>
<key> <string>publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1418206089.73</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>normie</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.62493.12341.2286</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1443087193.8</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1418205650.36</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1418205650.35</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>draft</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData><?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Starting Point</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>jabber_gadget_jabberclient_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
<!doctype html>\n
<html manifest="./gadget_jabberclient.appcache">\n
<head>\n
......
......@@ -342,9 +342,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
......@@ -451,6 +453,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
......@@ -488,15 +537,32 @@
}\n
gadget.props.contact_dict[jid].read = true;\n
\n
function sendMessageHandler(submit_event) {\n
var text = submit_event.target[0].value;\n
submit_event.target[0].value = "";\n
return RSVP.all([\n
connection_gadget.sendMessage(jid, text),\n
updateConversation(gadget, jid, text, false)\n
]);\n
function sendMessageHandler(e) {\n
// don\'t send empty messages \n
if (!message_box.value.trim()) {\n
if (e.which === 13 && !e.shiftKey) {\n
e.preventDefault();\n
} \n
return true;\n
}\n
// send messages when the field is focused and Enter is pressed \n
if (e.which == 13 && !e.shiftKey) {\n
e.preventDefault(); // prevent newline from being added before sending\n
var text = message_box.value;\n
message_box.value = "";\n
return RSVP.all([\n
connection_gadget.sendMessage(jid, text),\n
updateConversation(gadget, jid, text, false)\n
]);\n
}\n
}\n
\n
\n
// add keypress listener to textarea\n
message_box = document.getElementById(\'jabber-message\');\n
message_box.addEventListener(\'keypress\', function(e) {\n
sendMessageHandler(e);\n
});\n
\n
return loopEventListener(\n
gadget.props.content_element.querySelector(\'form.message-form\'),\n
\'submit\',\n
......@@ -786,13 +852,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
......@@ -1073,7 +1139,7 @@
</tuple>
<state>
<tuple>
<float>1442839765.51</float>
<float>1443097975.82</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