You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

207 lines
5.6 KiB
JavaScript

//**Review 保存js函数*******
//* savereview()
//*****//
var ajaxlogin = false;
function savereview(whereP){
$.ajax({
type: "POST",
url: "/community/userdo.asp?ac=usercomm&whereP="+whereP,
data: $("#writepreview").serialize(),
dataType:"xml",
beforeSend: function(){
// Handle the beforeSend event
// jQuery.facebox('Please wait.....');
},
success: function(html){
var statu = $(html).find("statu").text();
var nowid = $(html).find("nowid").text();
var message = $(html).find("message").text();
var ResultScript = $(html).find("ResultScript").text();
changeVC();
alert(message);
$("#reviewbody").val("Write your review here...");
//document.writepreview.reset(); //重置表单
switch(statu){
case "0":
//景点详细页
$("#commentTopThereList").prepend($(ResultScript));
$("#commentTopThereList li").each(function(i){
$(this).attr("className","bg-"+(i+1));
if(i == 2 ){$(this).addClass("last");}
if(i>2){$(this).remove();}
});
break;
case "1":
$("div .speech").eq(0).before($(ResultScript)).end();
scroller('focusInput',100);
break;
case "2":
break;
case "3":
break;
}
}
});
}
//信息页面添加评论 2009-08-17 ycc
//MainID 信息ID
//MainName 资源名字
//MainType 资源类型
/// Last modified by IMT 08 30.
function SendCommentForInfo(MainID,MainName,MainType){
var CommentError=document.getElementById('CommentError'),CommentContent=document.getElementById('CommentContent'),CommentUserName=document.getElementById('CommentUserName'),CommentPassWord=document.getElementById('CommentPassWord'),ResultData,conEv,uName,uPass;
if(CommentContent) conEv = CommentContent.value;
if(CommentUserName)
{
uName = CommentUserName.value;
}
else
{
uName ='';
}
if(CommentPassWord)
{
uPass = CommentPassWord.value;
}
else
{
uPass ='';
}
ResultData=savereview(uName,uPass,MainName,MainType,MainID,conEv);
if (ResultData=='no') {
CommentError.innerHTML='<em>Logon false!</em>';
}else{
window.location.reload();
}
}
function ajaxsavereview(whereP){
if(!ajaxlogin){ajaxlogin = isLogin();}
if($("#reviewbody").val() == "" || $("#reviewbody").val().length < 10){
alert("A minimum of 10 letters is requried.");return false;
}
if (ajaxlogin){
}else{
if( !$("#checkbox1").attr("checked") ){
alert("Please login !");return false;
}
if(! isEmail($("#uEmail").val()) ){
alert("The email you entered is not valid!");return false;
}
if($("#userName").val() == "" || $("#userName").val() == "User Name"){
alert("Write you name please!");return false;
}
if($("#verifycode").val() == "" || $("#verifycode").val().length != 4){
alert("Incorrect Verification Code!");return false;
}
}
savereview(whereP);
return;
}
function isEmail(strEmail) {
re=/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
if (re.test(strEmail))
return true;
else
return false;
}
function showloginSpan(o){
if(o.checked){
$('#nologinform').show();
changeVC();
}else{
$('#nologinform').hide();
$("#vcIMG").attr("src","/pic/ajax-loader-1.gif");
}
}
function changeVC(){
$("#vcIMG").attr("src","/community/getcode.asp?rand="+Math.random());
}
// 转换为数字
function intval(v)
{
v = parseInt(v);
return isNaN(v) ? 0 : v;
}
// 获取元素信息
function getPos(e)
{
var l = 0;
var t = 0;
var w = intval(e.style.width);
var h = intval(e.style.height);
var wb = e.offsetWidth;
var hb = e.offsetHeight;
while (e.offsetParent){
l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
t += e.offsetTop + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
e = e.offsetParent;
}
l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
t += e.offsetTop + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
}
// 获取滚动条信息
function getScroll()
{
var t, l, w, h;
if (document.documentElement && document.documentElement.scrollTop) {
t = document.documentElement.scrollTop;
l = document.documentElement.scrollLeft;
w = document.documentElement.scrollWidth;
h = document.documentElement.scrollHeight;
} else if (document.body) {
t = document.body.scrollTop;
l = document.body.scrollLeft;
w = document.body.scrollWidth;
h = document.body.scrollHeight;
}
return { t: t, l: l, w: w, h: h };
}
// 锚点(Anchor)间平滑跳转
function scroller(el, duration)
{
if(typeof el != 'object') { el = document.getElementById(el); }
if(!el) return;
var z = this;
z.el = el;
z.p = getPos(el);
z.s = getScroll();
z.clear = function(){window.clearInterval(z.timer);z.timer=null};
z.t=(new Date).getTime();
z.step = function(){
var t = (new Date).getTime();
var p = (t - z.t) / duration;
if (t >= duration + z.t) {
z.clear();
window.setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
} else {
st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
z.scroll(st, sl);
}
};
z.scroll = function (t, l){window.scrollTo(l, t)};
z.timer = window.setInterval(function(){z.step();},13);
}