save bonfire solution as a gist and fix search issue button query string
This commit is contained in:
@ -208,13 +208,66 @@ $(document).ready(function() {
|
||||
|
||||
$('#search-issue').unbind('click');
|
||||
$('#search-issue').on('click', function() {
|
||||
var queryIssue = window.location.href.toString();
|
||||
var queryIssue = window.location.href.toString().split('#?')[0];
|
||||
window.open('https://github.com/FreeCodeCamp/FreeCodeCamp/issues?q=' +
|
||||
'is:issue is:all ' + (challenge_Name || challengeName) + ' OR ' +
|
||||
queryIssue.substr(queryIssue.lastIndexOf('challenges/') + 11)
|
||||
.replace('/', ''), '_blank');
|
||||
});
|
||||
|
||||
$('#gist-share').unbind('click');
|
||||
$('#gist-share').on('click', function() {
|
||||
var gistWindow = window.open('', '_blank');
|
||||
|
||||
$('#gist-share')
|
||||
.attr('disabled', 'true')
|
||||
.removeClass('btn-danger')
|
||||
.addClass('btn-warning disabled');
|
||||
|
||||
function createCORSRequest(method, url) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
if ('withCredentials' in xhr) {
|
||||
xhr.open(method, url, true);
|
||||
} else if (typeof XDomainRequest !== 'undefined') {
|
||||
xhr = new XDomainRequest();
|
||||
xhr.open(method, url);
|
||||
} else {
|
||||
xhr = null;
|
||||
}
|
||||
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
|
||||
return xhr;
|
||||
}
|
||||
|
||||
var request = createCORSRequest('post', 'https://api.github.com/gists');
|
||||
if (request) {
|
||||
request.onload = function() {
|
||||
if (request.readyState === 4 &&
|
||||
request.status === 201 &&
|
||||
request.statusText === 'Created') {
|
||||
gistWindow.location.href = JSON.parse(request.responseText)['html_url'];
|
||||
}
|
||||
};
|
||||
var data = {
|
||||
description: (challenge_Name || challengeName),
|
||||
public: true,
|
||||
files: {}
|
||||
},
|
||||
queryIssue = window.location.href.toString().split('#?')[0],
|
||||
filename = queryIssue
|
||||
.substr(queryIssue.lastIndexOf('challenges/') + 11)
|
||||
.replace('/', '') + '.js';
|
||||
data['files'][filename] = {
|
||||
content: '// ' + data.description + '\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));
|
||||
}
|
||||
});
|
||||
|
||||
$('#help-ive-found-a-bug-wiki-article').unbind('click');
|
||||
$('#help-ive-found-a-bug-wiki-article').on('click', function() {
|
||||
window.open("https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Help-I've-Found-a-Bug", '_blank');
|
||||
|
@ -48,7 +48,8 @@ const trusted = [
|
||||
'http://hn.inspectlet.com/',
|
||||
'*.googleapis.com',
|
||||
'*.gstatic.com',
|
||||
'https://hn.inspectlet.com/'
|
||||
'https://hn.inspectlet.com/',
|
||||
'https://*.github.com'
|
||||
];
|
||||
|
||||
export default function csp() {
|
||||
|
@ -80,6 +80,10 @@ block content
|
||||
var dashedName = !{JSON.stringify(dashedName)};
|
||||
var _ = R;
|
||||
var dashed = !{JSON.stringify(dashedName)};
|
||||
var username;
|
||||
if (user)
|
||||
script(type="text/javascript").
|
||||
username = !{JSON.stringify(user.username)};
|
||||
|
||||
.col-md-8.col-lg-9
|
||||
.editorScrollDiv(style = "overflow-y: auto; overflow-x: hidden;")
|
||||
@ -103,12 +107,14 @@ block content
|
||||
.row
|
||||
if (user)
|
||||
#submit-challenge.animated.fadeIn.btn.btn-lg.btn-primary.btn-block Submit and go to my next challenge (ctrl + enter)
|
||||
a.animated.fadeIn.btn.btn-lg.btn-danger.btn-block#gist-share Share your solution as a GitHub gist
|
||||
if (user.progressTimestamps.length > 2)
|
||||
a.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript", onclick="ga('send', 'event', 'twitter', 'share', 'challenge completion share');")
|
||||
i.fa.fa-twitter  
|
||||
= phrase
|
||||
else
|
||||
#next-challenge.btn.btn-lg.btn-primary.btn-block Go to my next challenge (ctrl + enter)
|
||||
a.btn.btn-lg.btn-danger.btn-block#gist-share Share your solution as a GitHub gist
|
||||
#reset-modal.modal(tabindex='-1')
|
||||
.modal-dialog.animated.fadeInUp.fast-animation
|
||||
.modal-content
|
||||
|
Reference in New Issue
Block a user