mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-12-12 19:16:40 +00:00
UI - Fixing preview/diff "ignore text" highlight button (refactor, didnt work in "preview" mode) (#2455)
This commit is contained in:
@@ -1,14 +1,5 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
// duplicate
|
|
||||||
var csrftoken = $('input[name=csrf_token]').val();
|
|
||||||
$.ajaxSetup({
|
|
||||||
beforeSend: function (xhr, settings) {
|
|
||||||
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
|
|
||||||
xhr.setRequestHeader("X-CSRFToken", csrftoken)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
var browsersteps_session_id;
|
var browsersteps_session_id;
|
||||||
var browser_interface_seconds_remaining = 0;
|
var browser_interface_seconds_remaining = 0;
|
||||||
var apply_buttons_disabled = false;
|
var apply_buttons_disabled = false;
|
||||||
|
|||||||
10
changedetectionio/static/js/csrf.js
Normal file
10
changedetectionio/static/js/csrf.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
$.ajaxSetup({
|
||||||
|
beforeSend: function (xhr, settings) {
|
||||||
|
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
|
||||||
|
xhr.setRequestHeader("X-CSRFToken", csrftoken)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
@@ -1,13 +1,4 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var csrftoken = $('input[name=csrf_token]').val();
|
|
||||||
$.ajaxSetup({
|
|
||||||
beforeSend: function (xhr, settings) {
|
|
||||||
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
|
|
||||||
xhr.setRequestHeader("X-CSRFToken", csrftoken)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
$('.needs-localtime').each(function () {
|
$('.needs-localtime').each(function () {
|
||||||
for (var option of this.options) {
|
for (var option of this.options) {
|
||||||
var dateObject = new Date(option.value * 1000);
|
var dateObject = new Date(option.value * 1000);
|
||||||
@@ -48,6 +39,12 @@ $(document).ready(function () {
|
|||||||
$("#highlightSnippet").remove();
|
$("#highlightSnippet").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Listen for Escape key press
|
||||||
|
window.addEventListener('keydown', function (e) {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
clean();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
function dragTextHandler(event) {
|
function dragTextHandler(event) {
|
||||||
console.log('mouseupped');
|
console.log('mouseupped');
|
||||||
|
|||||||
@@ -13,16 +13,6 @@ $(document).ready(function() {
|
|||||||
$('#send-test-notification').click(function (e) {
|
$('#send-test-notification').click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// this can be global
|
|
||||||
var csrftoken = $('input[name=csrf_token]').val();
|
|
||||||
$.ajaxSetup({
|
|
||||||
beforeSend: function(xhr, settings) {
|
|
||||||
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
|
|
||||||
xhr.setRequestHeader("X-CSRFToken", csrftoken)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
notification_body: $('#notification_body').val(),
|
notification_body: $('#notification_body').val(),
|
||||||
notification_format: $('#notification_format').val(),
|
notification_format: $('#notification_format').val(),
|
||||||
|
|||||||
@@ -26,7 +26,11 @@
|
|||||||
<meta name="msapplication-TileColor" content="#da532c">
|
<meta name="msapplication-TileColor" content="#da532c">
|
||||||
<meta name="msapplication-config" content="favicons/browserconfig.xml">
|
<meta name="msapplication-config" content="favicons/browserconfig.xml">
|
||||||
<meta name="theme-color" content="#ffffff">
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
<script>
|
||||||
|
const csrftoken="{{ csrf_token() }}";
|
||||||
|
</script>
|
||||||
<script src="{{url_for('static_content', group='js', filename='jquery-3.6.0.min.js')}}"></script>
|
<script src="{{url_for('static_content', group='js', filename='jquery-3.6.0.min.js')}}"></script>
|
||||||
|
<script src="{{url_for('static_content', group='js', filename='csrf.js')}}" defer></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ def test_highlight_ignore(client, live_server):
|
|||||||
)
|
)
|
||||||
|
|
||||||
res = client.get(url_for("edit_page", uuid=uuid))
|
res = client.get(url_for("edit_page", uuid=uuid))
|
||||||
|
|
||||||
# should be a regex now
|
# should be a regex now
|
||||||
assert b'/oh\ yeah\ \d+/' in res.data
|
assert b'/oh\ yeah\ \d+/' in res.data
|
||||||
|
|
||||||
@@ -55,3 +54,7 @@ def test_highlight_ignore(client, live_server):
|
|||||||
# And it should register in the preview page
|
# And it should register in the preview page
|
||||||
res = client.get(url_for("preview_page", uuid=uuid))
|
res = client.get(url_for("preview_page", uuid=uuid))
|
||||||
assert b'<div class="ignored">oh yeah 456' in res.data
|
assert b'<div class="ignored">oh yeah 456' in res.data
|
||||||
|
|
||||||
|
# Should be in base.html
|
||||||
|
assert b'csrftoken' in res.data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user