diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-01-15 16:51:52 +0000 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-01-22 11:15:03 +0000 |
commit | 8907e143c1a3378c7dced4048b165e38bb2b17fa (patch) | |
tree | bf1a2b2cea306c6b94513be44b35bac88b93fed4 /jsfiddles/register_login | |
parent | Move scripts into scripts (diff) | |
download | synapse-8907e143c1a3378c7dced4048b165e38bb2b17fa.tar.xz |
Remove jsfiddles
Diffstat (limited to 'jsfiddles/register_login')
-rw-r--r-- | jsfiddles/register_login/demo.css | 7 | ||||
-rw-r--r-- | jsfiddles/register_login/demo.html | 20 | ||||
-rw-r--r-- | jsfiddles/register_login/demo.js | 79 |
3 files changed, 0 insertions, 106 deletions
diff --git a/jsfiddles/register_login/demo.css b/jsfiddles/register_login/demo.css deleted file mode 100644 index 11781c250f..0000000000 --- a/jsfiddles/register_login/demo.css +++ /dev/null @@ -1,7 +0,0 @@ -.loggedin { - visibility: hidden; -} - -p { - font-family: monospace; -} diff --git a/jsfiddles/register_login/demo.html b/jsfiddles/register_login/demo.html deleted file mode 100644 index fcac453ac2..0000000000 --- a/jsfiddles/register_login/demo.html +++ /dev/null @@ -1,20 +0,0 @@ -<div> - <p>This registration/login demo requires a home server to be running on http://localhost:8008</p> -</div> -<form class="registrationForm"> - <input type="text" id="user" placeholder="Username"></input> - <input type="password" id="password" placeholder="Password"></input> - <input type="button" class="register" value="Register"></input> -</form> -<form class="loginForm"> - <input type="text" id="userLogin" placeholder="Username"></input> - <input type="password" id="passwordLogin" placeholder="Password"></input> - <input type="button" class="login" value="Login"></input> -</form> -<div class="loggedin"> - <p id="welcomeText"></p> - <input type="button" class="testToken" value="Test token"></input> - <input type="button" class="logout" value="Logout"></input> - <p id="imSyncText"></p> -</div> - diff --git a/jsfiddles/register_login/demo.js b/jsfiddles/register_login/demo.js deleted file mode 100644 index 2e6957b631..0000000000 --- a/jsfiddles/register_login/demo.js +++ /dev/null @@ -1,79 +0,0 @@ -var accountInfo = {}; - -var showLoggedIn = function(data) { - accountInfo = data; - $(".loggedin").css({visibility: "visible"}); - $("#welcomeText").text("Welcome " + accountInfo.user_id+". Your access token is: " + - accountInfo.access_token); -}; - -$('.register').live('click', function() { - var user = $("#user").val(); - var password = $("#password").val(); - $.ajax({ - url: "http://localhost:8008/_matrix/client/api/v1/register", - type: "POST", - contentType: "application/json; charset=utf-8", - data: JSON.stringify({ user: user, password: password, type: "m.login.password" }), - dataType: "json", - success: function(data) { - showLoggedIn(data); - }, - error: function(err) { - var errMsg = "To try this, you need a home server running!"; - var errJson = $.parseJSON(err.responseText); - if (errJson) { - errMsg = JSON.stringify(errJson); - } - alert(errMsg); - } - }); -}); - -var login = function(user, password) { - $.ajax({ - url: "http://localhost:8008/_matrix/client/api/v1/login", - type: "POST", - contentType: "application/json; charset=utf-8", - data: JSON.stringify({ user: user, password: password, type: "m.login.password" }), - dataType: "json", - success: function(data) { - showLoggedIn(data); - }, - error: function(err) { - var errMsg = "To try this, you need a home server running!"; - var errJson = $.parseJSON(err.responseText); - if (errJson) { - errMsg = JSON.stringify(errJson); - } - alert(errMsg); - } - }); -}; - -$('.login').live('click', function() { - var user = $("#userLogin").val(); - var password = $("#passwordLogin").val(); - $.getJSON("http://localhost:8008/_matrix/client/api/v1/login", function(data) { - if (data.flows[0].type !== "m.login.password") { - alert("I don't know how to login with this type: " + data.type); - return; - } - login(user, password); - }); -}); - -$('.logout').live('click', function() { - accountInfo = {}; - $("#imSyncText").text(""); - $(".loggedin").css({visibility: "hidden"}); -}); - -$('.testToken').live('click', function() { - var url = "http://localhost:8008/_matrix/client/api/v1/initialSync?access_token=" + accountInfo.access_token + "&limit=1"; - $.getJSON(url, function(data) { - $("#imSyncText").text(JSON.stringify(data, undefined, 2)); - }).fail(function(err) { - $("#imSyncText").text(JSON.stringify($.parseJSON(err.responseText))); - }); -}); |