1const url = 'wss://snappy.ace2u.com/socket.io/?EIO=3socket.io/?EIO=3&transport=websocket'; 2let socket; 3 4function changeprice(price){ 5 var pricelast = price*0.5; 6// console.log("Price / (gram) :"+price+" Jika 0.5 gram ="+pricelast); 7} 8 9function connect() { 10 socket = new WebSocket(url); 11 12 socket.addEventListener('open', (event) => { 13 console.log('WebSocket connection opened'); 14 }); 15 16 socket.addEventListener('message', (event) => { 17 var text = event.data.replace(42,''); 18 try { 19 var json = JSON.parse(text); 20 if(json[0]=='gpweb'){ 21 document.getElementById("datepricefeed").innerHTML = json[1].gp_createDate; 22 23 document.getElementById("datepricefeed-mobile").innerHTML = json[1].gp_createDate; 24 var oldbuy = document.getElementById('gp_livebuyprice_gm').innerHTML; 25 var oldbuyrmtael = document.getElementById('gp_livebuyprice_tael').innerHTML; 26 var gp_livebuyprice_tael = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 27 //var gp_livebuyprice_gm = (Math.round(json[1].gp_livebuyprice_gm * 100) / 100).toFixed(3); 28 var gp_livebuyprice_gm = json[1].gp_livebuyprice_gm.toFixed(3); 29 30 //var gp_livebuyprice_gm_mobile = (Math.round(json[1].gp_livebuyprice_gm_mobile * 100) / 100).toFixed(3); 31 var gp_livebuyprice_gm_mobile = json[1].gp_livebuyprice_gm.toFixed(3); 32 33 34 35 36 var oldsell = document.getElementById('gp_livesellprice_gm').innerHTML; 37 var oldsellrmtael = document.getElementById('gp_livesellprice_tael').innerHTML; 38 var gp_livesellprice_tael = (Math.round(json[1].gp_livesellprice_tael * 100) / 100).toFixed(0); 39 // var gp_livesellprice_gm = (Math.round(json[1].gp_livesellprice_gm * 100) / 100).toFixed(3); 40 var gp_livesellprice_gm = json[1].gp_livesellprice_gm.toFixed(3); 41 42 //console.log("waktu : "+json[1].gp_createDate+" Harga : "+json[1].gp_livesellprice_gm.toFixed(3)); 43 44 changeprice(json[1].gp_livesellprice_gm.toFixed(3)); 45 46 47 48 49 50 /* for condition gp_livebuyprice_tael*/ 51 if(gp_livebuyprice_tael > oldbuyrmtael){ 52 document.getElementById("iconlivebuytael").style.color = "#1ac69c"; 53 document.getElementById("iconlivebuytael").className = "fa fa-long-arrow-up"; 54 document.getElementById("gp_livebuyprice_tael").style.color = "#1ac69c"; 55 document.getElementById("gp_livebuyprice_tael_mobile").style.color = "#1ac69c"; 56 document.getElementById("gp_livebuyprice_tael").innerHTML = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 57 document.getElementById("gp_livebuyprice_tael_mobile").innerHTML = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 58 } 59 if(gp_livebuyprice_tael < oldbuyrmtael){ 60 document.getElementById("iconlivebuytael").style.color = "red"; 61 document.getElementById("iconlivebuytael").className = "fa fa-long-arrow-down"; 62 document.getElementById("gp_livebuyprice_tael").style.color = "red"; 63 document.getElementById("gp_livebuyprice_tael_mobile").style.color = "red"; 64 document.getElementById("gp_livebuyprice_tael").innerHTML = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 65 document.getElementById("gp_livebuyprice_tael_mobile").innerHTML = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 66 67 } 68 if(gp_livebuyprice_tael == oldbuyrmtael){ 69 document.getElementById("iconlivebuytael").className = ""; 70 document.getElementById("gp_livebuyprice_tael").style.color = "black"; 71 document.getElementById("gp_livebuyprice_tael_mobile").style.color = "black"; 72 document.getElementById("gp_livebuyprice_tael").innerHTML = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 73 document.getElementById("gp_livebuyprice_tael_mobile").innerHTML = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 74 75 } 76 /*ENd Condition*/ 77 78 if(gp_livebuyprice_gm > oldbuy){ 79 80 document.getElementById("gp_livebuyprice_gm").style.color = "#1ac69c"; 81 document.getElementById("gp_livebuyprice_gm_mobile").style.color = "#1ac69c"; 82 document.getElementById("iconlivebuy").style.color = "#1ac69c"; 83 document.getElementById("iconlivebuy").className = "fa fa-long-arrow-up"; 84 //document.getElementById("gp_livebuyprice_gm").innerHTML = (Math.round(json[1].gp_livebuyprice_gm * 100) / 100).toFixed(3); 85 document.getElementById("gp_livebuyprice_gm").innerHTML = json[1].gp_livebuyprice_gm.toFixed(3); 86 //document.getElementById("gp_livebuyprice_gm_mobile").innerHTML = (Math.round(json[1].gp_livebuyprice_gm * 100) / 100).toFixed(3); 87 document.getElementById("gp_livebuyprice_gm_mobile").innerHTML = json[1].gp_livebuyprice_gm.toFixed(3); 88 89 }if(gp_livebuyprice_gm < oldbuy){ 90 document.getElementById("gp_livebuyprice_gm").style.color = "red"; 91 document.getElementById("gp_livebuyprice_gm_mobile").style.color = "red"; 92 document.getElementById("iconlivebuy").style.color = "red"; 93 document.getElementById("iconlivebuy").className = "fa fa-long-arrow-down"; 94 95 //document.getElementById("gp_livebuyprice_gm").innerHTML = (Math.round(json[1].gp_livebuyprice_gm * 100) / 100).toFixed(3); 96 document.getElementById("gp_livebuyprice_gm").innerHTML = json[1].gp_livebuyprice_gm.toFixed(3); 97 //document.getElementById("gp_livebuyprice_gm_mobile").innerHTML = (Math.round(json[1].gp_livebuyprice_gm * 100) / 100).toFixed(3); 98 document.getElementById("gp_livebuyprice_gm_mobile").innerHTML = json[1].gp_livebuyprice_gm.toFixed(3); 99 document.getElementById("gp_livebuyprice_tael").innerHTML = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 100 document.getElementById("gp_livebuyprice_tael_mobile").innerHTML = (Math.round(json[1].gp_livebuyprice_tael * 100) / 100).toFixed(0); 101 102 103 } 104 105 if(gp_livebuyprice_gm == oldbuy){ 106 document.getElementById("iconlivebuy").className = ""; 107 document.getElementById("gp_livebuyprice_gm").style.color = "black"; 108 document.getElementById("gp_livebuyprice_gm_mobile").style.color = "black"; 109 //document.getElementById("gp_livebuyprice_gm").innerHTML = (Math.round(json[1].gp_livebuyprice_gm * 100) / 100).toFixed(3); 110 document.getElementById("gp_livebuyprice_gm").innerHTML = json[1].gp_livebuyprice_gm.toFixed(3); 111 //document.getElementById("gp_livebuyprice_gm_mobile").innerHTML = (Math.round(json[1].gp_livebuyprice_gm * 100) / 100).toFixed(3); 112 document.getElementById("gp_livebuyprice_gm_mobile").innerHTML = json[1].gp_livebuyprice_gm.toFixed(3); 113 } 114 115 116 117 118 if(gp_livesellprice_gm > oldsell){ 119 document.getElementById("iconlivesell").style.color = "#1ac69c"; 120 document.getElementById("iconlivesell").className = "fa fa-long-arrow-up"; 121 document.getElementById("gp_livesellprice_gm").style.color = "#1ac69c"; 122 document.getElementById("gp_livesellprice_gm_mobile").style.color = "#1ac69c"; 123 //document.getElementById("gp_livesellprice_gm").innerHTML = (Math.round(json[1].gp_livesellprice_gm * 100) / 100).toFixed(3); 124 document.getElementById("gp_livesellprice_gm").innerHTML = json[1].gp_livesellprice_gm.toFixed(3); 125 //document.getElementById("gp_livesellprice_gm_mobile").innerHTML = (Math.round(json[1].gp_livesellprice_gm * 100) / 100).toFixed(3); 126 document.getElementById("gp_livesellprice_gm_mobile").innerHTML = json[1].gp_livesellprice_gm.toFixed(3); 127 } 128 129 if(gp_livesellprice_gm < oldsell){ 130 document.getElementById("iconlivesell").style.color = "red"; 131 document.getElementById("iconlivesell").className = "fa fa-long-arrow-down"; 132 document.getElementById("gp_livesellprice_gm").style.color = "red"; 133 document.getElementById("gp_livesellprice_gm_mobile").style.color = "red"; 134 //document.getElementById("gp_livesellprice_gm").innerHTML = (Math.round(json[1].gp_livesellprice_gm * 100) / 100).toFixed(3); 135 document.getElementById("gp_livesellprice_gm").innerHTML = json[1].gp_livesellprice_gm.toFixed(3); 136 //document.getElementById("gp_livesellprice_gm_mobile").innerHTML = (Math.round(json[1].gp_livesellprice_gm * 100) / 100).toFixed(3); 137 document.getElementById("gp_livesellprice_gm_mobile").innerHTML = json[1].gp_livesellprice_gm.toFixed(3); 138 } 139 if(gp_livesellprice_gm == oldsell){ 140 document.getElementById("iconlivesell").className = ""; 141 document.getElementById("gp_livesellprice_gm").style.color = "black"; 142 document.getElementById("gp_livesellprice_gm_mobile").style.color = "black"; 143 //document.getElementById("gp_livesellprice_gm").innerHTML = (Math.round(json[1].gp_livesellprice_gm * 100) / 100).toFixed(3); 144 document.getElementById("gp_livesellprice_gm").innerHTML = json[1].gp_livesellprice_gm.toFixed(3); 145 //document.getElementById("gp_livesellprice_gm_mobile").innerHTML = (Math.round(json[1].gp_livesellprice_gm * 100) / 100).toFixed(3); 146 document.getElementById("gp_livesellprice_gm_mobile").innerHTML = json[1].gp_livesellprice_gm.toFixed(3); 147 148 } 149 150 if(gp_livesellprice_tael > oldsellrmtael){ 151 document.getElementById("iconliveselltael").style.color = "#1ac69c"; 152 document.getElementById("iconliveselltael").className = "fa fa-long-arrow-up"; 153 document.getElementById("gp_livesellprice_tael").style.color = "#1ac69c"; 154 document.getElementById("gp_livesellprice_tael_mobile").style.color = "#1ac69c"; 155 document.getElementById("gp_livesellprice_tael").innerHTML = (Math.round(json[1].gp_livesellprice_tael * 100) / 100).toFixed(0); 156 document.getElementById("gp_livesellprice_tael_mobile").innerHTML = (Math.round(json[1].gp_livesellprice_tael * 100) / 100).toFixed(0); 157 } 158 if(gp_livesellprice_tael < oldsellrmtael){ 159 document.getElementById("iconliveselltael").style.color = "red"; 160 document.getElementById("iconliveselltael").className = "fa fa-long-arrow-down"; 161 document.getElementById("gp_livesellprice_tael").style.color = "red"; 162 document.getElementById("gp_livesellprice_tael_mobile").style.color = "red"; 163 document.getElementById("gp_livesellprice_tael").innerHTML = (Math.round(json[1].gp_livesellprice_tael * 100) / 100).toFixed(0); 164 document.getElementById("gp_livesellprice_tael_mobile").innerHTML = (Math.round(json[1].gp_livesellprice_tael * 100) / 100).toFixed(0); 165 } 166 167 if(gp_livesellprice_tael == oldsellrmtael){ 168 document.getElementById("iconliveselltael").className = ""; 169 document.getElementById("gp_livesellprice_tael").style.color = "black"; 170 document.getElementById("gp_livesellprice_tael_mobile").style.color = "black"; 171 document.getElementById("gp_livesellprice_tael").innerHTML = (Math.round(json[1].gp_livesellprice_tael * 100) / 100).toFixed(0); 172 document.getElementById("gp_livesellprice_tael_mobile").innerHTML = (Math.round(json[1].gp_livesellprice_tael * 100) / 100).toFixed(0); 173 } 174 175 176 //console.log(oldbuy); 177 178 179 180 181 182 183 184 185 186 187 }else{ 188 if(json[0]=='tradeopen' && json[1]=='false'){ 189 document.getElementById("tradeopen").innerHTML = 'CLOSE'; 190 document.getElementById("tradeopen").style.color = "#e21c3f"; 191 document.getElementById("tradeopen-mobile").style.color = "#e21c3f"; 192 document.getElementById("tradeopen-mobile").innerHTML = 'CLOSE'; 193 }else if(json[0]=='tradeopen' && json[1]=='true'){ 194 document.getElementById("tradeopen").innerHTML = 'OPEN'; 195 document.getElementById("tradeopen").style.color = "#198754"; 196 document.getElementById("tradeopen-mobile").style.color = "#198754"; 197 document.getElementById("tradeopen-mobile").innerHTML = 'OPEN'; 198 }else{ 199 if(json[1].gp_createDate != null){ 200 //document.getElementById("datepricefeed").innerHTML = json[1].gp_createDate; 201 //document.getElementById("datepricefeed-mobile").innerHTML = json[1].gp_createDate; 202 203 } 204 } 205 206 207 } 208 209 } catch (error) { 210 211 } 212 }); 213 214 socket.addEventListener('close', (event) => { 215 // console.log('WebSocket connection closed'); 216 setTimeout(connect, 100); // try to reconnect after 1 second 217 }); 218} 219 220connect();
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.