Skip to content

Instantly share code, notes, and snippets.

@stsievert
Last active April 4, 2019 23:23
Show Gist options
  • Save stsievert/7d933c83d10ed7f49f967b1257deb659 to your computer and use it in GitHub Desktop.
Save stsievert/7d933c83d10ed7f49f967b1257deb659 to your computer and use it in GitHub Desktop.
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="expires" content="0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<!-- Pleace this snippet right after opening the head tag to make it work properly -->
<!-- This code is licensed under GNU GPL v3 -->
<!-- You are allowed to freely copy, distribute and use this code, but removing author credit is strictly prohibited -->
<!-- Generated by http://insider.zone/tools/client-side-url-redirect-generator/ -->
<!-- REDIRECTING STARTS -->
<!--
<link rel="canonical" href="http://insider.zone/"/>
<noscript>
<meta http-equiv="refresh" content="0;URL=http://insider.zone/">
</noscript>
-->
<!--[if lt IE 9]><script type="text/javascript">var IE_fix=true;</script><![endif]-->
<script type="text/javascript">
function redirect(url) {
if(typeof IE_fix != "undefined") // IE8 and lower fix to pass the http referer
{
document.write("redirecting..."); // Don't remove this line or appendChild() will fail because it is called before document.onload to make the redirect as fast as possible. Nobody will see this text, it is only a tech fix.
var referLink = document.createElement("a");
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
}
else { window.location.replace(url); } // All other browsers
}
</script>
<!-- Credit goes to http://insider.zone/ -->
<!-- REDIRECTING ENDS -->
<body>
<h1>Redirecting...</h1>
</body>
<div id="ppl1"></div>
<div id="ppl2"></div>
</html>
<script>
// Create a request variable and assign a new XMLHttpRequest object to it.
var NEXT_URL = "http://localhost:8000";
var EXP_1 = "d83e63200750d97d2195ee928e8329";
var EXP_2 = "2af808bc1e91c282032ace91d0ce81";
//// Try to the number of participants from one experiment
/////////////////////////
var request = new XMLHttpRequest()
// Open a new connection, using the GET request on the URL endpoint
var next_url = NEXT_URL;
var exp_id = EXP_1;
var url = next_url + "/dashboard/get_stats"
request.open('POST', url, true);
request.setRequestHeader('Content-Type', 'application/json');
request.onreadystatechange = function() {//Call a function when the state changes.
//if(request.readyState == 4 && request.status == 200) {
alert(request.responseText);
//}
}
request.send(JSON.stringify({
'exp_uid': exp_id,
'args': {
'stat_id' : 'basic_info',
'params':{},
'force_recompute': false,
},
}));
// on completion, receive data and drive to the div key="ppl1" or "ppl2"
// document.getElementById(key).textContent = data["num_participants"];
//var NEXT_URL = "http://localhost:8000";
//var EXP_1 = "d83e63200750d97d2195ee928e8329";
//var EXP_2 = "2af808bc1e91c282032ace91d0ce81";
//window.setInterval(function(){
// var ppl1 = document.getElementById("ppl1").textContent;
// var ppl2 = document.getElementById("ppl2").textContent;
// if (ppl1 && ppl2){
// var exp = "";
// if (ppl1 < ppl2) {
// exp = EXP_1;
// } else {
// exp = EXP_2;
// }
// alert(exp);
// clearInterval();
// }
//}, 1000);
// Then finally redirect to the right URL
//var url = NEXT_URL + "/query/query_page/query_page/" + exp;
//redirect(url);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment