1function fetchParseSortAndLoadTournamentsForUser(url, tournaments, handleFinish){ 2 3 4 5 var result = fetch( url ).then( 6 function( response ) { 7 if ( !response.ok ) { 8 console.log(response); 9 response.text().then(body => console.log(body)); 10 throw new Exception( response.status ) 11 } 12 return response.text() 13 }).then( function( text ) { 14 var json = JSON.parse('['+text.split("}\n{").join("},{")+']');//TODO:how do i parse this properly 15 for (var x in json){ 16 if (json[x]["status"] != 30 && json[x]["variant"]["key"] == "crazyhouse") { 17 tournaments.push(new Tournament(json[x])); 18 } 19 } 20 }).then ( function(){ 21 tournaments.sort(function(a, b){return a.json['startsAt']-b.json['startsAt']}); 22 }).catch( function( error ) { 23 console.info( "Received error ", error); 24 }).then ( handleFinish ); 25 26 return result; 27 28} 29 30 31/////////////////////////////////////// 32 33function fetchParseSortAndLoadTournamentsOfLichess(tournaments, handleFinish){ 34 35 var result = fetch( "https://lichess.org/api/tournament" ).then( function( response ) { 36 if ( !response.ok ) { 37 console.log(response); 38 response.text().then(body => console.log(body)); 39 throw new Exception( response.status ) 40 } 41 return response.json() 42 }).then( function( json ) { 43 44 for (var x in json["started"]){ 45 var t = json["started"][x]; 46 if (t["variant"]["key"]=="crazyhouse"){ 47 tournaments.push(new Tournament(t)); 48 } 49 } 50 51 for (var x in json["created"]){ 52 var t = json["created"][x]; 53 if (t["variant"]["key"]=="crazyhouse"){ 54 tournaments.push(new Tournament(t)); 55 } 56 } 57 58 }).then ( function(){ 59 tournaments.sort(function(a, b){return a.json['startsAt']-b.json['startsAt']}); 60 }).catch( function( error ) { 61 console.info( "Received error ", error); 62 }).then (handleFinish ); 63 64 return result; 65 66}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.