Skip to content

Instantly share code, notes, and snippets.

@andy0130tw
Last active August 29, 2015 14:03
Show Gist options
  • Save andy0130tw/dbeebeabdf8b4d8abc77 to your computer and use it in GitHub Desktop.
Save andy0130tw/dbeebeabdf8b4d8abc77 to your computer and use it in GitHub Desktop.
The frontend of CRSC2014 guestbook for Yu-Ren Pan! (For debugging only)
<!DOCTYPE html>
<html>
<head>
<title>Guestbook Test</title>
<script src="res/js/jquery-1.10.2.min.js"></script>
<script>
$(function(){
$("#gb_form").submit(function(){
$("#gb_submit").attr("disabled","disabled");
sendForm();
return false;
});
$("#gb_admin_form").submit(function(){
$("#gb_admin_submit").attr("disabled","disabled");
sendAdmin();
return false;
});
});
function sendForm(){
var postdata=new FormData();
postdata.append("name",$("#gb_field_name").val());
postdata.append("email",$("#gb_field_email").val());
postdata.append("related",$("#gb_field_related").val());
postdata.append("comment",$("#gb_field_comment").val());
postdata.append("pass",$("#gb_field_pwd").val());
$.ajax({url:"gbapi.php?action=write",
method: "POST",
data: postdata,
processData: false,
contentType: false,
dataType: "json",
success: function(data){
console.log(data);
$("#gb_submit").removeAttr("disabled");
}
});
}
function sendAdmin(){
var postdata=new FormData();
postdata.append("pass",$("#gb_admin_field_pwd").val());
postdata.append("comment",$("#gb_admin_field_comment").val());
$.ajax({url:"gbapi.php?action=hide",
method: "POST",
data: postdata,
processData: false,
contentType: false,
dataType: "json",
success: function(data){
console.log(data);
$("#gb_admin_submit").removeAttr("disabled");
}
});
}
</script>
</head>
<body>
<form id="gb_form">
<div><label>暱稱:<input id="gb_field_name" type="text"/></label></div>
<div><label>電子郵件:<input id="gb_field_email" type="email"/></label></div>
<div><label>回覆串(除錯用):<input id="gb_field_related"/></label></div>
<div><label>密碼:<input id="gb_field_pwd" type="password"/></label></div>
<div><textarea id="gb_field_comment" placeholder="留言..." rows="6"></textarea></div>
<button id="gb_submit" type="submit">送出</button>
</form>
<form id="gb_admin_form">
<div><label>密碼:<input id="gb_admin_field_pwd" type="password"/></label></div>
<div><label>訊息:<input id="gb_admin_field_comment" type="text"/></label></div>
<button id="gb_admin_submit" type="submit">送出</button>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment