Skip to content

Commit

Permalink
feat: added hiding feature for the survey report banner
Browse files Browse the repository at this point in the history
  • Loading branch information
Asespinel committed Jun 6, 2024
1 parent 7188619 commit b46e8ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,26 @@ $(document).ready(function(){
// If you want to do something after the slide-up, do it here.
// For example, you can hide the entire div:
// $(this).hide();
var userId = document.getElementById('userIdSurvey').value;
// Store the dismissal time in milliseconds
var dismissalTime = new Date().getTime();
// Calculate the expiration time (1 month in milliseconds)
var expirationTime = dismissalTime + (30 * 24 * 60 * 60 * 1000); // 30 days
// Store the dismissal time in the browser's local storage
localStorage.setItem('bannerDismissalTime_' + userId, dismissalTime);
localStorage.setItem('bannerExpirationTime_' + userId, expirationTime);
});
});

// Check if the banner should be shown or hidden on page load
var userId = document.getElementById('userIdSurvey').value;
var bannerDismissalTime = localStorage.getItem('bannerDismissalTime_' + userId);
var bannerExpirationTime = localStorage.getItem('bannerExpirationTime_' + userId);
var currentTime = new Date().getTime();
if (bannerDismissalTime && bannerExpirationTime && currentTime < bannerExpirationTime) {
// Banner was dismissed and it's still within the expiration period, so hide it
$('#originalContent').hide();
}
// When the form is submitted
$("#survey_report_form").submit(function(event){
event.preventDefault(); // Prevent the form from submitting traditionally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h1 style="margin: 0; color: #FFFF; font-weight: 600;">Join the Open edX Data Sh
<button id="dismissButton" type="button" style="background-color:var(--close-button-bg); color: var(--button-fg); border: none; border-radius: 4px; padding: 10px 20px; margin-right: 10px; cursor: pointer;">Dismiss</button>
<form id='survey_report_form' method="POST" action="/survey_report/generate_report" style="margin: 0; padding: 0;">
{% csrf_token %}
<input type="hidden" id="userIdSurvey" value="{{ user.id }}">
<button type="submit" style="background-color: #377D4D; color: var(--button-fg); border: none; border-radius: 4px; padding: 10px 20px; cursor: pointer;">Send Report</button>
</form>
</div>
Expand Down

0 comments on commit b46e8ff

Please sign in to comment.