|
@@ -0,0 +1,162 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html>
|
|
|
+ <head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="apple-mobile-web-app-capable" content="yes" />
|
|
|
+ <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
|
|
|
+ <meta name="theme-color" content="#4b75ff">
|
|
|
+ <link rel="stylesheet" href="../script/semantic/semantic.min.css">
|
|
|
+ <script src="../script/jquery.min.js"></script>
|
|
|
+ <script src="../script/semantic/semantic.min.js"></script>
|
|
|
+ <script src="../script/ao_module.js"></script>
|
|
|
+ <title>Browser</title>
|
|
|
+ <style>
|
|
|
+
|
|
|
+ </style>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <div id="renderer">
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <script>
|
|
|
+ let renderingURL = "http://124.244.86.40:8080";
|
|
|
+ //Get window hash
|
|
|
+ let targetFrameingURL = "";
|
|
|
+ if (window.location.hash.length > 0){
|
|
|
+ targetFrameingURL = window.location.hash.substr(1);
|
|
|
+ targetFrameingURL = JSON.parse(decodeURIComponent(targetFrameingURL));
|
|
|
+ console.log(targetFrameingURL);
|
|
|
+ }
|
|
|
+
|
|
|
+ ao_module_agirun("Browser/backend/downpage.js", {
|
|
|
+ url: renderingURL
|
|
|
+ }, function(data){
|
|
|
+ var postScripts = manualScriptLoading(renderingURL, data, true);
|
|
|
+ //console.log(data);
|
|
|
+ var titleFilter = JSON.parse(JSON.stringify(data));
|
|
|
+ var pageTitle = $(titleFilter).filter('title').text();
|
|
|
+ var renderEle = $(JSON.parse(JSON.stringify(data)));
|
|
|
+ console.log(renderEle);
|
|
|
+ $(renderEle).each(function(){
|
|
|
+ if (!$(this).is("script")){
|
|
|
+ $("#renderer").append($(this));
|
|
|
+ if ($(this).attr("src") !== undefined){
|
|
|
+ fixRelativePath(renderingURL, $(this).attr("src"), $(this));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ao_module_setWindowTitle(pageTitle);
|
|
|
+
|
|
|
+ //Get the script parts and execute it
|
|
|
+ setTimeout(function(){
|
|
|
+ postScripts.forEach(function(script){
|
|
|
+ $("#renderer").append($(script));
|
|
|
+ });
|
|
|
+ }, 300);
|
|
|
+
|
|
|
+ //Replace all images
|
|
|
+ $("img").each(function(){
|
|
|
+ bufferImageLoad(renderingURL, $(this).attr("src"), $(this));
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ function manualScriptLoading(url, contentBody, srcOnly = true){
|
|
|
+ var scripts = $(contentBody).filter("script");
|
|
|
+ console.log(scripts);
|
|
|
+ var postScripts = [];
|
|
|
+ scripts.each(function(){
|
|
|
+ if (srcOnly){
|
|
|
+ if ($(this).attr("src") == undefined){
|
|
|
+ let internalScriptEle = $(this);
|
|
|
+ postScripts.push(internalScriptEle);
|
|
|
+ }else{
|
|
|
+ //Check for relative or absolute
|
|
|
+ if ($(this).attr("src").includes("//") == false){
|
|
|
+ let seperator = "/";
|
|
|
+ if ($(this).attr("src").substr(0, 1) == "/"){
|
|
|
+ seperator = "";
|
|
|
+ }
|
|
|
+ $(this).attr("src", url+seperator + $(this).attr("src"));
|
|
|
+ console.log("Fixing relative import with absolute: ", $(this).attr("src"));
|
|
|
+ }
|
|
|
+ $("head").append($(this));
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //Check for relative or absolute
|
|
|
+ if ($(this).attr("src").includes("//") == false){
|
|
|
+ let seperator = "/";
|
|
|
+ if ($(this).attr("src").substr(0, 1) == "/"){
|
|
|
+ seperator = "";
|
|
|
+ }
|
|
|
+ $(this).attr("src", url+seperator + $(this).attr("src"));
|
|
|
+ console.log("Fixing relative import with absolute: ", $(this).attr("src"));
|
|
|
+ }
|
|
|
+ $("head").append($(this));
|
|
|
+ }
|
|
|
+ console.log($(this).attr("src"));
|
|
|
+ });
|
|
|
+ return postScripts;
|
|
|
+ }
|
|
|
+
|
|
|
+ function fixRelativePath(baseURL, relpath, element){
|
|
|
+ let fullURL = relpath;
|
|
|
+ if (!relpath.includes("//")){
|
|
|
+ let seperator = "/";
|
|
|
+ if (relpath.substr(0, 1) == "/"){
|
|
|
+ seperator = "";
|
|
|
+ }
|
|
|
+ fullURL = baseURL + seperator + relpath;
|
|
|
+ }
|
|
|
+ $(element).attr('src',fullURL);
|
|
|
+ }
|
|
|
+
|
|
|
+ function bufferImageLoad(baseURL, imageURL, object){
|
|
|
+ //Parse the relative URL
|
|
|
+ let fullURL = imageURL;
|
|
|
+ let ext = imageURL.split(".").pop();
|
|
|
+ if (!imageURL.includes("//")){
|
|
|
+ let seperator = "/";
|
|
|
+ if (imageURL.substr(0, 1) == "/"){
|
|
|
+ seperator = "";
|
|
|
+ }
|
|
|
+ fullURL = baseURL + seperator + imageURL;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(fullURL);
|
|
|
+
|
|
|
+ if (ext == "svg"){
|
|
|
+ $(object).attr("src", fullURL);
|
|
|
+ }else{
|
|
|
+ ao_module_agirun("Browser/backend/downimg.js", {
|
|
|
+ url: fullURL
|
|
|
+ }, function(base64){
|
|
|
+ $(object).attr("src", "data:image/" + ext + ";base64," + base64);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ function stringToBytes (str) {
|
|
|
+ var ch, st, re = [];
|
|
|
+ for (var i = 0; i < str.length; i++ ) {
|
|
|
+ ch = str.charCodeAt(i);
|
|
|
+ st = [];
|
|
|
+ do {
|
|
|
+ st.push( ch & 0xFF );
|
|
|
+ ch = ch >> 8;
|
|
|
+ } while ( ch );
|
|
|
+ re = re.concat( st.reverse() );
|
|
|
+ } // return an array of bytes
|
|
|
+ return re;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ </script>
|
|
|
+ </body>
|
|
|
+</html>
|