Javascript Help?
Displaying 1-8 of 8 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
CrazyAznGamer

No, really, I should be posting this in some sort of Javascript help board, but I felt like posting it here....
...
...
...
Yeah.

Now my friend's doing a webcomic and I agreed to help him on the actual website. But I want syndicated weekly content. However, what I got was something that resembled syndicated weekly content:

<script language='javascript'>
<!--
var comicName = 'OnlineComic';
var comicDir = 'weekly/images/';
var noImage = 'images/noupdate.gif'; // Displays if no updates for 2 weeks.
var comicWidth = '652';
var comicHeight = '253';
var comicFormat = 'gif';

function lastComic()
{
var date = new Date(_date-24*60*60*1000*(_date.getDate()%7));
var blah_date = new Date(date-24*60*60*1000*(date.getDate()%7));
var d = blah_date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = blah_date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = blah_date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

// If IMG NAME changes, change next line.
document.images.OnlineComic.src = comicDir + year + month + day + '.' + comicFormat;
}

var _date = new Date();
var date = new Date(_date-24*60*60*1000*(_date.getDate()%7));
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (yy < 1000) ? yy + 1900 : yy;

// IMG NAME below
document.write('<IMG NAME='OnlineComic' ALT='' + comicName + '' BORDER=0 SRC='' + comicDir + year + month
+ day + '.' + comicFormat + '' WIDTH='' + comicWidth + '' HEIGHT='' + comicHeight + '' onError='lastComic()'>');
-->
</script>

Notice the double quotes have been changed to single quotes, which would make understanding some lines extremely hard.

<!-- I wonder if you can write cryptic messages like this... hmm...-->

Anyways, the thing is, this works only for days that are multiples of seven, and the last days of months. That really isn't too much of a problem, but I'd like it if it was actually weekly.

More important, and the problem I need to ask you guys is:
How can I archive this shizzle in Chapters and Pages without having to resort to manually change the archive every single time I have to upload a new page?

Any suggestions for javascript and/or filename format changes?

Posted on 2005-09-03 10:43:38 (last edited on 2005-09-03 10:46:04)

Overkill

Um... maybe don't... use Javascript? :D

PHP with a MySQL database does a lot of this crap way easier. Of course, then your webhost would need these enabled, but it's way worth it. Almost all popular syndicated comic sites tend to use PHP/MySQL, else they do it manually. But getting the latest comic out with JS is not the best solution, and it's sure to run into incompatibility issues.

I dunno... www.quirksmode.org seems to have a lot of interesting stuff on the topic of Javascript and the DOM though. Then there's always www.alistapart.com for other Javascript, but some of the JS there is probably likely to not be very compatible with browsers. ALA's better for CSS and XHTML articles.

Posted on 2005-09-03 12:15:58

Kildorf

I'm going to second overkill's advice -- use PHP, at the very least. If nothing else, then your readers won't download all the code for navigation themselves. That means it's faster, and you don't have to worry about people looking at stuff they shouldn't.

Posted on 2005-09-03 12:49:02

CrazyAznGamer

I had a feeling people would tell me to use PHP...
*sigh*
>_> Time to find a better server... (and tell my friend not to use the current one.)

Posted on 2005-09-03 15:17:25

CrazyAznGamer

I looked at the quick function reference for PHP after checking out the basics.
....
.....
I'm positively scared out of my mind right now.
I know, it's nothing compared to actual programming languages... but still...
It's a scripting language with about a thousand different functions.

...

So uh, where do I start if I want to script some sort of syncopated content?

And I give McGrue and everyone else major major kudos for actually coding this site.
I am such an idiot just need a bit of help.

Posted on 2005-09-03 16:50:54

Kildorf

A good place to start with PHP is the introduction in the php.net documentation. It lets you into PHP nice and easily. It is, in fact, where I learned to PHP!

As for what exactly you're trying to do... are you sure you're going about this in a way that you want to go about it? I'm not really exactly sure what you're trying to do, but why don't you just get the newest file and show that?

Anyway, good luck. Hopefully the PHP tutorial will be some help. If you're really stuck, I've written comic archive stuff before with PHP. I may be able to drag out some old stuff that will be helpful to you.

Posted on 2005-09-03 17:55:24

mcgrue

PHP tutorials are a good way to go in the beginning. Making sure you have a firm grasp of how your forms interact with the users and how submissions interact with the server will go a long way to solving beginning issues.

After you've had some familiarity, basically the php.net documentation is your best friend. The talkback in there is very useful and quite often will have sample code for exactly what you're looking for with any given function.

Good luck!

Posted on 2005-09-03 18:26:45

Overkill

PHP may be confusing at first, I mean I know it was for me when I just started. I was used to having to declare every variable, not just set a variable and have it magically come into existance.


<?php

// This *could* be the query for you!
$latest_comic_result = mysql_query('SELECT * FROM `comic` WHERE `comic`.`date` < NOW() ORDER BY `comic`.`date` DESC LIMIT 1') or die(mysql_error());
$latest_comic = mysql_fetch_assoc($latest_comic_result);
echo '<h1>'.$latest_comic['name'].'</h1>';
echo '<img src=\''.$latest_comic['image_src'].'\' />';

?>

Posted on 2005-09-03 19:35:03 (last edited on 2005-09-04 10:36:15)


Displaying 1-8 of 8 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.