Commit aefceeff authored by Thibaut Frain's avatar Thibaut Frain

Added jabber login gadget

parent 70063366
...@@ -98,7 +98,9 @@ module.exports = function (grunt) { ...@@ -98,7 +98,9 @@ module.exports = function (grunt) {
"<%= global_config.dest %>/presentation_editor/presentation_editor.css": "<%= global_config.dest %>/presentation_editor/presentation_editor.css":
"<%= global_config.src %>/presentation_editor/presentation_editor.css", "<%= global_config.src %>/presentation_editor/presentation_editor.css",
"<%= global_config.dest %>/presentation_viewer/presentation_viewer.css": "<%= global_config.dest %>/presentation_viewer/presentation_viewer.css":
"<%= global_config.src %>/presentation_viewer/presentation_viewer.css" "<%= global_config.src %>/presentation_viewer/presentation_viewer.css",
"<%= global_config.dest %>/jabber_login/jabber_login.css":
"<%= global_config.src %>/jabber_login/jabber_login.css"
} }
} }
}, },
...@@ -291,6 +293,11 @@ module.exports = function (grunt) { ...@@ -291,6 +293,11 @@ module.exports = function (grunt) {
src: 'https://svg-edit.googlecode.com/files/svg-edit-2.6.zip', src: 'https://svg-edit.googlecode.com/files/svg-edit-2.6.zip',
relative_dest: 'lib/svg-edit-2.6', relative_dest: 'lib/svg-edit-2.6',
dest: '<%= global_config.tmp %>/svgedit.zip' dest: '<%= global_config.tmp %>/svgedit.zip'
},
strophejs: {
src: 'https://raw.github.com/strophe/strophe.im/gh-pages/strophejs/downloads/strophejs-1.1.3.zip',
relative_dest: 'lib/strophejs-1.1.3/strophe.min.js',
dest: '<%= global_config.tmp %>/strophejs.zip'
} }
// qunit: { // qunit: {
// all: ['test/index.html'] // all: ['test/index.html']
...@@ -320,6 +327,10 @@ module.exports = function (grunt) { ...@@ -320,6 +327,10 @@ module.exports = function (grunt) {
svgedit: { svgedit: {
src: '<%= global_config.tmp %>/svgedit.zip', src: '<%= global_config.tmp %>/svgedit.zip',
dest: '<%= global_config.dest %>/lib/' dest: '<%= global_config.dest %>/lib/'
},
strophejs: {
src: '<%= global_config.tmp %>/strophejs.zip',
dest: '<%= global_config.dest %>/lib/'
} }
}, },
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Jabber login gadget</title>
<link rel="stylesheet" href="../<%= curl.jquerymobilecss.relative_dest %>">
<link rel="stylesheet" href="jabber_login.css">
<script src="../<%= curl.jquery.relative_dest %>"></script>
<script src="../<%= curl.jquerymobilejs.relative_dest %>"></script>
<script src="../<%= copy.rsvp.relative_dest %>"></script>
<script src="../<%= copy.renderjs.relative_dest %>"></script>
<script src="../<%= curl.strophejs.relative_dest %>"></script>
<script src="jabber_login.js"></script>
</head>
<body>
<div class="login-box ui-corner-all ui-shadow">
<h3 class="title">Log in to your jabber account:&nbsp</h3><br/>
<form class="login-form" data-ajax="false">
<div class="ui-field-contain">
<input type="url" name="server" placeholder="Jabber server url" value="https://mail.tiolive.com/chat/http-bind/" required>
</div>
<div class="ui-field-contain">
<input type="text" name="jid" placeholder="Jabber ID" required>
</div>
<div class="ui-field-contain">
<input type="password" name="passwd" placeholder="Password" required>
</div>
<fieldset class="ui-btn-inline">
<input type="submit" value="Log In">
</fieldset>
</form>
</div>
</body>
</html>
.login-box {
margin: 0 auto;
max-width: 35ch !important;
text-align: center;
padding: 1%;
}
.login-box form {
margin: 1%;
}
\ No newline at end of file
/*global window, rJS, Strophe, $, $iq, XMLSerializer, DOMParser*/
(function ($, Strophe, rJS) {
"use strict";
var serializeXML = function (xml) {
return (new XMLSerializer()).serializeToString(xml);
},
parseXML = function (xmlString) {
return new DOMParser()
.parseFromString(xmlString, 'text/xml')
.children[0];
};
rJS(window)
.declareAcquiredMethod('connected', 'connected')
.declareAcquiredMethod('disconnected', 'disconnected')
.declareAcquiredMethod('receive', 'receive')
.declareMethod('getJID', function () {
return Strophe.getBareJidFromJid(this.connection.jid);
})
.declareMethod('send', function (xmlString) {
return this.connection.send(parseXML(xmlString));
})
.declareMethod('disconnect', function () {
if (this.connection) {
return this.connection.disconnect();
}
})
.ready(function (g) {
function initInputs() {
g.connection.xmlInput = function (body) {
[].forEach.call(body.children, function (child) {
g.receive(serializeXML(child));
});
};
}
function initConnection(params) {
g.connection = new Strophe.Connection(params.server);
g.connection.connect(params.jid, params.passwd, function (status) {
if (status === Strophe.Status.CONNECTED) {
initInputs();
g.connected();
} else if (status === Strophe.Status.DISCONNECTED) {
g.disconnected();
}
});
window.connection = g.connection; // for debug purpose
}
$(document).on('submit', 'form.login-form', function (e) {
var params = {};
$(this).serializeArray().forEach(function (elem) {
params[elem.name] = elem.value;
});
initConnection(params);
return false;
});
});
}($, Strophe, rJS));
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