Commit a89c4d30 by swdanielli

v0.1 + small modification

parent 43717233
...@@ -394,7 +394,7 @@ function RecommenderXBlock(runtime, element) { ...@@ -394,7 +394,7 @@ function RecommenderXBlock(runtime, element) {
}); });
}); });
/* flag problematic resource: TODO */ /* flag problematic resource */
$('.flagResource').click(function() { $('.flagResource').click(function() {
$('.flagSourceBlock').show(); $('.flagSourceBlock').show();
$('.recommender_content').hide(); $('.recommender_content').hide();
...@@ -405,6 +405,7 @@ function RecommenderXBlock(runtime, element) { ...@@ -405,6 +405,7 @@ function RecommenderXBlock(runtime, element) {
var flaggedResourceDiv = $(this).parent().parent(); var flaggedResourceDiv = $(this).parent().parent();
$('.flag_reason').val($(flaggedResourceDiv).find('.recommender_problematicReason').text()); $('.flag_reason').val($(flaggedResourceDiv).find('.recommender_problematicReason').text());
/* record the flagging once user click on the flag button */
if (!$(this).hasClass('problematic')){ if (!$(this).hasClass('problematic')){
data = {}; data = {};
data['resource'] = parseInt($(flaggedResourceDiv).find('.recommender_entryId').text()); data['resource'] = parseInt($(flaggedResourceDiv).find('.recommender_entryId').text());
...@@ -423,6 +424,7 @@ function RecommenderXBlock(runtime, element) { ...@@ -423,6 +424,7 @@ function RecommenderXBlock(runtime, element) {
$('.flag_reason_submit').unbind(); $('.flag_reason_submit').unbind();
$('.unflag_button').unbind(); $('.unflag_button').unbind();
/* record the reason for problematic resource */
$('.flag_reason_submit').click(function() { $('.flag_reason_submit').click(function() {
data = {}; data = {};
data['resource'] = parseInt($(flaggedResourceDiv).find('.recommender_entryId').text()); data['resource'] = parseInt($(flaggedResourceDiv).find('.recommender_entryId').text());
...@@ -433,13 +435,13 @@ function RecommenderXBlock(runtime, element) { ...@@ -433,13 +435,13 @@ function RecommenderXBlock(runtime, element) {
url: flagResourceUrl, url: flagResourceUrl,
data: JSON.stringify(data), data: JSON.stringify(data),
success: function(result) { success: function(result) {
$(flagDiv).addClass('problematic');
$(flaggedResourceDiv).find('.recommender_problematicReason').text(data['reason']); $(flaggedResourceDiv).find('.recommender_problematicReason').text(data['reason']);
backToView(); backToView();
} }
}); });
}); });
/* unflag the resource */
$('.unflag_button').click(function() { $('.unflag_button').click(function() {
data = {}; data = {};
data['resource'] = parseInt($(flaggedResourceDiv).find('.recommender_entryId').text()); data['resource'] = parseInt($(flaggedResourceDiv).find('.recommender_entryId').text());
...@@ -474,6 +476,7 @@ function RecommenderXBlock(runtime, element) { ...@@ -474,6 +476,7 @@ function RecommenderXBlock(runtime, element) {
$('.edit_url').attr('title', 'Type in the hyperlink to the resource'); $('.edit_url').attr('title', 'Type in the hyperlink to the resource');
$('.backToViewButton').attr('title', 'Back to list of related resources'); $('.backToViewButton').attr('title', 'Back to list of related resources');
$('.flag_reason').attr('title', 'Type in the reason why you flag the resource');
if ($('.flagResource').hasClass('problematic')) { $('.flagResource').attr('title', 'Unflag this problematic resource or edit the reason for it'); } if ($('.flagResource').hasClass('problematic')) { $('.flagResource').attr('title', 'Unflag this problematic resource or edit the reason for it'); }
else { $('.flagResource').attr('title', 'Flag this resource as problematic and give the reason' ); } else { $('.flagResource').attr('title', 'Flag this resource as problematic and give the reason' ); }
......
Markdown is supported
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