MediaWiki:LipoqualityGet.js

Revision as of 01:43, 23 March 2020 by Jcblmaster (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, 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 / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// Last-update: 2020/01/30
var gAllData = null;
var gListData = 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);
}

// テキストデータから全データを取得する(最初の一回だけ)
// param callback - データ取得完了時に呼び出すコールバック関数
// return なし
function retrieveSelectionList(callback)
{
//	var files = ["Cell_Nontarget-Cell_3T_Wild_N.txt", "Cell_Nontarget-Cell_3T_Wild_P.txt"];
	var url = 'http://' + location.hostname + '/lipodata/list.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
				gListData = JSON.parse(this.response);
				callback(callback);
			} else {
				// error
				console.log('Retrieve list failed. ' + this.status + ':' + this.statusText + "/" + this.readyState);
			}
		}
	}

	// AJAXを使用して、全データを取得する
	xmlHttpRequest.open('GET', url, true);
	xmlHttpRequest.responseType = 'text';
	xmlHttpRequest.send(null);
}