twitter-bootstrapjqmodal

How can I get the Konami code to trigger a Bootstrap modal?


I'm trying to get the Konami code to (when upon completion) trigger a Bootstrap modal to popup.

This is the code i've tried so far but just can't get it working.

    <script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script>
<script type="text/javascript">
        konami = new Konami()
        konami.load;(function($){
        $("#myModal").modal('show');
        });
</script>

&

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <div align="center"><h1 class="modal-title" id="myModalLabel">Congrats</h1></div>
      </div>
      <div class="modal-body">
        <div align="center"><h3>You've just found an easter egg!</h3></div>
      </div>
      <div class="modal-footer">
<div align="center"><img src="Image.png" alt="....."></p></div>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

Solution

  • I looked in the documentation and the load function is only for opening URLs. You have to use the code member to set your code which you want to have executed:

    var konami = new Konami();
    konami.code = function() { 
        $("#myModal").modal('show'); 
    }
    konami.load();
    

    You can also use a smaller alternative:

    var konami = new Konami(function() { $("#myModal").modal('show'); });