Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var platform = new H.service.Platform({
- 'app_id': 'DCO4LUDHYRS1foINnFP0',
- 'app_code': '7fXbM6yMi_y2VwRdT6qu-g'
- });
- function foo(){
- var ajax = new XMLHttpRequest();
- var userId = 1;
- ajax.onreadystatechange = function(){
- if(ajax.readyState == 4 && ajax.status == 200){
- var response = JSON.parse(ajax.responseText);
- var tabela = document.getElementById('liste').getElementsByTagName('tbody')[0];
- tabela.innerHTML = "";
- response.data.forEach(function(element){
- var newRow = tabela.insertRow(tabela.rows.length);
- var newCell = newRow.insertCell(0);
- var newText = document.createTextNode(element.listName);
- newRow.id = element.listId;
- newCell.appendChild(newText);
- newRow.onclick = function(){foo2(newRow.id)}
- })
- }
- }
- ajax.open('GET','/' + userId + '/lists');
- ajax.send();
- }
- function foo2(id){
- var ajax = new XMLHttpRequest();
- if(localStorage.getItem('listId')) localStorage.removeItem(listId);
- localStorage.setItem('listId',id);
- var listId = id;
- var userId = 1;
- ajax.onreadystatechange = function(){
- if(ajax.readyState == 4 && ajax.status == 200){
- var response = JSON.parse(ajax.responseText);
- var tabela = document.getElementById('itemi').getElementsByTagName('tbody')[0];
- tabela.innerHTML = "";
- response.data.forEach(function(element){
- var newRow = tabela.insertRow(tabela.rows.length);
- var newCell = newRow.insertCell(0);
- var newText = document.createTextNode(element.itemContent);
- newRow.id = element.itemId;
- newCell.appendChild(newText);
- });
- }
- }
- ajax.open('GET', '/' + userId + '/lists/' + listId);
- ajax.send();
- }
- function foo3(){
- var userId = document.getElementById('userId').value;
- var listName = document.getElementById('listName').value;
- var ajax = new XMLHttpRequest();
- ajax.onreadystatechange = function(){
- if(ajax.readyState == 4 && ajax.status == 200){
- foo()
- }
- };
- ajax.open('POST', '/addList');
- ajax.setRequestHeader('Content-type', 'application/json');
- ajax.send(JSON.stringify({
- userId : userId,
- listName : listName
- }));
- }
- function foo4(){
- var listId = document.getElementById('deleteListId').value;
- var ajax = new XMLHttpRequest();
- ajax.onreadystatechange = function(){
- if(ajax.readyState == 4 && ajax.status == 200){
- foo();
- }
- };
- ajax.open('DELETE', '/deleteList/' + listId);
- ajax.send();
- }
- function foo5(){
- var itemId = document.getElementById('deleteItemId').value;
- var ajax = new XMLHttpRequest();
- ajax.onreadystatechange = function(){
- if(ajax.readyState == 4 && ajax.status == 200){
- foo2(localStorage.getItem('listId'));
- }
- };
- ajax.open('DELETE', '/deleteitem/' + itemId);
- ajax.send();
- }
- function foo6(){
- var itemId = document.getElementById('insertItemid').value;
- var listId = localStorage.getItem('listId');
- var content = document.getElementById('itemContent').value;
- var ajax = new XMLHttpRequest();
- ajax.onreadystatechange = function(){
- if(ajax.readyState == 4 && ajax.status == 200){
- foo2(localStorage.getItem('listId'));
- }
- };
- ajax.open('POST', '/' + listId + '/additem');
- ajax.setRequestHeader("Content-type",'application/json')
- ajax.send(JSON.stringify({
- item:{
- itemId : itemId,
- content : content
- }
- }));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement