forked from dreygur/XDPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
6931 lines (6228 loc) · 307 KB
/
main.js
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
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var commands = require("commands");
const {
alert,
confirm
} = require("./lib/dialogs.js");
window.jQuery = window.$ = require("./lib/jquery.min.js");
const fs = require("uxp").storage.localFileSystem;
$(window).keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
var $stored_auth_token = "";
var validate = false;
var useTest = {};
useTest['use_test'] = {};
useTest['user'] = {};
var test_json = {}
var customer_attr = {};
var default_questions;
var survey_question_types;
var default_survey_question_types;
var ut_tasks = {};
var test_screener_questions;
var test_screener_questions_json = {};
var survey_questions_json = {};
var ut_tasks_json = {};
var demographics;
var video_recording_times;
var sus_surveys;
var default_sus_surveys;
var default_demographics_field;
var use_test_ids;
var textareastr = [];
var website_url = "https://www.trymyui.com"// "https://www.trymyui.com";
var auth_token;
var customer_id;
var tmy_credits;
var private_credits;
var credit_type_value;
var customer_plan = {};
var default_recording_time;
var order_active;
var allowed_question_limit_planwise = {"paid_personal": 4, "team": 4, "enterprise": 16, "enterprise_trial": 16, "unlimited": 16};
var allowed_screener_question_limit = {"paid_personal": 0, "team": 1, "enterprise": 16, "enterprise_trial": 16, "unlimited": 16};
var opt_counter = 9;
var survey_opt_counter = 4;
var country_codes = {1: "us",7: "ru",20: "eg",27: "za",30: "gr",31: "nl",32: "be",33: "fr",34: "es",36: "hu",39: "va",40: "ro",41: "ch",43: "at",44: "gb",45: "dk",46: "se",47: "sj",48: "pl",49: "de",51: "pe",52: "mx",53: "cu",54: "ar",55: "br",56: "cl",57: "co",58: "ve",60: "my",61: "cc",62: "id",63: "ph",64: "nz",65: "sg",66: "th",81: "jp",82: "kr",84: "vn",86: "cn",90: "tr",91: "in",92: "pk",93: "af",94: "lk",95: "mm",98: "ir",211: "ss",212: "eh",213: "dz",216: "tn",218: "ly",220: "gm",221: "sn",222: "mr",223: "ml",224: "gn",225: "ci",226: "bf",227: "ne",228: "tg",229: "bj",230: "mu",231: "lr",232: "sl",233: "gh",234: "ng",235: "td",236: "cf",237: "cm",238: "cv",239: "st",240: "gq",241: "ga",242: "cg",243: "cd",244: "ao",245: "gw",246: "io",248: "sc",249: "sd",250: "rw",251: "et",252: "so",253: "dj",254: "ke",255: "tz",256: "ug",257: "bi",258: "mz",260: "zm",261: "mg",262: "re",263: "zw",264: "na",265: "mw",266: "ls",267: "bw",268: "sz",269: "km",290: "sh",291: "er",297: "aw",298: "fo",299: "gl",350: "gi",351: "pt",352: "lu",353: "ie",354: "is",355: "al",356: "mt",357: "cy",358: "ax",359: "bg",370: "lt",371: "lv",372: "ee",373: "md",374: "am",375: "by",376: "ad",377: "mc",378: "sm",380: "ua",381: "rs",382: "me",383: "xk",385: "hr",386: "si",387: "ba",389: "mk",420: "cz",421: "sk",423: "li",500: "fk",501: "bz",502: "gt",503: "sv",504: "hn",505: "ni",506: "cr",507: "pa",508: "pm",509: "ht",590: "mf",591: "bo",592: "gy",593: "ec",594: "gf",595: "py",596: "mq",597: "sr",598: "uy",599: "cw",670: "tl",672: "nf",673: "bn",674: "nr",675: "pg",676: "to",677: "sb",678: "vu",679: "fj",680: "pw",681: "wf",682: "ck",683: "nu",685: "ws",686: "ki",687: "nc",688: "tv",689: "pf",690: "tk",691: "fm",692: "mh",850: "kp",852: "hk",853: "mo",855: "kh",856: "la",880: "bd",886: "tw",960: "mv",961: "lb",962: "jo",963: "sy",964: "iq",965: "kw",966: "sa",967: "ye",968: "om",970: "ps",971: "ae",972: "il",973: "bh",974: "qa",975: "bt",976: "mn",977: "np",992: "tj",993: "tm",994: "az",995: "ge",996: "kg",998: "uz"}
///// Entry Dialog start///////
let entryDialog;
const entryHtml =
`<style>
.startup-dialog {
height: auto;
width: 300px;
margin: 40px 80px !important;
text-align:center;
}
.startup-dialog header {
margin-bottom:10px !important;
}
.close a{
display: flex;
flex-direction: row;
justify-content: end !important;
}
.close img{
text-align: right !important;
}
.startup-dialog .center {
padding-top: 10px;
}
.startup-dialog .row {
display: flex;
flex-direction: row;
justify-content: center;
}
.startup-dialog button {
width: 40%;
}
.startup-dialog #free_trial {
width: 120px;
height: 33px !important;
border-radius: 4px !important;
font-style: normal;
font-size: 14px !important;
line-height: 20px;
text-align: center;
letter-spacing: 0.5px;
color: #FFFFFF !important;
background: #88C149 !important;
padding: 4px 20px 3px 20px;
border: 1px solid transparent !important;
text-decoration: none;
margin-bottom:15px !important;
}
.startup-dialog #login {
border-radius: 6px;
width: 120px;
height: 33px !important;
border-radius: 4px !important;
font-style: normal;
font-size: 14px !important;
line-height: 20px;
text-align: center;
letter-spacing: 0.5px;
color: #FFFFFF !important;
background: #428aca !important;
padding: 4px 20px 3px 20px;
border: 1px solid transparent !important;
text-decoration: none;
margin-bottom:15px !important;
}
.startup-dialog p {
font-size: 14px !important;
color: #000000 !important;
}
.startup-dialog .footer-buttons {
margin-top: 10px !important;
}
.startup-dialog a {
text-decoration: none !important;
}
.startup-dialog .mt20 {
margin-top: 20px !important;
}
</style>
<div class="overlay-background">
<div class="close">
<a href="javascript:void(0);" id="close_app"><img src="close.png" alt="TryMyUi" width="20"></a>
</div>
<form method="dialog" class="startup-dialog">
<header>
<img src="trymyui_logo.png" alt="TryMyUi" width="150">
</header>
<hr>
<div class="row center">
<p>A plugin for getting quick user feedback on your designs via remote usability testing</p>
</div>
<div class="center footer-buttons">
<div class="row">
<a href="javascript:void(0);" id="login">Login</a>
</div>
<div class="row">
<a href="javascript:void(0);" id="free_trial">Free Trial</a>
</div>
<div class="row center mt20">
<p>*Please copy the public link for the prototype you want to test</p>
</div>
</div>
</form></div>`;
function createDialogEntry() {
entryDialog = document.createElement("dialog");
entryDialog.innerHTML = entryHtml;
const loginButton = entryDialog.querySelector("#login");
const freeTrialButton = entryDialog.querySelector("#free_trial");
const closeButton = entryDialog.querySelector("#close_app");
closeButton.addEventListener("click", e => {
entryDialog.close("reasonCanceled");
entryDialog.remove();
})
loginButton.addEventListener("click", e => {
entryDialog.close("reasonCanceled");
entryDialog.remove();
createDialogLogin();
loginDialog.showModal();
});
freeTrialButton.addEventListener("click", e => {
const url = `${website_url}/use_tests/create_use_test_adobexd`;
entryDialog.close("reasonCanceled");
const callGet = xhrRequestGetCreateTest(url, 'GET');
});
document.appendChild(entryDialog);
}
////Entry Dialog End ///////
//// After Use Test Create Customer Account Dialog Start ////
let registrationDialog;
const registrationHtml =
`<style>
.registration-dialog {
height: auto;
width: 410px;
}
.registration-dialog header {
margin-bottom: 10px !important;
}
.registration_step {
overflow-y: scroll;
}
.inner-div {
width: 360px;
margin: 0% 10% !important;
}
.registration-dialog input[type="text"],.registration-dialog input[type="password"] {
width: 90%;
margin-left: 0px !important;
}
.registration-dialog tr {
margin-bottom: 5px !important;
}
.registration-dialog .flex {
display: flex;
flex-direction: row;
}
.registration-dialog .end-flex {
justify-content: flex-end;
margin-right: 9% !important;
}
.registration-dialog .center {
justify-content: center;
}
.registration-dialog .mb5 {
margin-top: 0px !important;
}
.registration-dialog .green_button {
width: 150px;
height: 33px !important;
border-radius: 4px !important;
font-style: normal;
font-size: 14px !important;
line-height: 21px;
text-align: center;
letter-spacing: 0.5px;
color: #FFFFFF !important;
background: #88C149 !important;
padding: 4px 20px;
text-decoration: none !important;
margin-left:8px;
margin-right:8px;
}
.registration-dialog .disabled_button {
width: 150px;
height: 33px !important;
border-radius: 4px !important;
font-style: normal;
font-size: 14px !important;
line-height: 20px;
text-align: center;
letter-spacing: 0.5px;
color: #FFFFFF !important;
background: grey !important;
padding: 4px 20px;
text-decoration: none !important;
margin-left:8px;
margin-right:8px;
}
.registration-dialog #cancel_registartion {
border: 1px solid #444444;
border-radius: 6px;
width: 150px;
height: 33px !important;
border-radius: 4px !important;
font-style: normal;
font-size: 14px !important;
line-height: 20px;
text-align: center;
letter-spacing: 0.5px;
color: #000000 !important;
background: #ffffff !important;
padding: 4px 20px;
text-decoration: none !important;
margin-left:8px;
margin-right:8px;
}
.registration-dialog h2 {
font-size: 18px !important;
color: #000000 !important;
}
.registration-dialog span {
font-size: 14px !important;
color: #000000 !important;
}
.registration-dialog .heading {
font-size: 14px !important;
color: #000000 !important;
padding-bottom: 15px !important;
padding-top: 5px !important;
text-align: center !important;
}
.registration-dialog .registration_step {
min-height: 200px;
max-height: 420px;
overflow-y: scroll;
}
.registration-dialog .show_password {
margin-top: 0px !important;
}
.registration-dialog .show_password span{
font-size: 12px !important;
}
.registration-dialog .show_password input[type="checkbox"]{
margin-left: 0px !important;
}
.registration-dialog .error {
color: red !important;
}
.registration-dialog .flex {
display: flex;
flex-direction: row;
}
.registration-dialog .start {
justify-content: flex-start;
}
.registration-dialog .start strong {
margin-top: 12px !important;
margin-left: 5px !important;
}
.registration-dialog select {
width: 21%;
margin-left: 0px !important;
margin-right: 0px !important;
}
.registration-dialog #phone_number {
width: 64.5% !important;
margin-top: 8px !important;
margin-left: 5px !important;
}
.registration-dialog .mt0 {
margin-top: 0px !important;
}
.registration-dialog .mb0 {
margin-bottom: 0px !important;
}
.model_error {
font-size: 14px !important;
color: red !important;
margin-left: 0px !important;
margin-bottom: 10px !important;
}
.model_error p{
margin-left: 0px !important;
}
</style>
</style>
<div class="white-background">
<form method="dialog" class="registration-dialog" id="form_registration">
<header>
<img src="trymyui_logo.png" alt="TryMyUi" width="150">
</header>
<div class="row center">
<h2>Free trial signup</h2>
</div>
<hr>
<div class="registration_step">
<span class="heading center">Create an account and get the first 5 test results free!</span>
<div class="inner-div">
<table>
<tr class="mb5">
<td><span>Name:</span></td>
<td><input type="text" id="name" name="user[first_name]" required></td>
</tr>
<tr class="mb5">
<td><span>Work email:</span></td>
<td><input type="text" id="email" name="user[email]" required></td>
</tr>
<tr class="mb5">
<td><span>Company name:</span></td>
<td>
<input type="text" id="company_name" name="user[company_name]" required>
</td>
</tr>
<tr class="mb5">
<td><span>Phone number:</span></td>
<td class="flex start">
<select name="user[country_code]" id="country_code">
</select><strong>-</strong><input type="text" id="phone_number" name="user[phone_number]" required>
</td>
</tr>
<tr class="mb0">
<td><span>Password:</span></td>
<td>
<input type="password" id="plain_password" name="user[plain_password]" required>
</td>
</tr>
<tr class="mt0">
<td>
<label for="show_password_chkbox" class="row flex end-flex show_password">
<span>Show password</span>
<input type="checkbox" name="show_password_chkbox" id="show_password_chkbox"">
</label>
</td>
</tr>
</table>
</div>
</div>
<footer class="flex center">
<a href="javascript:void(0);" id="cancel_registartion">Cancel</a>
<a href="javascript:void(0);" id="create_registration" class="green_button">Create account</a>
</footer>
</form>`;
function createRegistrationDialog(params) {
registrationDialog = document.createElement("dialog");
registrationDialog.innerHTML = registrationHtml;
const cancelRegistrationButton = registrationDialog.querySelector("#cancel_registartion");
const registrationStepButton = registrationDialog.querySelector("#create_registration");
const show_password_chkbox = registrationDialog.querySelector("#show_password_chkbox")
cancelRegistrationButton.addEventListener("click", e => {
registrationDialog.close("reasonCanceled");
if (entryDialog) {
entryDialog.close("reasonCanceled");
entryDialog.remove();
}
createDialogEntry();
entryDialog.showModal();
})
show_password_chkbox.addEventListener("change", e => {
var input_password = registrationDialog.querySelector("#plain_password");
if (input_password.type === "password") {
input_password.type = "text";
}else{
input_password.type = "password";
}
});
registrationStepButton.addEventListener("click", e => {
useTest["user"] = {};
$('form#form_registration input[required], form#form_registration textarea[required]').each(function() {
$(this).css("border", "none");
if ($(this).attr("name").includes("phone_number")){
$(this).closest("td").next("span").remove();
}else{
$(this).next("span").remove();
}
var getInputVal = $(this).val();
isEmpty(getInputVal, $(this));
if (!validate) {
return false;
}
});
$('form#form_registration input[required], form#form_registration textarea[required]').focus(function() {
$(this).css("border", "none");
$(".model_error").remove();
if ($(this).attr("name").includes("phone_number")){
$(this).closest("td").next("span").remove();
}else{
$(this).next("span").remove();
}
});
var email_validate = false;
var email = $("#email").val();
var regex_email = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!regex_email.test(email)) {
$("#email").css("border", "none");
$("#email").next("span").remove();
email_validate = false;
$("#email").after("<span class='error'>Invalid Email</span>");
$("#email").css("border", "1px solid red");
} else {
email_validate = true;
$("#email").css("border", "none");
$("#email").next("span").remove();
}
var phone_validate = false;
var phone_number = $("#phone_number").val();
var regex_phone = /([0-9]{10})|(\([0-9]{3}\)\s+[0-9]{3}\-[0-9]{4})/;
if (!regex_phone.test(phone_number)) {
$("#phone_number").css("border", "none");
$("#phone_number").closest("td").next("span").remove();
phone_validate = false;
$("#phone_number").closest("td").after("<span class='error'>Invalid Phone Number</span>");
$("#phone_number").css("border", "1px solid red");
} else {
phone_validate = true;
$("#phone_number").css("border", "none");
$("#phone_number").closest("td").next("span").remove();
}
var password_validate = false;
var password = $("#plain_password").val();
if (password.length < 4) {
$("#plain_password").css("border", "none");
$("#plain_password").next("span").remove();
password_validate = false;
$("#plain_password").after("<span class='error'>Password must be greater than 4 characters</span>");
$("#plain_password").css("border", "1px solid red");
} else {
password_validate = true;
$("#plain_password").css("border", "none");
$("#plain_password").next("span").remove();
}
if (validate && email_validate && phone_validate && password_validate) {
$("#create_registration").addClass("disabled_button").removeClass("green_button");
$("#create_registration").text("Please wait...");
$("#create_registration").attr("disabled", true);
var obj = $("form#form_registration").serializeArray();
$.each(obj, function(i, v) {
if (v.name != "show_password_chkbox") {
var name = v.name.split("[")[1].split("]")[0];
useTest['user'][name] = v.value;
customer_attr[name] = v.value;
}
});
/// For serializing dropdown data
var selectData = $("form#form_registration").find('select').map(function() {
if (this.options[this.selectedIndex] != undefined) {
var select_value = this.options[this.selectedIndex].getAttribute("value");
var data_country = this.options[this.selectedIndex].getAttribute("data-country");
var value = data_country+"|"+select_value
var name = $(this).attr('name').split("[")[1].split("]")[0];
customer_attr[name] = value;
useTest['user'][name] = value;
return encodeURIComponent($(this).attr('name')) + '=' + encodeURIComponent(value);
}
}).get().join('&');
var url = `${website_url}/login/register_adobexd_user`
$.ajax({
url: url,
type: "GET",
data: {user: useTest["user"]},
dataType: 'json',
success: function(response) {
if (response.success) {
registrationDialog.close("reasonCanceled");
registrationDialog.remove();
if (newTestDialog) {
newTestDialog.close("reasonCanceled");
newTestDialog.remove();
}
createNewUseTestDialog();
return newTestDialog.showModal();
} else {
var error_messages = [];
$.each(response.errors, function(k,v){
$.each(v,function(key,val){
error_messages.push(toTitleCase(k).replace("_"," ")+": "+val);
})
})
$(".model_error").remove();
$("<div class='model_error'>Please fix below errors:</div>").insertBefore("table");
$.each(error_messages, function(i,v){
$("div.model_error").append(`<p>`+v+`</p>`);
})
$("#create_registration").addClass("green_button").removeClass("disabled_button");
$("#create_registration").text("Create account");
$("#create_registration").removeAttr("disabled");
}
},
error: function(request, error) {
registrationDialog.close("reasonCanceled");
registrationDialog.remove();
if (errorDialog){
errorDialog.close("reasonCanceled");
errorDialog.remove();
}
createDialogError("Sorry, there seems to be something wrong. Please contact [email protected]");
return errorDialog.showModal();
}
});
} else {
e.preventDefault();
}
});
document.appendChild(registrationDialog);
$.each(country_codes,function(key,value){
if (key == 1) {
$("#country_code").append($("<option selected></option>").attr("value", key).text("+"+key).attr("data-code", key).attr("data-country", value));
}else {
$("#country_code").append($("<option></option>").attr("value", key).text("+"+key).attr("data-code", key).attr("data-country", value));
}
})
}
//// After Use Test Create Customer Account Dialog End ////
///// Use Test Basic Step Start /////
let newTestDialog;
const newTestHtml =
`<style>
.basics-dialog {
height: auto;
width: 700px;
}
.basic_step {
height: 480px;
width: 700px;
overflow-y: scroll;
align-items: center;
margin: 0px 30px 0px 30px !important;
}
.basics-dialog hr{
margin-top: 0px !important;
margin-bottom: 0px !important;
padding-top: 0px !important;
padding-bottom: 0px !important;
}
.basics-dialog input[type="text"], .basics-dialog input[type="number"] {
width: 70%;
margin-left: 25px !important;
}
.basics-dialog table {
margin-left: 10px !important;
}
.basics-dialog .floatBlock {
margin: 0 1.81em 0 0;
}
.basics-dialog .floatBlock label {
color: #666666 !important;
font-size: 13px !important;
}
.basics-dialog .radioContainer {
border: none;
display: flex;
flex-direction: row;
justify-content: flex-start;
break-before: always;
margin: 1em;
}
.basics-dialog h1 {
margin-bottom: 10px;
margin-top: 20px;
}
.basics-dialog .head-center {
text-align: center !important;
margin-bottom: 20px !important;
}
.basics-dialog input[type="checkbox"]{
vertical-align:middle;
}
.basics-dialog .select-label{
display : inline-block;
margin-left: 4px;
}
.basics-dialog select{
width: 50%;
margin-left: 25px !important;
}
.basics-dialog .display_none {
display: none !important;
}
.basics-dialog .display_block {
display: block !important;
}
.basics-dialog .flex {
display: flex;
flex-direction: row;
}
.basics-dialog tr {
margin-top: 30px !important;
}
.basics-dialog .center-right {
justify-content: center;
margin-right: 9% !important;
margin-top: 0px !important;
}
.basics-dialog .start {
justify-content: flex-start;
}
.basics-dialog .end {
justify-content: flex-end;
}
.basics-dialog #new_test {
width: 120px;
height: 33px !important;
border-radius: 4px !important;
font-style: normal;
font-size: 14px !important;
line-height: 21px;
text-align: center;
letter-spacing: 0.5px;
color: #FFFFFF !important;
background: #88C149 !important;
padding: 5px 20px;
text-decoration: none !important;
margin-left:8px;
margin-right:8px;
}
.basics-dialog .primary-button {
border: 1px solid #444444;
border-radius: 6px;
width: 120px;
height: 33px !important;
border-radius: 4px !important;
font-style: normal;
font-size: 14px !important;
line-height: 20px;
text-align: center;
letter-spacing: 0.5px;
color: #000000 !important;
background: #ffffff !important;
padding: 5px 20px;
text-decoration: none !important;
margin-left:8px;
margin-right:8px;
}
.basics-dialog h2 {
font-size: 18px !important;
color: #000000 !important;
}
.basics-dialog td,.basics-dialog span, .basics-dialog .select-label {
font-size: 14px !important;
color: #000000 !important;
font-weight: normal !important;
}
.basics-dialog i {
font-style: italic !important;
color: #666666 !important;
font-size: 12px !important;
}
.basics-dialog a.upgrade_plan {
font-style: italic !important;
font-size: 12px !important;
text-decoration: underline !important;
margin-left: 5px !important;
}
.basics-dialog span.tester_text {
font-size: 13px !important;
}
.basics-dialog .error {
color: red !important;
margin-left: 25px !important;
}
.basics-dialog .upgrade_plan_div {
margin-left: 33px !important;
margin-top: 0px !important;
}
.recording_div, .recorder_orientation_div {
margin-bottom: 30px !important;
}
.basics-dialog #num_testers {
margin-bottom: 0px !important;
}
.basics-dialog .disabled_button {
width: 150px;
height: 33px !important;
border-radius: 4px !important;
font-style: normal;
font-size: 14px !important;
line-height: 20px;
text-align: center;
letter-spacing: 0.5px;
color: #FFFFFF !important;
background: grey !important;
padding: 4px 20px;
text-decoration: none !important;
margin-left:8px;
margin-right:8px;
}
</style>
<div class="white-background">
<form method="dialog" class="basics-dialog form-inline" id="form_new_test">
<header class="head-center">
<img src="trymyui_logo.png" alt="TryMyUi" width="150">
</header>
<hr>
<div class="basic_step">
<h1 class="text-center">Create a new test - Basics (Step 1 of 4)</h1>
<table>
<tr>
<td><span>Title:</span></td>
<td><input type="text" name="use_test[title]" id="title" placeholder="Enter your test title" required></td>
</tr>
<tr>
<td id="url-text"><span>Starting URL:</span></td>
<td><input type="text" name="use_test[url]" placeholder="Enter your prototype's sharable link"
pattern="https://.*" id="url" required></td>
</tr>
<tr>
<td><span>Device testers should use:</span></td>
<td>
<div id="radioContainer" name="radioContainer" class="radioContainer">
<div class="floatBlock">
<label for="tester_platform"><input type="radio" name="use_test[tester_platform]" value="pc_mac" checked> Computer</label>
</div>
<div class="floatBlock">
<label for="tester_platform"><input type="radio" name="use_test[tester_platform]" value="android_all" > Android phone</label>
</div>
<div class="floatBlock">
<label for="tester_platform"><input type="radio" name="use_test[tester_platform]" value="ios_all" > iPhone</label>
</div>
<div class="floatBlock">
<label for="tester_platform"><input type="radio" name="use_test[tester_platform]" value="all_mobile" > All mobile devices</label>
</div>
</td>
</tr>
<tr>
<td><span>Number of testers:</span></td>
<td><input type="number" name="use_test[num_testers]" id="num_testers" placeholder="Number of Testers" max="50" required>
<label for="new_testers_only" class="row flex center-right">
<span class="tester_text">Do not allow testers who have performed tests for me before:</span>
<input type="checkbox" name="use_test[new_testers_only]" id="new_testers_only" value="true">
</label>
</td>
</tr>
<tr class="display_block recording_div">
<td>
<label class="select-label">Time limit:</label>
<select name="use_test[recording_time]" id="recording_time">
</select>
</td>
</tr>
<tr class="face_recording_div display_none">
<td>
<label for="face_recording" class="row flex start" >
<input type="checkbox" name="use_test[opt_for_face_recording]" id="opt_for_face_recording" value="true">
<span>Include face recording of the users with my test.</span>
</label>
</td>
</tr>
<tr class="recorder_orientation_div display_none">
<td>
<label class="select-label">Screen Orientation:</label>
<select name="use_test[recorder_orientation]" id="recorder_orientation">
<option value="portrait">Portrait</option>
<option value="landscape">Landscape</option>
</select>
</td>
</tr>
<tr><td>*1 credit is equivalent to 1 tester</td></tr>
</table>
</div>
<hr>
<footer class="flex end">
<a href="javascript:void(0);" id="cancel_basic" class="primary-button display_block">Cancel</a>
<a href="javascript:void(0);" id="return_to_dashboard" class="primary-button display_none">Cancel</a>
<a href="javascript:void(0);" id="new_test">Continue</a>
</footer>
</form></div>`;
function createNewUseTestDialog(use_test, customer, type, back) {
newTestDialog = document.createElement("dialog");
newTestDialog.innerHTML = newTestHtml;
const cancelButton = newTestDialog.querySelector("#cancel_basic");
const returnDashboardButton = newTestDialog.querySelector("#return_to_dashboard");
const newTestButton = newTestDialog.querySelector("#new_test");
cancelButton.onclick = () => newTestDialog.close("reasonCanceled");
returnDashboardButton.addEventListener("click", e => {
$("#return_to_dashboard").addClass("disabled_button").removeClass("primary-button");
$("#return_to_dashboard").text("Please wait...");
e.preventDefault();
var use_test_id = [use_test["id"]];
var password = useTest['user']["password"];
var email = useTest['user']["email"];
var remember_user = false;
const url = `${website_url}/login_adobexd?user[plain_password]=${useTest['user']["password"]}&user[email]=${useTest['user']["email"]}&user[remember_user]=${useTest['user']["remember_user"]}`;
const callPost = xhrRequest(url, 'POST', password, email, remember_user);
})
newTestButton.addEventListener("click", e => {
$('form#form_new_test input[required], form#form_new_test .display_block select').each(function() {
$(this).css("border", "none");
$(this).next("span").remove();
var getInputVal = $(this).val();
isEmpty(getInputVal, $(this));
if (!validate) {
return false;
}
});
$('form#form_new_test input[required], form#form_new_test .display_block select').focus(function() {
$(this).css("border", "none");
$(this).next("span").remove();
});
var regex = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i
var url = $("#url").val();
var url_validate = false;
if (!regex.test(url)) {
$("#url").css("border", "none");
$("#url").next("span").remove();
url_validate = false;
$("#url").after("<span class='error'>Invalid URL</span>");
$("#url").css("border", "1px solid red");
} else {
url_validate = true;
$("#url").css("border", "none");
$("#url").next("span").remove();
}
var num_testers_validate = true;
if( $("#num_testers").val() > 50) {
$("#num_testers").after("<span class='error'>Number of testers cannot be greater than 50</span>");
$("#num_testers").css("border", "1px solid red");
num_testers_validate = false;
}
if (validate && url_validate && num_testers_validate) {
var str = $("form#form_new_test").serialize();
var obj = $("form#form_new_test").serializeArray();
test_json["basic_step"] = {};
$.each(obj, function(i, v) {
var name = v.name.split("[")[1].split("]")[0];
useTest['use_test'][name] = v.value || '';
test_json["basic_step"][name] = v.value || '';
});
if (use_test && use_test.hasOwnProperty('id')) {
useTest['use_test']['id'] = use_test["id"];
}
/// For serializing checkboxes
var checkBoxData = $("form#form_new_test").find('input[type=checkbox]').map(function() {
var name = this.name.split("[")[1].split("]")[0];
useTest['use_test'][name] = $('#'+name).is(":checked");
}).get().join('&');
/// For serializing dropdown data
var selectData = $("form#form_new_test").find('select').map(function() {
if (this.options[this.selectedIndex] != undefined) {
var select_value = this.options[this.selectedIndex].getAttribute("value");
var name = $(this).attr('name').split("[")[1].split("]")[0];
useTest['use_test'][name] = select_value;
test_json["basic_step"][name] = select_value;
return encodeURIComponent($(this).attr('name')) + '=' + encodeURIComponent(select_value);
}
}).get().join('&');
if (type == "edit_test") {
useTest["type"] = "edit_test";
}
var new_str = "";
newTestDialog.close("reasonCanceled");