MediaWiki:LipoqualityGet.js
From Metabolomics.JP
(Difference between revisions)
(Created page with "var gAllData = null; // GoogleDocから全データを取得する(最初の一回だけ) function retrieveAllDataFromGoogleDoc() { var url = 'https://script.google.com/macr...") |
|||
| Line 23: | Line 23: | ||
{ | { | ||
// var files = ["Cell_Nontarget-Cell_3T_Wild_N.txt", "Cell_Nontarget-Cell_3T_Wild_P.txt"]; | // var files = ["Cell_Nontarget-Cell_3T_Wild_N.txt", "Cell_Nontarget-Cell_3T_Wild_P.txt"]; | ||
| − | var url = '/ | + | var url = 'http://' + location.hostname + '/lipodata/json.txt';//allData.php'; |
var xmlHttpRequest = new XMLHttpRequest(); | var xmlHttpRequest = new XMLHttpRequest(); | ||
Revision as of 09:05, 25 October 2018
var gAllData = null;
// GoogleDocから全データを取得する(最初の一回だけ)
function retrieveAllDataFromGoogleDoc()
{
var url = 'https://script.google.com/macros/s/AKfycbxW5WpkJH0PUmmLrMtrluvkaKmz0OTTfeBucudy5-LxalQ7vus/exec?q=all&callback=hasAllDataRetrievedFromGoogleDoc';
var jsonp = document.createElement('script');
jsonp.src = url;
document.head.appendChild(jsonp);
}
function hasAllDataRetrievedFromGoogleDoc(jsonp)
{
var result = jsonp;
// データを整形し、gAllDataへ渡す。
}
// テキストデータから全データを取得する(最初の一回だけ)
// param callback - データ取得完了時に呼び出すコールバック関数
// return なし
function retrieveAllDataFromText(callback)
{
// var files = ["Cell_Nontarget-Cell_3T_Wild_N.txt", "Cell_Nontarget-Cell_3T_Wild_P.txt"];
var url = 'http://' + location.hostname + '/lipodata/json.txt';//allData.php';
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.onreadystatechange = function()
{
var READYSTATE_COMPLETED = 4;
if(this.readyState == READYSTATE_COMPLETED){
var HTTP_STATUS_OK = 200;
if(this.status == HTTP_STATUS_OK) {
// success
gAllData = JSON.parse(this.response);
callback(callback);
} else {
// error
console.log('Retrieve data failed. ' + this.status + ':' + this.statusText + "/" + this.readyState);
}
}
}
// AJAXを使用して、全データを取得する
xmlHttpRequest.open('GET', url, true);
xmlHttpRequest.responseType = 'text';
xmlHttpRequest.send(null);
}