2016-11-06 24 views
0

我曾經在Github的gh頁面上託管過這個網站。 Source Codegh-pages沒有部署在本地運行的網站

這不是加載它。這是網站:web-resume

搜索和查找後,我相信,錯誤就出在這行Typer.file="https://sudoankit.github.io/web-resume/themeat.txt";

Javascript這個代碼片段。

var Typer={ 
text: null, 
accessCountimer:null, 
index:0, // current cursor position 
speed:1, // speed of the Typer 
file:"", //file, must be set 
accessCount:0, //times alt is pressed for Access Granted 
deniedCount:0, //times caps is pressed for Access Denied 
init: function(){// inizialize Hacker Typer 
    accessCountimer=setInterval(function(){Typer.updLstChr();},500); // inizialize timer for blinking cursor 
    $.get(Typer.file,function(data){// get the text file 
     Typer.text=data;// save the textfile in Typer.text 
     Typer.text = Typer.text.slice(0, Typer.text.length-1); 
    }); 
}, 

content:function(){ 
    return $("#console").html();// get console content 
}, 

write:function(str){// append to console content 
    $("#console").append(str); 
    return false; 
}, 

makeAccess:function(){//create Access Granted popUp  FIXME: popup is on top of the page and doesn't show is the page is scrolled 
    Typer.hidepop(); // hide all popups 
    Typer.accessCount=0; //reset count 
    var ddiv=$("<div id='gran'>").html(""); // create new blank div and id "gran" 
    ddiv.addClass("accessGranted"); // add class to the div 
    ddiv.html("<h1>ACCESS GRANTED</h1>"); // set content of div 
    $(document.body).prepend(ddiv); // prepend div to body 
    return false; 
}, 
makeDenied:function(){//create Access Denied popUp  FIXME: popup is on top of the page and doesn't show is the page is scrolled 
    Typer.hidepop(); // hide all popups 
    Typer.deniedCount=0; //reset count 
    var ddiv=$("<div id='deni'>").html(""); // create new blank div and id "deni" 
    ddiv.addClass("accessDenied");// add class to the div 
    ddiv.html("<h1>ACCESS DENIED</h1>");// set content of div 
    $(document.body).prepend(ddiv);// prepend div to body 
    return false; 
}, 

hidepop:function(){// remove all existing popups 
    $("#deni").remove(); 
    $("#gran").remove(); 
}, 

addText:function(key){//Main function to add the code 
    if(key.keyCode==18){// key 18 = alt key 
     Typer.accessCount++; //increase counter 
     if(Typer.accessCount>=3){// if it's presed 3 times 
      Typer.makeAccess(); // make access popup 
     } 
    }else if(key.keyCode==20){// key 20 = caps lock 
     Typer.deniedCount++; // increase counter 
     if(Typer.deniedCount>=3){ // if it's pressed 3 times 
      Typer.makeDenied(); // make denied popup 
     } 
    }else if(key.keyCode==27){ // key 27 = esc key 
     Typer.hidepop(); // hide all popups 


    }else if(Typer.text){ // otherway if text is loaded 
     var cont=Typer.content(); // get the console content 
     if(cont.substring(cont.length-1,cont.length)=="|") // if the last char is the blinking cursor 
      $("#console").html($("#console").html().substring(0,cont.length-1)); // remove it before adding the text 
     if(key.keyCode!=8){ // if key is not backspace 
      Typer.index+=Typer.speed; // add to the index the speed 
     }else{ 
      if(Typer.index>0) // else if index is not less than 0 
       Typer.index-=Typer.speed;// remove speed for deleting text 
     } 
     var text=Typer.text.substring(0,Typer.index)// parse the text for stripping html enities 
     var rtn= new RegExp("\n", "g"); // newline regex 

     $("#console").html(text.replace(rtn,"<br/>"));// replace newline chars with br, tabs with 4 space and blanks with an html blank 
     window.scrollBy(0,100); // scroll to make sure bottom is always visible 
    } 
    if (key.preventDefault && key.keyCode != 122) { // prevent F11(fullscreen) from being blocked 
     key.preventDefault() 
    }; 
    if(key.keyCode != 122){ // otherway prevent keys default behavior 
     key.returnValue = false; 
    } 
}, 

updLstChr:function(){ // blinking cursor 
    var cont=this.content(); // get console 
    if(cont.substring(cont.length-1,cont.length)=="|") // if last  char is the cursor 
$("#console").html($("#console").html().substring(0,cont.length-1)); // remove it 
    else 
     this.write("|"); // else write it 
} 
} 
function replaceUrls(text) { 
var http = text.indexOf("http://"); 
var space = text.indexOf(".me ", http); 
if (space != -1) { 
    var url = text.slice(http, space-1); 
    return text.replace(url, "<a href=\"" + url + "\">" + url + "</a>"); 
} else { 
return text 
} 
} 
Typer.speed=3.14; 
Typer.file="https://sudoankit.github.io/web-resume/themeat.txt"; //error here? 
Typer.init(); 

var timer = setInterval("t();", 30); 
function t() { 
Typer.addText({"keyCode": 123748}); 
if (Typer.index > Typer.text.length) { 
    clearInterval(timer); 
    } 
} 

本網站在本地順利運行。 如果有鍛鍊,這真的會有幫助。

+0

固定後,它會正常加載上HTTPS

更改本地HTTP或遠程運行,無論'https'問題我也建議用html驗證器檢查頁面並修復任何問題:) –

回答

1

在瀏覽器開發工具控制檯中查找問題非常簡單。

網站上https協議,由於運行的混合內容的政策不是從http

加載jQuery的嘗試使用協議相對網址爲jQuery庫。然後

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 

還要注意的是1.4版本是非常非常老

+0

非常感謝!現在它完美無缺地工作。 – therewasaduck

+0

使用JavaScript處理瀏覽器控制檯。這是您排除故障的第一行 – charlietfl