Commit 0cc1f53c authored by taco@waag.org's avatar taco@waag.org
Browse files

provenance view sans css

parent d6baca8b
......@@ -11,14 +11,99 @@ if (window.hasRun) {
document.head.textContent = "";
document.body.textContent = "";
//todo read storage for current tab, and create the view
let header = document.createElement('h1');
header.textContent = "Provenance view";
document.body.appendChild(header)
let p = document.createElement('p');
p.textContent = JSON.stringify(state);
document.body.appendChild(p);
for (let i = 0; i < state.signatures.length; i++) {
let fragmentType = state.signatures[i][0];
let signature = JSON.parse(state.signatures[i][1]);
let message = signature.message;
let result = JSON.parse(state.results[i][1]);
switch(fragmentType){
case 'data-pop-v0-title':
renderTitle(message,result);
break;
case 'data-pop-v0-abstract':
renderAbstract(message,result);
break;
case 'data-pop-v0-body':
renderBody(message,result);
break;
case 'data-pop-v0-author':
renderAuthor(message,result);
break;
case 'data-pop-v0-img':
renderImage(message,result);
break;
}
}
}
function appendProof(fragment,result){
let proof_string = JSON.stringify(result);
let proof = document.createElement('span');
proof.classList.add('pop-proof');
proof.textContent = proof_string;
fragment.appendChild(proof);
}
function renderTitle(content, result){
let fragment = document.createElement('div');
fragment.classList.add('pop-title');
let header = document.createElement('h1');
header.textContent = content;
fragment.appendChild(header);
appendProof(fragment,result);
document.body.appendChild(fragment);
}
function renderAbstract(content, result){
let fragment = document.createElement('div');
fragment.classList.add('pop-abstract');
let p = document.createElement('pre');
p.textContent = content;
fragment.appendChild(p);
appendProof(fragment,result);
document.body.appendChild(fragment);
}
function renderBody(content, result){
let fragment = document.createElement('div');
fragment.classList.add('pop-body');
let p = document.createElement('pre');
p.textContent = content;
fragment.appendChild(p);
appendProof(fragment,result);
document.body.appendChild(fragment);
}
function renderAuthor(content, result){
let fragment = document.createElement('div');
fragment.classList.add('pop-author');
let p = document.createElement('pre');
p.textContent = content;
fragment.appendChild(p);
appendProof(fragment,result);
document.body.appendChild(fragment);
}
function renderImage(content, result){
let fragment = document.createElement('div');
fragment.classList.add('pop-image');
let p = document.createElement('img');
p.src = content;
fragment.appendChild(p);
appendProof(fragment,result);
document.body.appendChild(fragment);
}
function reset() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment