forked from SolidOS/mashlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowse.html
More file actions
142 lines (131 loc) · 4.72 KB
/
browse.html
File metadata and controls
142 lines (131 loc) · 4.72 KB
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
<!DOCTYPE html>
<html id="docHTML">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<!-- was https://solid.github.io/solid-panes/style/tabbedtab.css -->
<link type="text/css" rel="stylesheet" href="mash.css" />
<script type="text/javascript" src="mashlib.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const panes = require('mashlib')
const UI = panes.UI
const $rdf = UI.rdf
const dom = document
$rdf.Fetcher.crossSiteProxyTemplate = self.origin + '/xss?uri={uri}';
var uri = window.location.href;
window.document.title = 'Data browser: ' + uri;
var kb = UI.store;
var outliner = panes.getOutliner(dom)
function go ( event ) {
let uri = $rdf.uri.join(uriField.value, window.location.href)
console.log("User field " + uriField.value)
console.log("User requests " + uri)
const params = new URLSearchParams(location.search)
params.set('uri', uri);
window.history.replaceState({}, '', `${location.origin}${location.pathname}?${params}`);
var subject = kb.sym(uri);
// UI.widgets.makeDraggable(icon, subject) // beware many handlers piling up
outliner.GotoSubject(subject, true, undefined, true, undefined);
mungeLoginArea();
}
const uriField = dom.getElementById('uriField')
const goButton = dom.getElementById('goButton')
const loginButtonArea = document.getElementById("loginButtonArea");
const webIdArea = dom.getElementById('webId')
const banner = dom.getElementById('inputArea')
uriField.addEventListener('keyup', function (e) {
if (e.keyCode === 13) {
go(e)
}
}, false)
goButton.addEventListener('click', go, false);
let initial = new URLSearchParams(self.location.search).get("uri")
if (initial) {
uriField.value = initial
go()
} else {
console.log('ready for user input')
}
async function mungeLoginArea(){
loginButtonArea.innerHTML="";
if(uriField.value)
loginButtonArea.appendChild(UI.authn.loginStatusBox(document, null, {}))
if(UI.authn.authSession && UI.authn.authSession.info.isLoggedIn){
const logoutButton = loginButtonArea.querySelector('input');
logoutButton.value = "Logout";
let displayId = `<${UI.authn.authSession.info.webId}>`;
webIdArea.innerHTML = displayId;
banner.style.backgroundColor="#bbccbb";
}
else {
banner.style.backgroundColor="#ccbbbb";
}
loginButtonArea.style.display="inline-block";
}
async function initAuth(){
if( !UI.authn.currentUser() ) {
await UI.authn.checkUser();
}
}
//initAuth();
if( UI.authn.authSession ) {
UI.authn.authSession.onLogin(() => {
mungeLoginArea();
go()
})
UI.authn.authSession.onLogout(() => {
mungeLoginArea();
webIdArea.innerHTML = "public user";
go()
})
UI.authn.authSession.onSessionRestore((url) => {
mungeLoginArea();
go()
})
}
mungeLoginArea();
});
</script>
</head>
<body>
<div style="width:100%;" id="inputArea">
<div style="margin-bottom:0.6em">
The SolidOS Databrowser
</div>
<div style="margin-left:1em">
Viewing <input id="uriField" type="text" style="font-size:100%; min-width:25em; padding:0.5em;" placeholder="enter a pod address e.g. https://you.solidcommunity.net/"/> <input type="button" id="goButton" value="Go" />
</div>
<div style="margin-top:0.5em;margin-left:1em">
As user <span id="webId"><public user></span> <span id="loginButtonArea"></span>
</div>
</div>
<table style="width:100%;">
<tr>
<div class="TabulatorOutline" id="DummyUUID" role="main">
<table id="outline"></table>
<div id="GlobalDashboard"></div>
</div>
</tr>
</table>
<style>
#inputArea {
width:100%;
padding:0.5em;
background-color:#d0d0d0;
}
#loginButtonArea input {
display:inline-block;
margin:0.25em !important;
padding:0.25em !important;
}
#webId {
display:inline-block;
padding-top:0.6em;
padding-bottom:0.6em;
}
#uriField {
width:70%;
margin-top:0.6em !important;
}
</style>
</body></html>