This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ heroku login | |
Enter your Heroku credentials. | |
Email: name@example.com | |
Password: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addEventLink(){ | |
//ドキュメント内のaタグを全て取得 | |
Array.from(document.querySelectorAll("a"), (e) => { | |
//取得した要素(aタグ)にtouchstartイベントを設定(CHIRIMENではマウスイベントはtouchイベントに置き換えられる) | |
e.addEventListener("touchstart",()=>{ | |
}); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// task.js ライブラリ | |
const { spawn, sleep } = task; | |
// document 内のリソースが読み終わるのを待つ | |
document.addEventListener("DOMContentLoaded", () => { | |
// task.js の spawn 関数内では Promise が同期的に記述できる | |
spawn(function() { | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDistance(port,addr){ | |
return new Promise(function(resolve,reject){ | |
spawn(function(){ | |
const slave = yield port.open(addr); | |
yield slave.write8(0x00, 0x00); | |
yield sleep(1); | |
slave.write8(0x00, 0x51); | |
yield sleep(70); | |
const highBit = yield slave.read8(0x02, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scroll(val,min,max){ | |
//ドキュメントの高さを取得 | |
var ch = document.body.scrollHeight; | |
//距離センサの値がmaxより大きい時、何もしない | |
if(val > max){ | |
return; | |
} | |
//距離センサがminより小さいときは、minValの値で固定する | |
if(val < min){ | |
val = min; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scroll(val,min,max){ | |
//ドキュメントの高さを取得 | |
var ch = document.body.scrollHeight; | |
//値がmaxより大きい時、何もしない | |
if(val > max){ | |
return; | |
} | |
//値がminより小さいときは、minの値で固定する | |
if(val < min){ | |
val = min; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Lチカ用にLEDポートのためのグローバル変数を定義 | |
var ledPort; | |
// task.js ライブラリ | |
const { spawn, sleep } = task; | |
// document 内のリソースが読み終わるのを待つ | |
document.addEventListener("DOMContentLoaded", () => { | |
// task.js の spawn 関数内では Promise が同期的に記述できる | |
spawn(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Lチカ用にLEDポートのためのグローバル変数を定義 | |
var ledPort; | |
// task.js ライブラリ | |
const { spawn, sleep } = task; | |
// document 内のリソースが読み終わるのを待つ | |
document.addEventListener("DOMContentLoaded", () => { | |
// task.js の spawn 関数内では Promise が同期的に記述できる | |
spawn(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Lチカ用にLEDポートのためのグローバル変数を定義 | |
var ledPort; | |
// task.js ライブラリ | |
const { spawn, sleep } = task; | |
// document 内のリソースが読み終わるのを待つ | |
document.addEventListener("DOMContentLoaded", () => { | |
// task.js の spawn 関数内では Promise が同期的に記述できる | |
spawn(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRandomWiki(){ | |
//jqueryの関数を利用して、JSONPでwikipediaの記事タイトルをランダムで取得する。 | |
$.ajax({ | |
type: "get", | |
dataType: "jsonp", | |
url: "https://ja.wikipedia.org/w/api.php?action=query&list=random&rnnamespace=0&rnlimit=1&format=json", | |
//記事タイトルの取得が成功した時の処理 | |
success: function(json) { | |
//取得したjsonデータ中の記事タイトルを抽出 | |
var title = json.query.random[0].title; |
OlderNewer