saving an image in a windows 8 application using javascript - javascript

I'm writing an application for windows 8 that displays images from a json file.
i would like to add the ability to save the images to my local machine but i dont know where to start.
so im just asking for advice and where to look to find out how to do this, id like to make it clear that im not asking people for code but just for some guidance on how i could find out how to go about this.
thank you in advance
EDIT:
i found a way of doing it in after a bit more looking around, I found i was able to do a ajax call on the image i was trying to save and have it return a Blob this was then written to a file

i found a way of doing it in after a bit more looking around, I found i was able to do a ajax call on the image i was trying to save and have it return a Blob this was then written to a file

Related

Hide source code of Electron alteast 1 file.. Possible?

Hey so i started using Electron becouse of HTML/CSS/JS possibilites.
I have expirience mostly with PHP and some little with JS.
Was searching how to hide files of Electron (becouse .asar file can be unpacked) and its just stupid to put my MySQL server info in .js file and let users see that info..
Is there any way to hide atleast 1 .js file where i would put all necessery stuff like mysql connection and mysql managing?
I googled a lot about that some people say that Node.JS can to that but i cant find anywhere how to exacly do it?
Tried to switch to CEFSharp but cant realise how to interact between C# and Webpage (used webserver for template and php stuff but like how to tell C# that variable of A is A and use that C# variable for something)..
Hope somebody will help me, maybe its dumb question for some expirienced developers but i mostly work in PHP and i wanna learn new stuff..
Thanks!
Long story in short - no. In deep down, any code you ship in client to users should be considered to be revealed, just matter of how hard will it be. Instead of shipping important credential and obfuscate to not able to read it, application should be designed to be safe even if user reads whole code in client.
I'm not really any sort of expert on Electron. I'll assume that you will either create a login or a config file. In the first case you can use the database to determine if access is allowed. If you don't want to setup a login script then you can use a config.json file that is not part of the build file. There are a few node packages you can use - I believe one is "electron-storage" to help with the access to the database. Hope this helps.
Johnf

Working with PSD on psd.js library

I have a requirement from a client to show images from a PSD(photoshop) file which have multiple layers, on each layer there will be an image, I did some research about it but haven't got any leads, so far I come up with a JS library named psd.js, but I think that is only for parsing and converting to image format(not sure haven't found much documentation on internet). please suggest me if there is any open source library for reading and editing PSD files. (javascript or asp.net preferred)
here is my snippet I have tried so far but haven't got any success, please let me know if there is any way to work with PSDs
thanks.
PSD.fromURL("images/example.psd")
.then(function(psd) {
psd.tree()._children[3]._children[0].visble = false;
document.getElementById('ImageContainer')
.appendChild(psd.image.toPng());
console.log(psd.tree().export());
});
I did something similar for a project of mine, for that you can use imagemagick they even have a command line tool that can make the process very easy. It will let you extract the images from each layer. You can also use psd.js to get information about the each layer positioning and other information.
Hope this helps.

JavaScript- Extracting the main text from another website

I want the user to type in the URL of the website and then the program will get the main text of that website. How can this be done? I know on python this can be done with Beautiful soup but I don't know how else this could be done?
Thanks
Any question then let me know
As #Axnyff pointed out, due to CORS, you wont be able to do this on the client side (On the browser). However, if what you want is to use javascript instead of python for this task, you can do this using Node JS.
Scotch.io has a very good tutorial on this.

read text file and save the content in an array using JavaScript

I've searched a lot about this topic, but couldn't find solution. I have a *.txt file containing coordinates (each line has one coordinate) in one column. So, I want to read this file from my file system and use those coordinates to visualize the tracking route on Google Maps API v3. I've already visualized the track for three coordinates and it works fine.
Can anybody just share a sample code of reading a *.txt file and fill an array with the file content? Maybe this is quite easy thing, but I am really stuck on this and would appreciate your help!
Thanks in advance!
You can't read a file using javascript. It's a client-side programming language. But some developpers have developped a solution.
Check this link and tell me if it was helpful for you: http://www.htmlgoodies.com/beyond/javascript/read-text-files-using-the-javascript-filereader.html#fbid=iTAoMveIKhq
I'm not going to share a sample code but you could read the answers to that similar question :
Javascript - read local text file
Basically loading the txt file with Ajax, and read the responseTextattribute of the response.
Although it would be easier to read a xml file or a json file, which would be easier to parse than a simple txt file.

pulling pages from a pdf file and display it?

this is just a rough idea, i am trying to create a magazine reading platform and i need the reading flow to be smooth, and so is the magazine upload process, it must be fast and easy. so i am thinking of using pdf file.
I am thinking is it possible to have a module(maybe a system?) to pull each page from the pdf and display it in a interface written in html? i know there is something similar in flash, but what i want it is something lighter and easier from development. coz at the end i am gonna put this module into maybe a cms system.
thanks in advance guys:)
Regards,
WJ
hi guys i just found this solution, pdf.js, it uses javacript to implement pdf displaying on the web page, it also able to create pdf file from javascript.
anyway the reader is there, and interface is able to change since it is html, i guess this should be the solution.

Categories