Skip to content

Commit 8decc13

Browse files
Merge branch 'dev'
2 parents 5bd416c + 264972b commit 8decc13

File tree

568 files changed

+346658
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

568 files changed

+346658
-346
lines changed

jar/minima-nolibs.jar

346 KB
Binary file not shown.

jar/minima.jar

346 KB
Binary file not shown.
94.2 KB
Binary file not shown.

mds/code/minifs/browser.html

Lines changed: 327 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,327 @@
1+
<html>
2+
3+
<head>
4+
<title>MiniFS</title>
5+
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
8+
<!-- Load the main MDS JS lib -->
9+
<script type="text/javascript" src="mds.js"></script>
10+
11+
<!-- And the ICON for the page -->
12+
<link rel="icon" type="image/x-icon" href="favicon.ico">
13+
14+
<!-- JS -->
15+
<script type="text/javascript" src="./js/sql.js"></script>
16+
<script type="text/javascript" src="./js/auth.js"></script>
17+
<script type="text/javascript" src="./js/jszip.min.js"></script>
18+
<script type="text/javascript" src="./js/ziputil.js"></script>
19+
<script type="text/javascript" src="./js/mimetypes.js"></script>
20+
<script type="text/javascript" src="./js/jslib.js"></script>
21+
<script type="text/javascript" src="gui.js"></script>
22+
23+
<style type="text/css">
24+
25+
body {
26+
margin: 0 auto;
27+
padding:0;
28+
width : 100%;
29+
height : 100%;
30+
}
31+
32+
.mainiframe{
33+
margin: 0 auto;
34+
padding:0;
35+
width : 100%;
36+
height : 100%;
37+
}
38+
39+
</style>
40+
41+
</head>
42+
43+
<body>
44+
45+
<iframe class="mainiframe" id="webframe" frameborder="0" sandbox="allow-scripts" referrerpolicy="no-referrer"></iframe>
46+
47+
<script type="text/javascript">
48+
49+
//Is there apage defined..
50+
var MAIN_URL = MDS.form.getParams("mxsite");
51+
52+
//Get the current window location
53+
var mainstartpage = ""+window.location;
54+
var index = mainstartpage.indexOf("browser.html");
55+
BASE_PAGE = mainstartpage.substring(0,index-1);
56+
57+
BASE_PAGE = "https://127.0.0.1:10003/0x8877665544332211";
58+
MDS.log("BASE PAGE : "+BASE_PAGE);
59+
60+
//listen for post messages..
61+
window.onmessage = function(event){
62+
63+
//What was the message
64+
var msg = event.data;
65+
if(msg){
66+
var action = msg.action;
67+
if(action == "MINIWEB_JUMPTOURL"){
68+
69+
//Tell the iFrame we got the message
70+
var resp = {};
71+
resp.action = "MDS_RESPONSE";
72+
resp.randid = msg.randid;
73+
resp.data = true;
74+
75+
//Post to the iFrame
76+
document.getElementById('webframe').contentWindow.postMessage(resp,"*");
77+
78+
//And now jump to the page..
79+
go(msg.data);
80+
81+
}else if(action == "MINIWEB_GETMINIWEBURL"){
82+
83+
var domain = msg.data;
84+
85+
//Get the base domain..
86+
extractDomainToWeb(domain,function(extracted){
87+
88+
if(extracted){
89+
90+
var finalpage = addDomains(BASE_PAGE,convertDomainToURL(domain));
91+
92+
//Tell the iFrame we got the message
93+
var resp = {};
94+
resp.action = "MDS_RESPONSE";
95+
resp.randid = msg.randid;
96+
resp.data = finalpage;
97+
98+
//Post to the iFrame
99+
document.getElementById('webframe').contentWindow.postMessage(resp,"*");
100+
101+
}else{
102+
103+
//Need to Load it!..
104+
105+
}
106+
});
107+
108+
}else if(action == "MINIWEB_GETDATAURI"){
109+
110+
var webfile = msg.data;
111+
112+
//Get the base domain..
113+
extractDomain(webfile,function(extracted){
114+
115+
if(extracted){
116+
var internalfile = convertDomainToInternal(webfile);
117+
118+
//Load the file..
119+
MDS.file.loadbinary(internalfile, function(loader){
120+
121+
//Blank DATA URI
122+
var datauri= "data:,";
123+
124+
//Create a respoinse JSON
125+
var res = {};
126+
127+
if(loader.response.exists){
128+
res.exists = true;
129+
130+
//get the HEX data
131+
var hexdata = loader.response.load.data;
132+
133+
//Convert to base 64..
134+
var b64 = MDS.util.hexToBase64(hexdata);
135+
136+
//Consrtruct the data URI
137+
datauri= "data:"+getMimeTypeFromExtension(internalfile)+";base64,"+b64;
138+
}else{
139+
res.exists = false;
140+
}
141+
142+
//Tell the iFrame we got the message
143+
var resp = {};
144+
resp.action = "MDS_RESPONSE";
145+
resp.randid = msg.randid;
146+
resp.data = datauri;
147+
148+
//Post to the iFrame
149+
document.getElementById('webframe').contentWindow.postMessage(resp,"*");
150+
});
151+
152+
}else{
153+
154+
//Need to Load it!..
155+
156+
}
157+
});
158+
159+
}
160+
}
161+
};
162+
163+
//Listen for when the iFrame has loaded
164+
var LOAD_CALLBACK = null;
165+
webframe.addEventListener("load", function() {
166+
if(LOAD_CALLBACK){
167+
LOAD_CALLBACK();
168+
}
169+
});
170+
171+
//LOad a page in the iFrame
172+
function loadPage(page, callback){
173+
174+
if(callback){
175+
LOAD_CALLBACK = callback;
176+
}else{
177+
LOAD_CALLBACK = null;
178+
}
179+
180+
var fullpage = addDomains(BASE_PAGE,page);
181+
182+
MDS.log("Load Page : "+fullpage);
183+
184+
//Set the page
185+
webframe.src=fullpage;
186+
}
187+
188+
function go(domainreq){
189+
190+
domain = domainreq.trim();
191+
if(domain == ""){
192+
MDS.log("Cannot jump to blank domain..");
193+
return;
194+
}
195+
196+
if(domain.startsWith("miniweb://")){
197+
domain = domain.substring(10);
198+
}
199+
200+
MDS.log("Browser GO : "+domain);
201+
202+
//Get the base domain for this page
203+
var basedomain = getBaseDomain(domain);
204+
var webfolder = addDomains(BASE_WEB,basedomain);
205+
206+
var finalpage = addDomains(BASE_WEB,domain);
207+
if(!finalpage.endsWith(".html")){
208+
finalpage = addDomains(finalpage,"index.html");
209+
}
210+
211+
//Does site data exists allready..
212+
MDS.file.listweb(webfolder,function(listweb){
213+
214+
MDS.log("WEBFOLDER : "+JSON.stringify(listweb));
215+
216+
//Does the repo exists
217+
if(listweb.response.exists){
218+
MDS.log("WEBFOLDER EXISTS ");
219+
220+
loadPage(finalpage);
221+
}else{
222+
223+
MDS.log("WEBFOLDER DOES NOT EXISTS ");
224+
225+
//Extract the repo and then load
226+
loadPage("loading.html",function(){
227+
228+
//Now lets load the file..
229+
var api = {};
230+
api.action = "LOAD";
231+
api.data = basedomain;
232+
233+
//Send it to MiniWEB
234+
MDS.api.call("miniweb",JSON.stringify(api),function(resp){
235+
236+
//Call wqas replied to ?
237+
if(resp.status){
238+
239+
//Parse the data
240+
var data = JSON.parse(resp.data);
241+
242+
//Did we fiund it
243+
if(data.found){
244+
245+
MDS.log("DATA FOUND");
246+
247+
//OK - extract
248+
var fp = data.filepacket;
249+
250+
extractFilePacketToWeb(fp, function(resp){
251+
MDS.log("Extracted..");
252+
loadPage(finalpage);
253+
254+
});
255+
256+
}else{
257+
MDS.log("DATA NOT FOUND");
258+
259+
}
260+
261+
}else{
262+
alert("Could not conatct MiniFS MiniDAPP ?");
263+
}
264+
});
265+
266+
/*extractDomainToWeb(basedomain, function(extracted){
267+
268+
if(extracted){
269+
loadPage(finalpage);
270+
}else{
271+
loadPage("loading_notfound.html");
272+
273+
//Start Shoutout..
274+
//..
275+
}
276+
});*/
277+
});
278+
}
279+
});
280+
}
281+
282+
//Main message handler..
283+
MDS.init(function(msg){
284+
if(msg.event == "inited"){
285+
286+
//Try this first.. then do normal if not exists..
287+
MDS.cmd("checkmode", function(resp){
288+
289+
//This only works on 1.0.43 onwards..
290+
if(resp.response.untrustedmdsuid){
291+
//Use this as the UID for websites..
292+
MINIWEB_UID = resp.response.untrustedmdsuid;
293+
294+
}else{
295+
296+
//Use Our own UID
297+
MINIWEB_UID = MDS.minidappuid;
298+
}
299+
300+
var wipeold = true;
301+
302+
if(wipeold){
303+
//Delete all the old sites on refresh..
304+
MDS.file.deletefromweb(BASE_WEB,function(delweb){
305+
MDS.file.delete(BASE_INTERNAL,function(del){
306+
307+
MDS.log("Cleared web site cache..");
308+
309+
//NOW GO..
310+
go(MAIN_URL);
311+
312+
});
313+
});
314+
}else{
315+
//NOW GO..
316+
go(MAIN_URL);
317+
}
318+
319+
});
320+
}
321+
});
322+
323+
</script>
324+
325+
</body>
326+
327+
</html>

mds/code/minifs/dapp.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name":"MiniFS",
3+
"icon":"minifs.png",
4+
"version" : "0.1",
5+
"description": "Broadcast File System",
6+
"category":"General"
7+
}

0 commit comments

Comments
 (0)