<!DOCTYPE html>
<html>
    <head>
{% include head.html %}
    </head>
    <body>
{% include header.html %}
        <div class="container" id="main-container">

            {{content}}

{% if page.name != 'about.html' %}
            <div class="well well-sm small">
                <div class="pull-left" id="about-well-image">
                    <a href="{% link about.html %}">
                        <img src="{% link images/profile.svg %}" alt="">
                    </a>
                </div>
{%     include about.html %}
                <div class="clearfix"></div>
            </div>
{% endif %}
        </div>
        <script type="text/javascript">
         $(document).ready(function() {
             $('#tagcloud-button').click(function() {
                 $('#tag-cloud').toggle('slow');
             });
         });

         jQuery.extend_if_has = function(desc, source, array) {
             for (var i=array.length;i--;) {
                 if (typeof source[array[i]] != 'undefined') {
                     desc[array[i]] = source[array[i]];
                 }
             }
             return desc;
         };

         (function($) {
             $.fn.tilda = function(eval, options) {
                 if ($('body').data('tilda')) {
                     return $('body').data('tilda').terminal;
                 }
                 this.addClass('tilda');
                 options = options || {};
                 eval = eval || function(command, term) {
                     term.echo("you don't set eval for tilda");
                 };
                 var settings = {
                     prompt: 'guest@gergely.polonkai.eu> ',
                     name: 'tilda',
                     height: 400,
                     enabled: false,
                     greetings: 'Welcome to my Terminal.  Type `help\' to list the available commands.\n\nPowered by http://terminal.jcubic.pl',
                     keypress: function(e) {
                         if (e.which == 96) {
                             return false;
                         }
                     }
                 };
                 if (options) {
                     $.extend(settings, options);
                 }
                 this.append('<div class="td"></div>');
                 var self = this;
                 self.terminal = this.find('.td').terminal(eval, settings);
                 var focus = false;
                 $(document.documentElement).keypress(function(e) {
                     console.log(e);
                     if (e.which == 96) {
                         self.slideToggle('fast');
                         self.terminal.focus(focus = !focus);
                         self.terminal.attr({
                             scrollTop: self.terminal.attr("scrollHeight")
                         });
                     }
                 });
                 $('body').data('tilda', this);
                 this.hide();
                 return self;
             };
         })(jQuery);

         String.prototype.strip = function(char) {
             return this.replace(new RegExp("^\\s*"), '')
                        .replace(new RegExp("\\s*$"), '');
         }

         jQuery(document).ready(function($) {
             $('#tilda').tilda(function(command, terminal) {
                 command = command.strip();

                 switch (command) {
                     case 'help':
                         terminal.echo('about  - Go to the about page');
                         terminal.echo(' ');
                         terminal.echo('More commands will follow soon!');

                         break;
                     case 'about':
                         location = '{% link about.html %}';

                         break;
                     default:
                         terminal.echo(command + ': command not found');

                         break;
                 }
             });
         });
        </script>
        <div id="tilda"></div>
    </body>
</html>