PluginProbe
HTTP Headers / 1.10.4
HTTP Headers v1.10.4
1.19.5 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.14.0 1.14.1 1.14.2 1.15.0 All 60 releases
http-headers / assets / scripts.js

scripts.js in HTTP Headers 1.10.4, at assets/scripts.js

164 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($, undefined) {
2 $(function() {
3 "use strict";
4
5 $(document).on('change', 'select[name="hh_x_frame_options_value"]', function () {
6 var $el = $('input[name="hh_x_frame_options_domain"]'),
7 readOnly = $(this).find('option:selected').val() != 'allow-from';
8 if ($el.length) {
9 $el.prop('readOnly', readOnly).toggle(!readOnly);
10 }
11 }).on('change', 'select[name="hh_x_xxs_protection_value"]', function (e) {
12 var $el = $('input[name="hh_x_xxs_protection_uri"]'),
13 readOnly = $(this).find('option:selected').val() != '1; report=';
14 if ($el.length) {
15 $el.prop('readOnly', readOnly).toggle(!readOnly);
16 }
17 }).on('change', 'select[name="hh_x_powered_by_option"]', function () {
18 var $el = $('input[name="hh_x_powered_by_value"]'),
19 readOnly = $(this).find('option:selected').val() != 'set';
20 if ($el.length) {
21 $el.prop('readOnly', readOnly).toggle(!readOnly);
22 }
23 }).on('change', 'select[name="hh_access_control_allow_origin_value"]', function () {
24 var $el = $('input[name="hh_access_control_allow_origin_url"]'),
25 readOnly = $(this).find('option:selected').val() != 'origin';
26 if ($el.length) {
27 $el.prop('readOnly', readOnly);//.toggle(!readOnly);
28 }
29 if (readOnly) {
30 $(".hh-acao").addClass("hh-hidden");
31 } else {
32 $(".hh-acao").removeClass("hh-hidden");
33 }
34 }).on('change', 'select[name="hh_timing_allow_origin_value"]', function () {
35 var $el = $('input[name="hh_timing_allow_origin_url"]'),
36 readOnly = $(this).find('option:selected').val() != 'origin';
37 if ($el.length) {
38 $el.prop('readOnly', readOnly).toggle(!readOnly);
39 }
40 }).on('change', '.http-header', function () {
41 var $this = $(this),
42 $el = $this.closest('table').find('.http-header-value');
43
44 if (!$el.length) {
45 return;
46 }
47
48 if (Number($this.val()) === 1) {
49 $el.prop('readOnly', false).removeAttr('readonly').removeClass('readonly');
50 } else {
51 $el.prop('readOnly', true).addClass('readonly');
52 }
53 }).on('change', 'input[name="hh_x_frame_options"]', function () {
54 $('select[name="hh_x_frame_options_value"]').trigger('change');
55 }).on('change', 'input[name="hh_x_powered_by"]', function () {
56 $('select[name="hh_x_powered_by_option"]').trigger('change');
57 }).on('change', 'input[name="hh_access_control_allow_origin"]', function () {
58 $('select[name="hh_access_control_allow_origin_value"]').trigger('change');
59 }).on('change', 'input[name="hh_timing_allow_origin"]', function () {
60 $('select[name="hh_timing_allow_origin_value"]').trigger('change');
61 }).on('submit', '#frmIspect', function (e) {
62 e.preventDefault();
63 var $this = $(this),
64 $box = $('#hh-result').empty();
65 $.post($this.attr('action'), $this.serialize()).done(function (data) {
66 $box.html(data);
67 });
68 return false;
69 }).on('change', '#authentication', function () {
70 var $a = $('#box-authentication');
71 if (this.checked) {
72 $a.show();
73 } else {
74 $a.hide();
75 }
76 }).on('click', '#hh-btn-add-header', function () {
77 $(this).closest('tr').before('<tr> \
78 <td><input type="text" name="hh_custom_headers_value[name][]" class="http-header-value" placeholder="X-Custom-Name"></td> \
79 <td><input type="text" name="hh_custom_headers_value[value][]" class="http-header-value" placeholder="' + hh.lbl_value + '"></td> \
80 <td><button type="button" class="button button-small hh-btn-delete-header" title="' + hh.lbl_delete + '">x</button></td> \
81 </tr>');
82 }).on('click', '#hh-btn-add-endpoint', function () {
83 var $this = $(this),
84 index = Math.ceil(Math.random() * 9999),
85 $table = $this.closest("table"),
86 $clone = $table.find("tr:nth-child(2)").clone(),
87 name = $table.find("tr:nth-last-child(2)").find(":input:first").attr("name"),
88 m = name.match(/^hh_report_to_value\[(\d+)\]/),
89 index = Number(m[1]) + 1;
90
91 $clone.find('input[type="text"]').val("");
92 $clone.find('input[type="checkbox"]').prop("checked", false);
93 $clone.find("option:first").prop("selected", true);
94 $clone.find("td:last").html('<button type="button" class="button button-small hh-btn-delete-endpoint" title="' + hh.lbl_delete + '">x</button>');
95 $clone.find(":input").each(function () {
96 this.name = this.name.replace('[0]', '[' + index + ']');
97 });
98
99 $this.closest('tr').before($clone);
100 }).on('click', '.hh-btn-delete-header, .hh-btn-delete-endpoint, .hh-btn-delete-origin, .hh-btn-delete-user', function () {
101 $(this).closest('tr').remove();
102 }).on("click", ".hh-btn-add-origin", function () {
103 $(this).closest('tr').before('<tr class="hh-acao"> \
104 <td>&nbsp;</td> \
105 <td><input type="text" name="hh_access_control_allow_origin_url[]" class="http-header-value" placeholder="http://domain.com" size="35" /></td> \
106 <td><button type="button" class="button button-small hh-btn-delete-origin" title="' + hh.lbl_delete + '">x</button></td> \
107 </tr>');
108 }).on("click", ".hh-btn-add-user", function () {
109 $(this).closest('tr').before('<tr> \
110 <td>&nbsp;</td> \
111 <td><input type="text" name="hh_www_authenticate_user[]" class="http-header-value" /></td> \
112 <td><input type="text" name="hh_www_authenticate_pswd[]" class="http-header-value" /></td> \
113 <td><button type="button" class="button button-small hh-btn-delete-user" title="' + hh.lbl_delete + '">x</button></td> \
114 </tr>');
115 }).on("click", ".hh-btn-import-choose", function () {
116 $("#hh-import-file").trigger("click");
117 }).on("change", "#hh-import-file", function () {
118 $("#hh-import-name").html(this.files[0].name);
119 }).on("change", 'select[name^="hh_feature_policy_value"]', function () {
120 var $this = $(this),
121 value = $this.find("option:selected").val(),
122 $input = $this.siblings('input[name^="hh_feature_policy_origin"]');
123 if (value === "'self'" || value === "origin(s)") {
124 $input.show();
125 } else {
126 $input.hide();
127 }
128 });
129
130 $('.hh-tabs').on('click', 'ul a', function (e) {
131 e.preventDefault();
132
133 var $this = $(this);
134 $($this.attr('href'))
135 .removeClass('hh-hidden').addClass('hh-tab-active').attr('aria-hidden', 'false').attr('aria-expanded', 'true')
136 .siblings('div').addClass('hh-hidden').removeClass('hh-tab-active').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
137 $this.closest('li')
138 .addClass('hh-active').attr('aria-selected', 'true').attr('tabindex', 0)
139 .siblings('li').removeClass('hh-active').attr('aria-selected', 'false').attr('tabindex', -1);
140 }).each(function () {
141 var $this = $(this),
142 $ul = $this.children('ul').attr('role', 'tablist'),
143 $li = $ul.children('li').attr('role', 'tab')
144 .not(':first').attr('aria-selected', 'false').attr('tabindex', -1)
145 .end().eq(0).attr('aria-selected', 'true').attr('tabindex', 0)
146 .end(),
147 $a = $li.find('a').attr('role', 'presentation').attr('tabindex', -1),
148 $div = $this.children('div').attr('role', 'tabpanel')
149 .not(':first').attr('aria-hidden', 'true').attr('aria-expanded', 'false')
150 .end().eq(0).attr('aria-hidden', 'false').attr('aria-expanded', 'true')
151 .end();
152
153 $li.each(function (i) {
154 var $this = $(this),
155 id = 'hh-tabs-' + Math.ceil(Math.random() * 999999) + '-' + i,
156 $a = $this.attr('aria-labelledby', id).find('a').attr('id', id),
157 href = $a.attr('href');
158 $this.attr('aria-controls', href.substring(1)).attr('aria-labelledby', id);
159 $(href).attr('aria-labelledby', id);
160 });
161
162 });
163 });
164 })(jQuery);