UNPKG

aiom

Version:

A Highly Flexible and Modular Framework for Behavioral Experiments

83 lines (79 loc) 2.99 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Finish</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.3.4/axios.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.5/dist/js.cookie.min.js"></script> <link rel="icon" type="image/png" href="/pkg-static/images/favicon.png"/> <link rel="stylesheet" href="/pkg-static/css/debrief.css"> <!-- <link rel="stylesheet" href="/pkg-static/css/style.css"> --> <script> const ENV = { debrief: '/exp-static/debrief.html' }; </script> </head> <body> <div class="container"> <h1>Debrief</h1> <p id="debrief"> Loading... </p> <button id="redirect_button" style="margin-top: 20px;">Complete</button> </div> <script> function remove_cookie() { const cookies = Cookies.get(); for (name in cookies) Cookies.remove(name); } // function payBonuses() { // axios.get('/api/payBonuses', { // headers: { // 'ID': Cookies.get('pid'), // 'study_id': Cookies.get('study_id') // }, // }) // .then(response => { // console.log('Bonus payment response:', response.data); // }) // .catch(error => { // console.error('Error sending bonus payment request:', error); // }); // } function complete_redirect(status) { axios.get('/api/complete_redirect', { headers: { 'ID': Cookies.get('pid'), 'Status': status, 'study_id': Cookies.get('study_id') }, }) .then(response => { remove_cookie(); if (response.data.completionUrl) { window.location.href = response.data.completionUrl; } else { alert('You can close this page now.'); } }) .catch(error => { console.error('Error sending completion request:', error); }); } $(document).ready(function() { $('#debrief').load(ENV.debrief, function(response, status, xhr) { if (status == "error") { $("#debrief").html("Sorry, there was an error loading the debrief."); } }); // payBonuses(); $('#redirect_button').on('click', function() { complete_redirect('COMPLETED'); }); }) </script> </body> </html>