remove auto refresh in origami

This commit is contained in:
Yan
2017-09-07 13:55:40 +06:30
parent a50becb365
commit e9a305b573

View File

@@ -98,13 +98,13 @@
</div> </div>
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>
<!-- tabs - End --> <!-- tabs - End -->
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2"> <div class="col-lg-2 col-md-2 col-sm-2">
<button id="refreshbutton" type="button" class="btn btn-block radius-btn"> Refresh off </button> <!-- <button id="refreshbutton" type="button" class="btn btn-block radius-btn"> Refresh off </button> -->
<button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button> <button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button>
<button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button> <button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
<!-- Temporary Disabled --> <!-- Temporary Disabled -->
@@ -146,72 +146,72 @@ $(document).ready(function(){
}) })
}); });
$(function() { // $(function() {
var timer; // var timer;
function start() { // function start() {
timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 10000); //10000 // timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 10000); //10000
}; // };
function stop() { // function stop() {
clearTimeout(timer); // clearTimeout(timer);
}; // };
if(localStorage.getItem("refreshflag") != null){ // if(localStorage.getItem("refreshflag") != null){
if (localStorage.getItem("refreshflag") == 0) { // if (localStorage.getItem("refreshflag") == 0) {
$('#refreshbutton').html("Refresh off"); // $('#refreshbutton').html("Refresh off");
$('#refreshbutton').css("background-color","red"); // $('#refreshbutton').css("background-color","red");
stop(); // stop();
} // }
else{ // else{
$('#refreshbutton').html("Refresh on"); // $('#refreshbutton').html("Refresh on");
$('#refreshbutton').css("background-color","green"); // $('#refreshbutton').css("background-color","green");
start(); // start();
} // }
} // }
else{ // else{
localStorage.setItem("refreshflag", 0); // localStorage.setItem("refreshflag", 0);
} // }
var url = location.href; // var url = location.href;
if (location.href.slice(-1) == "/"){ // if (location.href.slice(-1) == "/"){
url = url.substring(0, url.length - 1); // url = url.substring(0, url.length - 1);
} // }
var arr = url.split("/"); // var arr = url.split("/");
if(arr[arr.length-1] != "origami"){ // if(arr[arr.length-1] != "origami"){
stop(); // stop();
} // }
$('#refreshbutton').bind("click", function(){ // $('#refreshbutton').bind("click", function(){
if(localStorage.getItem("refreshflag") == "0"){ // if(localStorage.getItem("refreshflag") == "0"){
localStorage.setItem("refreshflag", 1); // localStorage.setItem("refreshflag", 1);
$(this).html("Refresh on"); // $(this).html("Refresh on");
$(this).css("background-color","green"); // $(this).css("background-color","green");
// $(this).html("Auto Refresh on<span class='glyphicon glyphicon-ok'></span>"); // // $(this).html("Auto Refresh on<span class='glyphicon glyphicon-ok'></span>");
start(); // start();
} // }
else{ // else{
stop(); // stop();
localStorage.setItem("refreshflag", 0); // localStorage.setItem("refreshflag", 0);
$(this).html("Refresh off"); // $(this).html("Refresh off");
$(this).css("background-color","red"); // $(this).css("background-color","red");
} // }
}); // });
function refreshing(){ // function refreshing(){
if(localStorage.getItem("refreshflag") == "0"){ // if(localStorage.getItem("refreshflag") == "0"){
localStorage.setItem("refreshflag", 1); // localStorage.setItem("refreshflag", 1);
$(this).html("Refresh on"); // $(this).html("Refresh on");
$(this).css("background-color","green"); // $(this).css("background-color","green");
// $(this).html("Auto Refresh on<span class='glyphicon glyphicon-ok'></span>"); // // $(this).html("Auto Refresh on<span class='glyphicon glyphicon-ok'></span>");
start(); // start();
} // }
else{ // else{
stop(); // stop();
localStorage.setItem("refreshflag", 0); // localStorage.setItem("refreshflag", 0);
$(this).html("Refresh off"); // $(this).html("Refresh off");
$(this).css("background-color","red"); // $(this).css("background-color","red");
} // }
} // }
}); // });
$('#cash_in').on('click',function(){ $('#cash_in').on('click',function(){
window.location.href = '/origami/cash_ins/new'; window.location.href = '/origami/cash_ins/new';