MediaWiki:LipoqualityGet.js

From Jcbl.jp
Revision as of 11:18, 1 December 2017 by Jcblmaster (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences
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);
}
Personal tools