-
Notifications
You must be signed in to change notification settings - Fork 0
/
paper.html
173 lines (156 loc) · 6.77 KB
/
paper.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Alexandria - The library that cannot be burned</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/style.css">
<script src="js/index.js"></script>
<script src="js/utils/bs58.js"></script>
<script src="js/utils/buffer.js"></script>
<script type="text/javascript">
const ipfs = window.IpfsApi('127.0.0.1','5001',{protocol: 'http'});
const decoder = new TextDecoder('utf-8');
</script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#mainNavBar" aria-expanded="false">
<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="index.html"><img class="logo" src="images/logo.jpg"></a>
</div>
<ul class="collapse navbar-collapse nav navbar-nav" id="mainNavBar">
<li><a href="index.html">Home<span class="sr-only">(current)</span></a></li>
<li><a href="register.html">Register Journal</a></li>
<li><a href="about.html">About us</a></li>
</ul>
<form class="navbar-form navbar-collapse navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter you search here">
</div>
<button type="submit" class="btn btn-default">Search</button>
</form>
</div><!-- /.container-fluid -->
</nav>
<div class="content">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2 id="title"></h2>
</div>
</div>
<div class="row">
<div class="col-md-10">
<p id="ipfsaddr"></p>
<p id="authors"></p>
<p>Submitted to: <span id="journal"></span></p>
<p id="topics"></p>
<hr>
<h4>Abstract</h4>
<p style="line-height:1.2" id="abstract"></p>
</div>
<div class="col-md-2">
<p>Actual: <b>Draft 3</b></p>
<a href="http://localhost:8080/ipfs/QmSUCgFzy4rNbWy9eX1h5atQGxADC5aER5oUySHpgEcQex" download target="_blank" class="btn btn-xs" style="width:100%">Download paper</a>
<hr>
<p>
Previous drafts:<br>
<a href="#">Draft 2</a><br>
<a href="#">Draft 1</a>
</p>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$('.collapse').collapse({
toggle: false
});
$('#submitpaper').on('click',function () {
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
alert('The File APIs are not fully supported in this browser.');
return;
}
input = document.getElementById('fileinput');
if (!input) {
alert("Um, couldn't find the fileinput element.");
}
else if (!input.files) {
alert("This browser doesn't seem to support the `files` property of file inputs.");
}
else if (!input.files[0]) {
alert("Please select a file before clicking 'Load'");
}
else {
}
});
url = new URL(window.location);
searchParams = new URLSearchParams(url.search);
var paper_bin;
var paper_contract;
var res;
$.getJSON('abi/paper_abi.json', function (abi) {
paper_bin = web3.eth.contract(abi);
paper_contract = paper_bin.at(searchParams.get('q'));
PaperCreated_events = paper_contract.PaperCreated({}, {fromBlock: 0, toBlock: 'latest'});
PaperCreated_events.get((error, logs) => {
console.log(logs);
logs.forEach(
function (element) {
var hf = element.args["hf"].c[0];
var sz = element.args["sz"].c[0];
var data = element.args["data"];
var journal = element.args["journal"];
ipfs.cat(ds_encode(hf,sz,data)).then(
function (file) {
var raw = file.read();
var json = decoder.decode(raw);
var info = JSON.parse(json);
//console.log(JSON.stringify(info,null,2));
var title= info.title;
var topics_arr = info.topics;
var topics = "Topics: ";
var ipfsaddr= "IPFS address: " + info.ipfsaddr;
topics_arr.forEach(
function (topic) {
topics+='<a href="topic.html?q='+topic.id+'">'+topic.name+'</a>, ';
}
);
topics = topics.substr(0,topics.length-2);
var authors_arr = info.authors;
var authors = "Authors: ";
authors_arr.forEach(
function (author) {
authors+='<a href="author.html?q='+author.address+'">'+author.name+'</a>, ';
}
);
authors = authors.substr(0,authors.length-2);
$("#title").html(title);
$("#authors").html(authors);
$("#topics").html(topics);
$("#ipfsaddr").html(ipfsaddr);
$("#abstract").html(info.abstract);
$("#journal").html('<a href="journal.html?q='+journal+
'">'+journal+"</a>");
$("#ipfsaddr").on('click',function(){
});
}
);
});
});
});
</script>
</body>
</html>