How to Auto Upload a json file to my github Website - javascript

There is a program in my company that generates a JSON file. I created a website (that will be live on github pages) using java script and html that displays the information from this JSON. Now I want others in my company to generate individual JSON files and be able to upload them to this website by clicking a single button. I'm thinking the button they click would generate the JSON (let's say it saves automatically as c:data.json), programmatically open the github pages website and then programmatically upload c:data.json. I do not want the json file to be stored on the website, just uploaded for one time use.
I have done a couple google searches and can only seem to find stuff on how to upload a json file in your code which I am already doing locally. I need a local file to programmatically upload, in order to be used in a github pages website. I'm new to web dev and any help is appreciated :)
OS: Windows 10
developed using: node.js, javascript, html, json, github pages.

Related

How to convert DOCX to ODT format using javascript?

I am working on a in-website document editor(word and excel document). So far I am able to edit ODT files using WEBODF. Is there any way to convert DOCX file to ODT using javascript so that i can use the file in the editor? any alternatives for editing word and excel documents inside a website? I have tried saving the file in OneDrive and then using the share link to open editing on sharepoint but this editor cannot be inserted inside an website and can only be done in a new tab? i need the editor inside the website as i need to implement azure versioning of the documents
WebODF is an awesome tool to be used as an online editor. Assuming you have no restrictions implementing a separate backend server, you can use libreoffice, which gives you a command line utility to exactly perform that job. You can convert docx file to odt file using the following command -
soffice --headless --convert-to odt <input file>.docx
The approach would be to create an API
Which would take docx file as input
Store that file temporarily somewhere and run the above command
Serve the converted odt file and delete the temporary files.
If you want to store those files in the server, then you can maintain a database to achieve that as well.
To take care of restricted cross origin policy, you can implement AJAX calls in the front-end to perform file uploading and viewing operations using Javascript blobs.

Getting full page source information using PowerShell

So my ultimate problem is that I have a SharePoint list where each list item may have multiple image attachments. I am looking to scrape the list using PowerShell so that I can backup all the images.
I am able to access each item's page in the list because of similarities in the URL, but I am unable to extract the attachments. This is because the filename is non-determinant. Unfortunately, I don't seem to be able to parse the info with Invoke-WebRequest because it brings back the HTML of the page, which does not list the file attachments.
Instead, the file attachments can be viewed when you use the 'Inspect page source' button, and which I believe is because they are inside a JavaScript function.
So, my question is - Can I get each file in a page's attachment from the JavaScript function so that I can scrape the page? Also - am I interpreting this problem correctly, and are there any other ways to solve this problem?
Please note: I don't have access to SharePoint server dlls including Microsoft.Sharepoint.dll, so I can't use Classes from that dll (unless they might be easily imported without having to install the whole library).
Here is a photo of where the source changes. I believe this is where HTML ends and Javascript begins:
And the highlighted lines in this file shows the information that I am looking to parse from the page's source information so that I can form the URL to download the image attachments:

How to manipulate a local text file from an HTML page

I've generated an HTML file that sits on my local disk, and which I can access through my browser. The HTML file is basically a list of links to external websites. The HTML file is generated from a local text file, which is itself a list of links to the remote sites.
When I click on one of the links in the HTML document, as well the browser loading the relevant site (in a new tab), I want to remove the site from the list of sites in the local text file.
I've looked at Javascript, Flask (Python), and CherryPy (Python), but I'm not sure these are valid solutions.
Could someone advise on where I should look next? I'd prefer to do this with Python somehow - because it's what I'm familar with - but I'm open to anything.
Note that I'm running on a Linux box.
First, Javascript cannot modify the local filesystem from the context of a webpage. To allow that would be a massive security concern.
Any server-side web framework can do this, and Flask is a great one to use because it's so lightweight. The general steps you would want to take are:
When / is requested, load the list of links.
Change each link to point to /goto?line=<line_number>.
Display the list to the user.
Then when you click a link:
When /goto is requested, load the list of links.
Remove the line number from the list.
Save the list of links.
Return status code 302, with the real URL as the Location header.
There is many ways to do this
Here is the easiest 3
Use JavaScript
2 install wampserver or similar and use php o modify the file
3 don't use te browser to delete and instead use a bat file to open the browser and remove the link from the text file

href an excel sheet and save changes made to it. using jsp javascript html

I hace an Excel sheet. using html i am opening it as
href="other/Browser-Capture.xls" target="_blank"><img src="images/xlsimg.bmp"></a>
This opens the excel sheet in a new browser window. I am however not able to modify it.
any idea how it can that be done...
thanks in advance
When requesting a file from a server (like the Excel sheet), it is downloaded to your local computer. If you edit it there, your edits do not affect the Excel file on the server.
So editing it directly on the server using a browser is not possible.
You could add an upload functionality to your webpage where you can upload the changed excel file using <input type="file">. However this might get difficult because you would need to ensure that the uploaded file is the same as the original one.
If you want your users to be able to edit data on your webserver, you could save this data in a file, database etc. and provide a form to the users where they can edit the data.

How to show browse for FOLDER window(not browse for file)using just JSP and javascript?

I need a code for how to browse for folder (not file) using JSP and Javascript.
I looked for the JAVA code for browse for folder using JFileChooser library but I want the default window to be opened (which opens in browse for file).
I'm developing a webapp which will scan the folder based on the path and will generate the output.
Thanks in advance.
1.I need a code for how to browse for folder (not file) using JSP and Javascript.
Javascript does not have access to the file-system due to security reasons, as this answer says and also this answer.
So you would have to use flash or java applet as suggested in this answer or else you would have to wait till the time HTML5 File API matures :-)
But, if your requirement is that your a User (may be with administrator rights in the application) logins to the web-application through a web-browser and wants to scan (view the contents of) the particular folder on the server side (where the web-app is deployed and not the file system on his own machine) then you can use the suggestion given in this answer, just to elaborate on this:
Have a <form> which will have a text-box (to take the folder name or full-path) in the JSP, on submit of this form a request will be sent to the server.
The response would be list of files (List<String>) in that particular folder passed through the request.
you can also submit the request through ajax in which case you would return a JSONArray as suggested.
Now on the Server it would be normal Java File API stuff to fetch all the files in the folder you get from the request.
Sorry to say this but I don't think you would get a ready-made code to do what you want and that is not how things work on SO.
2.I looked for the JAVA code for browse for folder using JFileChooser library
You said you are building a web-app right? JFileChooser is a Swing component and as far as I know cannot be used in JSP to achieve what you desire.
3.I'm developing a webapp which will scan the folder based on the path and will generate the output.
The steps are explained in point (1).
Hope this helps and gives relevant hint and direction to go forward.

Categories

Resources