Advertisement
AndreasFurster

Untitled

Jul 3rd, 2014
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function () {
  2.     updateContent();
  3.     $(window).hashchange(updateContent);
  4.  
  5.     function updateContent() {
  6.         if (location.hash == "") location.hash = "overzicht";
  7.  
  8.         CurrentPageSettings = [];
  9.         var webAppPage = false;
  10.         $('#panelWrapper .panel > .panel-heading').html("Pagina");
  11.         $('script#contentScript').remove();
  12.         document.title = ProjectName;
  13.         CheckLogin();
  14.  
  15.         hash = location.hash;
  16.         if (!hash) ApiActions.Error();
  17.  
  18.         else {
  19.             hash = hash.charAt(0) === '#' ? hash.slice(1) : hash;
  20.             if (hash.substr(0, 7) == "WebApp_") {
  21.                 hash = "WebApp/" + hash.substr(7);
  22.                 var $container = $("#webAppWrapper");
  23.                 $("#webAppWrapper").show();
  24.                 $("#panelWrapper").hide();
  25.                 webAppPage = true;
  26.             }
  27.             else {
  28.                 var $container = $(".container .panel-body");
  29.                 $("#webAppWrapper").hide();
  30.             }
  31.  
  32.             filePath = "content/" + hash + ".html";
  33.  
  34.             $.ajax({
  35.                 type: "GET",
  36.                 url: filePath,
  37.                 success: function (response) {
  38.                     $container.html(response);
  39.  
  40.                     var src = 'content/contentScripts/' + hash + '.js';
  41.                     loadContentScript(src);
  42.  
  43.                     if (!webAppPage) {
  44.                         $("#panelWrapper").show();
  45.                         var title = $("#top nav a[href=#" + hash + "]").attr('title');
  46.                         if (typeof title != typeof undefined)
  47.                             $('#panelWrapper .panel > .panel-heading').html(title);
  48.                     }
  49.                 },
  50.                 statusCode: {
  51.                     404: function () { WebAppActions.NotFound() }
  52.                 }
  53.             });
  54.         }
  55.     }
  56. });
  57.  
  58. function loadContentScript(src) {
  59.     $.ajax({
  60.         url: src,
  61.         error: function () {
  62.             console.warn("Geen contentscript!");
  63.         }
  64.     });
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement