Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

How can I add a Konami code easter egg to my SMF site?

Aloittaja Sethv2, joulukuu 18, 2013, 11:41:11 IP

« edellinen - seuraava »

Sethv2

I found the following jquery code, but I'm not sure what to do with it;



    // Abracadabra
    var keys = [], konami = "38,38,40,40,37,39,37,39,66,65"; //represent all the keys to push down
    $(document).keydown(function(e){
    keys.push( e.keyCode );
    if ( keys.toString().indexOf( konami ) >= 0 ){
    $(document).unbind('keydown',arguments.callee);
     
    // DO WHATEVER YOUR WANT HERE
    }
    });



Would I add that to the index.php file?

kat

I gather you go it from here:

http://forrst.com/posts/Easy_way_to_put_Konami_Code_on_your_website_with-zaK

What's it supposed to do, exactly?

He says "You can try it on my blog here => leblogjeuvideo.be"

But, his site's such a mess that I can't see where this thing is...

Sethv2

I actually found this page with better instructions: http://doctorbin.tumblr.com/post/62134320493/add-the-iconic-konami-code-to-your-web-site. Step 2 is where I could use help in adding the script to SMF.

LainaaStep 2: Install the Script In Your Web Page

I won't go into the nitty gritty here (we can save that for the README.md on Github), but I will walk you through adding this script to your web page.  Adding the KonamiCode object to your web page is very easy.  All you have to do is create an instance of the object in your DOM as such:

var kCode = new KonamiCode({
    success: function(){window.location.href = "http://www.doctorbin.com/";}
});


Notice that the object takes one object as it's parameter.  There are three total parameters of the passed in object that you can set, but the most import is "success".  This parameter is the function that you would like to have invoked if the proper sequence of keys strokes is pressed.

kat

It'd depend where you want it. If you want it on every page, you'd need to add it to every theme's index.template.php file.

But, where you add it, in that file, depends where you want it to show and stuff.

Without knowing what the script's supposed to do, we're a bit in the dark, I'm afraid.

Sethv2

Ah sorry, I didn't answer that. What it does is monitors your keystrokes, and if you enter in the correct sequence, it will display a hidden element. For example, on this site http://vigetinterns13.tumblr.com/, if you type "mario" it changes the site's theme to a Mario Bro's one. It's something I wanted to add to my site for the holidays.

Arantor

Unless your site is a gaming site, most people won't even know about it and it means a lot of work for little benefit.

In any case the code you originally posted won't actually DO anything. It will detect if the Konami code gets entered but it won't actually do anything once done because nothing is defined there...
Holder of controversial views, all of which my own.


kat

That "mario" thing didn't do anything, for me. Maybe my browser, with all it's security add-ons, blocked it?

Sethv2

I manage a video game podcast site, so I think it'll be  fun for our visitors. I found the instruction linked in my second part were much more thorough, so I'm working with that now. I just needed to know where to add the script to get it topay on any page, and I think the index.template.php file should work.

Sethv2

I got it working. If you're interested to try it out, you check it out here: http://www.nogutsnogalaxy.net/forum/index.php. Enter in UP, UP, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT, B, A, A. I edited the current theme's index.template.php to make this work. I'm curious to know if there was a different file I could edit to make it appear on all pages.

kat

Put it in every theme's index.template?

Still doesn't do anything, for me, though. As I said, it's likely that my browser kills it. :)

Shambles

^--- same here, even on a virgin lappy. Nothing happens. Waste of effort  ::)

Sethv2

I've tested it in the three main browsers on three different computers and the images and sound work for me. Others have said they liked it, so I know it works on the index page. The only requirement I could find was that it requires your browser to support jQuery 2.x.

My goal at this point is to add the java script to each page. I've got it to work on the main page of the forum by editing index.template.php, but I would like like to see it on all of the sub-forum pages too. If I edit of the other theme's index.template, as assume that would get it to show up on the main page of the other theme's main page, but I only use the one theme.

Chen Zhen


Sethv2,

  Use a portal block/module instead of editing your files to have it appear on all pages or specifically where you want it to appear.

Note:
   The up to date jQuery library file can be put in your default theme scripts folder where you can use the script tag (src) in HTML to load it prior to executing your jQuery code. It sounds as though this is unnecessary for you though as another script must be loading a jQuery library file already or what you are using would not work at all.

My SMF Mods & Plug-Ins

WebDev

SMF support staff should be shaping a positive community experience & not provoking an argument or emotional reaction.

Sethv2

It turns out the the index.template.php file does affect each page, but that I need to who whole links to images and sounds rather than local links. Using portal blocks is a great idea though, I can activate and deactivate different ones throughout the year without risking my breaking anything. I'll mark this topic as solved, thanks!

Gargoyle


Colin

"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

Shambles

I find it quite astonishing that in this day and age of covert drive-by downloads and malware, internet users still allow any old scripts to run on sites they visit.


Arantor

Because in this day and age sites are increasingly powered by JavaScript. Too many sites will simply just fail to run without it these days.
Holder of controversial views, all of which my own.


Advertisement: