Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide prompt check box #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion dreampielib/gui/hist_persist.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ def save_history(textview, f):

f.write("""\
</style>
%s
</head>
<body>""")
<body>""" % hide_prompt())

cur_tags = []
it = tb.get_start_iter()
Expand Down Expand Up @@ -230,6 +231,54 @@ def save_history(textview, f):
</html>
""")

def hide_prompt(switched_on = 1):
"""
Add to the history.html file checkbox that switch the prompt off.
"""
if not switched_on:
return ''
return \
'''<style>
span.hidden {
visibility: hidden;
}
label.ctrl {
position: fixed;
top: 1em;
right: 1em;
background-color: inherit;
}
</style>
<script type="text/javascript">

window.addEventListener("DOMContentLoaded", function() {
document.body.innerHTML +=
'<label class="ctrl"><INPUT TYPE="checkbox" id="HideShowPrompt" onChange="showHidePrompt(this)">Hide Prompt</label>'
}, false);

function getElementByClass (className, parent) {
parent || (parent = document);
var descendants= parent.getElementsByTagName('*'), i=-1, e, result=[];
while (e=descendants[++i]) {
((' '+(e['class']||e.className)+' ').indexOf(' '+className+' ') > -1) && result.push(e);
}
return result;
}

function showHidePrompt(sh) {
var elements = getElementByClass("prompt", "");
for (var i in elements){
if (sh.checked) {
(elements[i].innerHTML != "&gt;&gt;&gt; " ) &&
(elements[i].className = 'prompt hidden');
} else {
(elements[i].innerHTML != "&gt;&gt;&gt; ") &&
(elements[i].className = 'prompt');
}
}
}
showHidePrompt(true);
</script>'''
class LoadError(Exception):
pass

Expand Down