Log in

No account? Create an account
21 August 2009 @ 05:36 pm
Computery questions  
I have created maybe a dozen or two webpages in my life, they've all been based on the same three or four templates, and they've all been done using only simple HTML.

So does anyone know if there's a way to take a static table and make the columns sortable? If there's a way with just HTML that would be great, but if not (as i rather expect,) what's the simplest way with the most commonly available scripting language? I'm guessing probably PHP or java something?

Also, a long time ago (like, the early 90s) i had an ancient PC utility that i would use to hack equally ancient PC games (SSI titles and other RPGs were frequent targets.) It was a TSR with an interface you could pop up in the middle of the game that would let you search the contents of the RAM for particular values, like your current number of hit points or gold for example. You could then go back to the game and wait until that value changed (get hit or heal yourself, get some gold, etc) and then go back to the TSR interface and do another search. The program would narrow down the list of hits until you'd figured out the memory location that property was being stored in, at which point you could edit that value, just like with a debugger.

jmpava says that he use something similar for hacking his own games, so it seems like they must have been fairly common, but neither one of use can remember the name of the program we used. Does anyone else happen to remember the name of such a program? Or a specific term for that class of programs in general? All the google terms i've tried so far have resulted in things like sites for buying RAM or game genie codes =P

I'm curious about whether or not such things still exist/still function on modern architectures.
Current Mood: geekygeeky
Steuardsteuard on August 22nd, 2009 02:27 am (UTC)
I am almost 100% certain that there's no way to dynamically sort data in either HTML or CSS. (I suppose there's a distant possibility that there might be something like that planned for HTML 5, but that's not really supported yet anyway.)

You could presumably implement something in Javascript that would do it, which would not require any special privileges on the server but would fail entirely for people who don't allow sites to run scripts by default. The preferred way to do such things these days involves manipulating the Document Object Model; sadly, I haven't really touched JavaScript since it matured to this point, so my skills there have atrophied significantly and I won't be much help. Java would also operate on the client side, as would Flash, but that seems like way too much overhead for what it sounds like you're trying to accomplish. Assuming the computational work involved isn't too big, I think JavaScript is almost certainly your best bet.

There's also an argument for doing the scripting on the server, but you'll need to make sure that your server supports whatever you choose (and that its implementation and your script are secure). The user will also have to deal with reloading the entire page every time they request an update, but they won't have to have scripting turned on. As for languages, I've never used PHP but it's supposed to be a pretty easy way to generate web pages on the fly. Perl has a very well-established CGI scripting module; that's what I've used when I've written scripted pages in the past. (It feels a bit clumsy to use, though, because rather than writing the web page yourself your providing instructions telling the program to write the web page.) There's presumably similar infrastructure for Python as well (I really ought to learn that one of these days), but I say that only because I've heard there's a Python module for everything.

Of course, the really cool kids these days combine them both (I think?) in their fancy Web 2.0 sites by using JavaScript interfaces like XMLHttpRequest as part of an AJAX application. That lets the server do all the data lookup and processing but avoids the need to reload a whole new web page (the changes can happen right in place on the existing page). This is presumably really, really overkill for what you want to do.
DonAithnendonaithnen on August 22nd, 2009 03:08 am (UTC)
I still have my webpage on Knuth, so definitely don't want to be depending on too much server-side stuff :) And simple is definitely what i want.

Steuardsteuard on August 22nd, 2009 02:30 pm (UTC)
I'm terribly embarrassed: I just happened to spot a your/you're mistake in my comment. I don't think I've done that in years (decades?). Sheesh.
Chaos Never Blinkssithjawa on August 22nd, 2009 02:31 am (UTC)
Please forgive me if this is too basic for you - I'm going off of the assumption "You know nothing about the web, but you know about programming."

Java is not a scripting language... Javascript is a scripting language. :)

Specifically it's a client-side scripting language which means your browser does the work, where PHP is server side which means your browser never knows anything beyond basic html is going on (except for the page extension being php, of course).

So the functional difference between a php(solely)-based table with sortable columns and a javascript(solely)-based table with sorted problems is as follows:

php: User clicks column header. This sends a command to the server to sort by that column header, and refreshes page for the user. Page retransmits, in full, with columns sorted as user desired. user does not have to have any special security settings, but server must have PHP enabled.
javascript: User clicks column header. User must have security enabled to allow page to rearrange its own text dynamically. Page does so. Server never knows, and requires no special configuration (beyond that required to serve the web page to the client). No page reload/network traffic is necessary.

You can probably see the pros and cons of each method from that.
DonAithnendonaithnen on August 22nd, 2009 03:01 am (UTC)
Yeah, i knew it wasn't plain java, that's why i said java something :)

Definitely sounds like java-whichever is the way to go if i'm not trying to make something cool and popular.

Thank you!
Chaos Never Blinkssithjawa on August 22nd, 2009 05:55 am (UTC)
No problem!

My actual programming experience with javascript is a little out of date... I suspect that whoever said you should look at AJAX was on the right track. Good luck!
Chaos Never Blinkssithjawa on August 22nd, 2009 02:32 am (UTC)
Oh, and in Microsoft land, Javascript is called JScript, and isn't really Javascript any more. Which means IE supports JScript and Firefox supports Javascript and while *most* scripts you could write will run on both, there are exceptions. The syntax is not identical.
Steuardsteuard on August 22nd, 2009 02:39 pm (UTC)
Right; I think the standard that was made to describe JavaScript is actually "ECMAScript" or something like that; JScript is just another implementation. I think that a simple sorting application like this should be pretty easy to make cross-browser compatible (don't, don't, don't do browser sniffing!). A website that I've really appreciated for such things is Quirksmode: it will tell you which JavaScript and CSS features are supported in various versions of each remotely major browser out there (or at least, in each remotely major rendering engine). As I said before, the "right" way to do this probably involves manipulating the DOM: simply moving each table row to a different place in the parsed HTML in the browser's memory. There will be some overhead involved in learning what you need, but I don't think it should be too bad.
shelleycatshelleycat on August 22nd, 2009 08:52 am (UTC)
Game hacking utility. Can't remember which one I used, though.