| 1 |
<!DOCTYPE HTML> |
| 2 |
<html> |
| 3 |
|
| 4 |
<head> |
| 5 |
<title>JSXC example application</title> |
| 6 |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 8 |
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico"> |
| 9 |
|
| 10 |
<link href="css/bootstrap.min.css" media="all" rel="stylesheet" type="text/css" /> |
| 11 |
|
| 12 |
<!-- require:dependencies --> |
| 13 |
<link href="css/jquery-ui.min.css" media="all" rel="stylesheet" type="text/css" /> |
| 14 |
<link href="../dev/css/jsxc.css" media="all" rel="stylesheet" type="text/css" /> |
| 15 |
<!-- endrequire --> |
| 16 |
|
| 17 |
<link href="css/example.css" media="all" rel="stylesheet" type="text/css" /> |
| 18 |
|
| 19 |
<!-- require:dependencies --> |
| 20 |
<script src="js/jquery.min.js"></script> |
| 21 |
<script src="js/jquery-ui.min.js"></script> |
| 22 |
<script src="../dev/lib/jquery.slimscroll.js"></script> |
| 23 |
<script src="../dev/lib/jquery.fullscreen.js"></script> |
| 24 |
<script src="../dev/lib/jsxc.dep.js"></script> |
| 25 |
<!-- endrequire --> |
| 26 |
|
| 27 |
<script src="js/bootstrap.min.js"></script> |
| 28 |
|
| 29 |
<!-- jsxc library --> |
| 30 |
<script src="../dev/jsxc.js"></script> |
| 31 |
|
| 32 |
<!-- init script --> |
| 33 |
<script src="js/example.js"></script> |
| 34 |
|
| 35 |
</head> |
| 36 |
|
| 37 |
<body> |
| 38 |
<div class="container" id="content" role="main"> |
| 39 |
|
| 40 |
<div class="row"> |
| 41 |
<div class="col-xs-12"> |
| 42 |
<h1 class="page-header">JSXC <small>developer example</small></h1> |
| 43 |
|
| 44 |
<div class="row"> |
| 45 |
<div class="col-md-6"> |
| 46 |
<p>This example demonstrates different types of login methods for <a href="https://www.jsxc.org/">JSXC</a>. You find further information in our <a href="https://github.com/jsxc/jsxc/wiki">wiki</a>.</p> |
| 47 |
</div> |
| 48 |
|
| 49 |
<div class="form form-horizontal col-md-6"> |
| 50 |
<div class="form-group"> |
| 51 |
<label for="xmpp-domain" class="col-xs-4 control-label">XMPP domain:</label> |
| 52 |
<div class="col-xs-8"> |
| 53 |
<input type="text" id="xmpp-domain" name="xmpp-domain" class="form-control" value="localhost" /> |
| 54 |
</div> |
| 55 |
</div> |
| 56 |
<div class="form-group"> |
| 57 |
<label for="bosh-url" class="col-xs-4 control-label">BOSH url:</label> |
| 58 |
<div class="col-xs-8"> |
| 59 |
<input type="text" id="bosh-url" name="bosh-url" class="form-control" value="/http-bind/" /> |
| 60 |
<p id="server-flash"></p> |
| 61 |
</div> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
</div> |
| 65 |
</div> |
| 66 |
</div> |
| 67 |
|
| 68 |
<div class="row"> |
| 69 |
|
| 70 |
<div class="col-xs-12 col-md-4"> |
| 71 |
<h3>Dual-Login</h3> |
| 72 |
|
| 73 |
<p>You should use this method if you have already a login in your website.</p> |
| 74 |
|
| 75 |
<form id="form" method="post" action="login.html" class="form form-horizontal"> |
| 76 |
<fieldset> |
| 77 |
<div class="form-group"> |
| 78 |
<label for="username" class="col-xs-4 control-label">Username:</label> |
| 79 |
<div class="col-xs-8"> |
| 80 |
<input type="text" id="username" name="username" class="form-control" /> |
| 81 |
</div> |
| 82 |
</div> |
| 83 |
|
| 84 |
<div class="form-group"> |
| 85 |
<label for="password" class="col-xs-4 control-label">Password:</label> |
| 86 |
<div class="col-xs-8"> |
| 87 |
<input type="password" id="password" name="password" class="form-control" /> |
| 88 |
</div> |
| 89 |
</div> |
| 90 |
|
| 91 |
<div class="form-group"> |
| 92 |
<div class="col-xs-offset-4 col-xs-8"> |
| 93 |
<button type="submit" class="submit btn btn-primary">Log in chat and submit</button> |
| 94 |
<button class="logout btn btn-default" style="display:none;">Log out</button> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
|
| 98 |
</fieldset> |
| 99 |
</form> |
| 100 |
|
| 101 |
<pre><form id="form"> |
| 102 |
<input type="text" id="username" /> |
| 103 |
<input type="password" id="password" /> |
| 104 |
<input type="submit" value="Submit" /> |
| 105 |
</form> |
| 106 |
|
| 107 |
<button id="logout">Logout</button></pre> |
| 108 |
|
| 109 |
<pre>jsxc.init({ |
| 110 |
loginForm: { |
| 111 |
form: '#form', |
| 112 |
jid: '#username', |
| 113 |
pass: '#password' |
| 114 |
}, |
| 115 |
logoutElement: $('#logout'), |
| 116 |
loadSettings: function() { |
| 117 |
return xmpp: { |
| 118 |
url: '/http-bind/', |
| 119 |
domain: 'localhost', |
| 120 |
resource: 'example', |
| 121 |
overwrite: true, |
| 122 |
onlogin: true |
| 123 |
}; |
| 124 |
}, |
| 125 |
root: '/jsxc/' |
| 126 |
});</pre> |
| 127 |
|
| 128 |
</div> |
| 129 |
|
| 130 |
<div class="col-xs-12 col-md-4"> |
| 131 |
<h3>AJAX Login</h3> |
| 132 |
|
| 133 |
<p>Do you want to login directly within your script? Choose this type. |
| 134 |
|
| 135 |
<form id="form2" class="form form-horizontal"> |
| 136 |
<fieldset> |
| 137 |
<div class="alert alert-warning col-xs-12" role="alert"> |
| 138 |
<strong>Warning!</strong> Your username or password is wrong! |
| 139 |
</div> |
| 140 |
|
| 141 |
<div class="form-group"> |
| 142 |
<label for="username2" class="col-xs-4 control-label">Username:</label> |
| 143 |
<div class="col-xs-8"> |
| 144 |
<input type="text" id="username2" class="form-control" /> |
| 145 |
</div> |
| 146 |
</div> |
| 147 |
|
| 148 |
<div class="form-group"> |
| 149 |
<label for="password2" class="col-xs-4 control-label">Password:</label> |
| 150 |
<div class="col-xs-8"> |
| 151 |
<input type="password" id="password2" class="form-control" /> |
| 152 |
</div> |
| 153 |
</div> |
| 154 |
|
| 155 |
<div class="form-group"> |
| 156 |
<div class="col-xs-offset-4 col-xs-8"> |
| 157 |
<button type="submit" id="submit2" class="submit btn btn-primary" data-loading-text="Logging in...">Log in chat</button> |
| 158 |
<button class="logout btn btn-default">Log out</button> |
| 159 |
</div> |
| 160 |
</div> |
| 161 |
</fieldset> |
| 162 |
</form> |
| 163 |
|
| 164 |
<pre><input type="text" id="username" /> |
| 165 |
<input type="password" id="password" /> |
| 166 |
<button id="submit">Log in</button></pre> |
| 167 |
|
| 168 |
<pre>jsxc.init({ |
| 169 |
xmpp: { |
| 170 |
url: '/http-bind/' |
| 171 |
}, |
| 172 |
root: '/jsxc/' |
| 173 |
}); |
| 174 |
|
| 175 |
$('#submit').click(function(){ |
| 176 |
var username = $('#username').val(); |
| 177 |
var password = $('#password').val(); |
| 178 |
|
| 179 |
var jid = username + '@localhost'; |
| 180 |
|
| 181 |
jsxc.start(jid , password); |
| 182 |
}); |
| 183 |
</pre> |
| 184 |
</div> |
| 185 |
|
| 186 |
<div class="col-xs-12 col-md-4"> |
| 187 |
<h3>Box Login</h3> |
| 188 |
|
| 189 |
<p>Do you look for a discrete login method? Choose this.</p> |
| 190 |
|
| 191 |
<div class="form" id="form3"> |
| 192 |
<button class="submit btn btn-primary">Open Box</button> |
| 193 |
<button class="logout btn btn-default">Log out</button> |
| 194 |
</div> |
| 195 |
|
| 196 |
<pre><button id="button">Open Box</button></pre> |
| 197 |
|
| 198 |
<pre>jsxc.init({ |
| 199 |
loadSettings: function() { |
| 200 |
return xmpp: { |
| 201 |
url: '/http-bind/', |
| 202 |
domain: 'localhost', |
| 203 |
resource: 'example', |
| 204 |
overwrite: true, |
| 205 |
onlogin: true |
| 206 |
}; |
| 207 |
}, |
| 208 |
root: '/jsxc/' |
| 209 |
}); |
| 210 |
|
| 211 |
$('#button').click(jsxc.gui.showLoginBox);</pre> |
| 212 |
</div> |
| 213 |
|
| 214 |
</div> |
| 215 |
|
| 216 |
<div class="row"> |
| 217 |
<div class="col-xs-12 col-md-4"> |
| 218 |
<h3>Prelogin</h3> |
| 219 |
|
| 220 |
<p>Attach to existing BOSH connection. Helpful if you login server side.</p> |
| 221 |
|
| 222 |
<pre>jsxc.init({ |
| 223 |
xmpp: { |
| 224 |
url: '/http-bind/', |
| 225 |
jid: 'username@localhost', |
| 226 |
sid: 'SID', |
| 227 |
rid: 'RID' |
| 228 |
}, |
| 229 |
root: '/jsxc/' |
| 230 |
});</pre> |
| 231 |
</div> |
| 232 |
|
| 233 |
<div class="col-xs-12 col-md-4"> |
| 234 |
<h3>AJAX Prelogin</h3> |
| 235 |
|
| 236 |
<p>Attach to existing BOSH connection after JSXC was initialized.</p> |
| 237 |
|
| 238 |
<pre>jsxc.init({ |
| 239 |
xmpp: { |
| 240 |
url: '/http-bind/' |
| 241 |
}, |
| 242 |
root: '/jsxc/' |
| 243 |
}); |
| 244 |
|
| 245 |
function callback() { |
| 246 |
jsxc.start('username@localhost', 'SID', 'RID'); |
| 247 |
}</pre> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
</div> |
| 251 |
</body> |
| 252 |
|
| 253 |
</html> |