Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Tutorials and Tips

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 12-09-2014, 01:07 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 115,261
Kyttias is on a distinguished road
Default

Konami Code Install

1 - You need a link to jQuery. My Bootstrap theme comes with it. If you don't have it, hop into **root**/templates/**your theme**/template.tpl and before </body>, add this:

HTML Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
2 - Open up notepad, paste this in, and save it as jQuery_konami_code.js in the /js folder at the base of your Mysidia framework installation. So it will be **root**/js/jQuery_konami_code.js.
HTML Code:
;(function( $, window, document, undefined){
  var keys = []

  $.fn.konami_code = function( options ) { 
    var settings = $.extend(true, {}, $.fn.konami_code.defaults, options )
    var executionCount = 0
    
    $(this).keydown(function(e) {
      if(settings.maximum > executionCount){        
        keys.push( e.keyCode )
      }
      // console.log(keys.toString()) 
      if ( keys.toString().indexOf( settings[settings.activeCode] ) >= 0 ){
        // execute the specified callback function when the activeCode is detected
        // if I ever use event triggers I'll need to append the event argument object to the end of settings.arguments
        settings.callback.apply( settings.scope, settings.arguments )
        executionCount++;
        // empty the array containing the key sequence entered by the user
        keys = []
      } else if (keys.length >1000) {
        keys = [] //a crude way to keep the array from getting too big for no reason--a better check would be to clear after a long delay between keypresses (400-800ms)
      }
    })
    console.log('konami_code: power on')
    return this
  } //end $.fn.konami_code()  

  defaultCallback = function(){
    console.log("power up")
    alert("power up")      
  }  

  $.fn.konami_code.defaults = {
    konami: '38,38,40,40,37,39,37,39,66,65',       
    SFII: '40,82,38,76,89,66,88,65',
    callback: defaultCallback,
    activeCode: 'konami',
    maximum: 1000000000000000,
    scope: window
  }
})( jQuery , window, document)
3 - Now you will need to link to it. Go back to **root**/templates/**your theme**/template.tpl and after the jQuery link from step 1, and before the end of the </body>, add in this (the $home variable will automatically find the root folder and does need to be changed in any way):
HTML Code:
<script src="{$home}js/jQuery_konami_code.js"></script>
4 - After this we need to initialize, that is, prepare the code. So, right after what we just did, we'll add this:
HTML Code:
<script type="text/javascript">
    myCallback = function(){ alert('yay!') }
    $(document).konami_code({ callback: myCallback })
</script>
Right now, it's creating a javascript alert window that contains 'yay!'. See how it's working alert('yay!') in the script above?

This code is now operational on every page in your site. As a reminder, the Konami Code is up, up, down, down, left, right, left, right, b, a. For some further reading on how this code can be modified, check out the github repository for it.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #12  
Old 04-19-2015, 10:23 PM
AndromedaKerova's Avatar
AndromedaKerova AndromedaKerova is offline
ChibiFur Queen
 
Join Date: Nov 2014
Location: England
Posts: 83
Gender: Female
Credits: 4,374
AndromedaKerova is on a distinguished road
Default

I'm curious how I would alter the message. I want it to appear like this:


Congratulations!
You've discovered the Promo Code for the: Konamibunny

Code: PROMOCODEHERE

Enter it on the Promo Code page: http://chibifurs.elementfx.com/promo

It would be awesome if it played a defined sound as the box pops up too.
If possible, what format would the sound need to be in and how long?

Is it also possible to alter the code so only members can enter the code and not a guest or nonlogged user?
__________________
Failing at being normal since 1990.

Last edited by AndromedaKerova; 04-19-2015 at 10:45 PM.
Reply With Quote
  #13  
Old 04-20-2015, 02:07 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 115,261
Kyttias is on a distinguished road
Default

Promo codes can already only be entered by logged in users. A non-logged in member would be able to press the sequence of keys to display the alert, but they probably would not know to, nor is there any harm in letting them...?

To change the text in the alert prompt, simply follow the instructions already given and replace the word 'yay!'. Alert prompts cannot be styled in any way. If you want to pop up a div and have it styled with css instead, learn Javascript or jQuery. Or, if you're using Bootstrap already, perhaps install and learn to use Bootbox.js.

If you want to play a sound, here's the top result I got from Google.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #14  
Old 04-20-2015, 02:22 AM
AndromedaKerova's Avatar
AndromedaKerova AndromedaKerova is offline
ChibiFur Queen
 
Join Date: Nov 2014
Location: England
Posts: 83
Gender: Female
Credits: 4,374
AndromedaKerova is on a distinguished road
Default

I've managed to at least put each piece on its own line via MANY spaces so yay! I'll make an attempt with the sound later.
__________________
Failing at being normal since 1990.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A small question regarding adoption limits and promo codes..c: Pear Feedback and Suggestions 2 06-25-2014 11:06 PM
Hiding the adoption ID? Aasixx Questions and Supports 8 11-01-2012 11:26 AM
Promo Codes SilverDragonTears Questions and Supports 2 06-30-2012 02:22 PM
promo codes maximillion Questions and Supports 5 07-05-2011 07:28 PM
Admins Can View All Active Promo Codes HIddenPanda Mys v1.1.x Mods 0 07-15-2010 07:55 PM


All times are GMT -5. The time now is 12:19 PM.

Currently Active Users: 488 (0 members and 488 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636