/* public void [emits->onShowRoom] */ switchRoom(roomName) { var instance = this; this.currentRoom = this.joinedRooms[roomName]; ajax.get( '/chatrooms/' + roomName, {}, (users) => { /* Overrides the users with whatever is in the server. */ instance.currentRoom.users.clear(); instance.joinedRooms.forEach((room) => { room.unselect(); }) /* Loads connected users from server. */ for (var i in users) { var userName = users[i]; if (userName == session.name) continue; instance.currentRoom.addUser( new User(userName) ); } instance.emit('onShowRoom'); instance.currentRoom.show(); } ); }
sendSmsCode = function (spinWrap, mobile, captcha, sendBtn ) { if ( sendBtn.matches('.disabled') ) { return false; } verifyMsg = validate.phone(mobile); if ( verifyMsg ) { toast.show('info', verifyMsg); return false; } if (!captcha) { toast.show('info', '请输入图形验证码'); return false; } ajax.get(apis.sendSmsCode, spinWrap, { phone: mobile, captchaCode: captcha }, function ( res ) { toast.show('success', '发送成功!'); codeSendDeay = 61; refreshSendBtn( sendBtn ); }, function ( res ) { toast.show('error', apisMsg.sendSmsCode[res.responseInfo] || '发送失败'); }); };
function onSearch(event) { var search = document.getElementById('search'), searchVal = search.value, popup = document.getElementById('popup'), popupval = popup.object.getValue(), apiURL = 'http://folkets-lexikon.csc.kth.se/folkets/service', request = '?word=' + searchVal + '&lang=both' + '&interface=' + popupval, content = document.getElementById('content'); ajax.get(apiURL+request,{ accept:'text/html', type:'application/x-www-form-urlencoded', charset:'iso-8859-1', timeout: 4000 }).then(function(result){ alert("result: " + result); var html = parseXML(result); content.innerHTML = html; document.getElementById("scrollArea").object.refresh(); },function(error){ content.innerHTML = error.message||error; document.getElementById("scrollArea").object.refresh(); }); }
static getLecture(id) { const lecture$ = es.EventStream(); ajax.get(`/api/lecture/${id}`, {}, data => { es.push(lecture$, data); }); return lecture$; }
static getContents() { const contents$ = es.EventStream(); ajax.get('/api/contents', {}, data => { contents = StateModel.parseContents(data); es.push(contents$, contents); }); return contents$; }
ajax.get('/r/create', function(data) { var obj = JSON.parse(data); sessionId = obj.id; ajax.get('/r/pair/' + sessionId, function(data) { obj = JSON.parse(data); console.log('pairId', obj.pairId); init(); }); });
static getTask(id) { const task$ = es.EventStream(); ajax.get(`/api/task/${id}`, {}, data => { es.push( task$, data ); }); return task$; }
exports.load = function(name, req, onLoad, config) { var uri = req.toUrl(name); if (globalRequire && globalRequire.nodeRequire) { onLoad(globalRequire.nodeRequire('fs').readFileSync(uri, 'utf8')); } else { ajax.get({ url: uri, callback: onLoad, dataType: 'text' }); } };
/* public async [emits->onShowRoom] */ findAvailableRooms() { var instance = this; ajax.get('/rooms', {}, (rooms) => { for (var index in rooms) { var room = rooms[index]; instance .availableRooms .add(room.roomName, Room.fromObject(room)); } instance.emit('onRoomsAvailable'); } ); /* this.availableRooms.add("Fun Jokes", new Room("Fun Jokes")); this.availableRooms.add("Tech Stuff", new Room("Tech Stuff")); */ }