HTML without javascript


(Jose) #1

Hello,

I’ve created a document with just a few images and text. Is it possible to export it without javascript?

Thanks.


#2

Unfortunately not – Tumult Hype’s runtime is based on JavaScript, which handles all positioning for those images.


(Jose) #3

Thanks for your quick answer.


(Loves Hype) #4

Short answer … no. As Hype renders everything “on the fly”.

Longer answer…


Version 1 (with script tags)


You can view it in Chrome. Then open the console and type …

copy(document.querySelector('html').outerHTML)

This copies the output to the clipboard and you then need to save it to a HTML file.


Version 2 (without script tags)


Only downside it still contains references to the scripts that generated the output in the first place.
One brute force way would be the same as described above but run this in your console …

var doc=document.querySelector('html').outerHTML; var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi; while (SCRIPT_REGEX.test(doc)) { doc = doc.replace(SCRIPT_REGEX, '');};copy(doc);

This removes the script tags before copying to the clipboard.


(Jose) #5

Thanks,

When I copy the first line I get an “undefined”


(Loves Hype) #6

Yes… but the content is in your clipboard. You only need either of the lines not both.
This is a total hack and probably only good for one scene layouts.


(Jose) #7

Yes, it worked!! but some special characters (it is in spanish) are lost and some code is shown at the top.


(Loves Hype) #8

Can you share your document so I can try it for myself? Viví en formentera durante 8 años.


(Jose) #9

Claro! He hecho un un zip pero no me deja subirlo aunque dice que es zip es uno de los archivos admitidos…


(Jose) #10

https://www.dropbox.com/s/w1cfb5px539e4c7/html_hype.zip?dl=0


(Loves Hype) #11

This worked for me… give it a try:

var head=document.querySelector('head').outerHTML; var HEAD_REGEX = /<div>|<\/div>|\&nbsp\;/gi; while (HEAD_REGEX.test(head)) { head = head.replace(HEAD_REGEX, '');}; var body=document.querySelector('body').outerHTML; var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi; while (SCRIPT_REGEX.test(body)) { body = body.replace(SCRIPT_REGEX, '');}; copy(head+body);

giving me this static page


(Jose) #12

Not working, same error. Can you send me the file that worked for you?


(Loves Hype) #13

That is strange. Sure I am currently shopping grocery but after that.


(Jose) #14

Thanks. I’m on a Mac, if it helps…


(Loves Hype) #15

I guess we all are using Hype and so on… :slight_smile:


(Jose) #16

:man_facepalming:Yes!!


(Jose) #17

Finally it worked in another computer, but if I see the code it still has javascript on it.


(Loves Hype) #18

I am back. The script is certainly not perfectly debugged and I put it together on the spot. I guess it still needs testing in different environments. I ran it in chrome! And this is my output:

index_static.html.zip (5,3 KB)


(Loves Hype) #19

I just realized that the URLs are full file refs and not shortend to relative paths. I’ll fix that next.


(Jose) #20

Yes, images are not displayed and the link is not working in “ver documentation técnica”.