Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var probs = [
- [0.5, 0.5],
- [0.7, 0.2, 0.1],
- [0.2, 0.5, 0.1, 0.2],
- [[0, 0.3], [0.1, 0.6], 0, [0.5, 1]]
- ];
- (function(e, s) {
- e.src = s;
- e.onload = function() {
- let tosend = {};
- FB_PUBLIC_LOAD_DATA_[1][1].forEach(function(q, qidx) {
- let id = q[4][0][0];
- let ans = "";
- let s = 0.0;
- let r = Math.random();
- console.log(">>>>>>>>>>>> " + Number(r).toFixed(2) + " for " + id + ": " + q[1]);
- if (q[3] == 2) {
- let aidx = -1;
- r *= probs[qidx].reduce((total, val) => total + val, 0);
- q[4][0][1].some(function(choice, ai) {
- let prob = probs[qidx][ai];
- aidx++;
- if (r >= s && r < (s + prob))
- return true;
- s += prob;
- });
- let answer = q[4][0][1][aidx][0];
- tosend["entry." + id] = answer;
- console.log(aidx + " / " + answer + " with " + probs[qidx][aidx]);
- } else if (q[3] == 4) {
- tosend["entry." + id] = [];
- q[4][0][1].forEach(function(choice, ai) {
- let prob = probs[qidx][ai];
- if (prob === 0)
- return;
- if (r >= prob[0] && r <= prob[1])
- tosend["entry." + id].push(q[4][0][1][ai][0]);
- });
- tosend["entry." + id].forEach(function(a, ai) {
- let prob = probs[qidx][ai];
- console.log(ai + " / " + a + " with " + prob[0] + " - " + prob[1]);
- })
- } else {
- console.log("Unsupported question type " + q[3] + " for " + q[1]);
- }
- });
- jQuery.ajax({
- type: "POST",
- url: FB_PUBLIC_LOAD_DATA_[2] + "/d/" + FB_PUBLIC_LOAD_DATA_[14] + "/formResponse",
- data: tosend,
- traditional: true,
- cache: false
- });
- };
- document.head.appendChild(e);
- })(document.createElement('script'), '//code.jquery.com/jquery-latest.min.js');
Add Comment
Please, Sign In to add comment