Fix lint issues with gist saving
This commit is contained in:
@ -300,34 +300,49 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var request = createCORSRequest('post', 'https://api.github.com/gists');
|
var request = createCORSRequest('post', 'https://api.github.com/gists');
|
||||||
if (request) {
|
if (!request) {
|
||||||
request.onload = function() {
|
return null;
|
||||||
if (request.readyState === 4 &&
|
}
|
||||||
request.status === 201 &&
|
|
||||||
request.statusText === 'Created') {
|
request.onload = function() {
|
||||||
gistWindow.location.href = JSON.parse(request.responseText)['html_url'];
|
if (
|
||||||
}
|
request.readyState === 4 &&
|
||||||
};
|
request.status === 201 &&
|
||||||
var data = {
|
request.statusText === 'Created'
|
||||||
description: (username ? 'http://www.freecodecamp.com/' + username +
|
) {
|
||||||
' \'s s' : 'S') + 'olution for ' + (challenge_Name || challengeName),
|
gistWindow.location.href =
|
||||||
public: true,
|
JSON.parse(request.responseText)['html_url'];
|
||||||
files: {}
|
}
|
||||||
},
|
};
|
||||||
queryIssue = window.location.href.toString().split('#?')[0],
|
|
||||||
filename = queryIssue
|
var description = common.username ?
|
||||||
|
'http://www.freecodecamp.com/' + common.username + ' \'s s' :
|
||||||
|
'S';
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
description: description + 'olution for ' + common.challengeName,
|
||||||
|
public: true,
|
||||||
|
files: {}
|
||||||
|
};
|
||||||
|
var queryIssue = window.location.href.toString().split('#?')[0];
|
||||||
|
var filename = queryIssue
|
||||||
.substr(queryIssue.lastIndexOf('challenges/') + 11)
|
.substr(queryIssue.lastIndexOf('challenges/') + 11)
|
||||||
.replace('/', '') + '.js';
|
.replace('/', '') + '.js';
|
||||||
data['files'][filename] = {
|
|
||||||
content: '// ' + (challenge_Name || challengeName) + '\n' +
|
|
||||||
(username ? '// Author: @' + username + '\n' : '') +
|
|
||||||
'// Challenge: ' + queryIssue + '\n' +
|
|
||||||
'// Learn to Code at Free Code Camp (www.freecodecamp.com)' +
|
|
||||||
'\n\n' + editor.getValue().trim()
|
|
||||||
};
|
|
||||||
|
|
||||||
request.send(JSON.stringify(data));
|
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' +
|
||||||
|
window.editor.getValue().trim()
|
||||||
|
};
|
||||||
|
|
||||||
|
request.send(JSON.stringify(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#help-ive-found-a-bug-wiki-article').unbind('click');
|
$('#help-ive-found-a-bug-wiki-article').unbind('click');
|
||||||
|
@ -125,9 +125,7 @@ block content
|
|||||||
common.dashedName = !{JSON.stringify(dashedName)};
|
common.dashedName = !{JSON.stringify(dashedName)};
|
||||||
|
|
||||||
common.started = Math.floor(Date.now());
|
common.started = Math.floor(Date.now());
|
||||||
if (user) {
|
common.username = !{JSON.stringify(user && user.username || '')};
|
||||||
common.username = !{JSON.stringify(user.username)};
|
|
||||||
}
|
|
||||||
|
|
||||||
include ../partials/challenge-footer
|
include ../partials/challenge-footer
|
||||||
script.
|
script.
|
||||||
|
Reference in New Issue
Block a user