More refactoring
This commit is contained in:
56
client/commonFramework/report-issue.js
Normal file
56
client/commonFramework/report-issue.js
Normal file
@@ -0,0 +1,56 @@
|
||||
window.common = (function({ common = { init: [] } }) {
|
||||
common.init.push(function($) {
|
||||
$('#report-issue').on('click', function() {
|
||||
var textMessage = [
|
||||
'Challenge [',
|
||||
(common.challengeName || window.location.pathname),
|
||||
'](',
|
||||
window.location.href,
|
||||
') has an issue.\n',
|
||||
'User Agent is: <code>',
|
||||
navigator.userAgent,
|
||||
'</code>.\n',
|
||||
'Please describe how to reproduce this issue, and include ',
|
||||
'links to screenshots if possible.\n\n'
|
||||
].join('');
|
||||
|
||||
if (
|
||||
common.editor &&
|
||||
typeof common.editor.getValue === 'function' &&
|
||||
common.editor.getValue().trim()
|
||||
) {
|
||||
var type;
|
||||
switch (common.challengeType) {
|
||||
case common.challengeTypes.html:
|
||||
type = 'html';
|
||||
break;
|
||||
case common.challengeTypes.js:
|
||||
case common.challengeTypes.bonfire:
|
||||
type = 'javascript';
|
||||
break;
|
||||
default:
|
||||
type = '';
|
||||
}
|
||||
|
||||
textMessage += [
|
||||
'My code:\n```',
|
||||
type,
|
||||
'\n',
|
||||
common.editor.getValue(),
|
||||
'\n```\n\n'
|
||||
].join('');
|
||||
}
|
||||
|
||||
textMessage = encodeURIComponent(textMessage);
|
||||
|
||||
$('#issue-modal').modal('hide');
|
||||
window.open(
|
||||
'https://github.com/freecodecamp/freecodecamp/issues/new?&body=' +
|
||||
textMessage,
|
||||
'_blank'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
return common;
|
||||
}(window));
|
Reference in New Issue
Block a user