-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
146 lines (142 loc) · 4.83 KB
/
index.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script>
function myjson(form) {
var title=form.title.value;
var description=form.description.value;
var authorname=form.authorname.value;
var authorwebsite=form.authorwebsite.value;
var titlefont=form.titlefont.value;
var bodyfont=form.bodyfont.value;
var flMarkdown=form.flMarkdown.value;
var img=form.img.value;
var text=form.text.value;
text=text.replace(/"/g, '\\"');
essay=text.split("\n");
var output='{';
output+='"title": "' + title + '",';
output+='"description": "' + description + '",';
output+='"authorname": "' + authorname + '",';
output+='"authorwebsite": "' + authorwebsite + '",';
output+='"titlefont": "' + titlefont + '",';
output+='"bodyfont": "' + bodyfont + '",';
output+='"flMarkdown": "' + flMarkdown + '",';
var d = new Date();
var date = d.toUTCString();
output+='"when": "' + date + '",';
if (img == null || img == "") {
output+='"img": "http://i.imgur.com/uEGtdGa.png",';
} else
{
output+='"img": "' + img+ '",';
}
output+='"subs": [';
var count = essay.length;
count = count - 1;
for (i=0;i<count;i++) {
output+='"' + essay[i] + '",';
}
output+='"' + essay[i] + '"]}';
document.getElementById("results").innerHTML=output;
// made possible via http://youmightnotneedjquery.com
var request = new XMLHttpRequest();
request.open('POST', 'https://api.myjson.com/bins', true);
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
request.send(output);
request.onload = function(output, textStatus, jqXHR) {
if (request.status >= 200 && request.status < 400) {
// Success!
var resp = request.responseText;
} else {
// We reached our target server, but it returned an error
}
var myArray = JSON.parse(request.responseText);
var api_url = myArray.uri;
document.getElementById("myjson_reply").innerHTML=api_url;
window.open("http://myword.io/?url=" + api_url);
};
}
</script>
<script>
function myword(form) {
var title=form.title.value;
var description=form.description.value;
var authorname=form.authorname.value;
var authorwebsite=form.authorwebsite.value;
var titlefont=form.titlefont.value;
var bodyfont=form.bodyfont.value;
var flMarkdown=form.flMarkdown.value;
var img=form.img.value;
var text=form.text.value;
text=text.replace(/"/g, '\\"');
essay=text.split("\n");
var output='{';
output+='"title": "' + title + '",';
output+='"description": "' + description + '",';
output+='"authorname": "' + authorname + '",';
output+='"authorwebsite": "' + authorwebsite + '",';
output+='"titlefont": "' + titlefont + '",';
output+='"bodyfont": "' + bodyfont + '",';
output+='"flMarkdown": "' + flMarkdown + '",';
var d = new Date();
var date = d.toUTCString();
output+='"when": "' + date + '",';
if (img == null || img == "") {
output+='"img": "http://i.imgur.com/uEGtdGa.png",';
} else
{
output+='"img": "' + img+ '",';
}
output+='"subs": [';
var count = essay.length;
count = count - 1;
for (i=0;i<count;i++) {
output+='"' + essay[i] + '",';
}
output+='"' + essay[i] + '"]}';
document.getElementById("results").innerHTML=output;
}
</script>
<div class="container">
<p> </p>
<form>
<p>title <input type="text" name="title"></p>
<p>description <input type="text" name="description"></p>
<p>author name <input type="text" name="authorname"></p>
<p>author website <input type="text" name="authorwebsite"></p>
<p>title font <input type="text" name="titlefont"></p>
<p>body font <input type="text" name="bodyfont"></p>
<p>enter "true" if you type in Markdown <input type="text" name="flMarkdown"></p>
<p>img <input type="url" name="img" size="40"><br></p>
Write your post here. Hit return for new paragraph. <br/ >
<textarea name="text" cols="100" rows="10"></textarea>
<br />
<input type="button" name="button" value="convert to json"
onClick="myword(this.form)">
<input type="button" value="send to myjson.com" onClick="myjson(this.form)">
</form>
<div class="col-md-6">
<h2>Your JSON Output</h2>
<p>Put the following in a text file. <br>
Give the filename a title and follow it by <code>.json</code>. <br>
Upload to your server, or make it shareable via Dropbox. If you use a Dropbox link, change `www.dropbox.com` to `dl.dropboxusercontent.com`.<br>
Append that url to <code>http://myword.io/?url=</code></p>
<textarea id="results" cols="60" rows="10"></textarea>
</div>
<div class="col-md-6">
<!-- myjson area -->
<h2>Your File Stored at myjson.com</h2>
<p>This is where your JSON is being stored:
<textarea id="myjson_reply" rows="1" cols="40"></textarea>
<br/><br />
<small>myjson.com is a service in beta that stores json files. This script uses the myjson.com api to easily store your json output so that you don't have to manually create and
upload a new file. However, there is no guarantee that your file will be stored "forever," so use at your own risk.</small>
</p>
</div>
<!-- end myjson area -->
</div>
</body>
</html>