-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathantreview.php
146 lines (136 loc) · 6.23 KB
/
antreview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
session_start();
if(!isset($_SESSION['logged_in'])) {
header('Location: index.php');
return;
}
require_once('DB.php');
require_once('utilities.php');
$db = new DB();
//ant event u_distortions
$ant = $db->get_ant_for_review($_SESSION['uid']);
if($ant==false) {
echo <<<NOANTS
<script type="text/javascript">
alert('Sorry - there are no ANTs available for review at this time.');
window.location = 'home.php';
</script>
NOANTS;
}
//TODO: what happens when there are no available ants for review?
?>
<html>
<head>
<title>Automatic Negative Thought review</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="utilities.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('button').click(function() {
save_data = new Object();
save_data['type'] = 'antreview';
save_data['ant'] = <?php echo json_encode($ant['ant']); ?>;
save_data['event'] = <?php echo json_encode($ant['event']); ?>;
save_data['u_uid'] = '<?php echo $ant['u_uid']; ?>';
save_data['u_distortions'] = '<?php echo $ant['u_distortions']; ?>';
save_data['comments'] = $("#anonymous-comments").val();
distortion1 = [];
distortion1.push('<i>'+$("#distortion-1a :selected").text()+'</i>', '<i>'+$("#distortion-1b :selected").text()+'</i>', '<i>'+$("#distortion-1c :selected").text()+'</i>');
distortion1.push('<i>---</i>'); //hackish. when we remove --- two lines later, this ensure it is in the array.
distortion1 = distortion1.unique();
distortion1.splice(distortion1.indexOf('<i>---</i>'), 1);
distortion1string = '';
for(var i=0;i<distortion1.length;i++) {
distortion1string += distortion1[i].substr(3,distortion1[i].length-7) + ',';
// eliminating the <i> and </i> ...
// TODO: refactor so that the container applies the formatting and we don't have to string manipulate
}
distortion1string = distortion1string.slice(0,-1);
save_data['r_distortions'] = distortion1string;
save_data['r_uid'] = <?php echo $_SESSION['uid']; ?>;
$.post('save.php', save_data, function(new_rank) {
initial_rank = <?php echo $db->calculate_rank($_SESSION['uid']); ?>;
rank_differential = initial_rank-new_rank;
alertmsg = 'Thanks. The anonymous reviewee will receive a notification with your comments. You have received 200 karma and are now ranked #' + new_rank+'.';
if(rank_differential>0) {
alertmsg += ' This is a jump of ' + rank_differential + ' spots.';
}
alert(alertmsg);
window.location = 'home.php';
});
});
});
</script>
<?php add_google_analytics_tracking(); ?>
</head>
<body>
<h2>Anonymous Event & Negative Thought</h2>
<span class="anonymous-desc">
<label>Event</label>: "<b><?php echo stripslashes(htmlentities($ant['event'])); ?></b>"<br />
</span>
<span class="anonymous-desc">
<label>Automatic Thought</label>: "<em><?php echo stripslashes(htmlentities($ant['ant'])); ?></em>"
</span>
<h2>What distortions do you detect?</h2>
<div class="distortion-list">(1)
<select id="distortion-1a">
<option value="assuming">assuming</option>
<option value="shoulds (musts/oughts)">shoulds (musts/oughts)</option>
<option value="the fairy-tale fantasy">the fairy-tale fantasy</option>
<option value="all or nothing thinking">all or nothing thinking</option>
<option value="overgeneralizing">overgeneralizing</option>
<option value="labeling">labeling</option>
<option value="dwelling on the negative">dwelling on the negative</option>
<option value="rejecting the positive">rejecting the positive</option>
<option value="unfavorable comparisons">unfavorable comparisons</option>
<option value="catastrophizing">catastrophizing</option>
<option value="personalizing">personalizing</option>
<option value="blaming">blaming</option>
<option value="making feelings facts">making feelings facts</option>
</select>
<img src="images/red-arrow-left-2.png" class="red-arrow-left" style="display: none;"/></div>
<div class="distortion-list">(2)
<select id="distortion-1b">
<option selected value="---">---</option>
<option value="assuming">assuming</option>
<option value="shoulds (musts/oughts)">shoulds (musts/oughts)</option>
<option value="the fairy-tale fantasy">the fairy-tale fantasy</option>
<option value="all or nothing thinking">all or nothing thinking</option>
<option value="overgeneralizing">overgeneralizing</option>
<option value="labeling">labeling</option>
<option value="dwelling on the negative">dwelling on the negative</option>
<option value="rejecting the positive">rejecting the positive</option>
<option value="unfavorable comparisons">unfavorable comparisons</option>
<option value="catastrophizing">catastrophizing</option>
<option value="personalizing">personalizing</option>
<option value="blaming">blaming</option>
<option value="making feelings facts">making feelings facts</option>
</select>
</div>
<div class="distortion-list">(3)
<select id="distortion-1c">
<option selected value="---">---</option>
<option value="assuming">assuming</option>
<option value="shoulds (musts/oughts)">shoulds (musts/oughts)</option>
<option value="the fairy-tale fantasy">the fairy-tale fantasy</option>
<option value="all or nothing thinking">all or nothing thinking</option>
<option value="overgeneralizing">overgeneralizing</option>
<option value="labeling">labeling</option>
<option value="dwelling on the negative">dwelling on the negative</option>
<option value="rejecting the positive">rejecting the positive</option>
<option value="unfavorable comparisons">unfavorable comparisons</option>
<option value="catastrophizing">catastrophizing</option>
<option value="personalizing">personalizing</option>
<option value="blaming">blaming</option>
<option value="making feelings facts">making feelings facts</option>
</select>
</div>
<div class="distortion-list">
<a href="#" onclick="javascript:distortionPopup();">distortion explanations</a>
</div>
<h2>Any (anonymous) comments?</h2>
<textarea class="event" id="anonymous-comments" rows="7" cols="49"></textarea>
<button>Submit your thoughts</button>
</body>
</html>