コード.gs
function doGet() { return HtmlService.createHtmlOutputFromFile("index"); } |
意訳この機能がやること 指定したHTMLファイルを表示する |
index.html
<!DOCTYPE html> <html> <body> <label>X</label><input type="text" id="movedX" value=0> <br> <label>Y</label><input type="text" id="movedY" value=0> <br> <label id="rightLeft"></label> <br> <label id="upDown"></label> <script> window.onmousemove = mouseMoved; function mouseMoved(e) { elem("movedX").value = e.movementX; elem("movedY").value = e.movementY; let rightLeft; if(e.movementX > 0) { rightLeft = "right"; } else { rightLeft = "left"; } let upDown; if(e.movementY > 0) { upDown = "down"; } else { upDown = "up"; } elem("rightLeft").textContent = rightLeft; elem("upDown").textContent = upDown; } function elem(id) { return document.getElementById(id); } </script> </body> </html> |