diff --git a/app/javascript/src/classes/browser_view.coffee b/app/javascript/src/classes/browser_view.coffee index 28d03a225..8b8c0ce51 100644 --- a/app/javascript/src/classes/browser_view.coffee +++ b/app/javascript/src/classes/browser_view.coffee @@ -1,5 +1,5 @@ import PreloadContainer from 'src/classes/preload_container' -import { escapeHtml } from 'src/utils/dom' +import { escapeHtml, stringToDom } from 'src/utils/dom' import { removeImageElement } from 'src/utils/image' import { numberToHumanSize } from 'src/utils/math' import FrameEditor from './frame_editor' @@ -675,14 +675,11 @@ export default class BrowserView sequence = pool_post.sequence if sequence.match(/^[0-9]/) sequence = '#' + sequence - html = '
Post ${sequence} in ${desc} ' + '(pool page)' + html = "
Post #{sequence} in #{escapeHtml(pool_title)} (pool page)" if Pool.can_edit_pool(pool) html += ' (remove)' html += '
' - div = html.subst( - sequence: sequence - pool_id: pool_id - desc: escapeHtml(pool_title)).createElement() + div = stringToDom html div.post_id = post.id div.pool_id = pool_id pool_info.appendChild div diff --git a/app/javascript/src/legacy/common.coffee b/app/javascript/src/legacy/common.coffee index 9b022f3eb..88523a7d4 100644 --- a/app/javascript/src/legacy/common.coffee +++ b/app/javascript/src/legacy/common.coffee @@ -138,21 +138,6 @@ window.clone_event = (orig) -> e = document.createEventObject(orig) Event.extend e -Object.extend String.prototype, - subst: (subs) -> - text = this - for s of subs - r = new RegExp('\\${' + s + '}', 'g') - to = subs[s] - if !to? - to = '' - text = text.replace(r, to) - text - createElement: -> - container = document.createElement('div') - container.innerHTML = this - container.removeChild container.firstChild - window.onerror = (error, file, line) -> ReportError error, file, line, null return diff --git a/app/javascript/src/utils/dom.coffee b/app/javascript/src/utils/dom.coffee index 5fcf494e8..9670fbd07 100644 --- a/app/javascript/src/utils/dom.coffee +++ b/app/javascript/src/utils/dom.coffee @@ -9,3 +9,9 @@ export escapeHtml = (str) -> str.replace(/[&<>"']/g, (str) => ({ export hideEl = (el) -> el.style.display = 'none' export showEl = (el) -> el.style.display = '' + +export stringToDom = (str) -> + container = document.createElement('div') + container.innerHTML = str + + container.firstChild