I have been developing an iOS application - a really simple application that is based on HTML and CSS (some of them will be using PHP and my SQL) However, I have been trying to find the way to embed HTML file in my project but all the tutorials that I had found (so far) would be either for older version or there is something missing in my Xcode (like file's owner button) which doesn't make it easy or sometimes in the tutorial that I followed had something different from my current version of Xcode. (I am really new to Xcode) my Xcode version is 6.1 running on the latest version of OSx Yosemite. I might have missed something that I should know about embedding HTML file in Xcode 6 for iOS8? I would be appreciated for any answer. Thank you.
I have tried to do the same a month ago, displaying html in iOS8. My html didn't need CSS though. But I suppose the way to do it is not so different.
We can load the html file as string and that display it with an UIWebView as follows:
var filePath = NSBundle.mainBundle().pathForResource("HtmlFileName", ofType: "html")
var htmlString = NSString.stringWithContentsOfFile(filePath!, encoding: NSUTF8StringEncoding, error: nil)
var myWebView = UIWebView(frame: DeviceUtil.getScreenRect())
myWebView.loadHTMLString(htmlString, baseURL: nil)
var viewController = UIViewController()
viewController.view = myWebView
self.navigationController?.pushViewController(viewController, animated: true)
Related
I've got a JSON file on AWS s3. I want to make a flutter button to trigger a download of that file from the URL. I've looked around stack quite a bit and I find ways to download JSON generated data but not from a URL. I did think this one was promising:
Force external download url
But I can't seem to get it working in flutter. Here's what I'm doing to try to use anchor with "download" attribute.
First off, my URL looks like this (this is fake though just for the sake of public stack question)
https://myfirmware.s3.amazonaws.com/proxy/version.json
Then I found this answer:
Flutter WEB download option
I tried this but it still (in Chrome Version 80.0.3987.149 (Official Build) (64-bit) shows the JSON in the browser rather than allowing me to save as a file directly on first click of the flutter button.
My flutter code looks like:
child: RaisedButton(
elevation: 1.0,
onPressed: () =>
downloadFile("https://myfirmware.s3.amazonaws.com/proxy/version.json"),
child: Text("Proxy Config File")),
My import is:
import 'package:universal_html/html.dart' as html;
And that method is:
void downloadFile(String url){
html.AnchorElement anchorElement = new html.AnchorElement();
anchorElement.href = url;
anchorElement.download = 'test.json';
anchorElement.click();
}
I am not sure how to see how this gets converted when building flutter for the web. But I was hoping this would look a lot like they mentioned here:
Force external download url
Which is:
Download Your File
You can use flutter_downloader plugin for this use case. Create a task with the download URL and target directory for storage.
final taskId = await FlutterDownloader.enqueue(
url: downloadUrl,
savedDir: downloadPath,
);
Make sure to initialize FlutterDownloader before creating a task.
WidgetsFlutterBinding.ensureInitialized();
await FlutterDownloader.initialize();
I have a Vue application and I'm trying to debug it in Chrome DevTools. The problem is when I try to find the file I want to debug, I get a list of files with the same name plus some weird hash tacked onto the end:
When I open any one file, I get some garbled minified code:
Sometimes I can find the file I want (with the original source code) but sometimes not.
What are these weird files and how can I find the file I want (with the original source code). Is there a way of getting the DevTools to list only the original source code files?
Thanks.
What tool in dev tools are you using to get that list? Seems like a list of cached files, so it's showing all the old versions of your code.
If you go to the network tab and reload the page. You should see a list of all the resources downloaded by the browser. Choose the js filter and you should see your vue js bundle (made by webpack) somewhere in that list.
To allow chrome to display the source correctly you need to generate the Source Maps in development deployments.
I am not sure what tool you are using to build and bundle, but it is likely that you might have support for this already.
Chrome Details:
https://developer.chrome.com/docs/devtools/javascript/source-maps/
OMG - debugging my debugging environment. It's SO maddening.
I'm working with Vue v2, and I'm using vuetify in my app. Here is a complete vue.config.js configuration that solved this problem for me.
// vue.config.js file
const path = require('path')
const { defineConfig } = require('#vue/cli-service')
module.exports = defineConfig({
transpileDependencies: [
'vuetify'
],
configureWebpack: config => {
if (process.env.NODE_ENV === 'development') {
// See available sourcemaps:
// https://webpack.js.org/configuration/devtool/#devtool
config.devtool = 'eval-source-map'
// console.log(`NOTICE: vue.config.js directive: ${config.devtool}`)
config.output.devtoolModuleFilenameTemplate = info => {
let resPath = path.normalize(info.resourcePath)
let isVue = resPath.match(/\.vue$/)
let isGenerated = info.allLoaders
let generated = `webpack-generated:///${resPath}?${info.hash}`
let vuesource = `vue-source:///${resPath}`
return isVue && isGenerated ? generated : vuesource
}
config.output.devtoolFallbackModuleFilenameTemplate =
'webpack:///[resource-path]?[hash]'
}
},
})
I found a work around for this. While you can not see the source code of your file, just change the code (add console or sth.) of the file you want to see while Vue is hot reloading your changes. It occurs to me that the source code is then reachable when you check the developer console.
There is a surprising number of developers I meet on projects that have no idea there are official browser extensions for debugging Vue, Router, VueX etc.
Stumbling across this question prompted me to post this life saving link for those that land here and have missed the existence of this essential tool:
https://devtools.vuejs.org/guide/installation.html
I'm building an simple stand-alone angular application in which u can submit information.
This information needs to be saved in a local JSON file that's in the asset folder. I know Angular runs in a web browser that's why I use electron to build it. The problem is that i can't figure out a way to edit the JSON files in angular 5 using electron (local).
I have tried the solutions mentioned in this post, But they didn't work for me, any other solutions?
After having this problem for quite some time i finally figured out how to solve it:
you need to put this in script tags in your index.html
var remote = require('electron').remote
var fs = remote.require('fs');
and in every component you want to use it you need to declare it globally
declare var fs: any;
then you can use it!
was quite a struggel to figure it out...
Because it's just JSON data, might I suggest using localStorage instead? Then, you can do something like:
...// Code that creates the JSON object
var theJSONdata = jsonObj.stringify(); // conver the object to a string
window.localStorage.setItem('mysavedJSON', theJSONdata)
;
Later, when you need to load the JSON to edit it or read it, just use:
jsonObj = JSON.parse(window.localStorage.getItem('mysavedJSON');
I have a single page web application using React and materialize-css and I would like to export it as static HTML and CSS so that it is possible to easily edit HTML for the purpose of prototyping. Is it possible to export at least a snapshot of current state?
I tried "save page" in Firefox and Chrome, but it does not provide good results.
Follow the following steps :-
1. In brouser, got to the developer tools,
2. select Inspector(firefox)/Elements(chrome),
3. then select the tag HTML, right click on it,
4. then click Edit as HTML.
Now you can copy all the code and save it. While the color and shape of the document remains, you will miss the pictures.
Good luck ! :)
Probably not ideal, but you can store the entire page as a variable and download it. Run this in your browser console after the page has loaded:
var pageHTML = document.documentElement.outerHTML;
var tempEl = document.createElement('a');
tempEl.href = 'data:attachment/text,' + encodeURI(pageHTML);
tempEl.target = '_blank';
tempEl.download = 'thispage.html';
tempEl.click();
The ReactDOMServer module contains a function for rendering a React application to static HTML - it's designed for use on the server, but I don't think there's anything to stop you using it in the browser (don't do this in production though!)
import ReactDOMServer from "react-dom/server";
import App from "./yourComponent";
document.body.innerHTML = ReactDOMServer.renderToStaticMarkup(App);
var pageHTML = window.document.getElementById('divToPDF').innerHTML;
let data = new Blob([pageHTML], {type: 'data:attachment/text,'});
let csvURL = window.URL.createObjectURL(data);
let tempLink = document.createElement('a');
tempLink.href = csvURL;
tempLink.setAttribute('download', 'Graph.html');
tempLink.click();
You can build your code and host it on github.io. The following tutorial will help you achieve that. You can then use the generated code in the gh-pages branch as your exported HTML
This was the first thread I found on SW.. so I think it would be appropriate to copy my own answer from another thread: https://stackoverflow.com/a/72422258/1215913
async function saveToFile() {
const handle = await showSaveFilePicker({
suggestedName: 'index.html',
types: [{
description: 'HTML',
accept: {'text/html': ['.html']},
}]
});
const writable = await handle.createWritable();
await writable.write(document.body.parentNode.innerHTML);
writable.close();
}; saveToFile();
for more info check the source answer
I had done this before but was stuck and couldn't seem to find the documentation anywhere. My scenario was I had a react js SPA and needed to create a static build to run without a server (through an organisations SharePoint using a static doc repository).
It is pretty simple in the end, run
npm run build
in your project directory and it will create the static build in a 'build' folder ready for you to dump wherever needed.
Reference: https://create-react-app.dev/docs/production-build/
I am using as3 and the Flash Professional IDE to code an app for Droid and IOS. I have noticed a few times when downloading a file nearly 100 megs that it sometimes stops for both android and IOS. It will stay at a certain percentage and I have to close the app to try again.
I am wondering if there is a "BREAK" some how for a moment in the internet connection that the file no longer sees the URL request and just stops. Does this make sense? Is there a way to fix this?
Here is the line of code I am using. The var urlString comes is an http request. Its a zip file. Exmaple is:
var urlString = "http://myWebsite.com/French.zip";
var urlReq:URLRequest = new URLRequest(urlString);
UPDATE: I think I have to add a URLstream to it but still not sure how to do this. I am getting closer I think.