|
|
@@ -117,6 +117,7 @@ US_Browser.CreatBrower=function (address,flag) {//创建窗口,url,是否为
|
|
|
});
|
|
|
webview.addEventListener('load-commit',function (e) {
|
|
|
US_Browser.LoadTips.innerHTML=e.url;
|
|
|
+ US_Browser.IsLove(e.url)
|
|
|
});
|
|
|
webview.addEventListener('found-in-page', function(e) {
|
|
|
if (e.result.finalUpdate) {
|
|
|
@@ -130,6 +131,9 @@ US_Browser.CreatBrower=function (address,flag) {//创建窗口,url,是否为
|
|
|
}
|
|
|
});
|
|
|
webview.addEventListener('did-fail-load',function (e) {
|
|
|
+ if (e.errorCode === -3) {
|
|
|
+ return
|
|
|
+ }
|
|
|
US_Browser.SelecteWebview.src = './blank.html'
|
|
|
});
|
|
|
/*webview.addEventListener('did-fail-load',function (e) {
|
|
|
@@ -204,7 +208,7 @@ US_Browser.CreatBrower=function (address,flag) {//创建窗口,url,是否为
|
|
|
US_Browser.MouseMenu=function (menu_main,data,e,flag) {//右键菜单事件
|
|
|
let createNode=document.body;//获取第一和参数父元素
|
|
|
let MouseMenuMain=$('.MouseMenuMain');//获取右键菜单事件的ul元素
|
|
|
- $('.MouseMenuMainer')[0].style.display='none';
|
|
|
+ US_Browser.MouseMenuMainer.style.display='none';
|
|
|
for(let i=0;i<MouseMenuMain.length;i++){//隐藏右键菜单事件所有
|
|
|
MouseMenuMain[i].style.display='none';
|
|
|
}
|
|
|
@@ -405,7 +409,7 @@ US_Browser.Bind=function(){//绑定
|
|
|
US_Browser.BrowersTag[j].className='BrowerList';
|
|
|
US_Browser.BrowersTag[0].className='BrowerList Listindex';
|
|
|
US_Browser.BrowerContainer[j].style.opacity='0';
|
|
|
- US_Browser.BrowerContainer[j].style.zIndex='-1';
|
|
|
+ US_Browser.BrowerContainer[j].style.zIndex='1';
|
|
|
}
|
|
|
US_Browser.BrowersTag[i].className+=' BrowerActive';
|
|
|
US_Browser.BrowerContainer[i].style.opacity='1';
|
|
|
@@ -511,12 +515,15 @@ US_Browser.HeadBind=function(){
|
|
|
US_Browser.Head[5].onkeydown=function (e) {//获取搜索框值
|
|
|
if(e.keyCode===13){//keycode为13
|
|
|
let secondary = /([a-z0-9--]{1,200})\.([a-z]{2,10})(\.[a-z]{2,10})?/
|
|
|
+ let file = /^(file|ftp)/
|
|
|
if(this.value.length){//如果存在值
|
|
|
if(this.value.match(http) || this.value.match(https)){//判断是否存在http或https
|
|
|
US_Browser.SelecteWebview.src=this.value;//给webview的src传值
|
|
|
}else if(this.value.match(www)||this.value.match(m)){
|
|
|
US_Browser.SelecteWebview.src='http://'+this.value;//给webview的src传值
|
|
|
- }else if (secondary.test(this.value)) {
|
|
|
+ }else if (file.test(this.value)) {
|
|
|
+ US_Browser.SelecteWebview.src = this.value
|
|
|
+ } else if (secondary.test(this.value)) {
|
|
|
US_Browser.SelecteWebview.src = 'http://' + this.value
|
|
|
} else {
|
|
|
US_Browser.SelecteWebview.src='https://www.baidu.com/s?cl=3&wd='+this.value;//给webview的src传值
|
|
|
@@ -541,14 +548,65 @@ US_Browser.HeadBind=function(){
|
|
|
US_Browser.CreatBrower(null);
|
|
|
US_Browser.Head[5].focus();
|
|
|
US_Browser.RightMenu.style.display='none';
|
|
|
+ US_Browser.MouseMenuMainer.style.display='none';
|
|
|
};
|
|
|
US_Browser.RightMenubtn.onclick = function () {
|
|
|
- let MouseMenuMainer = $('.MouseMenuMainer')[0]
|
|
|
- if (MouseMenuMainer.style.display === "none") {
|
|
|
- MouseMenuMainer.style.display = "block"
|
|
|
+ if (window.localStorage.getItem('arr') === null) {
|
|
|
+ window.localStorage.setItem('arr', `[{"url": "${US_Browser.SelecteWebview.src}","icon": "${$('.BrowerActive')[0].children[0].children[0].src}", "title": "${US_Browser.SelecteWebview.getTitle()}"}]`)
|
|
|
+ } else if (window.localStorage.getItem('arr').indexOf(US_Browser.SelecteWebview.src) != -1) {
|
|
|
+ let b = JSON.parse(window.localStorage.getItem('arr'))
|
|
|
+ b.map((i, j) => {
|
|
|
+ if (i.url === US_Browser.SelecteWebview.src) {
|
|
|
+ let arr = JSON.parse(window.localStorage.getItem('arr'))
|
|
|
+ arr.splice(j, 1);
|
|
|
+ window.localStorage.setItem('arr', JSON.stringify(arr))
|
|
|
+ $('#LoveWebSize')[0].className = 'fa fa-heart-o'
|
|
|
+ $('#FavoritesUl')[0].removeChild($('#FavoritesUl')[0].children[j + 3])
|
|
|
+ }
|
|
|
+ })
|
|
|
return
|
|
|
+ } else {
|
|
|
+ let c = JSON.parse(window.localStorage.getItem('arr'))
|
|
|
+ c.push({
|
|
|
+ "url": US_Browser.SelecteWebview.src,
|
|
|
+ "icon": $('.BrowerActive')[0].children[0].children[0].src,
|
|
|
+ "title": US_Browser.SelecteWebview.getTitle()
|
|
|
+ })
|
|
|
+ window.localStorage.setItem('arr', JSON.stringify(c))
|
|
|
}
|
|
|
- MouseMenuMainer.style.display = "none"
|
|
|
+ $('#FavoritesUl')[0].innerHTML += `<li onclick="US_Browser.gotoLove('${US_Browser.SelecteWebview.src}')">
|
|
|
+ <img class="tag_favicon" draggable="true" style="display: block;" src=${$('.BrowerActive')[0].children[0].children[0].src}>
|
|
|
+ <p class="Webname" draggable="true">${US_Browser.SelecteWebview.getTitle()}</p>
|
|
|
+ </li>`
|
|
|
+ $('#LoveWebSize')[0].className = 'fa fa-heart'
|
|
|
+ }
|
|
|
+ US_Browser.Loveitem = () => {
|
|
|
+ if (window.localStorage.getItem('arr') === null){ return }
|
|
|
+ JSON.parse(window.localStorage.getItem('arr')).map((i, j) => {
|
|
|
+ $('#FavoritesUl')[0].innerHTML += `<li onclick="US_Browser.gotoLove('${i.url}')">
|
|
|
+ <img class="tag_favicon" draggable="true" style="display: block;" src=${i.icon}>
|
|
|
+ <p class="Webname" draggable="true">${i.title}</p>
|
|
|
+ </li>`
|
|
|
+ $('.MouseMenuMainer')[0].innerHTML += `<li onclick="US_Browser.gotoLove('${i.url}')">
|
|
|
+ <img class="tag_favicon" draggable="true" style="display: block;" src=${i.icon}>
|
|
|
+ <p class="Webname" draggable="true">${i.title}</p>
|
|
|
+ </li>`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ US_Browser.IsLove = (msg) => {
|
|
|
+ if (window.localStorage.getItem('arr') === null){ return }
|
|
|
+ if (window.localStorage.getItem('arr').indexOf(msg) != -1) {
|
|
|
+ $('#LoveWebSize')[0].className = 'fa fa-heart'
|
|
|
+ } else {
|
|
|
+ $('#LoveWebSize')[0].className = 'fa fa-heart-o'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ US_Browser.gotoLove = (msg) => {
|
|
|
+ US_Browser.SelecteWebview.src = msg
|
|
|
+ US_Browser.MouseMenuMainer.style.display = 'none'
|
|
|
+ }
|
|
|
+ US_Browser.FavoritesMore.onclick = () => {
|
|
|
+ US_Browser.MouseMenuMainer.style.display = 'block'
|
|
|
}
|
|
|
window.addEventListener('dragleave',function (e) {
|
|
|
e.preventDefault();
|
|
|
@@ -645,6 +703,7 @@ US_Browser.HeadBind=function(){
|
|
|
};//浏览器头部事件绑定
|
|
|
US_Browser.Init=function () {//初始化
|
|
|
US_Browser.isready = false
|
|
|
+ US_Browser.Love = window.localStorage.getItem('arr')
|
|
|
US_Browser.NavContainer=$(".bowerCreaterWindow")[0];//获取标签页ul
|
|
|
US_Browser.MouseMenuMain=$("#webviewBrowserMenu")[0];//获取网页右键菜单
|
|
|
US_Browser.RightMenu=$("#CampusInfoBrowserOnclickMenu")[0];//获取浏览器菜单
|
|
|
@@ -654,6 +713,8 @@ US_Browser.Init=function () {//初始化
|
|
|
US_Browser.Elm=$(".BrowerFind *");//查找菜单的子级
|
|
|
US_Browser.MenuBack= $(".US_Browers_Back")[0];
|
|
|
US_Browser.MenuGo=$(".US_Browers_go")[0];
|
|
|
+ US_Browser.FavoritesMore = $('.FavoritesMore')[0]
|
|
|
+ US_Browser.MouseMenuMainer = $('.MouseMenuMainer')[0]
|
|
|
US_Browser.Elm[0].onkeyup=function (e) {//查找的input
|
|
|
if(this.value.length&&e.keyCode!==8){//如果存在值
|
|
|
US_Browser.SelecteWebview.findInPage(this.value);
|
|
|
@@ -670,4 +731,5 @@ US_Browser.Init=function () {//初始化
|
|
|
};
|
|
|
US_Browser.HeadBind();
|
|
|
US_Browser.IpcBind();
|
|
|
+ US_Browser.Loveitem();
|
|
|
}();
|