HTML template

Discussion and feedback on Construct 2

Post » Fri Nov 30, 2012 8:22 pm

So I find myself editing the index.html file from my games after exporting them quite often.

This is simple enough, but becomes a nuisance when copying all the files over from a new build later, knowing that it will overwrite any changes I made in the index.

I can set up a special case where it will ignore the index when copying everything, but I just want to be sure that I will never need to replace that file with a new version or a new export.

I was thinking it would be cool if within Construct2 there was an html template that more advanced developers could edit and would be used to create the final index.html upon export.

Anybody else already have a solution they use for this?

I searched the site and didn't come up with anything
B
14
S
5
G
2
Posts: 20
Reputation: 2,378

Post » Sat Dec 01, 2012 7:03 am

@helto
It'd be helpful if you could explain why you find yourself editing the index.html quite often.

What edits are you making?
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Sat Dec 01, 2012 7:39 am

Couldn't you set the attribute of the index.html file in your export folder to "read only" so that the consecutive exports don't overwrite it once you modified it first ?

Also, like Velojet I'm wondering why are you in need of modifying frequently the index.html file ?

In my tutorial about customizing the export HTML page 2 at the end of the page I point out a tip that looks like what you could be looking for.
But it's a hacky method and it could put your project and C2 at risks. Be warned.



New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Dec 03, 2012 4:46 pm

@Velojet
@Kyatric

There are several reasons:

I have extra code that references the parent when loading games in an iframe.

adding javascript functions

passing/referencing dynamic data
B
14
S
5
G
2
Posts: 20
Reputation: 2,378

Post » Mon Dec 03, 2012 4:52 pm

[QUOTE=helto]I have extra code that references the parent when loading games in an iframe.

adding javascript functions

passing/referencing dynamic data[/QUOTE]

Are those things stuff you use/need in your game ?
If so, I guess you could use AJAX for passing/referencing and "parent" (?).

As for adding JS functions, use those functions in a plugin you made.

If those are irrelevant to the game itself, simply don't copy the index.html when copying your files to the destination site, rather using the HTML entry point file in there.

It is still not clear to me what you're doing exactly and why you need editing of the file. It sounds even like you shouldn't be editing it at all.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Dec 03, 2012 9:24 pm

@helto
Thanks for the clarification. Any tedious repetitive handwork like that is a prime candidate for automation. Go with Kyatric's advice about making a plugin. That'll also let you append to index.html:
[CODE]jQuery('head').append('[text to append]');[/CODE](Put it in the runtime onCreate() function.)

Much better than a HTML template!
Velojet2012-12-03 21:29:51
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Tue Dec 04, 2012 7:14 pm

@Kyatric
@Velojet

Thanks guys, will do.
B
14
S
5
G
2
Posts: 20
Reputation: 2,378


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 16 guests