Use textarea placeholder instead of own code

<textarea placeholder="..."> is more simple that writing own code.
Thereby the own code / logic has been removed.
This commit is contained in:
Carsten Grohmann 2020-07-15 21:10:37 +02:00
parent 230cddae19
commit 468991a31b
2 changed files with 3 additions and 15 deletions

View File

@ -209,7 +209,7 @@ function goBack() {
<div class="js-text--default-show" id="input"> <div class="js-text--default-show" id="input">
<h2 id="step1">Step 1 - Enter your OOM message</h2> <h2 id="step1">Step 1 - Enter your OOM message</h2>
<textarea autocomplete="off" cols="100" id="textarea_oom" onfocus="OOMAnalyser.OOMDisplayInstance.empty_textarea_oom()" rows="20" title="OOM input field">Add your OOMhere</textarea> <textarea autocomplete="off" cols="100" id="textarea_oom" placeholder="<Paste your OOM here>" rows="20" title="OOM input field"></textarea>
<br/> <br/>
<button onclick="OOMAnalyser.OOMDisplayInstance.analyse_and_show()" title="Analyse the OOM from the input area and show it">Analyse</button> <button onclick="OOMAnalyser.OOMDisplayInstance.analyse_and_show()" title="Analyse the OOM from the input area and show it">Analyse</button>
<button onclick="OOMAnalyser.OOMDisplayInstance.reset_form()" title="Clean the input area">Reset</button> <button onclick="OOMAnalyser.OOMDisplayInstance.reset_form()" title="Clean the input area">Reset</button>

View File

@ -735,9 +735,6 @@ class OOMAnalyser(object):
class OOMDisplay(object): class OOMDisplay(object):
"""Display the OOM analysis""" """Display the OOM analysis"""
paste_note = "<paste your OOM here>"
"""Note for the user to paste the OOM to the textarea"""
oom_details = {} oom_details = {}
"""Extracted result""" """Extracted result"""
@ -1062,11 +1059,8 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
else: else:
element.innerHTML = self.svg_array_updown element.innerHTML = self.svg_array_updown
def set_HTML_defaults(self, clean_oom=True): def set_HTML_defaults(self):
"""Reset the HTML document but don't clean elements""" """Reset the HTML document but don't clean elements"""
if clean_oom:
document.getElementById('textarea_oom').value = self.paste_note
# hide all elements marked to be hidden by default # hide all elements marked to be hidden by default
for element in document.querySelectorAll('.js-text--default-hide'): for element in document.querySelectorAll('.js-text--default-hide'):
element.classList.add('js-text--display-none') element.classList.add('js-text--display-none')
@ -1190,12 +1184,6 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
def copy_example_to_form(self): def copy_example_to_form(self):
document.getElementById('textarea_oom').value = self.example document.getElementById('textarea_oom').value = self.example
def empty_textarea_oom(self):
element = document.getElementById('textarea_oom')
content = element.value
if content == self.paste_note:
element.value = ""
def reset_form(self): def reset_form(self):
self.set_HTML_defaults() self.set_HTML_defaults()
self.update_toc() self.update_toc()
@ -1222,7 +1210,7 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
# set defaults and clear notifications # set defaults and clear notifications
self.oom_details.clear() self.oom_details.clear()
self.set_HTML_defaults(False) self.set_HTML_defaults()
# analyse # analyse
analyser = OOMAnalyser(self.oom) analyser = OOMAnalyser(self.oom)