Fix lint issues with gist saving

This commit is contained in:
Berkeley Martinez
2015-11-06 17:48:17 -08:00
parent 13a505cf23
commit 328e75812a
2 changed files with 41 additions and 28 deletions

View File

@ -300,34 +300,49 @@ $(document).ready(function() {
}
var request = createCORSRequest('post', 'https://api.github.com/gists');
if (request) {
if (!request) {
return null;
}
request.onload = function() {
if (request.readyState === 4 &&
if (
request.readyState === 4 &&
request.status === 201 &&
request.statusText === 'Created') {
gistWindow.location.href = JSON.parse(request.responseText)['html_url'];
request.statusText === 'Created'
) {
gistWindow.location.href =
JSON.parse(request.responseText)['html_url'];
}
};
var description = common.username ?
'http://www.freecodecamp.com/' + common.username + ' \'s s' :
'S';
var data = {
description: (username ? 'http://www.freecodecamp.com/' + username +
' \'s s' : 'S') + 'olution for ' + (challenge_Name || challengeName),
description: description + 'olution for ' + common.challengeName,
public: true,
files: {}
},
queryIssue = window.location.href.toString().split('#?')[0],
filename = queryIssue
};
var queryIssue = window.location.href.toString().split('#?')[0];
var filename = queryIssue
.substr(queryIssue.lastIndexOf('challenges/') + 11)
.replace('/', '') + '.js';
data['files'][filename] = {
content: '// ' + (challenge_Name || challengeName) + '\n' +
(username ? '// Author: @' + username + '\n' : '') +
'// Challenge: ' + queryIssue + '\n' +
data.files[filename] = {
content: '// ' +
common.challengeName +
'\n' +
(common.username ? '// Author: @' + common.username + '\n' : '') +
'// Challenge: ' +
queryIssue +
'\n' +
'// Learn to Code at Free Code Camp (www.freecodecamp.com)' +
'\n\n' + editor.getValue().trim()
'\n\n' +
window.editor.getValue().trim()
};
request.send(JSON.stringify(data));
}
});
$('#help-ive-found-a-bug-wiki-article').unbind('click');

View File

@ -125,9 +125,7 @@ block content
common.dashedName = !{JSON.stringify(dashedName)};
common.started = Math.floor(Date.now());
if (user) {
common.username = !{JSON.stringify(user.username)};
}
common.username = !{JSON.stringify(user && user.username || '')};
include ../partials/challenge-footer
script.