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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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!-- <script src="https://assets.crowd.aws/crowd-html-elements.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js"></script>
<script type='text/javascript'>
    window.onload = function() {
        var btn = document.getElementById('submitButton');
        if (btn != null){
            btn.setAttribute('onclick', 'return submitClicked()');
        }
    }
    function validateForm() {
        var numForeign = 15;
        var numEnglish = 5;
        let checkbox, sliderStyle, sliderContent, sliderOverall = false;
        let sentence_num = 0;
        let sentence_type = "en_sentence";
        for (let i = 0; i < numEnglish + numForeign; i++) {
            if (i > numEnglish - 1) {
                sentence_type = "foreign_sentence";
                sentence_num = i - numEnglish;
            }
            checkbox = document.getElementsByName(sentence_type + sentence_num + "_invalid")[0].checked;
            sliderOverall = document.getElementsByName(sentence_type + sentence_num + "_overall")[0].set;
            // contraRadioButtons = document.getElementsByName(sentence_type + sentence_num + "_radio_contra");
            // contraRadio =  contraRadioButtons[0].checked || contraRadioButtons[1].checked;
            // influenceRadioButtons = document.getElementsByName(sentence_type + sentence_num + "_radio_influence");
            // influenceRadio = influenceRadioButtons[0].checked || influenceRadioButtons[1].checked;
            // if (!checkbox){
            //     if (!(sliderOverall && contraRadio)){
            //         return false;
            //     }
            //     if (contraRadioButtons[0].checked && !influenceRadio){
            //         return false;
            //     }
            // }
            if (!checkbox){
                if (!sliderOverall){
                    return false;
                }
            }
        }
        return true;
    }
    function handle_checkbox_click(e) {
        if (e.checked) {
            e.parentElement.parentElement.getElementsByClassName("labels_slider_container")[0].style.filter = "blur(5px)";
        } else {
            e.parentElement.parentElement.getElementsByClassName("labels_slider_container")[0].style.filter = "blur(0px)";
        }
    }
    function handle_slider_click(e) {
        e.set = true;
        e.className = 'slider_done slider';
    }
    function submitClicked(){
        if (!validateForm()) {
            alert("All fields need to be filled in");
            return false;
        }else{
            return true;
        }
    }
    function handle_contra_click(e) {
        if (e.value=="yes"){
            e.parentElement.parentElement.getElementsByClassName("checkbox_horiz")[1].getElementsByClassName("checkbox_horiz")[0].className = "checkbox_horiz"
        } else {
            e.parentElement.parentElement.getElementsByClassName("checkbox_horiz")[1].getElementsByClassName("checkbox_horiz")[0].className = "checkbox_horiz checkbox_horiz_hidden";
        }
    }
</script>
<style>
    body, form {
    font-family: Amazon Ember,Helvetica Neue,Roboto,Arial,sans-serif;
    margin: 0;
    height: 100%;
    width: 100%;
    }
    
    .slider {
        -webkit-appearance: none;
        width: 100%;
        height: 15px;
        /* border-radius: 5px; */
        background: #d3d3d3;
        outline: none;
        opacity: 0.7;
        -webkit-transition: .2s;
        transition: opacity .2s;
    }

    .slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 15px;
        height: 15px;
        border-radius: 50%;
        background: red;
        cursor: pointer;
    }

    .slider::-moz-range-thumb {
        width: 15px;
        height: 15px;
        /* border-radius: 50%; */
        background: red;
        cursor: pointer;
    }

    .slider_done.slider::-webkit-slider-thumb {
        background: #04AA6D
    }

    .slider_done.slider::-moz-range-thumb {
        background: #04AA6D
    }

    table {
        table-layout: fixed;
    }

    .slider_container {
        width: 95%;
    }

    .slider_labels {
        display: flex;
        justify-content: space-between;
        width: 100%;
        background-color: lightgrey;
    }

    .labels {
        width: 9%;
        height: 100%;
        /* overflow-wrap: break-word; */
        text-align: center;
        font-size: 12;
        /* background-color: lightpink; */
    }

    .labels_slider_container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-evenly;
        width: 600px;
        height: 120px;
        align-self: center;
    }

    .descriptive_container {
        /* height: 400px; */
        display: flex;
        /* justify-content: center; */
        margin-left: 64px;
        margin-right: 64px;
        /* margin-bottom: 16px; */
        /* margin-top: 16px; */
    }

    .checkbox_contianer {
        /* height: 400px; */
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin-left: 64px;
        margin-right: 64px;
        margin-bottom: 16px;
        margin-top: 16px;
    }

    .slider_descriptions {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        height: 150px;
        align-self: center;
    }

    .description {
        font-size: 14;
    }

    .sentence_container {
        width: 40%;
        align-self: center;
        /* margin-right: 64px; */
        /* margin-top: 100px;
        margin-bottom: 100px; */
        /* overflow: scroll;
        max-height: 200px; */
    }

    .button_container {
        display: flex;
        width: 100%;
        justify-content: center;
        margin-top: 32px;
        margin-bottom: 32px;
    }

    .buttons {
        width: 108px;
        height: 32px;
        margin: 8px;
        border: 1px solid black;
        font-weight: bolder;
        border-radius: 4px;
    }

    .buttons:hover{
        cursor: pointer;
        opacity: 0.7;
    }

    .buttons.next{
        background-color: lightseagreen;
    }

    .buttons.prev{
        background-color: lightcoral ;
    }
    .checkbox_horiz {
        font-size: 14;
        display: flex;
        flex-direction: row;
        justify-content: center;
    }

    .checkbox_horiz_hidden {
        display: none;
    }
</style>
<div style="padding-right: 64px; padding-left: 64px;">
    <div id='form' class="form">
        <h1>Politeness Annotation</h1>
        <p><b>Please rate how polite the request comes across for you</b>. Each request is a part of a conversation between editors on wikipedia. There can be multiple factors affecting the politeness level of a sentence, such as style and content. 
        <ul>
            <li><b>Style</b>: How did the requester phrase their request? The same content could be conveyed in both an impolite and polite manner. After reading the sentence, if you're able to think of a more polite way of saying the same thing, the style is not very polite</li>
            <li><b>Content</b>: What is being asked in this request? For example, if the request is assuming the other editor made a mistake or violated rules intentionally, it less polite than one where editors are discussing what changes to make to a page. The content score will reflect the nature of the request</li>
        </ul>
        </p>
        
        <p>You'll assign a single politeness score after considering all factors.</p>
        <!-- After assigning a politeness score, please mark if there is discrepancy between style and content in this request. Some requests could be conveying a more negative message, but could be using a better choice of words to do it. Some requests could be the other way round, conveying a positive message with a bad choice of words.</p> -->

        <!-- <p>Consider the following request</p>
        <ul>
        <li>I'm somewhat puzzled by your recent edits on the Harper page, which have left two different sets of footnotes. Could you please explain your rationale for the change?</li>
        </ul>
        <p>The person making the request is frustrated that some confusing edits have been made to a page, but is using a careful set of words to convey it in a polite manner. This request is an example of one that has an impolite/negative content, but a polite/positve style.</p>
        
        <p>Whereas, looking at this request</p>
        <ul>
        <li>Restored history. Can check that I did it all ok?</li>
        </ul>
        <p>This request is conveying a simple message about some revision to a page, but is conveyed in a very short and terse manner that makes it appear rude. This reqeust is an example of one that has a polite/positive content, but an impolite/negative style.</p>

        <p>Most sentences are unlikely to have contradicting content and style. If you mark that there is discrepancy between style and content, you will be asked to provide an additional piece of information - whether it was style or content that affected your final score more.</p> -->

        <p>A small fraction of the sentences may not be actual valid text. Simply mark those as invalid on the rightmost column.</p>
        
        <p>The task is spread over 4 pages. The first page contains 5 sentences in English and the remaining 3 pages contain 5 sentences each in a Foreign langauge.</p>

        <p>You can navigate between the pages using the Previous and Next Buttons.</p>
        
        <p>Before we start, please enter you Prolific ID</p>
        <label for="prolific_id">Prolific ID:</label>
        <input type="text" id="prolific_id" name="prolific_id"><br><br>

        <div id="progress" hidden>0</div>
        <div id="sentence_container"></div>
        <!-- <p>First are 5 requests in English that you will have to annotate</p>
        <div id="en_sentences"></div>

        <p>Now, we present 15 requests from a foreign language that you will have to annotate</p>
        <div id="foreign_sentences"></div> -->
        
        <div class="button_container">
            <button id="prev_btn" type="button" onclick="prevPage()" class="buttons prev">Previous</button>
            <button id="next_btn" type="button" onclick="nextPage()" class="buttons next">Next</button>
        </div>

        <p>If you have any comments about any particular sentence or about the set of factors (style/content) for a particular sentence, please leave them below.</p>
        <textarea name="comments" id="comments" style="font-family:sans-serif"></textarea>

        <p>Click the button below once you're done. If there are any missing fields, you'll be notified and you have to check the form again</p>
        <!-- <p>If everything has been filled properly, you have successfully completed the task and <b>your completion code will be copied to your clipboard</b></p> -->
        <!-- <p><b>Paste this code to complete the task on Prolific</b>. You can go to the appropriate field on Prolific and use Ctrl + V to paste the code.</p> -->
        <!-- <button type="submit" onclick="submitClicked(event)">Submit</button> -->
</div>
</div>
<div id="data">
    <div id="en_sentence0" hidden>${en_sentence0}</div>
    <div id="en_sentence1" hidden>${en_sentence1}</div>
    <div id="en_sentence2" hidden>${en_sentence2}</div>
    <div id="en_sentence3" hidden>${en_sentence3}</div>
    <div id="en_sentence4" hidden>${en_sentence4}</div>
    
    <div id="foreign_sentence0" hidden>${foreign_sentence0}</div>
    <div id="foreign_sentence1" hidden>${foreign_sentence1}</div>
    <div id="foreign_sentence2" hidden>${foreign_sentence2}</div>
    <div id="foreign_sentence3" hidden>${foreign_sentence3}</div>
    <div id="foreign_sentence4" hidden>${foreign_sentence4}</div>
    <div id="foreign_sentence5" hidden>${foreign_sentence5}</div>
    <div id="foreign_sentence6" hidden>${foreign_sentence6}</div>
    <div id="foreign_sentence7" hidden>${foreign_sentence7}</div>
    <div id="foreign_sentence8" hidden>${foreign_sentence8}</div>
    <div id="foreign_sentence9" hidden>${foreign_sentence9}</div>
    <div id="foreign_sentence10" hidden>${foreign_sentence10}</div>
    <div id="foreign_sentence11" hidden>${foreign_sentence11}</div>
    <div id="foreign_sentence12" hidden>${foreign_sentence12}</div>
    <div id="foreign_sentence13" hidden>${foreign_sentence13}</div>
    <div id="foreign_sentence14" hidden>${foreign_sentence14}</div>
</div>
<template id="annotation">
    {{#each sentences}}
        <div class="descriptive_container">
            <div class="sentence_container">
                {{sentence}}
            </div>
            <div class="labels_slider_container">
                <div class="slider_labels">
                <div class="labels">Very Impolite</div>
                    <div class="labels">Impolite</div>
                    <div class="labels">Somewhat Impolite</div>
                    <div class="labels">Neutral</div>
                    <div class="labels">Somewhat Polite</div>
                    <div class="labels">Polite</div>
                    <div class="labels">Very Polite</div>
                </div>
                <div class="slider_container">
                    <input type="range" min="-3" max="3" step="0.5" class="slider" name="{{id}}_overall"
                        onclick="handle_slider_click(this)" onchange="handle_slider_click(this)">
                    </div>
                <!-- <div class="checkbox_horiz">
                    Style and Content of this sentence imply opposite politeness levels?
                    <input type="radio" name="{{id}}_radio_contra" value="yes" onchange="handle_contra_click(this)">
                    <label>Yes</label>
                    <input type="radio" name="{{id}}_radio_contra" value="no" onchange="handle_contra_click(this)">
                    <label>No</label>
                    <input type="checkbox" name="{{id}}_contra" onchange="handle_contra_click(this)">
                </div>
                <div class="checkbox_horiz">
                    <div>&nbsp;</div>
                    <div class="checkbox_horiz checkbox_horiz_hidden" hidden>
                    Which aspect influenced your score more?
                    <input type="radio" name="{{id}}_radio_influence" value="style">
                    <label>Style</label>
                    <input type="radio" name="{{id}}_radio_influence" value="content">
                    <label>Content</label>
                    </div>
                </div> -->
            </div>
            <div class="checkbox_contianer">
                <input type="checkbox" name="{{id}}_invalid" onclick="handle_checkbox_click(this)">
                <label for="{{id}}_valid">Invalid</label><br>
            </div>
        </div>
    {{/each}}
    <p style="text-align:center;">Page {{page_num}}/{{total_pages}}</p>
</template>
<script>
    var template = document.getElementById('annotation').innerHTML;
    var render_sentences = Handlebars.compile(template);
    var numForeign = 5;
    var numEnglish = 5;
    var numEnGroups = 1;
    var numForeignGroups = 3
    var enElements = [];
    var foreignElements = []
    for (let i=0; i < numEnGroups; i++){
        enElements.push([]);
        for (let j=0; j < numEnglish; j++){
            enElements[i].push({id: "en_sentence"+ (i*numEnglish + j), sentence: document.getElementById("en_sentence" + (i*numEnglish + j)).textContent});
        }
        var element = document.createElement("div");
        element.setAttribute("id", "group" + i);
        element.innerHTML = render_sentences({sentences: enElements[i], page_num: i + 1, total_pages: numEnGroups + numForeignGroups});
        element.setAttribute("hidden", "true");
        document.getElementById('sentence_container').appendChild(element);
    }
    for (let i=0; i < numForeignGroups; i++){
        foreignElements.push([]);
        for (let j=0; j < numForeign; j++){
            foreignElements[i].push({id: "foreign_sentence"+ (i*numForeign + j), sentence: document.getElementById("foreign_sentence" + (i*numForeign + j)).textContent});
        }
        var element = document.createElement("div");
        element.setAttribute("id", "group" + (i + numEnGroups));
        element.innerHTML = render_sentences({sentences: foreignElements[i], page_num: numEnGroups + i + 1, total_pages: numEnGroups + numForeignGroups});
        element.setAttribute("hidden", "true");
        document.getElementById('sentence_container').appendChild(element);
    }
    document.getElementById("group0").removeAttribute("hidden");
    document.getElementById("progress").textContent = 0;

    function prevPage(){
        var group = parseInt(document.getElementById("progress").textContent);
        if (group != 0) {
            document.getElementById("group" + (group)).setAttribute("hidden", "true");
            document.getElementById("group" + (group - 1)).removeAttribute("hidden");
            document.getElementById("progress").textContent = group - 1;
        }
    }

    function nextPage(){
        var group = parseInt(document.getElementById("progress").textContent);
        if (group != numEnGroups + numForeignGroups - 1) {
            document.getElementById("group" + (group)).setAttribute("hidden", "true");
            document.getElementById("group" + (group + 1)).removeAttribute("hidden");
            document.getElementById("progress").textContent = group + 1;
        }
    }
    var search = window.location.search;
    if (search != "") {
        var params = new URLSearchParams(search);
        var assignmentId = params.get("assignmentId");
        if (assignmentId == "ASSIGNMENT_ID_NOT_AVAILABLE") {
            document.getElementById("sentence_container").style.pointerEvents = 'none';
        }
    }
</script>