Ver código fonte

[phr] 진료관리 상황판 - 갱신 주기 localStorage 저장.

sjpark 4 anos atrás
pai
commit
3dd991769f
1 arquivos alterados com 51 adições e 15 exclusões
  1. 51 15
      src/main/webapp/WEB-INF/jsp/clinic/state.jsp

+ 51 - 15
src/main/webapp/WEB-INF/jsp/clinic/state.jsp

@@ -9,9 +9,29 @@
 var totalList = ${total}; // 저장된 데이터 항목 수
 var viewEntry = 30;		// 한 화면에 표시되는 갯수 
 var totalPage = Math.ceil(totalList / viewEntry);
-var reloadIntervalTime = 30;	// 
 var reloadTimer = null;
 
+function getReloadIntervalTime() {
+	// console.log("getReloadIntervalTime");
+	return localStorage.getItem('reloadIntervalTime') || "30";
+}
+
+function setReloadIntervalTime(value) {
+	// console.log("setReloadIntervalTime" + value);
+	localStorage.setItem('reloadIntervalTime', value);
+}
+
+// function getPlayOnOff() {
+// 	console.log("getPlayOnOff");
+// 	console.log(localStorage.getItem('isPlaying'));
+// 	return localStorage.getItem('isPlaying') || "off";
+// }
+
+// function setPlayOnOff(value) {
+// 	console.log("setPlayOnOff" + value);
+// 	localStorage.setItem('isPlaying', value);
+// }
+
 function ajaxErrorHandler(request, status, error){
 	if (request.status === 0) {
         alert('Not connect.\n Verify Network.');
@@ -49,25 +69,21 @@ function ajaxErrorHandler(request, status, error){
 }
 
 function changeReloadInterval() {
-	reloadIntervalTime = $("#reloadIntervalSelect option:selected").val();
+	var value = $("#reloadIntervalSelect option:selected").val();
+
+	setReloadIntervalTime(value);
 }
 
 function activeReloadTimer() {	
-	if (reloadIntervalTime) {
-		if (reloadTimer) {
-			deactiveReloadTimer();
-		}
-		
-		reloadTimer = setInterval(function() {
+	if (reloadTimer) {
+		deactiveReloadTimer();
+	}
+	
+	reloadTimer = setInterval(function() {
 			nextPage();
-		}, reloadIntervalTime * 1000);
+	}, getReloadIntervalTime() * 1000);
 
-		return true;
-	}
-	else {
-		
-		return false;
-	}
+	return true;
 }
 
 function deactiveReloadTimer() {	
@@ -192,6 +208,22 @@ function responsiblePagination() {
 
 $(document).ready(function() {
 
+	$("#reloadIntervalSelect").val(getReloadIntervalTime());
+
+	// if (getPlayOnOff() === "on") {
+	// 	if (activeReloadTimer()) {	
+	// 		$(".playPause").attr('id','pauseButton');
+	// 		$(".playPause").find('i').removeClass('fa-play').addClass('fa-pause');
+	// 		$('#reloadIntervalSelect').prop('disabled',true);
+	// 	}
+	// }
+	// else {
+	// 	deactiveReloadTimer();
+	// 	$(".playPause").attr('id','playButton');
+	// 	$(".playPause").find('i').removeClass('fa-pause').addClass('fa-play');
+	// 	$('#reloadIntervalSelect').prop('disabled',false);
+	// }
+
 	$(document).on("click", ".patients-stats", function() {
 		var searchText = '<c:out value="${searchText}" />';
 		var currentPage = $("#pagination .active").children("a").text();
@@ -211,6 +243,8 @@ $(document).ready(function() {
           	$(this).attr('id','pauseButton');
           	$(this).find('i').removeClass('fa-play').addClass('fa-pause');
           	$('#reloadIntervalSelect').prop('disabled',true);
+
+						// setPlayOnOff("on");
     	  }
        }
        else if(thisID == 'pauseButton'){
@@ -218,6 +252,8 @@ $(document).ready(function() {
           $(this).attr('id','playButton');
           $(this).find('i').removeClass('fa-pause').addClass('fa-play');
           $('#reloadIntervalSelect').prop('disabled',false);
+
+					// setPlayOnOff("off");
        }
     });