depedborongancitydivision-sgod.com Open in urlscan Pro
46.21.149.90  Public Scan

Submitted URL: http://depedborongancitydivision-sgod.com/js/logic.js
Effective URL: https://depedborongancitydivision-sgod.com/js/logic.js
Submission: On August 21 via api from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

jQuery(document).ready(function($) {

		$("#invalid").hide();
		$("#error").hide();

	  	/**  YOUR SCRIPT HERE  **/
	  	
	  	loadCarouselImages()
	  	    .done((result) => {
	  	        if (result.images.length > 0) {
	  	            
	  	            var images = "";
	  	            var img_texts = "";
	  	            
	  	            $.each(result.images, (val, key) => {
	  	                is_active = val == 0 ? 'class="is-active"' : ''
	  	                
	  	                images +=   "<li class='orbit-slide'>" + 
	  	                                "<img src='/img/carousel/" + key.img + "' />" + 
                                        "<figcaption class='orbit-caption'>" + key.text + "</figcaption>" + 
                                    "</li>"
                                    
                        img_texts += '<button ' + is_active + ' data-slide="' + val + '"><span class="show-for-sr">' + key.text + '</span><span class="show-for-sr">Current Slide</span></button>'
	  	            })
	  	            
	  	            var carousel = '<div class="orbit" role="region" aria-label="Favorite Space Pictures" data-orbit>' + 
                                        '<ul class="orbit-container" id="slider_full">' + 
                                            '<button class="orbit-previous"><span class="show-for-sr">Previous Slide</span>&#9664;&#xFE0E;</button>' + 
                                            '<button class="orbit-next"><span class="show-for-sr">Next Slide</span>&#9654;&#xFE0E;</button>' + 
                                            images + 
                                        '</ul>' + 
                                        '<nav class="orbit-bullets">' + 
                                            img_texts + 
                                        '</nav>' + 
                                  '</div>'
                                  
                    $("#carousel_images").append(carousel)
                    var elem = new Foundation.Orbit($("#carousel_images"));
	  	            
	  	        }
	  	    })
	  	    .fail((error) => {
	  	        alert("An error has occurred: " + error.responseText)
	  	    })

	  	function authenticateUser() {

	    	var em = $("#myEmail").val();
	    	var pw = $("#myPassword").val();

	  		return $.ajax({
		  		async: true,
		  		url: "../login/authenticate.php",
		  		method: "POST",
		  		dataType: "JSON",
		  		data: {
		  			em: em,
		  			pw: pw
		  		}
		  	});
		}
		
		function authenticateUserPrivate() {
		    var em = $("#myEmail2").val();
	    	var pw = $("#myPassword2").val();

	  		return $.ajax({
		  		async: true,
		  		url: "/login/authenticatePrivate.php",
		  		method: "POST",
		  		dataType: "JSON",
		  		data: {
		  			em: em,
		  			pw: pw
		  		}
		  	});
		}
		
		function loadCarouselImages() {
		    return $.ajax({
    	        async: true,
    	        url: "../../load_carousel_images.php",
    	        method: "POST",
    	        dataType: "JSON"
    	    });
		}
		
		$(document).on("click", "#btnLoginPrivate", function() {
	        authenticateUserPrivate()
	          .done(function(r) {
	            if(r["status"] == 1) {
	              window.location.href = "/private_school/";
	            } else if(r["status"] == 0) {
	            	$("#myEmail2").focus();
	              	$("#invalid2").show();
	              	$("#error2").text("--");
	              	$("#error2").hide();
	            }
	          })
	          .fail(function(x) {
	            $("#invalid2").hide();
	            $("#error2").text("An error has occurred. " + x.responseText);
	            $("#error2").show();
	          })
	      });

	  	$(document).on("click", "#btnLogin", function() {
	        authenticateUser()
	          .done(function(r) {
	            if(r["status"] == 1) {
	              window.location.href = "../";
	            } else if(r["status"] == 0) {
	            	$("#myEmail").focus();
	              	$("#invalid").show();
	              	$("#error").text("--");
	              	$("#error").hide();
	            }
	          })
	          .fail(function(x) {
	            $("#invalid").hide();
	            $("#error").text("An error has occurred. " + x.responseText);
	            $("#error").show();
	          })
	      });



	$(document).on("click", "#logout", function(e) {
		e.preventDefault();

		if(confirm("Are you sure you want to logout?")) {
			logOutCurrentUser()
				.done(function(r) {
					window.location.replace("login/");
				})
				.fail(function(x) {
					showDBError(x);
				});
		}
	});

	function logOutCurrentUser(){
		return $.ajax({
			async: true,
			url: "/logout.php",
			method: "POST",
			dataType: "JSON"
		});
		
	}
	
	setInterval(function(){
        getFeatureDate()
        .done(function(r) {
            var today = new Date();
            var created = new Date(r.created_on);
            var daysPast = getDaysPast(created, today);
            
            if(daysPast > 15) {
                $("#feedback").append("<label class='label error'>new feature</label>");
            }
            
        })
			.fail(function(x) {
				showDBError(x);
			});
    }, 1000);
			
	function getFeatureDate() {
	    return $.ajax({
	        async: true,
	        url: "checker.php",
	        method: "POST",
	        dataType: "JSON"
	    });
	}
	
	function getDaysPast(from, to) {
	    const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
	    
        const diffDays = Math.round(Math.abs((from - to) / oneDay));
        
        return diffDays;
	}

	function showDBError(x) {
  		$("#error_messages").find("div#save_error").remove();
  		$("#error_messages").append('<div class="row" id="save_error">' +
							              '<div class="medium-12 columns">' +
							                '<div class="callout alert">' +
							                  '<h6 style="color: red; font-weight: bolder">An unexpected error has occurred.</h6>' +
							                  '<span id="fetch_msg" style="color: red; font-style: italic;">' +
							                  	x.responseText + 
							                  '</span>' +
							                '</div>' +
							              '</div>' +
							            '</div>');
  	}

});;