Commit 8bea99b0 by swdanielli

javascript code clean

parent dcbb8263
...@@ -727,8 +727,8 @@ class RecommenderXBlock(XBlock): ...@@ -727,8 +727,8 @@ class RecommenderXBlock(XBlock):
data['recommendations'] = self.recommendations data['recommendations'] = self.recommendations
tracker.emit('import_resources', {'Status': 'SUCCESS', 'data': data}) tracker.emit('import_resources', {'Status': 'SUCCESS', 'data': data})
response.body = json.dumps(data, sort_keys=True)
response.headers['Content-Type'] = 'application/json' response.headers['Content-Type'] = 'application/json'
response.body = json.dumps(data, sort_keys=True)
response.status = 200 response.status = 200
return response return response
except: except:
......
...@@ -86,30 +86,30 @@ ...@@ -86,30 +86,30 @@
elsewhere, please add it. elsewhere, please add it.
</div> </div>
% for elem in resources: % for elem in resources:
<% <%
if elem['id'] in endorsed_recommendation_ids: if elem['id'] in endorsed_recommendation_ids:
endorse_mode = 'endorsed' endorse_mode = 'endorsed'
endorsed_index = endorsed_recommendation_ids.index(elem['id']) endorsed_index = endorsed_recommendation_ids.index(elem['id'])
endorsed_reason = endorsed_recommendation_reasons[endorsed_index] endorsed_reason = endorsed_recommendation_reasons[endorsed_index]
else: else:
endorse_mode = '' endorse_mode = ''
endorsed_reason = '' endorsed_reason = ''
if elem['id'] in downvoted_ids:
vote_mode = "downvoting"
elif elem['id'] in upvoted_ids:
vote_mode = 'upvoting'
else:
vote_mode = ''
if elem['id'] in flagged_ids: if elem['id'] in downvoted_ids:
flag_mode = 'problematic' vote_mode = "downvoting"
reason = flagged_reasons[flagged_ids.index(elem['id'])] elif elem['id'] in upvoted_ids:
else: vote_mode = 'upvoting'
flag_mode = '' else:
reason = '' vote_mode = ''
%>
<%include file="resourcebox.html" args="id=elem['id'],title=elem['title'],votes=elem['votes'],url=elem['url'],description=elem['description'],descriptionText=elem['descriptionText'],isProblematic=flag_mode,problematicReason=reason,voteMode=vote_mode,endorseMode=endorse_mode,endorsedReason=endorsed_reason" /> if elem['id'] in flagged_ids:
flag_mode = 'problematic'
reason = flagged_reasons[flagged_ids.index(elem['id'])]
else:
flag_mode = ''
reason = ''
%>
<%include file="resourcebox.html" args="id=elem['id'],title=elem['title'],votes=elem['votes'],url=elem['url'],description=elem['description'],descriptionText=elem['descriptionText'],isProblematic=flag_mode,problematicReason=reason,voteMode=vote_mode,endorseMode=endorse_mode,endorsedReason=endorsed_reason" />
% endfor % endfor
</div> </div>
<div class="resourceAddButton" role="button" tabindex="0">Add new resource &gt;&gt;</div> <div class="resourceAddButton" role="button" tabindex="0">Add new resource &gt;&gt;</div>
......
...@@ -9,8 +9,8 @@ function RecommenderXBlock(runtime, element) { ...@@ -9,8 +9,8 @@ function RecommenderXBlock(runtime, element) {
$('.configSubmit').click(function() { $('.configSubmit').click(function() {
var data = {}; var data = {};
data['DISABLE_DEV_UX'] = $('.developedUXDisable').val() == 'true'; data['DISABLE_DEV_UX'] = $('.developedUXDisable').val() == 'true';
data['ENTRIES_PER_PAGE'] = parseInt($('.entriesPerPage').val()); data['ENTRIES_PER_PAGE'] = parseInt($('.entriesPerPage').val(), 10);
data['PAGE_SPAN'] = parseInt($('.pageSpan').val()); data['PAGE_SPAN'] = parseInt($('.pageSpan').val(), 10);
data['INTRO_ENABLE'] = $('.introEnable').val() == 'true'; data['INTRO_ENABLE'] = $('.introEnable').val() == 'true';
$.ajax({ $.ajax({
......
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