<!--
______   ______     ______     ______   __     ______
/\  == \ /\  __ \   /\  ___\   /\__  _\ /\ \   /\  ___\
\ \  _-/ \ \ \/\ \  \ \  __\   \/_/\ \/ \ \ \  \ \ \____
\ \_\    \ \_____\  \ \_____\    \ \_\  \ \_\  \ \_____\
 \/_/     \/_____/   \/_____/     \/_/   \/_/   \/_____/

   ______     ______     ______   ______   __     __     ______     ______     ______
  /\  ___\   /\  __ \   /\  ___\ /\__  _\ /\ \  _ \ \   /\  __ \   /\  == \   /\  ___\
  \ \___  \  \ \ \/\ \  \ \  __\ \/_/\ \/ \ \ \/ ".\ \  \ \  __ \  \ \  __<   \ \  __\
   \/\_____\  \ \_____\  \ \_\      \ \_\  \ \__/".~\_\  \ \_\ \_\  \ \_\ \_\  \ \_____\
   \/_____/   \/_____/   \/_/       \/_/   \/_/   \/_/   \/_/\/_/   \/_/ /_/   \/_____/

-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Poetic Software</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

    <script src="index.js"></script>
      <script src="/static/notify.js"></script>
      <link rel="stylesheet"
            href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.15.6/build/styles/default.min.css">
      <script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.15.6/build/highlight.min.js"></script>

      <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.css">
    <link rel="stylesheet" href="/static/css/style.css">
    {% block css %} {% endblock%}
  </head>
  <body>
<div id="buttons">
<label><input type="checkbox" name="getlost" value="getlost">Get Lost Mode!</label><br>
<label><input type="checkbox" name="links" value="links">Links</label>
</div>

    {% with messages = get_flashed_messages() %}
      {% if messages %}
        <ul class=flashes>
        {% for message in messages %}
          <li>{{ message }}</li>
        {% endfor %}
        </ul>
      {% endif %}
    {% endwith %}
    <main>
<a href={{ url_for('index') }} class="title" ><h1>Poetic Software</h1></a>
        <div class="container">

            {% block main %}{% endblock %}

        </div>
    </main>
<div id="index"><a href="index">index</a></div>
    {% block js %} {% endblock%}

<script>
function doSomething() {
  var myArray = ['Are you aware of the software you are using?','Do you feel your dependence?', 'I am not neutral', 'Do you have full control?'];
  $.notify(myArray[Math.floor(Math.random() * myArray.length)], "warn");

}

(function loop() {
    var rand = Math.round(Math.random() * (100000 - 500)) + 500;
    setTimeout(function() {

            doSomething();
            loop();
    }, rand);
}());

</script>

{% if "edit" not in request.path and "writer" not in request.path %}
<script>

function inIframe () {
  try {
      return window.self !== window.top;
  } catch (e) {
      return true;
  }
}

$('a').click(function(){
  return false;
})
$("a").on("mousedown", function(e){

if(inIframe()){
    var link = $(this).prop('href');

  window.parent.location = window.location.href+"?page="+link

}
    e.preventDefault();
    var iframe = document.createElement('iframe');
  var link = $(this).prop('href');
  console.log(link);
iframe.src = link;
iframe.id = "secondframe";
$('.post').css({'width': '50%'});
document.body.appendChild(iframe);
})

$("body").ready(function(){
 var url = new URL(window.location.href)
 if(url.searchParams.get("page"))
 {
 var page = url.searchParams.get("page");
 var iframe = document.createElement('iframe');
var link = page;
console.log(link);
iframe.src = link;
iframe.id = "secondframe"
$(".post").css("width", "50%");
document.body.appendChild(iframe);}

})

</script>
{% endif %}

  </body>
</html>
