Comment Feature---New

Source: Internet
Author: User

<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<link href= ". /bootstrap-3.3.5-dist/css/bootstrap.css "rel=" stylesheet "/>
<link href= ". /kindeditor-4.1.10/themes/default/default.css "rel=" stylesheet "/>
<script src= ". /bootstrap-3.3.5-dist/js/jquery-1.10.2.min.js "></script>
<script src= ". /bootstrap-3.3.5-dist/js/bootstrap.min.js "></script>
<script src= ". /kindeditor-4.1.10/kindeditor-min.js "></script>
<script src= ". /kindeditor-4.1.10/lang/zh_cn.js "></script>
<style type= "Text/css" >

. Comment {
position:relative;
/*width:330px;*/
padding:10px;
}

. comment. Ke-toolbar {
/*position:absolute;*/
/*bottom:6px;*/
}

. btn_pl {
Display:block;
Float:right;
}
</style>
<body>
<div class= "Container" style= "margin-top:50px" >
<form class= "Form-horizontal" >
<!--<textarea class= "Form-control" rows= "3" id= "PL" ></textarea>-->
<div class= "Row" >
<div class= "comment col-md-10 col-md-offset-1" >
<textarea class= "Form-control" name= "content" id= "PL" > Reply comments </textarea>
<input type= "button" value= "comments" name= "BTN_PL" class= "btn_pl form" style= "margin-top:7px"/>
</div>
</div>
<div class= "Row col-md-11" >
<div class= "col-md-offset-1" style= "margin-top:20px" id= "pls" >
<!--<ul id= "pls" ></ul>-->
</div>
</div>
</form>

</div>
<script type= "Text/javascript" >
var datas = [
{
ID: ' 1 ',
PID: ",
Cont: ' AAA ',
User: ' AAA ',
UserId: ' SDG '
},
{
ID: ' 2 ',
PID: ",
Cont: ' BBB ',
User: ' RTW ',
UserId: ' 213 '
},
{
ID: ' 4 ',
PID: ' 2 ',
Cont: ' DD ',
User: ' DF ',
UserId: ' 1adf4 '
},
{
ID: ' 5 ',
PID: ' 1 ',
Cont: ' EE ',
User: ' DDS ',
UserId: ' 2fa34 '
},
{
ID: ' 3 ',
PID: ' 5 ',
Cont: ' CCC ',
User: ' 123 ',
UserId: ' 123TG4 '
}
]

Kinder Initialization
var editor;
Kindeditor.ready (function (K) {
Editor = k.create (' textarea[name= ' content "] ', {
Resizetype:1,
Allowpreviewemoticons:false,
Allowimageupload:false,
Width: "100%",
Items: [
' Emoticons ', ' image ', ' link '
});

});

$ (function () {
Load comments
$.get ("", "", function (res) {
if ();
for (var i = 0; i < datas.length; i++) {
HTMLText = "<div id=" + datas[i].id + "' style= ' border-bottom:solid #0096ff 1px ' >"
+ Datas[i].cont
+ "<div class= ' col-md-offset-8 ' >"
+ "Comment Person:"
+ "<span class= ' user_pl ' >" + datas[i].user + "</span>"
+ "+ "&nbsp;&nbsp;&nbsp;&nbsp;"
+ "<span class= ' date_pl ' >" + getDate () + "<span/>"
+ "</div>"
+ "<div class= ' col-md-offset-10 ' >"
+ "<a href= ' # ' onclick= ' Replay (this) ' > Reply </a>"
+ "</div>"
+ "<div class= ' hidden ' >"
+ "<form>"
+ "<!--<textarea class= ' Form-control ' rows= ' 3 ' class= ' pl ' ></textarea>-->"
+ "<div class= ' comment ' >"
+ "<textarea class= ' form-control ' name= ' content ' class= ' pl ' > Reply to Comments </textarea>"
+ "<input type= ' button ' value= ' reviews ' name= ' btn_pl ' class= ' btn_pl ' style= ' margin-top:7px ' onclick= '" replayok (This) '/ > "
+ "</div>"
+ "</form>"
+ "</div>"
+ "</div>"

$ ("#pls"). Append (HTMLText);
}
});

Binding Comment Events
$ (". Btn_pl"). Unbind ("click"). Bind ("click", Function () {

if ($ (". Pl"). val () = = "" | | $ (". Pl"). val () = = null) {
Return
}
HTMLText = "<div style= ' border-bottom:solid #0096ff 1px ' >"
+ $ (". Pl"). Val ()
+ "<div class= ' col-md-offset-8 ' >"
+ "Comment Person:"
+ "Admin"
+ "&nbsp;&nbsp;&nbsp;&nbsp;"
+ getDate ()
+ "</div>"
+ "<div class= ' col-md-offset-10 ' >"
+ "<a href= ' # ' onclick= ' Replay (this) ' > Reply </a>"
+ "</div>"
+ "<div class= ' hidden ' >"
+ "<form>"
+ "<!--<textarea class= ' Form-control ' rows= ' 3 ' id= ' pl ' ></textarea>-->"
+ "<div class= ' comment ' >"
+ "<textarea class= ' form-control ' name= ' content ' class= ' pl ' > Reply to Comments </textarea>"
+ "<input type= ' button ' value= ' reviews ' name= ' btn_pl ' class= ' btn_pl ' style= ' margin-top:7px ' onclick= '" replayok (This) '/ > "
+ "</div>"
+ "</form>"
+ "</div>"
+ "</div>"
$ (". Pl"). Append (HTMLText);
});
});
Click the Reply button
Function Replay (t) {
Self = $ (t);
if (Self.parent (). Next (). Hasclass (' hidden ')) {
Self.parent (). Next (). Removeclass ("hidden");
} else {
Self.parent (). Next (). addclass ("hidden");
}

var editor;
Kindeditor.ready (function (K) {
Editor = k.create (' textarea[name= ' content "] ', {
Resizetype:1,
Allowpreviewemoticons:false,
Allowimageupload:false,
Width: "100%",
Items: [
' Emoticons ', ' image ', ' link '
});
Comment Person
user = Self.parent (). Prev (). Children (". User_pl"). Text ();
Comment Person ID
UserId = Self.parent (). Prev (). Children (". UserId"). attr ("value");
Comment Content
Cont = Self.parent (). Parent (). text ();
Comment ID
Contid = Self.parent (). Parent (). attr ("id");
Alert ("Comment person" + user + "---reviewer ID" + userId + "---comment" + cont + "--Comment Content ID" + contid)
});
}

Reply Click OK button
function Replayok (t) {

HTMLText = "<div style= ' border-bottom:solid #0096ff 1px ' >"
+ $ (". Pl"). Val ()
+ "<div class= ' col-md-offset-8 ' >"
+ "Comment Person:"
+ "Admin"
+ "&nbsp;&nbsp;&nbsp;&nbsp;"
+ getDate ()
+ "</div>"
+ "<div class= ' col-md-offset-10 ' >"
+ "<a href= ' # ' onclick= ' Replay (this) ' > Reply </a>"
+ "</div>"
+ "<div class= ' hidden ' >"
+ "<form>"
+ "<!--<textarea class= ' Form-control ' rows= ' 3 ' id= ' pl ' ></textarea>-->"
+ "<div class= ' comment ' >"
+ "<textarea class= ' form-control ' name= ' content ' class= ' pl ' > Reply to Comments </textarea>"
+ "<input type= ' button ' value= ' reviews ' name= ' btn_pl ' class= ' btn_pl ' style= ' margin-top:7px ' onclick= '" replayok (This) '/ > "
+ "</div>"
+ "</form>"
+ "</div>"
+ "</div>"
}

Get current time
function GetDate () {
var d = new Date ()
var vyear = D.getfullyear ()
var Vmon = d.getmonth () + 1
var VDay = D.getdate ()
var h = d.gethours ();
var m = d.getminutes ();
var se = d.getseconds ();
return s = vyear + "-" + (Vmon < 10?) "0" + Vmon:vmon + "-" + (VDay < 10?) "0" + vday:vday) + "" + (H < 10?) 0 "+ h:h) +": "+ (M < 10?) 0 "+ m:m) +": "+ (SE < 10?) 0 "+ se:se);
}
</script>
</body>

Comment Feature---New

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.