mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
f705f8ee87
Former-commit-id: 233bca65b4c97b6fa9d9994f53d5692c4aaee608 [formerly 42b853d2ef81f0228bb8c6c26acd48017c26615d] [formerly b17adf186b4474a662592cb77a2e1551f8821eb1 [formerly a0f73d2232b5276e02a91954f3db237ebd33f2f6 [formerlybcda5fc69b
]]] Former-commit-id: 5a5a0f15c82c5f23a298dc921197e38b71298424 [formerly 4fdda72b32f570b3be1d5210b0ced6ce0a2682f7] Former-commit-id: b77e98e3db2abc7ad6a978641086b2c5641224fe Former-commit-id:98dbd6a7f0
370 lines
12 KiB
Cheetah
370 lines
12 KiB
Cheetah
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>{{ .Title }}</title>
|
|
|
|
{{ template "header" }}
|
|
|
|
|
|
|
|
<script src="/static/js/jquery.autogrowtextarea.min.js"></script>
|
|
{{if .NoEdit}} {{else}}
|
|
<script src="/static/js/websockets.js"></script> {{end}}
|
|
|
|
<script>
|
|
external_ip = '{{ .ExternalIP }}'
|
|
title_name = '{{ .Title }}'
|
|
socketType = '{{ .SocketType }}'
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
.CodeMirror {
|
|
border: 1px solid #eee;
|
|
height: auto;
|
|
}
|
|
|
|
textarea {
|
|
width: 100%;
|
|
margin: 5px 0;
|
|
padding: 10px;
|
|
border: none;
|
|
overflow: auto;
|
|
outline: none;
|
|
font-size: large;
|
|
-webkit-box-shadow: none;
|
|
-moz-box-shadow: none;
|
|
box-shadow: none;
|
|
font-family: Tahoma, sans-serif;
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
background: #fff;
|
|
max-width: 900px;
|
|
margin: 0 auto;
|
|
padding-bottom: 65px;
|
|
}
|
|
|
|
@media (min-width: 1200px) {
|
|
.container {
|
|
max-width: 960px;
|
|
}
|
|
}
|
|
</style>
|
|
<script src="/static/js/sweetalert-dev.js"></script>
|
|
<link rel="stylesheet" href="/static/css/sweetalert.css">
|
|
{{ if .Coding }}
|
|
<script src="/static/js/codemirror.js"></script>
|
|
<link rel="stylesheet" href="/static/css/codemirror.css">
|
|
<script src="/static/js/{{ .CodeType }}.js"></script>
|
|
{{ if eq .CodeType "htmlmixed" }}
|
|
<script src="/static/js/css.js"></script>
|
|
<script src="/static/js/javascript.js"></script>
|
|
<script src="/static/js/xml.js"></script>
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ if eq .Suffix "txt" }}
|
|
<tag autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
|
<link href='https://fonts.googleapis.com/css?family=Ubuntu+Mono|Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
|
<style type="text/css">
|
|
textarea {
|
|
font: 400 16px/1.62 'Ubuntu Mono','Droid Sans Mono';
|
|
}
|
|
</style>
|
|
{{ end }}
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Fixed navbar -->
|
|
<nav class="navbar navbar-default navbar-fixed-bottom">
|
|
<div class="container">
|
|
<!-- <div class="navbar-header">
|
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
|
<span class="sr-only">Toggle navigation</span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="/">{{ .Title }} </a>
|
|
</div> -->
|
|
<div id="navbar" class="collapse navbar-collapse">
|
|
<ul class="nav navbar-nav">
|
|
<li class="dropdown active">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" class="active"><span class="glyphicon glyphicon-pencil" id="saveInfo" aria-hidden="true"></span> Edit <span class="caret"></span></a>
|
|
<ul class="dropdown-menu">
|
|
<li class="dropdown-header">Version: #{{ .CurrentVersionNum }}</li>
|
|
<li class="dropdown-header">Time edited: {{ .TotalTime }}</li>
|
|
<li role="separator" class="divider"></li>
|
|
<li class="dropdown-header">Other versions</li>
|
|
<li><a href="/{{ .Title }}?version=0">First</a></li>
|
|
{{ range .Versions }}
|
|
<li><a href="/{{ $.Title }}?version={{ .VersionNum }}">{{ .VersionDate }}</a></li>
|
|
{{ end }}
|
|
<li><a href="/{{ .Title }}">Current</a></li>
|
|
<li role="separator" class="divider"></li>
|
|
<li class="dropdown-header">Options</li>
|
|
<li><a href="#" class="postencrypt">Encrypt</a></li>
|
|
<li><a href="#" class="postlock">Lock</a></li>
|
|
<li><a href="#" class="postselfdestruct">Self-destruct</a></li>
|
|
<li><a href="#" id="{{ .Title }}" class="deleteable">Erase</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="/{{ .Title }}/view"><span class="glyphicon glyphicon-sunglasses" aria-hidden="true"></span> View</a></li>
|
|
<li><a href="/{{ .Title }}/list"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span> List</a></li>
|
|
|
|
<li class="dropdown">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" class="active"><span class="glyphicon glyphicon-globe" aria-hidden="true"></span> More <span class="caret"></span></a>
|
|
<ul class="dropdown-menu">
|
|
<li>
|
|
<a class="trigger right-caret">Recent</a>
|
|
<ul class="dropdown-menu sub-menu">
|
|
{{ range .RecentlyEdited}}
|
|
<li><a href="/{{.}}/view"> {{.}}</a></li>
|
|
{{ end }}
|
|
</ul>
|
|
</li>
|
|
<li><a href="/Help/view"> Help</a></li>
|
|
<li><a href="/PrivacyPolicy/view"> Privacy Policy</a></li>
|
|
</ul>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
</div>
|
|
<!--/.nav-collapse -->
|
|
</div>
|
|
</nav>
|
|
|
|
|
|
<form action='#' id="emit" method="post" name="emit">
|
|
|
|
<div>
|
|
<textarea autofocus rows={{ .NumRows }} class='auto_submit_item' id="emit_data" name="emit_data" placeholder="Start typing, it will save automatically.">{{ .CurrentText }}</textarea>
|
|
</div>
|
|
|
|
</form>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$("#emit_data").autoGrow();
|
|
});
|
|
|
|
$(document).keydown(function(e) {
|
|
if (e.which === 90 && e.ctrlKey && e.shiftKey) {
|
|
console.log('control + shift + z');
|
|
window.location = "/{{ .Title }}/view";
|
|
}
|
|
});
|
|
|
|
$(document).keydown(function(e) {
|
|
if (e.which === 76 && e.ctrlKey && e.shiftKey) {
|
|
console.log('control + shift + l');
|
|
window.location = "/{{ .Title }}/list";
|
|
}
|
|
});
|
|
|
|
|
|
$('.postencrypt').click(function(event) {
|
|
var pass1 = "";
|
|
var pass2 = "";
|
|
event.preventDefault();
|
|
swal({
|
|
title: "Encryption",
|
|
text: "Enter your passphrase:",
|
|
type: "input", inputType: "password",
|
|
showCancelButton: true,
|
|
closeOnConfirm: false,
|
|
animation: "slide-from-top",
|
|
inputPlaceholder: "Write something"
|
|
}, function(inputValue) {
|
|
if (inputValue === false) return false;
|
|
if (inputValue === "") {
|
|
swal.showInputError("You need to write something!");
|
|
return false
|
|
}
|
|
pass1 = inputValue;
|
|
swal({
|
|
title: "Encryption",
|
|
text: "Enter your passphrase again:",
|
|
type: "input", inputType: "password",
|
|
showCancelButton: true,
|
|
closeOnConfirm: false,
|
|
animation: "slide-from-top",
|
|
inputPlaceholder: "Write something"
|
|
}, function(inputValue) {
|
|
if (inputValue === false) return false;
|
|
if (inputValue === "") {
|
|
swal.showInputError("You need to write something!");
|
|
return false
|
|
}
|
|
pass2 = inputValue
|
|
if (pass1 == pass2) {
|
|
swal("Encryption", "Passwords match!", "success");
|
|
$.ajax({
|
|
type: "POST",
|
|
//the url where you want to sent the userName and password to
|
|
url: '/{{ .Title }}/encrypt',
|
|
dataType: 'json',
|
|
data: JSON.stringify({
|
|
text: $('#emit_data').val(),
|
|
password: pass1
|
|
}),
|
|
success: function (data) {
|
|
if (data['success'] == true) {
|
|
swal("Encryption", "Encrypted!", "success");
|
|
window.location.href = '/{{ .Title }}/view?noprompt=1';
|
|
} else {
|
|
swal("Encryption", "Something went wrong.", "error");
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
swal("Encryption", "Passwords do not match.", "error");
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('.postlock').click(function(event) {
|
|
var pass1 = "";
|
|
var pass2 = "";
|
|
event.preventDefault();
|
|
swal({
|
|
title: "Locking",
|
|
text: "Enter your passphrase:",
|
|
type: "input", inputType: "password",
|
|
showCancelButton: true,
|
|
closeOnConfirm: false,
|
|
animation: "slide-from-top",
|
|
inputPlaceholder: "Write something"
|
|
}, function(inputValue) {
|
|
if (inputValue === false) return false;
|
|
if (inputValue === "") {
|
|
swal.showInputError("You need to write something!");
|
|
return false
|
|
}
|
|
pass1 = inputValue;
|
|
swal({
|
|
title: "Locking",
|
|
text: "Enter your passphrase again:",
|
|
type: "input", inputType: "password",
|
|
showCancelButton: true,
|
|
closeOnConfirm: false,
|
|
animation: "slide-from-top",
|
|
inputPlaceholder: "Write something"
|
|
}, function(inputValue) {
|
|
if (inputValue === false) return false;
|
|
if (inputValue === "") {
|
|
swal.showInputError("You need to write something!");
|
|
return false
|
|
}
|
|
pass2 = inputValue
|
|
if (pass1 == pass2) {
|
|
swal("Locking", "Passwords match!", "success");
|
|
$.ajax({
|
|
type: "POST",
|
|
//the url where you want to sent the userName and password to
|
|
url: '/{{ .Title }}/lock',
|
|
dataType: 'json',
|
|
data: JSON.stringify({
|
|
text: $('#emit_data').val(),
|
|
password: pass1
|
|
}),
|
|
success: function (data) {
|
|
if (data['success'] == true) {
|
|
swal("Locking", "Page locked!", "success");
|
|
window.location.href = '/{{ .Title }}/view';
|
|
} else {
|
|
swal("Locking", "Something went wrong.", "error");
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
swal("Encryption", "Passwords do not match.", "error");
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
$('.deleteable').click(function(event) {
|
|
event.preventDefault();
|
|
var deleteName = $(this).attr('id')
|
|
var href = $(this).attr('href')
|
|
swal({
|
|
title: "Are you sure?",
|
|
text: "You will not be able to recover /{{ .Title }}!",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "Yes, delete it!",
|
|
closeOnConfirm: false
|
|
}, function() {
|
|
$.ajax({
|
|
url: "/deletepage" + '?' + $.param({
|
|
"DeleteName": deleteName,
|
|
"AdminKey": "none"
|
|
}),
|
|
type: 'DELETE',
|
|
success: function() {
|
|
swal("Deleted!", "/{{ .Title }} has been deleted.", "success");
|
|
setTimeout(function() {
|
|
window.location.reload(true);
|
|
}, 1000);
|
|
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
{{ if .Coding }}
|
|
<script>
|
|
var editor = CodeMirror.fromTextArea(document.getElementById("emit_data"), {
|
|
lineNumbers: true,
|
|
mode: "{{ .CodeType }}",
|
|
matchBrackets: true,
|
|
viewportMargin: Infinity
|
|
});
|
|
editor.setSize("100%", "100%")
|
|
function currentText() {
|
|
return editor.getValue()
|
|
}
|
|
</script>
|
|
{{ else }}
|
|
<script>
|
|
function currentText() {
|
|
return $('#emit_data').val()
|
|
}
|
|
</script>
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|