generated from DavideBri/Gesko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.html
114 lines (93 loc) · 3.71 KB
/
post.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Post</title>
<style type="text/css" media="screen">
body {font-family:verdana, sans-serif; color:#666; background:#fafafa; padding:20px; text-align:center;}
#page {text-align:left; max-width:600px; margin:0 auto;}
h1 {font-size:16px; font-weight:normal; text-align:center;}
label {font-size:16px;}
label i {font-style:normal; display:inline-block; text-align:right; width:100px;}
label textarea {vertical-align:top;}
button {margin-left:105px; padding:5px; margin-top:5px; font-size:16px;}
input, textarea {width:400px; font-size:16px; font-family: courier, "courier new", monospace; margin:0 0 5px 0; padding:5px; border:1px solid #eee;}
select {margin:0 0 5px 0;}
@media (min-width:300px) and (max-width: 768px) {
input, textarea {width:100%;}
label i {display:block; width:auto; text-align:left;}
button {display:block; margin:0;}
}
</style>
<script type="text/javascript">
// Current date - http://stackoverflow.com/a/4929629/412329
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = yyyy+'-'+mm+'-'+dd;
function saveFormAsTextFile()
// Based on https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/
{
var textToSave =
'---\n'+
'layout: post' + '\n' + // =title
'title: ' + document.getElementById('title').value + '\n' + // =title
'link: ' + document.getElementById('link').value + '\n' + // =link
'summary: ' + document.getElementById('summary').value + '\n' + // =link
'tags: ' + document.getElementById('tags').value + '\n' + // =link
'---\n' + '\n'
var textToSaveAsBlob = new Blob([textToSave], {type:"text/plain"});
var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
var denemeform = today + '-' + document.getElementById("title").value.replace(/ /g, "-");
var fileNameToSaveAs = denemeform;
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs + ".md";
downloadLink.innerHTML = "Download File";
downloadLink.href = textToSaveAsURL;
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
downloadLink.click();
}
function destroyClickedElement(event)
{
document.body.removeChild(event.target);
}
</script>
</head>
<body>
<div id="page">
<label for="title">
<i>title</i> <!-- =title - input example -->
<input id="title" size="40" placeholder="title">
</label>
<br>
<label for="title">
<i>link</i> <!-- =link - input example -->
<input id="link" size="40" placeholder="link">
</label>
<label for="summary">
<i>sum</i> <!-- =link - input example -->
<input id="summary" size="40" placeholder="summary">
</label>
<input type="hidden" id="date" size="40"> <!-- =date - hidden input example (automatically populated with current date in yyyy-mm-dd format) -->
<br>
<label for="tags">
<i>tags</i> <!-- =tags textarea example -->
<input id="tags" cols="40" rows="3" placeholder="tag tag tag">
</label>
<button onclick="saveFormAsTextFile()">
Save
</button>
</div>
</body>
</html>