|
@@ -28,7 +28,6 @@ US_Browser.CreatBrower=function (address,flag) {//创建窗口,url,是否为
|
|
|
ListBody.tag_favicon.style.display=(address&&address!==null)?"block":"none";
|
|
ListBody.tag_favicon.style.display=(address&&address!==null)?"block":"none";
|
|
|
ListBody.tag_favicon.onerror=function () {//不存在时显示的标签页图标
|
|
ListBody.tag_favicon.onerror=function () {//不存在时显示的标签页图标
|
|
|
this.src='public/img/tray/logo.png';
|
|
this.src='public/img/tray/logo.png';
|
|
|
- webview.tag.data.favicons=this.src;
|
|
|
|
|
};
|
|
};
|
|
|
ListBody.Webname=$$("p", {//标签页标题
|
|
ListBody.Webname=$$("p", {//标签页标题
|
|
|
"className": "Webname","innerHTML":address?"正在加载":"新建标签","draggable":"false"
|
|
"className": "Webname","innerHTML":address?"正在加载":"新建标签","draggable":"false"
|
|
@@ -38,8 +37,13 @@ US_Browser.CreatBrower=function (address,flag) {//创建窗口,url,是否为
|
|
|
}, ListBody);
|
|
}, ListBody);
|
|
|
let BrowerContainer=$$("div", {"className":"BrowerContainer"},$("body")[0]);//装载webview
|
|
let BrowerContainer=$$("div", {"className":"BrowerContainer"},$("body")[0]);//装载webview
|
|
|
let webview=$$("webview", {//创建webview
|
|
let webview=$$("webview", {//创建webview
|
|
|
- "allowpopups":"", "autosize":"on"
|
|
|
|
|
|
|
+ "allowpopups":"", "autosize":"on","preload":"./public/js/preload.js"
|
|
|
}, BrowerContainer);
|
|
}, BrowerContainer);
|
|
|
|
|
+ li.onmousedown=function(e){
|
|
|
|
|
+ if(e.button===1){
|
|
|
|
|
+ ListBody.tag_close.click(0)
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
webview.setAttribute('plugins','');
|
|
webview.setAttribute('plugins','');
|
|
|
webview.state=(address&&address!==null)?false:true;
|
|
webview.state=(address&&address!==null)?false:true;
|
|
|
webview.tag=li;//把li赋给webview标签
|
|
webview.tag=li;//把li赋给webview标签
|
|
@@ -92,6 +96,7 @@ US_Browser.CreatBrower=function (address,flag) {//创建窗口,url,是否为
|
|
|
US_Browser.LoadTips.innerHTML='正在请求:'+e.originalURL;
|
|
US_Browser.LoadTips.innerHTML='正在请求:'+e.originalURL;
|
|
|
});
|
|
});
|
|
|
webview.addEventListener('did-start-loading',function (e) {
|
|
webview.addEventListener('did-start-loading',function (e) {
|
|
|
|
|
+ ListBody.tag_favicon.src='';
|
|
|
US_Browser.IsLoading(this,true);
|
|
US_Browser.IsLoading(this,true);
|
|
|
});
|
|
});
|
|
|
webview.addEventListener('did-finish-load',function (e) {
|
|
webview.addEventListener('did-finish-load',function (e) {
|
|
@@ -118,12 +123,37 @@ US_Browser.CreatBrower=function (address,flag) {//创建窗口,url,是否为
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- webview.addEventListener('did-fail-load',function (e) {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ /*webview.addEventListener('did-fail-load',function (e) {
|
|
|
|
|
+ if(webview.state) {
|
|
|
|
|
+ let msg = e.errorDescription;
|
|
|
|
|
+ let old_url = US_Browser.Head[5].value;
|
|
|
|
|
+ US_Browser.SelecteWebview.src = 'error.html?msg=' + msg + '&url=' + this.src;
|
|
|
|
|
+ US_Browser.Head[5].value = old_url;
|
|
|
|
|
+ }
|
|
|
|
|
+ });*/
|
|
|
webview.fullSrceen=false;
|
|
webview.fullSrceen=false;
|
|
|
webview.FindKey=false;
|
|
webview.FindKey=false;
|
|
|
webview.onmousedown=function (e) {//webview鼠标事件
|
|
webview.onmousedown=function (e) {//webview鼠标事件
|
|
|
|
|
+ ipcRenderer.on('elm',function (e,msg) {
|
|
|
|
|
+ US_Browser.MouseData=msg;
|
|
|
|
|
+ US_Browser.US_OpenLinkInNew.style.display=US_Browser.US_OpenImgInNew.style.display='none';
|
|
|
|
|
+ if(US_Browser.MouseData) {
|
|
|
|
|
+ let tag = US_Browser.MouseData.tag;
|
|
|
|
|
+ if (tag === 'A') {
|
|
|
|
|
+ US_Browser.US_OpenLinkInNew.style.display = 'block';
|
|
|
|
|
+ US_Browser.US_OpenLinkInNew.onclick = function () {
|
|
|
|
|
+ US_Browser.CreatBrower(US_Browser.MouseData.href)
|
|
|
|
|
+ };
|
|
|
|
|
+ } else if (tag === 'IMG') {
|
|
|
|
|
+ US_Browser.US_OpenImgInNew.style.display = 'block';
|
|
|
|
|
+ US_Browser.US_OpenImgInNew.onclick = function () {
|
|
|
|
|
+ US_Browser.CreatBrower(US_Browser.MouseData.src)
|
|
|
|
|
+ };
|
|
|
|
|
+ } else {
|
|
|
|
|
+ US_Browser.US_OpenLinkInNew.style.display = US_Browser.US_OpenImgInNew.style.display = 'none';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
US_Browser.MouseMenu(US_Browser.MouseMenuMain,this,e);//右键显示创建应用菜单
|
|
US_Browser.MouseMenu(US_Browser.MouseMenuMain,this,e);//右键显示创建应用菜单
|
|
|
};
|
|
};
|
|
|
ListBody.tag_close.onclick=function () {//点击标题页关闭按钮
|
|
ListBody.tag_close.onclick=function () {//点击标题页关闭按钮
|
|
@@ -170,17 +200,17 @@ US_Browser.MouseMenu=function (menu_main,data,e,flag) {//右键菜单事件
|
|
|
}
|
|
}
|
|
|
document.onmouseup=function () {//鼠标事件后触发
|
|
document.onmouseup=function () {//鼠标事件后触发
|
|
|
if (e.button === 2||flag) {
|
|
if (e.button === 2||flag) {
|
|
|
|
|
+ menu_main.style.display = 'block';//显示菜单
|
|
|
if (!flag) {
|
|
if (!flag) {
|
|
|
menu_main.style.left = e.pageX + -parseFloat(createNode.getBoundingClientRect().left) + createNode.offsetLeft + 'px';//菜单定位横坐标
|
|
menu_main.style.left = e.pageX + -parseFloat(createNode.getBoundingClientRect().left) + createNode.offsetLeft + 'px';//菜单定位横坐标
|
|
|
menu_main.style.top = e.pageY + -parseFloat(createNode.getBoundingClientRect().top) + createNode.offsetTop + 'px';//菜单定位纵坐标
|
|
menu_main.style.top = e.pageY + -parseFloat(createNode.getBoundingClientRect().top) + createNode.offsetTop + 'px';//菜单定位纵坐标
|
|
|
- if (menu_main.getBoundingClientRect().left + menu_main.offsetHeight - createNode.getBoundingClientRect().left > createNode.offsetWidth) {//判断距左位置
|
|
|
|
|
- menu_main.style.left = menu_main.style.left.split('px')[0] - menu_main.offsetWidth + 'px';//距左多少
|
|
|
|
|
|
|
+ if (menu_main.getBoundingClientRect().left + menu_main.offsetWidth > createNode.offsetWidth) {//判断距左位置
|
|
|
|
|
+ menu_main.style.left = menu_main.style.left.split('px')[0] - menu_main.offsetWidth -30+ 'px';//距左多少
|
|
|
}
|
|
}
|
|
|
- if (menu_main.getBoundingClientRect().top + menu_main.offsetHeight - createNode.getBoundingClientRect().top > createNode.offsetHeight) {//判断距上位置
|
|
|
|
|
|
|
+ if (menu_main.getBoundingClientRect().top + menu_main.offsetHeight> createNode.offsetHeight) {//判断距上位置
|
|
|
menu_main.style.top = menu_main.style.top.split('px')[0] - menu_main.offsetHeight + 'px';//距上多少
|
|
menu_main.style.top = menu_main.style.top.split('px')[0] - menu_main.offsetHeight + 'px';//距上多少
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- menu_main.style.display = 'block';//显示菜单
|
|
|
|
|
document.onmouseup = null;//清空
|
|
document.onmouseup = null;//清空
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -335,17 +365,17 @@ US_Browser.IpcBind=function(){
|
|
|
if(message>0){
|
|
if(message>0){
|
|
|
US_Browser.ControlButton[1].className='icon-window-restore';
|
|
US_Browser.ControlButton[1].className='icon-window-restore';
|
|
|
US_Browser.NavContainer.style.padding = "5px 0 0";
|
|
US_Browser.NavContainer.style.padding = "5px 0 0";
|
|
|
- US_Browser.RightMenu.style.top='70px';
|
|
|
|
|
|
|
+ US_Browser.RightMenu.style.top='71px';
|
|
|
US_Browser.BrowerContainer.each(function (index,elm) {
|
|
US_Browser.BrowerContainer.each(function (index,elm) {
|
|
|
- elm.style.top='70px';
|
|
|
|
|
|
|
+ elm.style.top='71px';
|
|
|
elm.style.height='calc(100% - 70px)';
|
|
elm.style.height='calc(100% - 70px)';
|
|
|
})
|
|
})
|
|
|
}else {
|
|
}else {
|
|
|
US_Browser.ControlButton[1].className='icon-window-maximize';
|
|
US_Browser.ControlButton[1].className='icon-window-maximize';
|
|
|
US_Browser.NavContainer.style.padding = "15px 0 0";
|
|
US_Browser.NavContainer.style.padding = "15px 0 0";
|
|
|
- US_Browser.RightMenu.style.top='80px';
|
|
|
|
|
|
|
+ US_Browser.RightMenu.style.top='81px';
|
|
|
US_Browser.BrowerContainer.each(function (index,elm) {
|
|
US_Browser.BrowerContainer.each(function (index,elm) {
|
|
|
- elm.style.top='80px';
|
|
|
|
|
|
|
+ elm.style.top='81px';
|
|
|
elm.style.height='calc(100% - 80px)';
|
|
elm.style.height='calc(100% - 80px)';
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -356,6 +386,8 @@ US_Browser.Bind=function(){//绑定
|
|
|
US_Browser.BrowersTag=$(".BrowerList");//获取选项卡li
|
|
US_Browser.BrowersTag=$(".BrowerList");//获取选项卡li
|
|
|
US_Browser.BrowerContainer=$(".BrowerContainer");//获取webview
|
|
US_Browser.BrowerContainer=$(".BrowerContainer");//获取webview
|
|
|
US_Browser.SelecteWebview=US_Browser.BrowerContainer[0].children[0];
|
|
US_Browser.SelecteWebview=US_Browser.BrowerContainer[0].children[0];
|
|
|
|
|
+ US_Browser.US_OpenLinkInNew=$(".US_OpenLinkInNew")[0];
|
|
|
|
|
+ US_Browser.US_OpenImgInNew=$(".US_OpenImgInNew")[0];
|
|
|
for(let i=0;i<US_Browser.BrowersTag.length;i++){//对选项卡及webview进行操作
|
|
for(let i=0;i<US_Browser.BrowersTag.length;i++){//对选项卡及webview进行操作
|
|
|
(function (i) {
|
|
(function (i) {
|
|
|
US_Browser.BrowersTag[i].onclick=function () {
|
|
US_Browser.BrowersTag[i].onclick=function () {
|
|
@@ -397,6 +429,22 @@ US_Browser.Bind=function(){//绑定
|
|
|
})(i);
|
|
})(i);
|
|
|
}
|
|
}
|
|
|
};//标签页事件绑定
|
|
};//标签页事件绑定
|
|
|
|
|
+US_Browser.Find=function(){
|
|
|
|
|
+ if(US_Browser.FindContainer.offsetWidth) {
|
|
|
|
|
+ US_Browser.FindContainer.style.display = 'none';
|
|
|
|
|
+ US_Browser.Elm[0].blur();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ US_Browser.FindContainer.style.display = 'block';
|
|
|
|
|
+ US_Browser.Elm[0].value = '';
|
|
|
|
|
+ US_Browser.Elm[1].innerHTML = '0/0';
|
|
|
|
|
+ US_Browser.Elm[0].focus();
|
|
|
|
|
+ }
|
|
|
|
|
+};//开启关闭查找函数;
|
|
|
|
|
+US_Browser.SaveAs=function(){
|
|
|
|
|
+ US_Browser.SelecteWebview.getWebContents().savePage(US_Browser.Head[5].value,'HTMLComplete',function () {
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
|
|
+};//另存为喊
|
|
|
US_Browser.HeadBind=function(){
|
|
US_Browser.HeadBind=function(){
|
|
|
let http = /^(http)/;
|
|
let http = /^(http)/;
|
|
|
let https = /^(https)/;
|
|
let https = /^(https)/;
|
|
@@ -413,7 +461,7 @@ US_Browser.HeadBind=function(){
|
|
|
ipc.send('show-window');
|
|
ipc.send('show-window');
|
|
|
this.className='icon-window-restore';
|
|
this.className='icon-window-restore';
|
|
|
US_Browser.NavContainer.style.padding = "5px 0 0";
|
|
US_Browser.NavContainer.style.padding = "5px 0 0";
|
|
|
- US_Browser.RightMenu.style.top='70px';
|
|
|
|
|
|
|
+ US_Browser.RightMenu.style.top='71px';
|
|
|
US_Browser.BrowerContainer.each(function (index,elm) {
|
|
US_Browser.BrowerContainer.each(function (index,elm) {
|
|
|
elm.style.top='70px';
|
|
elm.style.top='70px';
|
|
|
elm.style.height='calc(100% - 70px)';
|
|
elm.style.height='calc(100% - 70px)';
|
|
@@ -422,9 +470,9 @@ US_Browser.HeadBind=function(){
|
|
|
ipc.send('orignal-window');
|
|
ipc.send('orignal-window');
|
|
|
this.className='icon-window-maximize';
|
|
this.className='icon-window-maximize';
|
|
|
US_Browser.NavContainer.style.padding = "15px 0 0";
|
|
US_Browser.NavContainer.style.padding = "15px 0 0";
|
|
|
- US_Browser.RightMenu.style.top='80px';
|
|
|
|
|
|
|
+ US_Browser.RightMenu.style.top='81px';
|
|
|
US_Browser.BrowerContainer.each(function (index,elm) {
|
|
US_Browser.BrowerContainer.each(function (index,elm) {
|
|
|
- elm.style.top='80px';
|
|
|
|
|
|
|
+ elm.style.top='81px';
|
|
|
elm.style.height='calc(100% - 80px)';
|
|
elm.style.height='calc(100% - 80px)';
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -465,6 +513,9 @@ US_Browser.HeadBind=function(){
|
|
|
this.blur();
|
|
this.blur();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+ US_Browser.Head[5].onfocus=function(e){
|
|
|
|
|
+ this.select();
|
|
|
|
|
+ };
|
|
|
US_Browser.Head[6].onmousedown=function (event) {//点击菜单
|
|
US_Browser.Head[6].onmousedown=function (event) {//点击菜单
|
|
|
US_Browser.MouseMenu(US_Browser.RightMenu,this,event,true);//右键显示创建应用菜单
|
|
US_Browser.MouseMenu(US_Browser.RightMenu,this,event,true);//右键显示创建应用菜单
|
|
|
};
|
|
};
|
|
@@ -498,25 +549,30 @@ US_Browser.HeadBind=function(){
|
|
|
evt = (evt) ? evt : window.event;
|
|
evt = (evt) ? evt : window.event;
|
|
|
if(evt.keyCode===112 ){
|
|
if(evt.keyCode===112 ){
|
|
|
US_Browser.about();
|
|
US_Browser.about();
|
|
|
- }else if(evt.keyCode===114||((evt.ctrlKey)&&(evt.keyCode===70))) {
|
|
|
|
|
- if(US_Browser.FindContainer.offsetWidth) {
|
|
|
|
|
- US_Browser.FindContainer.style.display = 'none';
|
|
|
|
|
- US_Browser.Elm[0].blur();
|
|
|
|
|
- }else {
|
|
|
|
|
- US_Browser.FindContainer.style.display = 'block';
|
|
|
|
|
- US_Browser.Elm[0].value = '';
|
|
|
|
|
- US_Browser.Elm[1].innerHTML = '0/0';
|
|
|
|
|
- US_Browser.Elm[0].focus();
|
|
|
|
|
- }
|
|
|
|
|
- }else if(evt.keyCode===116){
|
|
|
|
|
|
|
+ }else if(evt.keyCode===114||((evt.ctrlKey)&&(evt.keyCode===70))||((evt.ctrlKey)&&(evt.keyCode===71))) {//查找
|
|
|
|
|
+ US_Browser.Find();
|
|
|
|
|
+ }else if((evt.keyCode===116)||((evt.ctrlKey)&&(evt.keyCode===82))){//重新加载、刷新
|
|
|
if(US_Browser.Head[2].className==='icon-cw') {
|
|
if(US_Browser.Head[2].className==='icon-cw') {
|
|
|
US_Browser.reFresh()
|
|
US_Browser.reFresh()
|
|
|
}else{
|
|
}else{
|
|
|
US_Browser.Stop();
|
|
US_Browser.Stop();
|
|
|
US_Browser.Head[2].className='icon-cw';
|
|
US_Browser.Head[2].className='icon-cw';
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- else if(evt.keyCode===117){
|
|
|
|
|
|
|
+ }else if((evt.ctrlKey)&&(evt.keyCode===72)){//历史记录
|
|
|
|
|
+ US_Browser.ShowHistory();
|
|
|
|
|
+ }else if((evt.ctrlKey)&&(evt.keyCode===80)){//打印
|
|
|
|
|
+ US_Browser.Print();
|
|
|
|
|
+ }else if((evt.ctrlKey)&&(evt.keyCode===84)){//打开一个新标签页
|
|
|
|
|
+ US_Browser.CreatBrower(null);
|
|
|
|
|
+ }else if((evt.ctrlKey)&&(evt.keyCode===78)){//打开一个新的窗口
|
|
|
|
|
+ US_Browser.CreatBrowerWindow('');
|
|
|
|
|
+ }else if((evt.ctrlKey)&&(evt.keyCode===85)){//查看网页源代码
|
|
|
|
|
+ US_Browser.SourceCode();
|
|
|
|
|
+ }else if((evt.altKey)&&(evt.keyCode===39)){//前进
|
|
|
|
|
+ US_Browser.goForward();
|
|
|
|
|
+ }else if((evt.altKey)&&(evt.keyCode===37)){//后退
|
|
|
|
|
+ US_Browser.goBack();
|
|
|
|
|
+ }else if(evt.keyCode===117){//选择地址栏
|
|
|
if(document.activeElement.id===US_Browser.Head[5].id){
|
|
if(document.activeElement.id===US_Browser.Head[5].id){
|
|
|
US_Browser.Head[5].blur();
|
|
US_Browser.Head[5].blur();
|
|
|
}else{
|
|
}else{
|
|
@@ -546,10 +602,18 @@ US_Browser.HeadBind=function(){
|
|
|
}
|
|
}
|
|
|
}else if (evt.keyCode===123||((evt.ctrlKey)&&(evt.shiftKey)&&(evt.keyCode===73))) {//F12、ctrl+shift+i
|
|
}else if (evt.keyCode===123||((evt.ctrlKey)&&(evt.shiftKey)&&(evt.keyCode===73))) {//F12、ctrl+shift+i
|
|
|
US_Browser.DevTools();
|
|
US_Browser.DevTools();
|
|
|
- }else if((evt.ctrlKey)&&(evt.keyCode===87)){
|
|
|
|
|
- if($(".BrowerContainer").length>0&&US_Browser.SelecteWebview.tag.children[0].tag_favicon.offsetWidth) {
|
|
|
|
|
|
|
+ }else if((evt.ctrlKey)&&(evt.keyCode===87)) {//关闭标签页
|
|
|
|
|
+ if ($(".BrowerContainer").length > 0) {
|
|
|
US_Browser.SelecteWebview.tag.children[0].tag_close.click();
|
|
US_Browser.SelecteWebview.tag.children[0].tag_close.click();
|
|
|
}
|
|
}
|
|
|
|
|
+ }else if(((evt.ctrlKey)&&(evt.shiftKey)&&(evt.keyCode===81))){//退出浏览器
|
|
|
|
|
+ US_Browser.Exit();
|
|
|
|
|
+ }else if(((evt.ctrlKey)&&(evt.shiftKey)&&(evt.keyCode===46))){
|
|
|
|
|
+ US_Browser.ClearCache();
|
|
|
|
|
+ }else if(((evt.altKey)&&(evt.shiftKey)&&(evt.keyCode===73))){
|
|
|
|
|
+ US_Browser.Feedback();
|
|
|
|
|
+ }else if(((evt.altKey)&&(evt.shiftKey)&&(evt.keyCode===83))){
|
|
|
|
|
+ US_Browser.CampusInfo();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
US_Browser.Head[0].style.color = '#d3d3d3';
|
|
US_Browser.Head[0].style.color = '#d3d3d3';
|