forked from scripting/myWord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
177 lines (168 loc) · 6.49 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<html>
<head>
<title>myword.io: open source essay reader</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://fargo.io/code/jquery-1.9.1.min.js"></script>
<link href="http://fargo.io/code/bootstrap.css" rel="stylesheet">
<script src="http://fargo.io/code/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://fargo.io/code/fontAwesome/css/font-awesome.min.css"/>
<link href="http://fargo.io/code/ubuntuFont.css" rel="stylesheet" type="text/css">
<script src="http://fargo.io/code/node/shared/utils.js"></script>
<script src="http://fargo.io/code/node/shared/alertdialog.js"></script>
<script src="http://fargo.io/code/markdownConverter.js"></script>
<link href="./essay.css" type="text/css" rel="stylesheet" id="idCSS" class="classCSS">
<!-- Facebook metadata -->
<meta property="og:url" content="http://myword.io/" />
<meta property="og:type" content="website" />
<meta property="og:title" content="myword.io" />
<meta property="og:description" content="An easy open source way to create nice-looking web pages for essays." />
<meta property="og:image" content="http://scripting.com/2015/02/12/beatles.png" />
<meta property="og:site_name" content="myword.io" />
<!-- Twitter metadata -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@davewiner">
<meta name="twitter:title" content="myword.io">
<meta name="twitter:description" content="An easy open source way to create nice-looking web pages for essays.">
<meta name="twitter:image:src" content="http://scripting.com/2015/02/12/beatles.png">
<script>
var appConsts = {
productname: "myWord",
productnameForDisplay: "myword.io",
domain: "myword.io",
version: "0.47"
}
var defaultImageUrl = "http://scripting.com/2015/02/12/beatles.png";
function everySecond () {
}
function initGoogleAnalytics () {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-39531990-1', appConsts.domain);
ga('send', 'pageview');
}
function startup () {
var urlparam = decodeURIComponent (getURLParameter ("url")), urlEssay = "essay.json", jstruct, imgurl = defaultImageUrl;;
var cssparam = decodeURIComponent (getURLParameter ("css")), urlCSS = "essay.css";
var markdown = new Markdown.Converter (), now = new Date (), flmarkdown;
console.log ("startup");
$("#idVersionNumber").html ("<a href=\"https://github.com/scripting/myWord\" target=\"_blank\">v" + appConsts.version + "</a>");
initGoogleAnalytics ();
if (urlparam != "null") {
urlEssay = urlparam;
}
if (cssparam != "null") {
urlCSS = cssparam;
}
readHttpFile (urlEssay, function (s) {
try {
jstruct = JSON.parse (s);
}
catch (err) {
alertDialog (err + ". Try using <a href=\"http://jsonlint.com/\" target=\"_blank\">jsonlint</a> to find the error in the JSON file.");
return;
}
flmarkdown = getBoolean (jstruct.flMarkdown); //2/13/15 by DW
//image
if (jstruct.img != undefined) {
imgurl = jstruct.img;
}
$("#idBackgroundImage").css ("background-image", "url(" + imgurl + ")");
//title
if (jstruct.title != undefined) {
$("#idPageTitle").html (jstruct.title);
document.title = appConsts.productnameForDisplay + ": " + jstruct.title;
}
//fonts
if (jstruct.titlefont != undefined) {
$("#idPageTopText").css ("font-family", jstruct.titlefont);
}
if (jstruct.bodyfont != undefined) {
$("#idEssayText").css ("font-family", jstruct.bodyfont);
}
//byline
if (jstruct.authorname != undefined) {
var author = jstruct.authorname, byline;
if (jstruct.authorwebsite != undefined) {
author = "<a href=\"" + jstruct.authorwebsite + "\">" + author + "</a>";
}
byline = "By " + author;
if (jstruct.when != undefined) {
var whenstring;
if (sameDay (new Date (jstruct.when), now)) {
whenstring = " at ";
}
else {
whenstring = " on ";
}
byline += whenstring + viewDate (jstruct.when);
}
$("#idPageByline").html (byline + ".");
}
//description
if (jstruct.description != undefined) {
$("#idPageDescription").html (jstruct.description);
}
//essay text
var essaytext = "";
function dolist (thelist) {
for (var i = 0; i < thelist.length; i++) {
var sub = thelist [i];
if (typeof sub == "string") {
if (flmarkdown) {
essaytext += sub + "\n\n";
}
else {
essaytext += "<p>" + sub + "</p>";
}
}
else {
if (sub.title != undefined) {
essaytext += "<div class=\"divSubhead\">" + sub.title + "</div>";
}
if (sub.subs != undefined) {
dolist (sub.subs);
}
}
}
}
dolist (jstruct.subs);
if (flmarkdown) {
console.log ("startup: essay text before Markdown processing == " + essaytext);
essaytext = "<div class=\"divMarkdownText\">" + markdown.makeHtml (essaytext) + "</div>";
}
// stylesheet if utilized
$("link#idCSS").attr("href", urlCSS);
$("#idEssayText").html (essaytext);
});
self.setInterval (function () {everySecond ()}, 1000);
}
</script>
</head>
<body>
<div class="divVersionNumber" id="idVersionNumber">
</div>
<div class="divTextContainer" id="idTextContainer">
<div class="divBackgroundImage" id="idBackgroundImage">
<div class="divOverlay" id="idOverlay"></div>
<div class="divPageTopText" id="idPageTopText">
<div class="divPageByline" id="idPageByline">
</div>
<div class="divPageTitle" id="idPageTitle">
</div>
<div class="divPageDescription" id="idPageDescription">
</div>
</div>
<div class="divEssayText" id="idEssayText">
</div>
</div>
</div>
<script>
$(document).ready (function () {
startup ();
});
</script>
</body>
</html>