diff --git a/client/commonFramework/ask-for-help.js b/client/commonFramework/ask-for-help.js new file mode 100644 index 0000000000..9db2374132 --- /dev/null +++ b/client/commonFramework/ask-for-help.js @@ -0,0 +1,34 @@ +window.common = (function({ common = { init: [] } }) { + common.init.push(function($) { + $('#ask-for-help-button').on('click', function() { + var helpTitle = common.challengeName; + var helpMessage = [ + '**Tell us what\'s happening:**\n\n\n\n', + '**Your code so far**\n', + '```' + common.editor.getValue() + '```\n', + '**Your browser information:**\n\n', + 'Your Browser User Agent is: ```', + navigator.userAgent, + '```.\n\n', + '**Link to the challenge:**\n', + window.location.href + '\n' + + ].join(''); + + helpTitle = encodeURIComponent(helpTitle); + helpMessage = encodeURIComponent(helpMessage); + + $('#ask-for-help-modal').modal('hide'); + window.open( + 'https://forum.freecodecamp.org/new-topic?title=' + + helpTitle + + '&body=' + + helpMessage + + '&category=help', + '_blank' + ); + }); + }); + + return common; +}(window)); diff --git a/client/commonFramework/bindings.js b/client/commonFramework/bindings.js index 4b47e8400e..931ee48cdd 100644 --- a/client/commonFramework/bindings.js +++ b/client/commonFramework/bindings.js @@ -169,6 +169,10 @@ window.common = (function(global) { $('#help-modal').modal('show'); }); + $('#trigger-ask-for-help-modal').on('click', function() { + $('#ask-for-help-modal').modal('show'); + }); + $('#trigger-reset-modal').on('click', function() { $('#reset-modal').modal('show'); }); diff --git a/gulpfile.js b/gulpfile.js index 2426e34a88..5d63399848 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -130,6 +130,7 @@ var paths = { 'output-display', 'phone-scroll-lock', 'report-issue', + 'ask-for-help', 'run-tests-stream', 'show-completion', 'step-challenge', diff --git a/server/views/challenges/showBonfire.jade b/server/views/challenges/showBonfire.jade index 65d6bf6f9c..2b2cac4b8b 100644 --- a/server/views/challenges/showBonfire.jade +++ b/server/views/challenges/showBonfire.jade @@ -34,8 +34,10 @@ block content | Run tests (ctrl + enter) .button-spacer button.btn-big.btn.btn-primary.btn-block#trigger-reset-modal Reset your code - .button-spacer + .button-spacer a.btn-big.btn.btn-primary.btn-block(href="https://forum.freecodecamp.org/t/freecodecamp-algorithm-challenge-guide-" + dashedName target="_blank") Get a hint + .button-spacer + button.btn-big.btn.btn-primary.btn-block#trigger-ask-for-help-modal Ask for help on the forum if (!user) .button-spacer a.btn.signup-btn.btn-block.btn-block(href='/login') Sign in so you can save your progress diff --git a/server/views/challenges/showHTML.jade b/server/views/challenges/showHTML.jade index f283f25f8d..edfb05d74e 100644 --- a/server/views/challenges/showHTML.jade +++ b/server/views/challenges/showHTML.jade @@ -28,8 +28,10 @@ block content | Run tests (ctrl + enter) .button-spacer button.btn-big.btn.btn-primary.btn-block#trigger-reset-modal Reset your code - .button-spacer + .button-spacer a.btn-big.btn.btn-primary.btn-block(href="https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-" + dashedName target="_blank") Get a hint + .button-spacer + button.btn-big.btn.btn-primary.btn-block#trigger-ask-for-help-modal Ask for help on the forum script. var userLoggedIn = true; if (!user) diff --git a/server/views/challenges/showJS.jade b/server/views/challenges/showJS.jade index df121dad19..3886522cf1 100644 --- a/server/views/challenges/showJS.jade +++ b/server/views/challenges/showJS.jade @@ -39,8 +39,10 @@ block content | Run tests (ctrl + enter) .button-spacer button.btn-big.btn.btn-primary.btn-block#trigger-reset-modal Reset your code - .button-spacer + .button-spacer a.btn-big.btn.btn-primary.btn-block(href="https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-" + dashedName target="_blank") Get a hint + .button-spacer + button.btn-big.btn.btn-primary.btn-block#trigger-ask-for-help-modal Ask for help on the forum if (!user) .button-spacer a.btn.signup-btn.btn-block.btn-block(href='/signin') Sign in so you can save your progress diff --git a/server/views/partials/challenge-modals.jade b/server/views/partials/challenge-modals.jade index d934881695..ab9ddc56ba 100644 --- a/server/views/partials/challenge-modals.jade +++ b/server/views/partials/challenge-modals.jade @@ -19,3 +19,16 @@ h3 This will restore your code editor to its original state. a.btn.btn-lg.btn-warning.btn-block#reset-button(href='#', data-dismiss='modal', aria-hidden='true') Clear my code a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel + +#ask-for-help-modal.modal(tabindex='-1') + .modal-dialog.animated.fadeInUp.fast-animation + .modal-content + .modal-header.challenge-list-header Ask for help? + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + .modal-body + h3 + | If you've already tried the  + a(href='https://forum.freecodecamp.org/t/the-read-search-ask-methodology-for-getting-unstuck/137307', target='_blank') Read-Search-Ask + |  method, then you can ask for help on the freeCodeCamp forum. + a.btn.btn-lg.btn-primary.btn-block#ask-for-help-button(name='_csrf', value=_csrf) Create a help post on the forum + a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel