From 1cdc29e2602a17e156babb9c8a35f96a1f53a174 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 29 Aug 2014 15:01:46 +0100 Subject: Fix JSFiddles to work with the new C-S API. --- jsfiddles/create_room_send_msg/demo.js | 17 ++++---- jsfiddles/event_stream/demo.js | 18 ++++----- jsfiddles/example_app/demo.js | 56 +++++++++++++++++--------- jsfiddles/register_login/demo.js | 4 +- jsfiddles/room_memberships/demo.html | 6 +-- jsfiddles/room_memberships/demo.js | 73 ++++++++++++++++------------------ 6 files changed, 93 insertions(+), 81 deletions(-) (limited to 'jsfiddles') diff --git a/jsfiddles/create_room_send_msg/demo.js b/jsfiddles/create_room_send_msg/demo.js index c17eb26b98..db2ae2d606 100644 --- a/jsfiddles/create_room_send_msg/demo.js +++ b/jsfiddles/create_room_send_msg/demo.js @@ -25,11 +25,12 @@ $('.login').live('click', function() { }); var getCurrentRoomList = function() { - var url = "http://localhost:8080/matrix/client/api/v1/im/sync?access_token=" + accountInfo.access_token + "&from=END&to=START&limit=1"; + var url = "http://localhost:8080/matrix/client/api/v1/initialSync?access_token=" + accountInfo.access_token + "&limit=1"; $.getJSON(url, function(data) { - for (var i=0; i=0; --i) { addMessage(data.chunk[i]); @@ -190,7 +193,8 @@ var getMessages = function(roomId) { var getMemberList = function(roomId) { $("#members").empty(); memberInfo = []; - var url = "http://localhost:8080/matrix/client/api/v1/rooms/" + roomId + "/members/list?access_token=" + accountInfo.access_token; + var url = "http://localhost:8080/matrix/client/api/v1/rooms/" + + encodeURIComponent(roomId) + "/members?access_token=" + accountInfo.access_token; $.getJSON(url, function(data) { for (var i=0; i"; + } + else if (data.content.membership === "join") { + msg = "joined the room"; + } + else if (data.content.membership === "leave") { + msg = "left the room"; + } + else { + msg = "" + data.content.membership + ""; + } + } + var row = "" + ""+data.user_id+"" + - ""+data.content.body+"" + + ""+msg+"" + ""; $("#messages").append(row); }; var addMember = function(data) { var row = "" + - ""+data.target_user_id+"" + + ""+data.state_key+"" + ""+data.content.membership+"" + ""; $("#members").append(row); diff --git a/jsfiddles/register_login/demo.js b/jsfiddles/register_login/demo.js index 1644f76ac7..270a96786c 100644 --- a/jsfiddles/register_login/demo.js +++ b/jsfiddles/register_login/demo.js @@ -45,7 +45,7 @@ $('.login').live('click', function() { var user = $("#userLogin").val(); var password = $("#passwordLogin").val(); $.getJSON("http://localhost:8080/matrix/client/api/v1/login", function(data) { - if (data.type !== "m.login.password") { + if (data.flows[0].type !== "m.login.password") { alert("I don't know how to login with this type: " + data.type); return; } @@ -60,7 +60,7 @@ $('.logout').live('click', function() { }); $('.testToken').live('click', function() { - var url = "http://localhost:8080/matrix/client/api/v1/im/sync?access_token=" + accountInfo.access_token + "&from=END&to=START&limit=1"; + var url = "http://localhost:8080/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) { diff --git a/jsfiddles/room_memberships/demo.html b/jsfiddles/room_memberships/demo.html index 96232e827a..4c1bf6b4bb 100644 --- a/jsfiddles/room_memberships/demo.html +++ b/jsfiddles/room_memberships/demo.html @@ -14,9 +14,9 @@ diff --git a/jsfiddles/room_memberships/demo.js b/jsfiddles/room_memberships/demo.js index b3ce0f0e33..91cc96ab6f 100644 --- a/jsfiddles/room_memberships/demo.js +++ b/jsfiddles/room_memberships/demo.js @@ -4,6 +4,14 @@ var showLoggedIn = function(data) { accountInfo = data; getCurrentRoomList(); $(".loggedin").css({visibility: "visible"}); + $("#membership").change(function() { + if ($("#membership").val() === "invite") { + $("#targetUser").css({visibility: "visible"}); + } + else { + $("#targetUser").css({visibility: "hidden"}); + } +}); }; $('.login').live('click', function() { @@ -31,10 +39,11 @@ var getCurrentRoomList = function() { // solution but that is out of scope of this fiddle. $("#rooms").find("tr:gt(0)").remove(); - var url = "http://localhost:8080/matrix/client/api/v1/im/sync?access_token=" + accountInfo.access_token + "&from=END&to=START&limit=1"; + var url = "http://localhost:8080/matrix/client/api/v1/initialSync?access_token=" + accountInfo.access_token + "&limit=1"; $.getJSON(url, function(data) { - for (var i=0; i