How to change urls in Hype generated files without opening Hype?

A couple of times clients had requested ability to change links – defined on a rectangle element – in hype generated pages/animations – without my later involvement.

My instructions on how to search the urls in the generated js-files and edit themselves in ie Sublime have so far been met with a bit anxiety and I have had no better straightforeward sollution.

Do anyone know of some sort of a setup – ie with jquerry – where a user can edit a linked html-, xml- or txt-file and update links defined inside Hype?

Kind regards, Mikael

Here's one way: Importing content from a text file (.txt)

I think your best bet (for controlling your sanity and making future edits easier) is to use Hype itself. If you just change URLs, you would just need to upload the single modified .js file.

1 Like

There are examples of using extenal .js, .txt files with global vars in that list the urls ( hah, I see @Daniel just posted one for you :grinning: )

But here is a quick example.

We set up the head file to import a .js file with a list of urls. Each url in the list has a key name and the url

window.theUrls = {
'question':'https://forums.tumult.com/t/how-to-change-urls-in-hype-generated-files-without-opening-hype/10967',
'site':'https://forums.tumult.com'
}

keys here are ‘question’ and ‘site’.

The file will be place in the same path as the exported html ( or where evere you choose as long as you point to it in the head)

Like so.
<script type="text/javascript" src="./urls.js"></script>

This will now import the global var window.theUrls with its list.

In this example I have given each button an id related to a key

And use a swtich() to choose the correct url using the id/key.

    switch(element.id) {
    case 'question':
     window.open(window.theUrls['question'],"_self")
        break;
    case 'site':
     window.open(window.theUrls['site'],"_self")
        break;
     
}

So now all they have to contend with is editing a file that is easier to understand.

UrlSwitch.zip (109.7 KB)

3 Likes

Very nice, thank you!, Mark and Daniel. I’ll try it out. Kind regards, Mikael