UNPKG

scalra

Version:

node.js framework to prototype and scale rapidly

121 lines (94 loc) 2.83 kB
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="/lib/scalra.js"></script> <script type="text/javascript" src="logic.js"></script> <script> var accountField = undefined; var emailField = undefined; var dataArea = undefined; var onConnect = function () { console.log('onConnect called...'); SR.API._ACCOUNT_GETDATA({types: ['email', 'data']}, function (err, result) { if (err) { alert(err); document.location.href = 'demo-login.html'; return; } accountField.value = result.account; emailField.value = result.email; var str = JSON.stringify(result.data, undefined, 2); dataArea.value = str; }); // check if SR.Video exists if (typeof SR.Video === 'object') { console.log('SR.Video exists...'); if (typeof SR.Video.WebRTC === 'object') console.log('SR.Video.WebRTC exists...'); } } // perform action only after page is loaded document.addEventListener ("DOMContentLoaded", function () { // load message area accountField = document.getElementById("account"); emailField = document.getElementById("email"); dataArea = document.getElementById('user_data'); }); function update_email() { var account = document.getElementById("account").value; var email = document.getElementById("email").value; SR.API._ACCOUNT_SETDATA({data: {email: email}}, function (err, result) { if (err) { return alert(err); } alert('update success\n更新成功'); }); } function update_data() { var obj = undefined; try { obj = JSON.parse(dataArea.value); } catch (e) { console.log('parse error: '); console.error(e); } if (obj === undefined) { alert('no data to update or cannot properly parse input data'); return; } SR.API._ACCOUNT_SETDATA({data: {data: obj}}, function (err, result) { if (err) { return alert(err); } alert('update success\n更新成功'); }); } </script> </head> <body> <form name="login" action="" method="GET"> Main Lobby <p> account: <input type="text" value="" id="account"> email: <input type="text" value="" id="email"> <a href="javascript:update_email()">Change E-mail</a><br> <a href="javascript:logout('/web/demo-login.html')">Logout</a><br> <a href="./demo-chat.html">Chat</a><br> <a href="./demo-upload.html">Upload</a><br> <a href="./demo-listfiles.html">List Uploads</a><br> <a href="./demo-TTT.html?multiuser=true">Tic-tac-toe</a><br> <p> user_data:<br> <textarea id="user_data" rows="10" cols="100"></textarea> <a href="javascript:update_data()">Update data</a><br> <p> <p> Local account: <input type="text" value="" id="local_account"> Password: <input type="text" value="" id="local_password"> Server: <input type="text" value="" id="server"> <a href="javascript:add_account()">Add Account</a><br> <p> </form> </body> </html>