-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstory.html
64 lines (50 loc) · 2.33 KB
/
story.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="https://fonts.googleapis.com/css?family=Droid+Sans|Lato" rel="stylesheet">
<style>body{margin:1em auto; margin-top: 1.6em; max-width:35em;padding:0.62em;font:1.2em/1.62 'Droid Sans',sans-serif;color:#333;line-height: 1.45;}h1,h2,h3{line-height:1em;letter-spacing:-0.1ex;font-family:'Lato',sans-serif;font-weight:normal;font-size: 1.9416em;color:#222;}#author{color:#888;font-size: 70%;display: block;letter-spacing: -0.07ex;}@media print{body{max-width:none}}</style>
</head>
<body>
<!--<button onclick="previous()">‹</button><a href="#">author</a>/<a href="#">title</a><button onclick="next()">›</button>-->
<article id="story"></article>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script type="text/javascript">
function renderStory(url, title, author) {
$.get(url,
function (data, textStatus, jqXHR) {
lines = data.split(/\n\n/);
var start = 0;
while ((lines[start].toLowerCase().indexOf(author.toLowerCase()) != -1) ||
(lines[start].toLowerCase().indexOf(title.toLowerCase()) != -1)) {
start = start + 1;
}
var $body = $('#story');
$body.empty();
$('title').text(title + ' by ' + author)
$body.append('<h1>'+ title + '<span id="author"> by ' + author +'</span></h1>')
for (var i = start; i<lines.length; i++) {
$body.append('<p>' + lines[i] + '</p>')
}
})
}
$( document ).ready(function() {
var current = $(location).attr('href');
var index = current.indexOf('?') + 1;
var paramString = current.substring(index);
var parts = paramString.split('&');
var param = {};
for (var i = 0; i < parts.length; i++) {
var components = parts[i].split('=');
param[components[0]] = decodeURIComponent(components[1]);
}
renderStory(param.url, param.title, param.author);
});
</script>
</body>
</html>