2022-01-28 21:00:11 +00:00
|
|
|
import $ from 'jquery';
|
2023-02-19 04:06:14 +00:00
|
|
|
import {hideElem, showElem} from '../utils/dom.js';
|
2022-01-28 21:00:11 +00:00
|
|
|
|
2022-01-07 01:18:52 +00:00
|
|
|
export function initUnicodeEscapeButton() {
|
|
|
|
$(document).on('click', 'a.escape-button', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
$(e.target).parents('.file-content, .non-diff-file-content').find('.file-code, .file-view').addClass('unicode-escaped');
|
2023-02-19 04:06:14 +00:00
|
|
|
hideElem($(e.target));
|
|
|
|
showElem($(e.target).siblings('a.unescape-button'));
|
2022-01-07 01:18:52 +00:00
|
|
|
});
|
|
|
|
$(document).on('click', 'a.unescape-button', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
$(e.target).parents('.file-content, .non-diff-file-content').find('.file-code, .file-view').removeClass('unicode-escaped');
|
2023-02-19 04:06:14 +00:00
|
|
|
hideElem($(e.target));
|
|
|
|
showElem($(e.target).siblings('a.escape-button'));
|
2022-01-07 01:18:52 +00:00
|
|
|
});
|
|
|
|
$(document).on('click', 'a.toggle-escape-button', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
const fileContent = $(e.target).parents('.file-content, .non-diff-file-content');
|
|
|
|
const fileView = fileContent.find('.file-code, .file-view');
|
|
|
|
if (fileView.hasClass('unicode-escaped')) {
|
|
|
|
fileView.removeClass('unicode-escaped');
|
2023-02-19 04:06:14 +00:00
|
|
|
hideElem(fileContent.find('a.unescape-button'));
|
|
|
|
showElem(fileContent.find('a.escape-button'));
|
2022-01-07 01:18:52 +00:00
|
|
|
} else {
|
|
|
|
fileView.addClass('unicode-escaped');
|
2023-02-19 04:06:14 +00:00
|
|
|
showElem(fileContent.find('a.unescape-button'));
|
|
|
|
hideElem(fileContent.find('a.escape-button'));
|
2022-01-07 01:18:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|