Is there a download function in jsFiddle? - jsfiddle

Is there a download function in jsFiddle, so you can download an HTML with the CSS, HTML and JS in one file, so you can run it without jsFiddle for debug purposes?

Ok I found out:
You have to put /show a after the URL you're working on:
http://jsfiddle.net/<your_fiddle_id>/show/
It is the site that shows the results.
And then when you save it as a file. It is all in one HTML-file.
For example:
http://jsfiddle.net/Ua8Cv/show/
for the site http://jsfiddle.net/Ua8Cv

New answer to an old question:
Method 1:
Step 1: You have to put /show after the URL you are working on:
http://jsfiddle.net/<fiddle_id>/show/
It shows the output with a result header.
Step 2: Right click the bottom frame and select View Frame Source. That's it. You got the html code with online JS links, CSS.
Just Save it.
For Example:
http://jsfiddle.net/YRafQ/20/show/
for the site http://jsfiddle.net/YRafQ/20/
Note: View Frame Source and not View Page Source
Method 2:
You can use this code: view-source:http://fiddle.jshell.net/<fiddle_id>/show/light/
For Example: For my fiddle_id: YRafQ/20
view-source:http://fiddle.jshell.net/YRafQ/20/show/light/

Step 1:
Go to a fiddle page like jsfiddle.net/oskar/v5893p61
Step 2:
Add '/show' at the end of the URL, like jsfiddle.net/oskar/v5893p61/show
Step 3:
Right click on the page and click on the View frame source. You will get the HTML code including CSS in tag and Javascript (js) in tag. [Also source link of all library will be added].
See screenshot
Step 4:
Now you can save the source code in a .html file.

Adding /show does not present a pure source code, it's an embedded working example. To display it without any additional scripts, css and html, use:
http://fiddle.jshell.net/<fiddle id>/show/light/
An example:
http://fiddle.jshell.net/Ua8Cv/show/light/

No, JSFiddle doesn't have a download feature. However, it's not very difficult to get around that and save the contents of a fiddle anyway.
Since the time the accepted answer was posted, JSFiddle has made some recent UI and backend changes that affect the way a fiddle should be downloaded. Note the updated procedures below.
Simple Commandline Method
This method only downloads the fiddle's HTML, JavaScript, and CSS as a single file. The fiddle's external resources are not saved.
In the commandline shown below, fiddle_id refers to the ID number of the fiddle. For a fiddle with the URL "http://jsfiddle.net/<fiddle_user>/<fiddle_id>" or "http://jsfiddle.net/<fiddle_id>", only the fiddle_id is needed. The fiddle_user is unimportant.
At a shell prompt, enter the single commandline:
fiddleId=fiddle_id; curl "http://fiddle.jshell.net/${fiddleId}/show/" -H "Referer: http://fiddle.jshell.net/${fiddleId}/" --output "${fiddleId}.html"
The fiddle will be saved to a file named "fiddle_id.html".
Longer Browser Method
This method downloads the fiddle as well as its external resources. The steps given are based on using Google Chrome. Using other web browsers should work as well, but they may use different filenames.
Select the "Share/Embed" menu/link at the top of the JSFiddle edit page. In the dialog box that appears, copy the URL shown in the "Share full screen result" field. It will be of the form "http://jsfiddle.net/<fiddle_user>/<fiddle_id>/embedded/result/" or "http://jsfiddle.net/<fiddle_id>/embedded/result/".
Open a new browser window and paste in the URL copied in the previous step. Load that page.
Use your browser's save feature to save the page and all of its resources to your local computer. To save all the resources using Google Chrome, for example, be sure to select "Webpage, Complete" in the "Format" menu. Be sure to specify a name for the page. Let's say it's named "fiddle.html" for this example.
After the page is saved to your computer, you will have the "fiddle.html" file and a directory named "fiddle_files". The file "fiddle.html" is the wrapper page that JSFiddle uses to display a header with a "Result" title and other links. It will load your fiddle in an iframe element. For the most part, this file can be ignored or even deleted. Your fiddle's HTML, JavaScript, and CSS content will all be saved in the "fiddle_files" directory as a single file named "saved_resource.html".
Copy "fiddle_files/saved_resource.html" to wherever you'd like to use it. If your fiddle included items under "External Resources", those will also appear in the "fiddle_files" directory. Be sure to copy those files to the same place to which you copied "saved_resource.html", because the HTML file will refer to those resources using relative URLs.
As mentioned earlier, other browsers may name the files differently when they are saved. For example, Firefox names the combined HTML/JS/CSS file "fiddle_files/a.html".

Still no download functionality supported.. BUT.. you can use the jsfiddle-downloader node script.
Installation:
npm install jsfiddle-downloader -g
To download a single fiddle from its id:
jsfiddle-downloader -i <fiddle-id> [-o <output file>]
To download a single fiddle from its url:
jsfiddle-downloader -l <url> [-o <output file>]
jsfiddle-downloader -l jsfiddle.net/<user>/<fiddle-id>
jsfiddle-downloader -l https://jsfiddle.net/<fiddle-id>
jsfiddle-downloader -l https://jsfiddle.net/<user>/<fiddle-id>/show/ -o myfiddle.html
To download all scripts of a determinated 'user' from jsFiddle.net:
jsfiddle-downloader -u <user> [-o <output file>]
It'll download all backups in the currrent directory, the jsFiddles scripts will be named as:
[<output-folder>/]<id-fiddle>.html

The best way is:
Right-click on the output panel.
Choose view frame source, then the whole code will appear.
After that you can copy that code, and paste it in your computer.

You have to put /show a after the URL you're working on:
For example:
"http://jsfiddle.net/rkw79/PagTJ/show/"
for Field URL :
"http://jsfiddle.net/rkw79/PagTJ/"
after that save the file and go to the show folder(or the file name you have saved with) under that folder u will get a html file show_resource.HTML .that is your actual file.now open it in browser and view the source code. Best of luck--------Ujjwal Gupta

In a recent work I had to download a list of fiddle urls and create separate folder for each fiddles having separate html css js file for each, i have created the following crawler program for this.
https://github.com/sguha-work/FiddleCrawler
.It will create folder name with counter value and each folder will have a html, a css, a js and a details file. (The details file will holds the links of external resources).

I found an article under the above topic.There by I could take the full code .I will mention it.
Here are steps mentioned in the article:
Add embedded/result/ at the end of the JSFiddle URL you wanna grab.
Show the frame or the frame’s source code: right-click anywhere in the page and view the frame in a new tab or the source right-away
(requires Firefox).
Finally, save the page in your preferred format (MHT, HTML, TXT, etc.) and voilà!
also you can find it : https://sirusdark.wordpress.com/2014/04/10/how-to-save-and-download-jsfiddle-code/

You can download using this package in node js,
https://www.npmjs.com/package/jsfiddle-downloader

There is not such a proper way to download all the things all together from JSFiddle but there is a hack way to do just that.
Simply add "embedded/" or "embedded/result/" at the end of your JSFiddle URL!, and then you can save the whole page as an HTML file + the external libraries (if you wants).

If you want to download all of your fiddles to an offline folder, there is a script available for this:
https://github.com/isonno/DownloadJSF

Try copying and pasting your code into WebDen and then downloading it from there. Only drawback is that it only supports pure JS, html, and css, so any other code may need to be downloaded another way.

Okay, the easiest way, I found out was just changing the url (jsfiddle[dot]net) to fiddle[dot]jshell[dot]net/
There u have a clear html code, without any kind of iframe...
Example:
https://jsfiddle[dot]net/mfvmoy64/27/show/light/ -> http://fiddle[dot]jshell[dot]net/mfvmoy64/27/show/light/
(Must change the '.''s to "[dot]" because of stackeroverflow... :c)
PS: sry 4 bad english

There is npm-package jsfiddle-downloader.

Use http://jsfiddle.net//show/light/
then just use inspect element function of browser. you will get code in iframe tab. . in chrome just right click and cick on edit as html tab. and copy the html content. that is your actual code.

Ctrl + S, saves the entire fiddle, inside the files folder there is the clean page you are looking for

Related

need to automatically create a list of links for indexing

I have 2,500 html files which I need to automatically add to my index page, so I can create a sitemap and my file can be crawled and indexed. Obviously I cannot add that many manually. Any idea of how to accomplish this quickly?
Thanks in advance,
Sascha
It sounds like you want to link to the 2500 pages from your index page. I'm assuming that all of your HTML content is located in a folder called "html-folder/".
Add the following code to a new file (e.g., "my-script.sh"), then run it using bash my-script.sh.
#!/usr/bin/env bash
for i in html-folder/*; do
page_path="html-folder/$i"
page_name="$i"
echo "$page_name" >> links.html
done
After running the script, copy and paste the content of its output located in links.html into whichever page of your site where you want to list the links.

Is there any way to archive and recover entire page (with entire html, css, img, js, ...) using selenium chromedriver on ubuntu?

I'm looking for a way to archive the entire state of webpage, for the purpose of archiving the webpage.
Actually, what I want to somehow save all rendered results of the page (not as the form of screenshot, but the form of rendered result of DOM element) that we can see on browser, and recover them in local environment without network.
I really don't need to save all the functionalities of the page that interact with other computer. Only the view of the page is needed to be archived.
What I tried to archive youtube.com's home page were,
Using beautiful soup to get immediate html sources
Using python selenium and chromedriver to get dynamically loaded html sources
2 + downloading all referenced .css, .js, and images from links in html codes to local directory.
Pressing ctrl+s on chrome, which downloads html sources and several files. (.js, .css, .jpg, ...)
But all of them did not work correctly.
At first, 4th method seems working, but soon I found out that it downloads initial html source, not a dynamically loaded one.
Is there any known ways to do this kind of stuffs? (archiving currently rendered state of the page)
Thanks in advance.

How do I render a PDF from HTML with working named anchors?

Is there a way for a bunch of named anchors in a large html to be clickable within a PhantomJs generated PDF file?
I.e. say I have a table of contents or a list of FAQ questions. When clicking on the question/title - I'm taken to its answer/content within the same HTML file which is great but when the same HTML is rendered into a PDF each named anchor becomes an absolute URL (i.e. http://example.com/render.html#anchor_1) so clicking on it opens a browser with that URL instead of jumping to its content within the PDF file.
So, basically, is it possible (and how?) for a markup like this - https://fiddle.jshell.net/jyjuaaog/ to work within the generated PDF?
BTW, this works great when "printing as a PDF file" in Google Chrome but links end up broken when rendered in PhantomJs so there must be something I'm missing that I can't seem to find in the docs.
Any ideas?
Thanks!
Apparently there's a bug in PhantomJs preventing this. As suggested by PhantomJsCloud a quick-and-dirty workaround would be to replace the links with page links.

Can JQuery File upload be used without AJAX?

I want to use something along the lines of JQuery file upload (i'm open minded) in a form with lots of other fields for the UI (ex. image previews, delete, file sizes .etc), but I want to submit the files along with the form as if i used a normal HTML file field.
Is this at all possible?
If you console.log() the form after submission you will get an object in return that has a bunch of information. Among that information you can find for example file information of the file you just upload.
You can check this http://jsfiddle.net/1r0Lprkj/1/ and open your console after you've submitted the form.
Then if you want to go deeper into this, then you can check out the Javascript FileReader which lets you do a bunch of cool stuff with the uploaded file. https://developer.mozilla.org/en-US/docs/Web/API/FileReader
To answer your question; Yes it is possible to achieve without AJAX.

Disable browser cache for displayed in an iFrame PDF by means of TCPDF

I am trying for hours to solve the following caching problem.
My application has the following structure (simplified):
index.php - main page (contains various input fields, submit button and an iframe for dispaying PDF content with the help of TCPDF)
generate.php - generates PDF file based on the supplied POST parameters and stores the file to the filesystem
viewer.php - Displays the PDF document (TCPDF libraries). The iframe loads this script to show the pdf file
The workflow is pretty simple - the user chooses some options and clicks the submit button on the main page. The selected parameters are sent per AJAX by POST to the generate.php script. The script generates the PDF file and stores it to the filesystem. At the end it returns the newly created/edited filename. The filename is fetched in the AJAX callback function, which then refreshes the iframe with the new/edited filename:
viewer.php?filename=NEW_OR_EDITED_FILENAME
Everything is working, but when the file is being replaced, sometimes (NOT ALWAYS), the browser shows the old pdf file, although the new version is on the hard drive. I tried the following solutions:
Add Meta tags to disable cache to the generated HTML by index.php and viewer.php
Disabling cache for jQuery AJAX calls by: jQuery.ajaxSetup({cache: false});
Adding some random string to the the filename parameter:
viewer.php?filename=FILENAME_RANDOMSTRING
The RANDOMSTRING is then removed from the script and the filename is extracted.
None of these solutions worked for me. Tested browsers are: Chrome 25.0.1364.152 and Firefox 19.0. Can someone help me with this?
Thanks in advance
Just had the same problem but after adding a random string it works perfect:
<iframe src="file.pdf?=<?=time();?>"></iframe>
After many hours of trying, the solution I found is to really generate a new file each time (Solution 3 from the question without removing the random string at the end of the file). As a result it was necessary to update the database and to delete the old files on every change. My initial intention was to avoid these actions, but unfortunately no other solution was found