Skip to content

Instantly share code, notes, and snippets.

@sakunyo
Last active December 20, 2015 10:59
Show Gist options
  • Save sakunyo/6119245 to your computer and use it in GitHub Desktop.
Save sakunyo/6119245 to your computer and use it in GitHub Desktop.
event.accelerationIncludingGravity のテスト
// Karma configuration
// Generated on Wed Jul 31 2013 11:47:28 GMT+0900 (JST)
// base path, that will be used to resolve files and exclude
basePath = '';
// list of files / patterns to load in the browser
files = [
MOCHA,
MOCHA_ADAPTER,
'karma.runner.js',
'node_modules/chai/chai.js',
'script.js'
];
// list of files to exclude
exclude = [
];
// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters = ['progress'];
// web server port
port = 9876;
// cli runner port
runnerPort = 9100;
// enable / disable colors in the output (reporters and logs)
colors = true;
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;
// enable / disable watching file and executing tests whenever any file changes
autoWatch = true;
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['Chrome', 'PhantomJS'];
// If browser does not capture in given timeout [ms], kill it
captureTimeout = 60000;
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;
/**
* Date: 2013-07-31
*/
(function () {
var html = [];
html.push("<pre>\
window.addEventListener(\"devicemotion\", function(event){\n\
var gravity;\n\
gravity = event.accelerationIncludingGravity;\n\
gravity.x;\n\
gravity.y;\n\
gravity.z;\n\
);</pre>");
html.push('<div id="log" style="color:red;"></div>');
document.write(html.join("\n"));
})();
{
"name": "test.Acceleration",
"version": "0.0.0",
"description": "",
"main": "",
"scripts": {
"test": ""
},
"repository": "",
"author": "",
"license": "BSD",
"devDependencies": {
"chai": "*"
}
}
var app = {};
(function (app) {
var log, floatNth;
floatNth = function (_float, nth) {
var regexp = new RegExp('([\\d].[\\d]{' + nth + '})[\\d]*');
return parseFloat(_float.toString().replace(regexp, '$1'));
};
log = document.querySelector("#log");
window.addEventListener("devicemotion", function (event) {
var gravity, html;
gravity = event.accelerationIncludingGravity;
html = [
"Gravity.x :",
floatNth(gravity.x, 2),
"Gravity.y :",
floatNth(gravity.y, 2),
"Gravity.z :",
floatNth(gravity.z, 2)
];
log.innerHTML = html.join("<br>\n");
}, false);
console.log("launch.");
})(app);
//@ sourceMappingURL=script.js.map
{"version":3,"file":"script.js","sources":["script.ts"],"names":["",".floatNth",""],"mappings":"AAIA,IAAI,GAAG,GAAG,EAAE,CAAC;;AAEb,CAAC,UAAU,GAAG;IAEZA,IAAIA,GAAGA,EAAEA,QAAQA,CAACA;;IAElBA,QAAQA,GAAGA,UAAUA,MAAaA,EAAEA,GAAUA;QAC5CC,IAAIA,MAAMA,GAAGA,IAAIA,MAAMA,CAACA,eAAeA,GAAGA,GAAGA,GAAGA,UAAUA,CAAAA,CAAEA;;QAE5DA,OAAOA,UAAUA,CAACA,MAAMA,CAACA,QAAQA,EAACA,CAAEA,OAAOA,CAACA,MAAMA,EAAEA,IAAIA,CAAAA,CAACA,CAAEA;IAC7DA,CAACA,CAACD;;IAGFA,GAAGA,GAAGA,QAAQA,CAACA,aAAaA,CAACA,MAAMA,CAAAA,CAAEA;;IAErCA,MAAMA,CAACA,gBAAgBA,CAACA,cAAcA,EAAEA,UAACA,KAASA;QAChDE,IAAIA,OAAOA,EAAEA,IAAIA,CAACA;;QAElBA,OAAOA,GAAGA,KAAKA,CAACA,4BAA4BA,CAACA;QAC7CA,IAAIA,GAAGA;YACLA,aAAaA;YAAEA,QAAQA,CAACA,OAAOA,CAACA,CAACA,EAAEA,CAACA,CAAAA;YACpCA,aAAaA;YAAEA,QAAQA,CAACA,OAAOA,CAACA,CAACA,EAAEA,CAACA,CAAAA;YACpCA,aAAaA;YAAEA,QAAQA,CAACA,OAAOA,CAACA,CAACA,EAAEA,CAACA,CAAAA;SACrCA,CAACA;QACFA,GAAGA,CAACA,SAASA,GAAGA,IAAIA,CAACA,IAAIA,CAACA,QAAQA,CAAAA,CAAEA;IACtCA,CAACA,EAAEF,KAAKA,CAAAA,CAAEA;;IAEVA,OAAOA,CAACA,GAAGA,CAACA,SAASA,CAAAA,CAAEA;AAEzBA,CAACA,CAAC,CAAC,GAAG,CAAA,CAAE"}
/**
* Date: 2013-07-31
*/
var app = {};
(function (app) {
var log, floatNth;
floatNth = function (_float:number, nth:number):number {
var regexp = new RegExp('([\\d].[\\d]{' + nth + '})[\\d]*');
return parseFloat(_float.toString().replace(regexp, '$1'));
};
log = document.querySelector("#log");
window.addEventListener("devicemotion", (event:any)=> {
var gravity, html;
gravity = event.accelerationIncludingGravity;
html = [
"Gravity.x :", floatNth(gravity.x, 2),
"Gravity.y :", floatNth(gravity.y, 2),
"Gravity.z :", floatNth(gravity.z, 2)
];
log.innerHTML = html.join("<br>\n");
}, false);
console.log("launch.");
})(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment