changes indicator
This commit is contained in:
@@ -291,8 +291,10 @@ tr:nth-child(odd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#editor_area {
|
#editor_area {
|
||||||
width: 40vw;
|
width: 82vw;
|
||||||
float: left;
|
float: left;
|
||||||
|
background-color: var(--background-light-color);
|
||||||
|
border: 2px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#editor_preview {
|
#editor_preview {
|
||||||
@@ -300,6 +302,7 @@ tr:nth-child(odd) {
|
|||||||
margin-left: 2vw;
|
margin-left: 2vw;
|
||||||
float: left;
|
float: left;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#editor_preview p {
|
#editor_preview p {
|
||||||
|
|||||||
@@ -151,20 +151,40 @@ function UploadURL() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateEditorPreview() {
|
function updateEditor() {
|
||||||
var input = document.getElementById("editor_area");
|
var input = document.getElementById("editor_area");
|
||||||
var preview = document.getElementById("editor_preview");
|
var preview = document.getElementById("editor_preview");
|
||||||
|
if (preview.style.display === 'block') {
|
||||||
preview.innerHTML = md.render(input.value);
|
preview.innerHTML = md.render(input.value);
|
||||||
|
}
|
||||||
|
var currentHash = hashCode(input.value);
|
||||||
|
if (currentHash == editorHash) {
|
||||||
|
document.getElementById("editor_save").value = "Save ";
|
||||||
|
} else {
|
||||||
|
document.getElementById("editor_save").value = "Save*";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function previewToggle() {
|
function previewToggle() {
|
||||||
toggler("editor_preview");
|
toggler("editor_preview");
|
||||||
if (document.getElementById("editor_preview").style.display === 'block') {
|
if (document.getElementById("editor_preview").style.display === 'block') {
|
||||||
document.getElementById("editor_area").style.width = "40vw";
|
document.getElementById("editor_area").style.width = "40vw";
|
||||||
|
updateEditor();
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("editor_area").style.width = "82vw";
|
document.getElementById("editor_area").style.width = "82vw";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hashCode(s) {
|
||||||
|
var h = 0, l = s.length, i = 0;
|
||||||
|
if ( l > 0 )
|
||||||
|
while (i < l)
|
||||||
|
h = (h << 5) - h + s.charCodeAt(i++) | 0;
|
||||||
|
return h;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
function changeTitle(newTitle) {
|
function changeTitle(newTitle) {
|
||||||
document.title = "Flees - " + newTitle;
|
document.title = "Flees - " + newTitle;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,13 @@
|
|||||||
title="File name to write. Must end in .txt to later edit."
|
title="File name to write. Must end in .txt to later edit."
|
||||||
value="{{ filename | safe }}" onclick="clear_text(this.id,'paste.txt')">
|
value="{{ filename | safe }}" onclick="clear_text(this.id,'paste.txt')">
|
||||||
<br>
|
<br>
|
||||||
<input type=submit value=Save>
|
<input id=editor_save type=submit value=Save>
|
||||||
<a class="href_button" onclick="previewToggle()" title="Toggle preview window">Preview</a>
|
<a class="href_button" onclick="previewToggle()" title="Toggle Markdown preview window">Preview</a>
|
||||||
<a class="href_button" href="{{ url_for('list_view',name = name) }}" title="Forget all changes">Cancel</a>
|
<a class="href_button" href="{{ url_for('list_view',name = name) }}" title="Forget all changes">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
<div id=editor_floats>
|
<div id=editor_floats>
|
||||||
<textarea rows="25" name="paste" id="editor_area" autofocus oninput="updateEditorPreview()">{{ content | safe }}</textarea>
|
<textarea rows="25" name="paste" id="editor_area" autofocus oninput="updateEditor()">{{ content | safe }}</textarea>
|
||||||
<div id=editor_preview style="display: block;"></div>
|
<div id=editor_preview></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
var md = new Remarkable({
|
var md = new Remarkable({
|
||||||
linkify: true
|
linkify: true
|
||||||
});
|
});
|
||||||
updateEditorPreview();
|
var editorHash = hashCode(document.getElementById("editor_area").value);
|
||||||
|
updateEditor()
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user