Commit 02509671 authored by Baptiste Mouterde's avatar Baptiste Mouterde Committed by ikoalaz
Browse files

comment : fix click issues, add result for score, fix text and button...

comment : fix click issues, add result for score,  fix text and button display, fix answer and scores
parent 5808eeaa
......@@ -98,7 +98,7 @@ function comment_form(id, post_url, reload_url, package_version_id, filename, pa
reload_comments(package_version_id)
}
$("#send" + id).click(function (evt) {
$("#send" + id).bind('click',function (evt) {
evt.preventDefault();
var title = $("#titlei" + id).val();
var type = $("#typei" + id).val();
......@@ -210,28 +210,39 @@ function init_js() {
return jQuery.ajax;
}
function score_result(output,comment_id,result){
$('<div id="score_result'+ comment_id +'">'+result+'</div>').insertAfter(output);
$('#score_result' + comment_id).fadeOut(5000);
}
function comments(id, reload_comment_url, comment_url, score_ajax_url, package_version_id, filename) {
if (init_js()) {
//removing test and non js version
$('.test,.no-js').remove();
$('.debexup ,.debexdown,.answer').show();
$('.optional-js').hide();
$('.answer').show();
}
else {
//this won't work removing the comment side panel, it's sad..
$('.answer,.debexup,.debexdown').remove();
$('.answer').remove();
return false
}
var reload_comments = load_reload(id, package_version_id, reload_comment_url, filename)
$(".answer." + id).click(function () {
//$($("#form" + id).html()).insertAfter($(this).parent().parent().parent().parent())
$(".answer." + id).click(function (evt) {
evt.preventDefault();
$('.optional-js').show();
$('#parent'+id).val(this.value);
var formhtml=$("#form" + id).html();
$('#form'+id).remove()
$("<span id='tempform'>"+formhtml+"</span>").insertAfter($(this).parent().parent().parent().parent())
$("#send" + id).unbind('click');
comment_form(id, comment_url, reload_comment_url, package_version_id, filename, this.value)
$('tempform').remove()
})
$(".debexup." + id).click(function (evt) {
evt.preventDefault();
var comment_id = this.id.match(/\d+/)[0];
var output=$(this).parents()[4];
var comment_id = this.id.split('.')[1];
jQuery.ajax({
type:'POST',
url:score_ajax_url,
......@@ -239,8 +250,12 @@ function comments(id, reload_comment_url, comment_url, score_ajax_url, package_v
// sending a dict to python here
data:{ id:comment_id, value:true},
success:function (result) {
comment_result(result, this.id);
reload_comments(package_version_id)
score_result(output,comment_id,result);
if (!result.indexOf('failure')>=0){
console.log('success!')
reload_comments(package_version_id);
comment_form(id, comment_url, reload_comment_url, package_version_id, filename)
}
},
error:function (xhr, ajaxOptions, thrownError) {
try {
......@@ -256,7 +271,8 @@ function comments(id, reload_comment_url, comment_url, score_ajax_url, package_v
$(".debexdown." + id).click(function (evt) {
evt.preventDefault()
var comment_id = this.id.match(/\d+/)[0];
var comment_id = this.id.split('.')[1];
var output=$(this).parents()[4];
jQuery.ajax({
type:'post',
url:score_ajax_url,
......@@ -264,8 +280,11 @@ function comments(id, reload_comment_url, comment_url, score_ajax_url, package_v
// sending a dict to python here
data:{ id:comment_id, value:false},
success:function (result) {
comment_result(result, this.id);
reload_comments(package_version_id)
score_result(output,comment_id,result);
if (!result.indexOf('failure')>=0){
reload_comments(package_version_id);
comment_form(id, comment_url, reload_comment_url, package_version_id, filename);
}
},
error:function (xhr, ajaxOptions, thrownError) {
try {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment