| 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", "input[name^='hh_vary_value[']", function () { |
| 24 |
|
| 25 |
if (this.name === "hh_vary_value[*]") { |
| 26 |
if (this.checked) { |
| 27 |
$("input[name^='hh_vary_value[']").not(this).prop("checked", false); |
| 28 |
} |
| 29 |
} else { |
| 30 |
if (this.checked) { |
| 31 |
$("input[name='hh_vary_value[*]']").prop("checked", false); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
}).on("change", "input[name^='hh_access_control_allow_methods_value[']", function () { |
| 36 |
|
| 37 |
if (this.name === "hh_access_control_allow_methods_value[*]") { |
| 38 |
if (this.checked) { |
| 39 |
$("input[name^='hh_access_control_allow_methods_value[']").not(this).prop("checked", false); |
| 40 |
} |
| 41 |
} else { |
| 42 |
if (this.checked) { |
| 43 |
$("input[name='hh_access_control_allow_methods_value[*]']").prop("checked", false); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
}).on('change', 'select[name="hh_access_control_allow_origin_value"]', function () { |
| 48 |
var $el = $('input[name="hh_access_control_allow_origin_url"]'), |
| 49 |
readOnly = $(this).find('option:selected').val() != 'origin'; |
| 50 |
if ($el.length) { |
| 51 |
$el.prop('readOnly', readOnly);//.toggle(!readOnly); |
| 52 |
} |
| 53 |
if (readOnly) { |
| 54 |
$(".hh-acao").addClass("hh-hidden"); |
| 55 |
} else { |
| 56 |
$(".hh-acao").removeClass("hh-hidden"); |
| 57 |
} |
| 58 |
}).on('change', 'select[name="hh_timing_allow_origin_value"]', function () { |
| 59 |
var $el = $('input[name="hh_timing_allow_origin_url"]'), |
| 60 |
readOnly = $(this).find('option:selected').val() != 'origin'; |
| 61 |
if ($el.length) { |
| 62 |
$el.prop('readOnly', readOnly).toggle(!readOnly); |
| 63 |
} |
| 64 |
}).on('change', '.http-header', function () { |
| 65 |
var $this = $(this), |
| 66 |
$el = $this.closest('table').find('.http-header-value'); |
| 67 |
|
| 68 |
if (!$el.length) { |
| 69 |
return; |
| 70 |
} |
| 71 |
|
| 72 |
if (Number($this.val()) === 1) { |
| 73 |
$el.prop('readOnly', false).removeAttr('readonly').removeClass('readonly'); |
| 74 |
} else { |
| 75 |
$el.prop('readOnly', true).addClass('readonly'); |
| 76 |
} |
| 77 |
}).on('change', 'input[name="hh_x_frame_options"]', function () { |
| 78 |
$('select[name="hh_x_frame_options_value"]').trigger('change'); |
| 79 |
}).on('change', 'input[name="hh_x_powered_by"]', function () { |
| 80 |
$('select[name="hh_x_powered_by_option"]').trigger('change'); |
| 81 |
}).on('change', 'input[name="hh_access_control_allow_origin"]', function () { |
| 82 |
$('select[name="hh_access_control_allow_origin_value"]').trigger('change'); |
| 83 |
}).on('change', 'input[name="hh_timing_allow_origin"]', function () { |
| 84 |
$('select[name="hh_timing_allow_origin_value"]').trigger('change'); |
| 85 |
}).on('submit', '#frmIspect', function (e) { |
| 86 |
e.preventDefault(); |
| 87 |
var $this = $(this), |
| 88 |
$box = $('#hh-result').empty(); |
| 89 |
$.post($this.attr('action'), $this.serialize()).done(function (data) { |
| 90 |
$box.html(data); |
| 91 |
}); |
| 92 |
return false; |
| 93 |
}).on('change', '#authentication', function () { |
| 94 |
var $a = $('#box-authentication'); |
| 95 |
if (this.checked) { |
| 96 |
$a.show(); |
| 97 |
} else { |
| 98 |
$a.hide(); |
| 99 |
} |
| 100 |
}).on('click', '#hh-btn-add-header', function () { |
| 101 |
$(this).closest('tr').before('<tr> \ |
| 102 |
<td><input type="text" name="hh_custom_headers_value[name][]" class="http-header-value" placeholder="X-Custom-Name"></td> \ |
| 103 |
<td><input type="text" name="hh_custom_headers_value[value][]" class="http-header-value" placeholder="' + hh.lbl_value + '"></td> \ |
| 104 |
<td><button type="button" class="button button-small hh-btn-delete-header" title="' + hh.lbl_delete + '">x</button></td> \ |
| 105 |
</tr>'); |
| 106 |
}).on('click', '.hh-btn-add-endpoint', function () { |
| 107 |
|
| 108 |
var $tr = $(this).closest("tr"); |
| 109 |
|
| 110 |
$tr.children("td").each(function() { |
| 111 |
if ($(this).attr("rowspan") !== undefined) { |
| 112 |
this.rowSpan = this.rowSpan + 1; |
| 113 |
} |
| 114 |
}); |
| 115 |
|
| 116 |
var name, |
| 117 |
$clone = $tr.clone().removeClass("hh-tr-first hh-tr-group-start"), |
| 118 |
$this = $(this), |
| 119 |
index = Math.ceil(Math.random() * 9999); |
| 120 |
|
| 121 |
if ($tr.hasClass("hh-tr-group-end")) { |
| 122 |
name = $tr.find("input[name$='[url]']").attr("name"); |
| 123 |
} else { |
| 124 |
name = $tr.nextAll(".hh-tr-group-end:eq(0)").find("input[name$='[url]']").attr("name"); |
| 125 |
} |
| 126 |
|
| 127 |
var m = name.match(/\[(\d+)\]\[url\]$/), |
| 128 |
index = Number(m[1]) + 1; |
| 129 |
|
| 130 |
$clone.find("td").each(function() { |
| 131 |
if ($(this).attr("rowspan") !== undefined) { |
| 132 |
$(this).remove(); |
| 133 |
} |
| 134 |
}); |
| 135 |
|
| 136 |
$clone.find('input[type="text"]').val(""); |
| 137 |
$clone.find('input[type="number"]').val(""); |
| 138 |
$clone.find("td:last").html('<button type="button" class="button hh-btn-delete-endpoint" title="' + hh.lbl_delete + '">' + hh.lbl_remove_endpoint + '</button>'); |
| 139 |
$clone.find(":input").each(function () { |
| 140 |
this.name = this.name.replace('[endpoints][0]', '[endpoints][' + index + ']'); |
| 141 |
}); |
| 142 |
|
| 143 |
$clone.addClass("hh-tr-group-end"); |
| 144 |
if ($tr.hasClass("hh-tr-group-end")) { |
| 145 |
$tr.removeClass("hh-tr-group-end"); |
| 146 |
$tr.after($clone); |
| 147 |
} else { |
| 148 |
$tr.nextAll(".hh-tr-group-end:eq(0)").removeClass("hh-tr-group-end").after($clone); |
| 149 |
} |
| 150 |
|
| 151 |
}).on('click', '#hh-btn-add-endpoint-group', function () { |
| 152 |
var $this = $(this), |
| 153 |
index = Math.ceil(Math.random() * 9999), |
| 154 |
$table = $this.closest("table"), |
| 155 |
$clone = $table.find("tr.hh-tr-first").eq(0).clone(), |
| 156 |
name = $table.find("tr:nth-last-child(2)").find(":input:first").attr("name"), |
| 157 |
m = name.match(/^hh_report_to_value\[(\d+)\]/), |
| 158 |
index = Number(m[1]) + 1; |
| 159 |
|
| 160 |
$clone.find("td").each(function() { |
| 161 |
if ($(this).attr("rowspan") !== undefined) { |
| 162 |
this.rowSpan = 1; |
| 163 |
} |
| 164 |
}); |
| 165 |
|
| 166 |
$clone.find('input[type="text"]').val(""); |
| 167 |
$clone.find('input[type="number"]').val(""); |
| 168 |
$clone.find('input[type="checkbox"]').prop("checked", false); |
| 169 |
$clone.find("option:first").prop("selected", true); |
| 170 |
$clone.find("td:last").html('<button type="button" class="button hh-btn-delete-endpoint-group" title="' + hh.lbl_delete + '">' + hh.lbl_remove_group + '</button>'); |
| 171 |
$clone.find(":input").each(function () { |
| 172 |
this.name = this.name.replace('[0]', '[' + index + ']'); |
| 173 |
}); |
| 174 |
$clone.addClass("hh-tr-group-end").removeClass("hh-tr-first"); |
| 175 |
|
| 176 |
$this.closest('tr').before($clone); |
| 177 |
}).on('click', '.hh-btn-delete-header, .hh-btn-delete-origin, .hh-btn-delete-user, .hh-btn-delete-ac', function () { |
| 178 |
|
| 179 |
$(this).closest('tr').remove(); |
| 180 |
|
| 181 |
}).on('click', '.hh-btn-delete-endpoint', function() { |
| 182 |
|
| 183 |
var $group, |
| 184 |
$tr = $(this).closest("tr"); |
| 185 |
|
| 186 |
if ($tr.prev("tr").hasClass("hh-tr-group-start")) { |
| 187 |
$group = $tr.prev("tr"); |
| 188 |
} else { |
| 189 |
$group = $tr.prevUntil("tr.hh-tr-group-start").prev("tr"); |
| 190 |
} |
| 191 |
|
| 192 |
$group.children("td").each(function() { |
| 193 |
if (this.rowSpan > 1) { |
| 194 |
this.rowSpan = this.rowSpan - 1; |
| 195 |
} |
| 196 |
}); |
| 197 |
|
| 198 |
if ($tr.hasClass("hh-tr-group-end")) { |
| 199 |
$tr.prev("tr").addClass("hh-tr-group-end"); |
| 200 |
} |
| 201 |
|
| 202 |
$tr.remove(); |
| 203 |
|
| 204 |
}).on('click', '.hh-btn-delete-endpoint-group', function () { |
| 205 |
var rows = $(this).closest("td").attr("rowspan"); |
| 206 |
if (rows === undefined || rows < 2) { |
| 207 |
$(this).closest('tr').remove(); |
| 208 |
} else { |
| 209 |
$(this).closest('tr').nextAll("tr").addBack().slice(0, rows).remove(); |
| 210 |
} |
| 211 |
}).on("click", ".hh-btn-add-ac", function () { |
| 212 |
var $this = $(this); |
| 213 |
$this.closest('tr').before('<tr> \ |
| 214 |
<td><input type="text" name="' + $this.data("name") + '" class="http-header-value" size="35" /></td> \ |
| 215 |
<td><button type="button" class="button button-small hh-btn-delete-ac" title="' + hh.lbl_delete + '">x</button></td> \ |
| 216 |
</tr>'); |
| 217 |
}).on("click", ".hh-btn-add-origin", function () { |
| 218 |
$(this).closest('tr').before('<tr class="hh-acao"> \ |
| 219 |
<td> </td> \ |
| 220 |
<td><input type="text" name="hh_access_control_allow_origin_url[]" class="http-header-value" placeholder="http://domain.com" size="35" /></td> \ |
| 221 |
<td><button type="button" class="button button-small hh-btn-delete-origin" title="' + hh.lbl_delete + '">x</button></td> \ |
| 222 |
</tr>'); |
| 223 |
}).on("click", ".hh-btn-add-user", function () { |
| 224 |
$(this).closest('tr').before('<tr> \ |
| 225 |
<td> </td> \ |
| 226 |
<td><input type="text" name="hh_www_authenticate_user[]" class="http-header-value" /></td> \ |
| 227 |
<td><input type="text" name="hh_www_authenticate_pswd[]" class="http-header-value" /></td> \ |
| 228 |
<td><button type="button" class="button button-small hh-btn-delete-user" title="' + hh.lbl_delete + '">x</button></td> \ |
| 229 |
</tr>'); |
| 230 |
}).on("click", ".hh-btn-import-choose", function () { |
| 231 |
$("#hh-import-file").trigger("click"); |
| 232 |
}).on("change", "#hh-import-file", function () { |
| 233 |
$("#hh-import-name").html(this.files[0].name); |
| 234 |
}).on("change", 'select[name^="hh_feature_policy_value"]', function () { |
| 235 |
var $this = $(this), |
| 236 |
value = $this.find("option:selected").val(), |
| 237 |
$input = $this.siblings('input[name^="hh_feature_policy_origin"]'); |
| 238 |
if (value === "'self'" || value === "origin(s)") { |
| 239 |
$input.show(); |
| 240 |
} else { |
| 241 |
$input.hide(); |
| 242 |
} |
| 243 |
}).on("change", 'select[name^="hh_permissions_policy_value"]', function () { |
| 244 |
var $this = $(this), |
| 245 |
value = $this.find("option:selected").val(), |
| 246 |
$input = $this.siblings('input[name^="hh_permissions_policy_origin"]'); |
| 247 |
if (value === "self" || value === "origin(s)") { |
| 248 |
$input.show(); |
| 249 |
} else { |
| 250 |
$input.hide(); |
| 251 |
} |
| 252 |
}).on("change", 'input[name^="hh_content_security_policy_value"]', function () { |
| 253 |
|
| 254 |
var $this = $(this); |
| 255 |
|
| 256 |
if (this.checked) { |
| 257 |
if (/\[\*\]$/.test(this.name)) { |
| 258 |
$this.closest("td").find('input[type="checkbox"]').not(this).prop("checked", false); |
| 259 |
$this.closest("p").siblings("p").hide(); |
| 260 |
} else { |
| 261 |
$this.closest("td").find('input[type="checkbox"][name$="[*]"]').prop("checked", false); |
| 262 |
} |
| 263 |
} else { |
| 264 |
if (/\[\*\]$/.test(this.name)) { |
| 265 |
$this.closest("p").siblings("p").show(); |
| 266 |
} |
| 267 |
} |
| 268 |
}).on("change", 'input[type="checkbox"][name="hh_cookie_security_value[SameSite]"]', function () { |
| 269 |
if (this.checked) { |
| 270 |
$(".hh-csv-value") |
| 271 |
.removeClass("hh-hidden") |
| 272 |
.find('input[type="radio"]') |
| 273 |
.prop("disabled", false) |
| 274 |
.filter(":first") |
| 275 |
.prop("checked", true); |
| 276 |
} else { |
| 277 |
$(".hh-csv-value") |
| 278 |
.addClass("hh-hidden") |
| 279 |
.find('input[type="radio"]') |
| 280 |
.prop("disabled", true); |
| 281 |
} |
| 282 |
}); |
| 283 |
|
| 284 |
$('.hh-tabs').on('click', 'ul a', function (e) { |
| 285 |
e.preventDefault(); |
| 286 |
|
| 287 |
var $this = $(this); |
| 288 |
$($this.attr('href')) |
| 289 |
.removeClass('hh-hidden').addClass('hh-tab-active').attr('aria-hidden', 'false').attr('aria-expanded', 'true') |
| 290 |
.siblings('div').addClass('hh-hidden').removeClass('hh-tab-active').attr('aria-hidden', 'true').attr('aria-expanded', 'false'); |
| 291 |
$this.closest('li') |
| 292 |
.addClass('hh-active').attr('aria-selected', 'true').attr('tabindex', 0) |
| 293 |
.siblings('li').removeClass('hh-active').attr('aria-selected', 'false').attr('tabindex', -1); |
| 294 |
}).each(function () { |
| 295 |
var $this = $(this), |
| 296 |
$ul = $this.children('ul').attr('role', 'tablist'), |
| 297 |
$li = $ul.children('li').attr('role', 'tab') |
| 298 |
.not(':first').attr('aria-selected', 'false').attr('tabindex', -1) |
| 299 |
.end().eq(0).attr('aria-selected', 'true').attr('tabindex', 0) |
| 300 |
.end(), |
| 301 |
$a = $li.find('a').attr('role', 'presentation').attr('tabindex', -1), |
| 302 |
$div = $this.children('div').attr('role', 'tabpanel') |
| 303 |
.not(':first').attr('aria-hidden', 'true').attr('aria-expanded', 'false') |
| 304 |
.end().eq(0).attr('aria-hidden', 'false').attr('aria-expanded', 'true') |
| 305 |
.end(); |
| 306 |
|
| 307 |
$li.each(function (i) { |
| 308 |
var $this = $(this), |
| 309 |
id = 'hh-tabs-' + Math.ceil(Math.random() * 999999) + '-' + i, |
| 310 |
$a = $this.attr('aria-labelledby', id).find('a').attr('id', id), |
| 311 |
href = $a.attr('href'); |
| 312 |
$this.attr('aria-controls', href.substring(1)).attr('aria-labelledby', id); |
| 313 |
$(href).attr('aria-labelledby', id); |
| 314 |
}); |
| 315 |
|
| 316 |
}); |
| 317 |
}); |
| 318 |
})(jQuery); |