1console.log("start"); 2 3let gps_lat = 0.0; 4let gps_lng = 0.0; 5let gps_update_time = null; 6let id_timeout = null; 7export let baseuri = "/gsm_location/location_ajax/" 8 9async function post_postition(){ 10 console.log(gps_lat + " : " + gps_lng); 11 let h_apikey = document.getElementById('apikey'); 12 let s_apikey = h_apikey.value; 13 console.log(s_apikey); 14 15 try { 16 const response = await post(baseuri + 'post_location', { body: {apikey:s_apikey, latitude: gps_lat, longitude: gps_lng, gps_update_time: gps_update_time} }) 17 18 if (response.ok) { 19 console.log("response OK") 20 } else { 21 console.log("response NG") 22 } 23 } catch(e) { 24 console.log(e); 25 } 26} 27 28function setLocation(pos){ 29 // 緯度ã»çµåº¦ãåå¾ 30 gps_lat = pos.coords.latitude; 31 gps_lng = pos.coords.longitude; 32 gps_update_time = Date.now()/1000.0; 33 post_postition(); 34} 35 36// ã¨ã©ã¼æã«å¼ã³åºããã颿° 37export function logErr(err){ 38 switch(err.code) { 39 case 1 : 40 console.log("PERMISSION_DENIED"); 41 break; 42 case 2 : 43 console.log("POSITION_UNAVAILABLE"); 44 break; 45 case 3 : 46 console.log("TIMEOUT"); 47 break; 48 default : 49 console.log(err.message); 50 } 51} 52 53// geolocation ã«å¯¾å¿ãã¦ãããå¦ããç¢ºèª 54if("geolocation" in navigator){ 55 let opt = { 56 "enableHighAccuracy": true, 57 "timeout": 10000, 58 "maximumAge": 10000, 59 }; 60 navigator.geolocation.getCurrentPosition(setLocation, logErr, opt); 61 /* 62 let tm = 30*1000; 63 id_timeout = setTimeout( function(e) { 64 id_gps = navigator.geolocation.watchPosition( setLocation, logErr, opt) 65 }, tm); 66 */ 67 const tm = 30*1000; 68 id_timeout = setInterval( function(e) { 69 navigator.geolocation.getCurrentPosition(setLocation, logErr, opt); 70 }, tm); 71} 72 73function dailog_confirm(message){ 74 message = 'éå§ãã¾ããï¼'; 75 if(window.confirm(message)){ 76 return true; 77 } else { 78 return false; 79 } 80} 81 82// document.getElementById('to_drive').setAttribute('onclick', dailog_confirm('å®è¡ãã¾ããï¼')); 83let to_drive = document.getElementById('to_drive'); 84if(to_drive) { 85 to_drive.onclick = dailog_confirm; 86} 87 88import {post} from "@rails/request.js";
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.