diff --git a/ecs/jskult-webapp/src/static/function/businessLogicScript.js b/ecs/jskult-webapp/src/static/function/businessLogicScript.js index 56d971e4..6f67cba6 100644 --- a/ecs/jskult-webapp/src/static/function/businessLogicScript.js +++ b/ecs/jskult-webapp/src/static/function/businessLogicScript.js @@ -1,3 +1,49 @@ +// ローディング + +/** + * ローディングクラス + * @param {string} loading_elem_id ローディングのHTML要素 + */ +class Loading { + constructor(loadingElemId = '_loading') { + this.loadingElemId = loadingElemId; + // ロード中かどうか + this.isLoading = false; + } + + /** + * ローディングを開始する。
+ * 開始済みの場合と、ローディングの要素が見つからない場合は何もしない。 + */ + start() { + if (this.isLoading) + return; + + const loadingElem = document.getElementById(this.loadingElemId); + + if (loadingElem) { + this.isLoading = true; + loadingElem.style.display = 'block'; + } + } + + /** + * ローディングを停止する。
+ * 開始されていない場合と、ローディングの要素が見つからない場合は何もしない。 + */ + stop() { + if (!this.isLoading) + return; + + const loadingElem = document.getElementById(this.loadingElemId); + + if (loadingElem) { + this.isLoading = false; + loadingElem.style.display = 'none'; + } + } +} + // 検索フォーム // 戻るボタンの関数 diff --git a/ecs/jskult-webapp/src/templates/bioSearchList.html b/ecs/jskult-webapp/src/templates/bioSearchList.html index 6a33c904..cb72d729 100644 --- a/ecs/jskult-webapp/src/templates/bioSearchList.html +++ b/ecs/jskult-webapp/src/templates/bioSearchList.html @@ -195,10 +195,12 @@ - +