html(lang="en")
	head
		include import/_meta.jade
		title Saihu Project
		link(rel="stylesheet", href="./css/saihu.css")
		script(src='./js/js.js')
	body

		include include/_nav.jade

		#saihu.page-intro(data-animsition-in-class="fade-in",data-animsition-out-class='fade-out',data-animsition-in-duration='1000')
			header
				.title Protected : Saihu
				.content This content is password protected.
			main#loginbox
				.box
					.inputbox
						input#password(style='margin: 16px; text-align: center;', type='password', placeholder='password')
					button#loginbutton.animsition-link(type='button') Enter
					span#wrongPassword(style='display: none') wrong password

				.name(style='visibility: hidden;')
					.darkBg
					.lightBg
			#scrolltop
				.scrolllineup
	script(src='https://cdn.rawgit.com/chrisveness/crypto/master/sha1.js')
	script.
		"use strict";
		function loadPage(pwd) {
			var hash= pwd;
			hash= Sha1.hash(pwd);
			var url= hash + "/saihu.html";
			$.ajax({
				url : url,
				dataType : "html",
				success : function(data) {

					window.location= url;

				},
				error : function(xhr, ajaxOptions, thrownError) {
				

					parent.location.hash= hash;

					//$("#wrongPassword").show();
					$("#password").attr("placeholder","wrong password");
					$("#password").val("");
				}
			});
		}

		 
		$("#loginbutton").on("click", function() {
			loadPage($("#password").val());
		});
		$("#password").keypress(function(e) {
			if (e.which == 13) {
				
				loadPage($("#password").val());
			}
		});
		$("#password").focus();