Boss mode

Tuesday November 04, 2003 @ 12:31 AM (PST)

I was doing a bit of CSS tweaking on the site this evening, and my mind started wandering. For some reason, I started thinking about how all the best old DOS games had a “boss mode” that you could activate, usually by pressing the “b” key, that would instantly pause the game and throw up a spreadsheet screen or something similar for when your boss walked up while you were playing at work.

So, since I was already in tweaking mode, I whipped up a short JavaScript function that hides the title banner, the sidebar, and all images when you hold control and double-click anywhere in the page. Now you can get your daily wonkofix without making it terribly obvious to The Man that you’re not doing work. Utterly useless, but it was fun to write.

Comments

Printing an articel look better without the menu and stuph... could end up missing the pic's contained in any given article tho' :-)

You see, this is the sort of guy that makes open source developers give up on user support. He feels a sense of entitlement to the software he has put forth no effort to produce, he's too stupid to read the fucking manual (or in this case, the post), and he's an inarticulate moron with no social skills.

Actually, if your browser complies with the CSS media type descriptor standard, the sidebar and title banner should go away automatically when you print the page. Do a print preview in Mozilla and you'll see what I mean.

You'll also get a slightly slimmed down style if you visit the site on a handheld device that supports media descriptors.

Weee :-P
forgot bout' that... :-D
Sorry ;-)

wow, someone woke up on the wrong side of the bed. take a step back and go have a beer or something, you seem a little frustreated. maybe you lack in the skills down there if you know what i mean. i simply wanted to know how he did it. i had no plans to use it as i have no side, i was simply curious. perhaps you can shut the fuck up you ignorant cock sucking faggot?

Aw, what happened to the thoughtful, mature r4wb we all know and love?

Sometimes I can't help admiring your angelic patience, Wonko. I must confess that I would probably have re-routed all requests from this user to goatse by now.

sry i lost my cool with that MOTHER FUCKEr... wont happen again

Are you saying you'd redirect a poor innocent reader to goatse.cx? How utterly crass and immature of you! Shame!

Like this:

<script language="javascript" type="text/javascript">
function bossMode()
{
var images = document.getElementsByTagName("img");
var logo = document.getElementById("logo").style;
var sidebar = document.getElementById("sidebar").style;
var mainbar = document.getElementById("mainbar").style;

if (sidebar.display == 'none')
{
logo.display = '';
sidebar.display = '';
mainbar.left = '190px';
mainbar.marginTop = '55px';

for (i=0; i < images.length; i++)
images.item(i).style.display = '';
}
else
{
logo.display = 'none';
sidebar.display = 'none';
mainbar.left = '5px';
mainbar.marginTop = '0px';

for (i=0; i < images.length; i++)
images.item(i).style.display = 'none';
}
}
</script>

And then:

<body ondblclick="bossMode();">

If only the <pre> tag had worked...

thanks grey

and Mithrandir FUCK YOU !! for being an asshole.

Calm down, r4wb. There are limits to people's patience. Even Wonko's. Furthermore, if you wish to righteously criticize someone for being impolite, it doesn't help to be even more impolite. You would benefit from learning the art of simply ignoring insults instead of escalating them. The latter approach will get you nothing but a peptic ulcer.

From Webster's:

Peptic ulcer, Pathol.
An erosion of the mucous membrane of the lower esophagus, stomach, or duodenum, caused in part by the corrosive action of the gastric juice.

Clicking twice in rapid succession on a scroll bar (be it attached to a text box or the main page scrollbar) seems to register as a double-click event on Firebird. As does double-click text selection. There's nothing in the spec that says it shouldn't, as far as I can tell, so I don't think we can call this a browser bug.

Perhaps you could use a keystroke instead? I know the specs support accelerator keys, but I don't know if browsers implement them well. That, and I think you would then have to use an on-focus handler, since the accelerators don't raise their own events, IIRC.

Maybe just ctrl-dblclick?
Yeah, the specs are frustratingly vague about certain things.

I've modified the function to listen for control-double-click instead of just double-click, and it only pays attention to the left mouse button now as well. I attempted to use preventDefault() to keep the browser from highlighting text, activating links, etc. when the event fires, but either I misunderstood the spec or Mozilla's DOM implementation is broken, because it didn't have any effect. Oh well.

I also notice now that it triggers even on white space. Before when I double clicked on whitespace it just sat there (like under the left menu system).

Yeah. In order to capture the event object for the double click event (which I need in order to detect whether control is pressed and which mouse button was clicked), I had to set the event listener on document.ondblclick instead of in the ondblclick attribute of the <body> element.

ok

so enough of the small talk, whens the new image gallery coming out? looks so good

and hows the forum coming.

This guy reminds me of the slashdot troll. Where did that friendly troll go??

Hey, yeah! That guy was fun. And where's that other guy? The kid that looked about twelve years old but probably made more money than I did. What was his name again?

dave !!!!

wonko where is he image gallery... i cant wait to use it. how far done is it

Lucida won't be released publicly until there's a stable version of PHP with a working glob() function.

omg man come on just release a beta u cant do this to me

and you never answered my forum question

...fixing the text selection. When I try to select any article text, it for some reason selects huge blocks of text that my cursor is nowhere near.

Just use Mozilla instead of IE. :o)

Hey now, I think my IT dept. would disapprove of my installing lots of new software the third day on the job. I have the same problem, and I think I have to use IE here.

I've noticed this too, and I can assure you I've tried everything to fix it. It's just a bug in IE. Short of replacing my beautiful 100% CSS layout with a crufty old table, there's nothing I can do to fix it.

The problem stems from the fact that wonko.com uses CSS to position the sidebar block and the main block, which is what the W3C recommends these days (in the old days, I would've used a two-column table, but that sort of thing is condemned now). Mozilla, Opera, and other browsers deal with this properly, but IE gets confused about where the text really is, so it tries to select everything from the beginning instead of limiting your selection to a single block like it should.

If anyone can come up with a good, standards-compliant solution for this in CSS, I'll be very, very grateful. Until then, sorry. :/

Maybe you could put in a request? Point them to this list of unpatched IE security holes and say that you're worried about the potential damaging effects IE could have on the network.

I love it when a conversation about coding turns into a diagram of the human intestines. Interesting.

Like I know enough about network security to claim the network's insecure.

wonko ill paypal u $20 right now if u answer my forum question

I've run into this "tables are bad" vibe before. I don't really understand it. Is this a general statement, or just something that applies to larger page layout (navbars, titles, content)?

Really, I find tables to be incredibly useful. Short of display: inline-block (which Mozilla does not yet support), I know of no other reasonable way to do any sort of columnar layout.

Also, absolute positioning doesn't seem to provide for a way to place things at the bottom of a document. The 'bottom' style element is relative to the bottom of the viewport, or some user-specified height, but not the bottom of the tallest positioned element. I think we need a position: footer, so that we can have a box guarenteed to be below everything else.

If I'm wrong, please, enlighten me.
I didn't understand it for a long time either, and it's something that I'm even now somewhat divided about, but it has its basis in some pretty solid reasoning. Basically, what it comes down to is that tables are (and always have been) intended to be used for presenting tabular data. As you probably know, in the muddled past of HTML, there was really no deliniation between markup and layout. Tables were used for positioning instead of for presenting data, font tags abounded, cats and dogs slept together, etc.

Nowadays, as the standards are becoming increasingly solidifed, the W3C has made a very strong effort to separate content from presentation. As such, the font tag has been deprecated, cats and dogs have been relegated to their own separate beds, and there's been a massive attempt to shoehorn tables back into their proper role as a markup tool rather than a layout tool. The good thing about this is that it makes websites more accessible and allows designs to degrade gracefully for handheld devices, screen-readers, printers, and other things that could care less about presentation and would rather just have the raw content. The bad thing is that it's a lot harder to duplicate the layout possibilities of tables with pure CSS. It's mostly doable, but it takes some work. And of course, there's always that one non-compliant browser that's a huge pain in the ass about it.

The CSS footer problem is something I've battled with myself (and you'll notice I generally tend to shove the footer in at the bottom of the main content box in most of my designs), however a quick Google search turns up an elegant solution that actually appears to be backwards-compatible with older browsers.

I don't like the linked footer solution; it's an abuse of float, which is no better than using tables.

I suppose you could do:

header
/header
content
  left
  /left
  middle
  /middle
  right
  /right
/content
footer
/footer

But you'd end up using display: table-cell for left, middle and right, and then we're back to tables. Once we have a working display: inline-block, I'll be happy. Until then, I think I'll stick to tables.
Why would you need to use display: table-cell or display: inline-block? Column positioning is easy enough without those. Look at wonko.com's CSS for an example of simple absolute positioning with a fixed column. There are also plenty of other excellent examples online of multi-column CSS layouts, with both fixed and relative widths, with floats or without.

While I agree that floats should be avoided if possible, I don't agree that floats are as bad as using tables for layout. The W3C itself even recommends using floats (they use the technique they describe on their own website).

Wonko would NEVER do that! Just ask Sssnake...

One reason that using tables for positioning is bad is that the readers that blind people use get confused by them. They see the beginning of a table and therefore expect tabular data. So it screws up their ability to read a web page in a way that will make sense.

FWIW... :)

Wow

I'm surprised you even remember those "old DOS games". Of course I played "Dam Buster" in glorious ASCII graphics on our old Commodore PET, and remeber buying the original Zork and MS Flight Simulator I and Ultima I and.. Maybe I remeber you playing around with them a bit back then too...

You're forgetting that I lived in your old bedroom for several years. I remember finding lots of old Infocom game boxes, complete with manuals, hintbooks, and fun extras (the Hitchhiker's Guide to the Galaxy box had the coolest stuff inside). Sadly, most of them were lacking actual game disks.

Luckily, Mom had saved copies of some of them, so I still managed to spend countless hours playing the Zork games, lots of the old Sierra stuff, and plenty of shareware. I also got UncaTim to help me write (read: write for me) a 2D lightcycles-style game in QBasic which I tweaked endlessly and released as shareware (it's still listed here as "curves13.zip"!), and I spent years writing little text adventures with increasingly complex language parsers. Eventually I managed to trick someone (I can't remember who, now) into buying me a silly 3D engine complete with map creation tools and a small library of textures and sprites, and I spent another year or two building goofy Doom knockoffs.

Then the INTARWEB happened and I got sidetracked.

Copyright © 2002-2012 Ryan Grove. All rights reserved.
Powered by Thoth.