From 2d2afd4b0cff061500709990153b61e6bd1a7c8c Mon Sep 17 00:00:00 2001 From: prateekgoel Date: Sat, 5 Aug 2017 23:53:05 +0530 Subject: [PATCH 1/4] Ask for help button feature --- client/commonFramework/ask-for-help.js | 34 +++++++++++++++++++++ client/commonFramework/bindings.js | 4 +++ gulpfile.js | 1 + server/views/challenges/showBonfire.jade | 4 ++- server/views/challenges/showHTML.jade | 4 ++- server/views/challenges/showJS.jade | 4 ++- server/views/partials/challenge-modals.jade | 13 ++++++++ 7 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 client/commonFramework/ask-for-help.js diff --git a/client/commonFramework/ask-for-help.js b/client/commonFramework/ask-for-help.js new file mode 100644 index 0000000000..053f2f2edb --- /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 = [ + '**Whats happening**\n\n\n', + '**My code so far**\n', + '```' + common.editor.getValue() + '```\n', + '**My browser information**\n\n', + 'User Agent is: ```', + navigator.userAgent, + '```.\n\n', + '**Link to the challenge**\n\n', + window.location.href + '\n' + + ].join(''); + + helpTitle = encodeURIComponent(helpTitle); + helpMessage = encodeURIComponent(helpMessage); + + $('#ask-for-help-modal').modal('hide'); + window.open( + 'http://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..70b986f8a1 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 From 52edcedb61ab57d9201d4b4bcf865caf80d894de Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Mon, 7 Aug 2017 15:19:06 -0500 Subject: [PATCH 2/4] Fix a trailing space that was in the anchor tag --- server/views/partials/challenge-modals.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/views/partials/challenge-modals.jade b/server/views/partials/challenge-modals.jade index 70b986f8a1..ab9ddc56ba 100644 --- a/server/views/partials/challenge-modals.jade +++ b/server/views/partials/challenge-modals.jade @@ -28,7 +28,7 @@ .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(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 From aefcf9c2acf9def066947ce5c55196fab1ab3e00 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Wed, 9 Aug 2017 10:44:29 -0500 Subject: [PATCH 3/4] Make some minor copy edits --- client/commonFramework/ask-for-help.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/commonFramework/ask-for-help.js b/client/commonFramework/ask-for-help.js index 053f2f2edb..f5709b9ef3 100644 --- a/client/commonFramework/ask-for-help.js +++ b/client/commonFramework/ask-for-help.js @@ -3,14 +3,14 @@ window.common = (function({ common = { init: [] } }) { $('#ask-for-help-button').on('click', function() { var helpTitle = common.challengeName; var helpMessage = [ - '**Whats happening**\n\n\n', - '**My code so far**\n', + '**Tell us what\'s happening:**\n\n\n\n', + '**Your code so far**\n', '```' + common.editor.getValue() + '```\n', - '**My browser information**\n\n', - 'User Agent is: ```', + '**Your browser information:**\n\n', + 'Your Browser User Agent is: ```', navigator.userAgent, '```.\n\n', - '**Link to the challenge**\n\n', + '**Link to the challenge:**\n', window.location.href + '\n' ].join(''); From 1a7a0fb8942e2782ea8b4c4cf6eb56af951f48bd Mon Sep 17 00:00:00 2001 From: Prateek Goel Date: Wed, 9 Aug 2017 21:14:14 +0100 Subject: [PATCH 4/4] Change http to https --- client/commonFramework/ask-for-help.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/commonFramework/ask-for-help.js b/client/commonFramework/ask-for-help.js index f5709b9ef3..9db2374132 100644 --- a/client/commonFramework/ask-for-help.js +++ b/client/commonFramework/ask-for-help.js @@ -20,7 +20,7 @@ window.common = (function({ common = { init: [] } }) { $('#ask-for-help-modal').modal('hide'); window.open( - 'http://forum.freecodecamp.org/new-topic?title=' + 'https://forum.freecodecamp.org/new-topic?title=' + helpTitle + '&body=' + helpMessage