<!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="{{ site_url }}/about/">
                        <img src="{{'/images/profile.svg' | prepend: site.baseurl}}" 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');
             });
         });

         (function() {
             var po = document.createElement('script');
             po.type = 'text/javascript';
             po.async = true;
             po.src = 'https://apis.google.com/js/client:plusone.js?onload=start';

             var s = document.getElementsByTagName('script')[0];
             s.parentNode.insertBefore(po, s);
         })();

         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

         ga('create', 'UA-43569023-1', 'polonkai.eu');
         ga('send', 'pageview');

         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 = '{{ site_url }}/about/';

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

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