From ccc29b7fcb3321aedab877d984c71871b2a8e54f Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Fri, 19 Jun 2015 17:26:04 -0700 Subject: [PATCH] improve upon @lemonyandrew pull request --- .../coursewares/coursewaresJSFramework_0.0.6.js | 11 +++++++---- public/js/main_0.0.2.js | 2 ++ server/views/coursewares/showBonfire.jade | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js index 53204220f62..16073e25547 100644 --- a/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js +++ b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js @@ -45,8 +45,8 @@ editor.setOption("extraKeys", { localBonfire: singleton object that contains properties and methods related to dealing with the localStorage system. The keys work off of the variable challenge_name to make unique identifiers per bonfire - - Two extra functionalities: + + Two extra functionalities: Added anonymous version checking system incase of future updates to the system Added keyup listener to editor(myCodeMirror) so the last update has been saved to storage */ @@ -81,7 +81,6 @@ localBonfire.updateStorage = function(){ } } localBonfire.updateTimeoutId = null; - console.log('updated!'); }; // ANONYMOUS 1 TIME UPDATE VERSION (function(){ @@ -96,7 +95,7 @@ localBonfire.updateStorage = function(){ } })(); -editor.on('keyup', function(codMir, event){ +editor.on('keyup', function(codMir, event){ window.clearTimeout(localBonfire.updateTimeoutId); localBonfire.updateTimeoutId = window.setTimeout(localBonfire.updateStorage, localBonfire.updateWait); }); @@ -106,6 +105,10 @@ if (attempts) { attempts = 0; } +var resetEditor = function() { + editor.setValue(allSeeds); + localBonfire.updateStorage(); +}; var codeOutput = CodeMirror.fromTextArea(document.getElementById("codeOutput"), { lineNumbers: false, diff --git a/public/js/main_0.0.2.js b/public/js/main_0.0.2.js index 65ec9f170c0..7fce4bdaba6 100644 --- a/public/js/main_0.0.2.js +++ b/public/js/main_0.0.2.js @@ -331,6 +331,8 @@ $(document).ready(function() { $('#story-submit').on('click', storySubmitButtonHandler); + $('#reset-button').on('click', resetEditor); + var commentSubmitButtonHandler = function commentSubmitButtonHandler() { $('#comment-button').unbind('click'); var data = $('#comment-box').val(); diff --git a/server/views/coursewares/showBonfire.jade b/server/views/coursewares/showBonfire.jade index 8ca3e962e19..c28f20e322c 100644 --- a/server/views/coursewares/showBonfire.jade +++ b/server/views/coursewares/showBonfire.jade @@ -88,6 +88,12 @@ block content if (user && user.sentSlackInvite) .button-spacer .btn-group.input-group.btn-group-justified + label.btn.btn-success#trigger-help-modal + i.fa.fa-refresh + |   Reset + label.btn.btn-success#trigger-help-modal + i.fa.fa-refresh + |   Reset label.btn.btn-success#trigger-help-modal i.fa.fa-medkit |   Help @@ -119,7 +125,7 @@ block content form.code .form-group.codeMirrorView textarea#codeEditor(autofocus=true, style='display: none;') - script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.5.js') + script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.6.js') #complete-courseware-dialog.modal(tabindex='-1') .modal-dialog.animated.zoomIn.fast-animation @@ -140,6 +146,15 @@ block content = phrase else a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress + #reset-modal.modal(tabindex='-1') + .modal-dialog.animated.fadeInUp.fast-animation + .modal-content + .modal-header.challenge-list-header Clear your code? + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + .modal-body + h3 This will restore your code editor to its original state. + a.btn.btn-lg.btn-info.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 include ../partials/challenge-modals script. var MDNlinks = !{JSON.stringify(MDNlinks)};