Fixed the navigation tab
This commit is contained in:
parent
cd83ef4b7d
commit
e1b2752fb6
@ -463,7 +463,7 @@ async function load_cached_or_remote_ui_pack(channel: string, stats_update: (mes
|
|||||||
|
|
||||||
let remote_version_dropped = false;
|
let remote_version_dropped = false;
|
||||||
/* remote version gathering */
|
/* remote version gathering */
|
||||||
{
|
remote_loader: {
|
||||||
stats_update("Loading remote info", .25);
|
stats_update("Loading remote info", .25);
|
||||||
let remote_versions: local_ui_cache.UIPackInfo[];
|
let remote_versions: local_ui_cache.UIPackInfo[];
|
||||||
try {
|
try {
|
||||||
@ -472,6 +472,7 @@ async function load_cached_or_remote_ui_pack(channel: string, stats_update: (mes
|
|||||||
if(available_versions.length === 0)
|
if(available_versions.length === 0)
|
||||||
throw "failed to query remote UI packs: " + error;
|
throw "failed to query remote UI packs: " + error;
|
||||||
console.error("Failed to query remote UI packs: %o", error);
|
console.error("Failed to query remote UI packs: %o", error);
|
||||||
|
break remote_loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
stats_update("Parsing UI packs", .40);
|
stats_update("Parsing UI packs", .40);
|
||||||
@ -480,6 +481,7 @@ async function load_cached_or_remote_ui_pack(channel: string, stats_update: (mes
|
|||||||
throw "no UI pack available for channel " + channel;
|
throw "no UI pack available for channel " + channel;
|
||||||
|
|
||||||
let newest_local_version = available_versions.map(e => e.pack_info.timestamp).reduce((a, b) => Math.max(a, b), bundles_ui ? bundles_ui.download_timestamp : 0);
|
let newest_local_version = available_versions.map(e => e.pack_info.timestamp).reduce((a, b) => Math.max(a, b), bundles_ui ? bundles_ui.download_timestamp : 0);
|
||||||
|
console.log("Remote version %d, Local version %d", remote_version.timestamp, newest_local_version);
|
||||||
const required_version = parse_version(remote_version.min_client_version);
|
const required_version = parse_version(remote_version.min_client_version);
|
||||||
if(required_version.newer_than(client_version) && !is_debug) {
|
if(required_version.newer_than(client_version) && !is_debug) {
|
||||||
const result = await electron.dialog.showMessageBox({
|
const result = await electron.dialog.showMessageBox({
|
||||||
|
@ -21,7 +21,8 @@ import WebviewTag = Electron.WebviewTag;
|
|||||||
/**
|
/**
|
||||||
* DEPENDENCIES
|
* DEPENDENCIES
|
||||||
*/
|
*/
|
||||||
var jq = require('jquery');
|
//@ts-ignore
|
||||||
|
var $ = require('jquery');
|
||||||
var Color = require('color.js');
|
var Color = require('color.js');
|
||||||
var urlRegex = require('url-regex');
|
var urlRegex = require('url-regex');
|
||||||
const contextMenu = require('electron-context-menu')
|
const contextMenu = require('electron-context-menu')
|
||||||
@ -65,27 +66,27 @@ function Navigation(options) {
|
|||||||
* ADD ELEMENTS
|
* ADD ELEMENTS
|
||||||
*/
|
*/
|
||||||
if (options.showBackButton) {
|
if (options.showBackButton) {
|
||||||
jq('#nav-body-ctrls').append('<i id="nav-ctrls-back" class="nav-icons disabled" title="Go back">' + this.SVG_BACK + '</i>');
|
$('#nav-body-ctrls').append('<i id="nav-ctrls-back" class="nav-icons disabled" title="Go back">' + this.SVG_BACK + '</i>');
|
||||||
}
|
}
|
||||||
if (options.showForwardButton) {
|
if (options.showForwardButton) {
|
||||||
jq('#nav-body-ctrls').append('<i id="nav-ctrls-forward" class="nav-icons disabled" title="Go forward">' + this.SVG_FORWARD + '</i>');
|
$('#nav-body-ctrls').append('<i id="nav-ctrls-forward" class="nav-icons disabled" title="Go forward">' + this.SVG_FORWARD + '</i>');
|
||||||
}
|
}
|
||||||
if (options.showReloadButton) {
|
if (options.showReloadButton) {
|
||||||
jq('#nav-body-ctrls').append('<i id="nav-ctrls-reload" class="nav-icons disabled" title="Reload page">' + this.SVG_RELOAD + '</i>');
|
$('#nav-body-ctrls').append('<i id="nav-ctrls-reload" class="nav-icons disabled" title="Reload page">' + this.SVG_RELOAD + '</i>');
|
||||||
}
|
}
|
||||||
if (options.showUrlBar) {
|
if (options.showUrlBar) {
|
||||||
jq('#nav-body-ctrls').append('<input id="nav-ctrls-url" type="text" title="Enter an address or search term"/>')
|
$('#nav-body-ctrls').append('<input id="nav-ctrls-url" type="text" title="Enter an address or search term"/>')
|
||||||
}
|
}
|
||||||
if (options.showAddTabButton) {
|
if (options.showAddTabButton) {
|
||||||
jq('#nav-body-tabs').append('<i id="nav-tabs-add" class="nav-icons" title="Add new tab">' + this.SVG_ADD + '</i>');
|
$('#nav-body-tabs').append('<i id="nav-tabs-add" class="nav-icons" title="Add new tab">' + this.SVG_ADD + '</i>');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* ADD CORE STYLE
|
* ADD CORE STYLE
|
||||||
*/
|
*/
|
||||||
if (options.verticalTabs) {
|
if (options.verticalTabs) {
|
||||||
jq('head').append('<style id="nav-core-styles">#nav-body-ctrls,#nav-body-tabs,#nav-body-views,.nav-tabs-tab{display:flex;align-items:center;}#nav-body-tabs{overflow:auto;min-height:32px;flex-direction:column;}#nav-ctrls-url{box-sizing:border-box;}.nav-tabs-tab{min-width:60px;width:100%;min-height:20px;}.nav-icons{fill:#000;width:24px;height:24px}.nav-icons.disabled{pointer-events:none;opacity:.5}#nav-ctrls-url{flex:1;height:24px}.nav-views-view{flex:0 1;width:0;height:0}.nav-views-view.active{flex:1;width:100%;height:100%}.nav-tabs-favicon{align-content:flex-start}.nav-tabs-title{flex:1;cursor:default;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.nav-tabs-close{align-content:flex-end}@keyframes nav-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}</style>');
|
$('head').append('<style id="nav-core-styles">#nav-body-ctrls,#nav-body-tabs,#nav-body-views,.nav-tabs-tab{display:flex;align-items:center;}#nav-body-tabs{overflow:auto;min-height:32px;flex-direction:column;}#nav-ctrls-url{box-sizing:border-box;}.nav-tabs-tab{min-width:60px;width:100%;min-height:20px;}.nav-icons{fill:#000;width:24px;height:24px}.nav-icons.disabled{pointer-events:none;opacity:.5}#nav-ctrls-url{flex:1;height:24px}.nav-views-view{flex:0 1;width:0;height:0}.nav-views-view.active{flex:1;width:100%;height:100%}.nav-tabs-favicon{align-content:flex-start}.nav-tabs-title{flex:1;cursor:default;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.nav-tabs-close{align-content:flex-end}@keyframes nav-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}</style>');
|
||||||
} else {
|
} else {
|
||||||
jq('head').append('<style id="nav-core-styles">#nav-body-ctrls,#nav-body-tabs,#nav-body-views,.nav-tabs-tab{display:flex;align-items:center}#nav-body-tabs{overflow:auto;min-height:32px;}#nav-ctrls-url{box-sizing:border-box;}.nav-tabs-tab{min-width:60px;width:180px;min-height:20px;}.nav-icons{fill:#000;width:24px;height:24px}.nav-icons.disabled{pointer-events:none;opacity:.5}#nav-ctrls-url{flex:1;height:24px}.nav-views-view{flex:0 1;width:0;height:0}.nav-views-view.active{flex:1;width:100%;height:100%}.nav-tabs-favicon{align-content:flex-start}.nav-tabs-title{flex:1;cursor:default;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.nav-tabs-close{align-content:flex-end}@keyframes nav-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}</style>');
|
$('head').append('<style id="nav-core-styles">#nav-body-ctrls,#nav-body-tabs,#nav-body-views,.nav-tabs-tab{display:flex;align-items:center}#nav-body-tabs{overflow:auto;min-height:32px;}#nav-ctrls-url{box-sizing:border-box;}.nav-tabs-tab{min-width:60px;width:180px;min-height:20px;}.nav-icons{fill:#000;width:24px;height:24px}.nav-icons.disabled{pointer-events:none;opacity:.5}#nav-ctrls-url{flex:1;height:24px}.nav-views-view{flex:0 1;width:0;height:0}.nav-views-view.active{flex:1;width:100%;height:100%}.nav-tabs-favicon{align-content:flex-start}.nav-tabs-title{flex:1;cursor:default;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.nav-tabs-close{align-content:flex-end}@keyframes nav-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}</style>');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* EVENTS
|
* EVENTS
|
||||||
@ -93,15 +94,15 @@ function Navigation(options) {
|
|||||||
//
|
//
|
||||||
// switch active view and tab on click
|
// switch active view and tab on click
|
||||||
//
|
//
|
||||||
jq('#nav-body-tabs').on('click', '.nav-tabs-tab', function () {
|
$('#nav-body-tabs').on('click', '.nav-tabs-tab', function () {
|
||||||
jq('.nav-tabs-tab, .nav-views-view').removeClass('active');
|
$('.nav-tabs-tab, .nav-views-view').removeClass('active');
|
||||||
|
|
||||||
var sessionID = jq(this).data('session');
|
var sessionID = $(this).data('session');
|
||||||
jq('.nav-tabs-tab, .nav-views-view')
|
$('.nav-tabs-tab, .nav-views-view')
|
||||||
.filter('[data-session="' + sessionID + '"]')
|
.filter('[data-session="' + sessionID + '"]')
|
||||||
.addClass('active');
|
.addClass('active');
|
||||||
|
|
||||||
var session = jq('.nav-views-view[data-session="' + sessionID + '"]')[0];
|
var session = $('.nav-views-view[data-session="' + sessionID + '"]')[0];
|
||||||
(NAV.changeTabCallback || (() => {}))(session);
|
(NAV.changeTabCallback || (() => {}))(session);
|
||||||
NAV._updateUrl((session as WebviewTag).getURL());
|
NAV._updateUrl((session as WebviewTag).getURL());
|
||||||
NAV._updateCtrls();
|
NAV._updateCtrls();
|
||||||
@ -110,8 +111,8 @@ function Navigation(options) {
|
|||||||
// close tab and view
|
// close tab and view
|
||||||
//
|
//
|
||||||
}).on('click', '.nav-tabs-close', function() {
|
}).on('click', '.nav-tabs-close', function() {
|
||||||
var sessionID = jq(this).parent('.nav-tabs-tab').data('session');
|
var sessionID = $(this).parent('.nav-tabs-tab').data('session');
|
||||||
var session = jq('.nav-tabs-tab, .nav-views-view').filter('[data-session="' + sessionID + '"]');
|
var session = $('.nav-tabs-tab, .nav-views-view').filter('[data-session="' + sessionID + '"]');
|
||||||
|
|
||||||
if (session.hasClass('active')) {
|
if (session.hasClass('active')) {
|
||||||
if (session.next('.nav-tabs-tab').length) {
|
if (session.next('.nav-tabs-tab').length) {
|
||||||
@ -130,7 +131,7 @@ function Navigation(options) {
|
|||||||
//
|
//
|
||||||
// add a tab, default to google.com
|
// add a tab, default to google.com
|
||||||
//
|
//
|
||||||
jq('#nav-body-tabs').on('click', '#nav-tabs-add', function () {
|
$('#nav-body-tabs').on('click', '#nav-tabs-add', function () {
|
||||||
let params;
|
let params;
|
||||||
if(typeof options.newTabParams === "function"){
|
if(typeof options.newTabParams === "function"){
|
||||||
params = options.newTabParams();
|
params = options.newTabParams();
|
||||||
@ -148,20 +149,20 @@ function Navigation(options) {
|
|||||||
//
|
//
|
||||||
// go back
|
// go back
|
||||||
//
|
//
|
||||||
jq('#nav-body-ctrls').on('click', '#nav-ctrls-back', function () {
|
$('#nav-body-ctrls').on('click', '#nav-ctrls-back', function () {
|
||||||
NAV.back();
|
NAV.back();
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
// go forward
|
// go forward
|
||||||
//
|
//
|
||||||
jq('#nav-body-ctrls').on('click', '#nav-ctrls-forward', function () {
|
$('#nav-body-ctrls').on('click', '#nav-ctrls-forward', function () {
|
||||||
NAV.forward();
|
NAV.forward();
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
// reload page
|
// reload page
|
||||||
//
|
//
|
||||||
jq('#nav-body-ctrls').on('click', '#nav-ctrls-reload', function () {
|
$('#nav-body-ctrls').on('click', '#nav-ctrls-reload', function () {
|
||||||
if (jq(this).find('#nav-ready').length) {
|
if ($(this).find('#nav-ready').length) {
|
||||||
NAV.reload();
|
NAV.reload();
|
||||||
} else {
|
} else {
|
||||||
NAV.stop();
|
NAV.stop();
|
||||||
@ -170,10 +171,10 @@ function Navigation(options) {
|
|||||||
//
|
//
|
||||||
// highlight address input text on first select
|
// highlight address input text on first select
|
||||||
//
|
//
|
||||||
jq('#nav-ctrls-url').on('focus', function (e) {
|
$('#nav-ctrls-url').on('focus', function (e) {
|
||||||
jq(this)
|
$(this)
|
||||||
.one('mouseup', function () {
|
.one('mouseup', function () {
|
||||||
jq(this).select();
|
$(this).select();
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.select();
|
.select();
|
||||||
@ -181,7 +182,7 @@ function Navigation(options) {
|
|||||||
//
|
//
|
||||||
// load or search address on enter / shift+enter
|
// load or search address on enter / shift+enter
|
||||||
//
|
//
|
||||||
jq('#nav-ctrls-url').keyup(function (this: HTMLInputElement, e) {
|
$('#nav-ctrls-url').keyup(function (this: HTMLInputElement, e) {
|
||||||
if (e.keyCode == 13) {
|
if (e.keyCode == 13) {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
NAV.newTab(this.value, {
|
NAV.newTab(this.value, {
|
||||||
@ -189,7 +190,7 @@ function Navigation(options) {
|
|||||||
icon: NAV.TAB_ICON
|
icon: NAV.TAB_ICON
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (jq('.nav-tabs-tab').length) {
|
if ($('.nav-tabs-tab').length) {
|
||||||
NAV.changeTab(this.value);
|
NAV.changeTab(this.value);
|
||||||
} else {
|
} else {
|
||||||
NAV.newTab(this.value, {
|
NAV.newTab(this.value, {
|
||||||
@ -207,22 +208,22 @@ function Navigation(options) {
|
|||||||
// update controls like back, forward, etc...
|
// update controls like back, forward, etc...
|
||||||
//
|
//
|
||||||
this._updateCtrls = function () {
|
this._updateCtrls = function () {
|
||||||
let webview = jq('.nav-views-view.active')[0] as WebviewTag;
|
let webview = $('.nav-views-view.active')[0] as WebviewTag;
|
||||||
if (!webview) {
|
if (!webview) {
|
||||||
jq('#nav-ctrls-back').addClass('disabled');
|
$('#nav-ctrls-back').addClass('disabled');
|
||||||
jq('#nav-ctrls-forward').addClass('disabled');
|
$('#nav-ctrls-forward').addClass('disabled');
|
||||||
jq('#nav-ctrls-reload').html(this.SVG_RELOAD).addClass('disabled');
|
$('#nav-ctrls-reload').html(this.SVG_RELOAD).addClass('disabled');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (webview.canGoBack()) {
|
if (webview.canGoBack()) {
|
||||||
jq('#nav-ctrls-back').removeClass('disabled');
|
$('#nav-ctrls-back').removeClass('disabled');
|
||||||
} else {
|
} else {
|
||||||
jq('#nav-ctrls-back').addClass('disabled');
|
$('#nav-ctrls-back').addClass('disabled');
|
||||||
}
|
}
|
||||||
if (webview.canGoForward()) {
|
if (webview.canGoForward()) {
|
||||||
jq('#nav-ctrls-forward').removeClass('disabled');
|
$('#nav-ctrls-forward').removeClass('disabled');
|
||||||
} else {
|
} else {
|
||||||
jq('#nav-ctrls-forward').addClass('disabled');
|
$('#nav-ctrls-forward').addClass('disabled');
|
||||||
}
|
}
|
||||||
if (webview.isLoading()) {
|
if (webview.isLoading()) {
|
||||||
this._loading();
|
this._loading();
|
||||||
@ -230,9 +231,9 @@ function Navigation(options) {
|
|||||||
this._stopLoading();
|
this._stopLoading();
|
||||||
}
|
}
|
||||||
if (webview.getAttribute('data-readonly') == 'true') {
|
if (webview.getAttribute('data-readonly') == 'true') {
|
||||||
jq('#nav-ctrls-url').attr('readonly', 'readonly');
|
$('#nav-ctrls-url').attr('readonly', 'readonly');
|
||||||
} else {
|
} else {
|
||||||
jq('#nav-ctrls-url').removeAttr('readonly');
|
$('#nav-ctrls-url').removeAttr('readonly');
|
||||||
}
|
}
|
||||||
|
|
||||||
} //:_updateCtrls()
|
} //:_updateCtrls()
|
||||||
@ -243,11 +244,11 @@ function Navigation(options) {
|
|||||||
tab = tab || null;
|
tab = tab || null;
|
||||||
|
|
||||||
if (tab == null) {
|
if (tab == null) {
|
||||||
tab = jq('.nav-tabs-tab.active');
|
tab = $('.nav-tabs-tab.active');
|
||||||
}
|
}
|
||||||
|
|
||||||
tab.find('.nav-tabs-favicon').css('animation', 'nav-spin 2s linear infinite');
|
tab.find('.nav-tabs-favicon').css('animation', 'nav-spin 2s linear infinite');
|
||||||
jq('#nav-ctrls-reload').html(this.SVG_CLEAR);
|
$('#nav-ctrls-reload').html(this.SVG_CLEAR);
|
||||||
} //:_loading()
|
} //:_loading()
|
||||||
//
|
//
|
||||||
// stop loading animations
|
// stop loading animations
|
||||||
@ -256,11 +257,11 @@ function Navigation(options) {
|
|||||||
tab = tab || null;
|
tab = tab || null;
|
||||||
|
|
||||||
if (tab == null) {
|
if (tab == null) {
|
||||||
tab = jq('.nav-tabs-tab.active');
|
tab = $('.nav-tabs-tab.active');
|
||||||
}
|
}
|
||||||
|
|
||||||
tab.find('.nav-tabs-favicon').css('animation', '');
|
tab.find('.nav-tabs-favicon').css('animation', '');
|
||||||
jq('#nav-ctrls-reload').html(this.SVG_RELOAD);
|
$('#nav-ctrls-reload').html(this.SVG_RELOAD);
|
||||||
} //:_stopLoading()
|
} //:_stopLoading()
|
||||||
//
|
//
|
||||||
// auto add http protocol to url input or do a search
|
// auto add http protocol to url input or do a search
|
||||||
@ -292,8 +293,8 @@ function Navigation(options) {
|
|||||||
// add event listeners to current webview
|
// add event listeners to current webview
|
||||||
//
|
//
|
||||||
this._addEvents = function (sessionID, options) {
|
this._addEvents = function (sessionID, options) {
|
||||||
let currtab = jq('.nav-tabs-tab[data-session="' + sessionID + '"]');
|
let currtab = $('.nav-tabs-tab[data-session="' + sessionID + '"]');
|
||||||
let webview = jq('.nav-views-view[data-session="' + sessionID + '"]') as JQuery<WebviewTag>;
|
let webview = $('.nav-views-view[data-session="' + sessionID + '"]') as JQuery<WebviewTag>;
|
||||||
|
|
||||||
webview.on('dom-ready', function () {
|
webview.on('dom-ready', function () {
|
||||||
if (options.contextMenu) {
|
if (options.contextMenu) {
|
||||||
@ -323,26 +324,26 @@ function Navigation(options) {
|
|||||||
NAV._stopLoading(currtab);
|
NAV._stopLoading(currtab);
|
||||||
});
|
});
|
||||||
webview.on('enter-html-full-screen', function () {
|
webview.on('enter-html-full-screen', function () {
|
||||||
jq('.nav-views-view.active').siblings().not('script').hide();
|
$('.nav-views-view.active').siblings().not('script').hide();
|
||||||
jq('.nav-views-view.active').parents().not('script').siblings().hide();
|
$('.nav-views-view.active').parents().not('script').siblings().hide();
|
||||||
});
|
});
|
||||||
webview.on('leave-html-full-screen', function () {
|
webview.on('leave-html-full-screen', function () {
|
||||||
jq('.nav-views-view.active').siblings().not('script').show();
|
$('.nav-views-view.active').siblings().not('script').show();
|
||||||
jq('.nav-views-view.active').parents().siblings().not('script').show();
|
$('.nav-views-view.active').parents().siblings().not('script').show();
|
||||||
});
|
});
|
||||||
webview.on('load-commit', function () {
|
webview.on('load-commit', function () {
|
||||||
NAV._updateCtrls();
|
NAV._updateCtrls();
|
||||||
});
|
});
|
||||||
webview[0].addEventListener('did-navigate', (res) => {
|
webview[0].addEventListener('did-navigate', (res) => {
|
||||||
if(currtab[0] === jq('.nav-tabs-tab.active')[0])
|
if(currtab[0] === $('.nav-tabs-tab.active')[0])
|
||||||
NAV._updateUrl(res.url);
|
NAV._updateUrl(res.url);
|
||||||
});
|
});
|
||||||
webview[0].addEventListener('did-fail-load', (res) => {
|
webview[0].addEventListener('did-fail-load', (res) => {
|
||||||
if(currtab[0] === jq('.nav-tabs-tab.active')[0])
|
if(currtab[0] === $('.nav-tabs-tab.active')[0])
|
||||||
NAV._updateUrl(res.validatedURL);
|
NAV._updateUrl(res.validatedURL);
|
||||||
});
|
});
|
||||||
webview[0].addEventListener('did-navigate-in-page', (res) => {
|
webview[0].addEventListener('did-navigate-in-page', (res) => {
|
||||||
if(currtab[0] === jq('.nav-tabs-tab.active')[0])
|
if(currtab[0] === $('.nav-tabs-tab.active')[0])
|
||||||
NAV._updateUrl(res.url);
|
NAV._updateUrl(res.url);
|
||||||
});
|
});
|
||||||
webview[0].addEventListener("new-window", (res) => {
|
webview[0].addEventListener("new-window", (res) => {
|
||||||
@ -353,10 +354,10 @@ function Navigation(options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
webview[0].addEventListener('page-favicon-updated', (res) => {
|
webview[0].addEventListener('page-favicon-updated', (res) => {
|
||||||
currtab.find('.nav-tabs-favicon').replaceWith(jq('<img class="nav-tabs-favicon nav-icons" src="' + res.favicons[0] + '"/>'));
|
currtab.find('.nav-tabs-favicon').replaceWith($('<img class="nav-tabs-favicon nav-icons" src="' + res.favicons[0] + '"/>'));
|
||||||
});
|
});
|
||||||
webview[0].addEventListener('did-fail-load', (res) => {
|
webview[0].addEventListener('did-fail-load', (res) => {
|
||||||
if (res.validatedURL == jq('#nav-ctrls-url').val() && res.errorCode != -3) {
|
if (res.validatedURL == $('#nav-ctrls-url').val() && res.errorCode != -3) {
|
||||||
this.executeJavaScript('document.body.innerHTML=' +
|
this.executeJavaScript('document.body.innerHTML=' +
|
||||||
'<div style="background-color:whitesmoke;padding:40px;margin:20px;font-family:consolas;">' +
|
'<div style="background-color:whitesmoke;padding:40px;margin:20px;font-family:consolas;">' +
|
||||||
'<h2 align=center>Oops, this page failed to load correctly.</h2>' +
|
'<h2 align=center>Oops, this page failed to load correctly.</h2>' +
|
||||||
@ -377,10 +378,10 @@ function Navigation(options) {
|
|||||||
//
|
//
|
||||||
this._updateUrl = function (url) {
|
this._updateUrl = function (url) {
|
||||||
url = url || null;
|
url = url || null;
|
||||||
let urlInput = jq('#nav-ctrls-url');
|
let urlInput = $('#nav-ctrls-url');
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
if (jq('.nav-views-view').length) {
|
if ($('.nav-views-view').length) {
|
||||||
url = (jq('.nav-views-view.active')[0] as WebviewTag).getURL();
|
url = ($('.nav-views-view.active')[0] as WebviewTag).getURL();
|
||||||
} else {
|
} else {
|
||||||
url = '';
|
url = '';
|
||||||
}
|
}
|
||||||
@ -438,12 +439,12 @@ Navigation.prototype.newTab = function (url, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate options.id
|
// validate options.id
|
||||||
jq('.nav-tabs-tab, .nav-views-view').removeClass('active');
|
$('.nav-tabs-tab, .nav-views-view').removeClass('active');
|
||||||
if (jq('#' + options.id).length) {
|
if ($('#' + options.id).length) {
|
||||||
console.log('ERROR[electron-navigation][func "newTab();"]: The ID "' + options.id + '" already exists. Please use another one.');
|
console.log('ERROR[electron-navigation][func "newTab();"]: The ID "' + options.id + '" already exists. Please use another one.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!(/^[A-Za-z]+[\w\-\:\.]*jq/.test(options.id))) {
|
if (!(/^[A-Za-z]+[\w\-\:\.]*$/.test(options.id))) {
|
||||||
console.log('ERROR[electron-navigation][func "newTab();"]: The ID "' + options.id + '" is not valid. Please use another one.');
|
console.log('ERROR[electron-navigation][func "newTab();"]: The ID "' + options.id + '" is not valid. Please use another one.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -470,29 +471,29 @@ Navigation.prototype.newTab = function (url, options) {
|
|||||||
// finish tab
|
// finish tab
|
||||||
tab += '</span>';
|
tab += '</span>';
|
||||||
// add tab to correct position
|
// add tab to correct position
|
||||||
if (jq('#nav-body-tabs').has('#nav-tabs-add').length) {
|
if ($('#nav-body-tabs').has('#nav-tabs-add').length) {
|
||||||
jq('#nav-tabs-add').before(tab);
|
$('#nav-tabs-add').before(tab);
|
||||||
} else {
|
} else {
|
||||||
jq('#nav-body-tabs').append(tab);
|
$('#nav-body-tabs').append(tab);
|
||||||
}
|
}
|
||||||
// add webview
|
// add webview
|
||||||
let composedWebviewTag = `<webview class="nav-views-view active" data-session="jq{this.SESSION_ID}" src="jq{this._purifyUrl(url)}"`;
|
let composedWebviewTag = `<webview class="nav-views-view active" data-session="${this.SESSION_ID}" src="${this._purifyUrl(url)}"`;
|
||||||
|
|
||||||
composedWebviewTag += ` data-readonly="jq{((options.readonlyUrl) ? 'true': 'false')}"`;
|
composedWebviewTag += ` data-readonly="${((options.readonlyUrl) ? 'true': 'false')}"`;
|
||||||
if (options.id) {
|
if (options.id) {
|
||||||
composedWebviewTag += ` id=jq{options.id}`;
|
composedWebviewTag += ` id=${options.id}`;
|
||||||
}
|
}
|
||||||
if (options.node) {
|
if (options.node) {
|
||||||
composedWebviewTag += " nodeintegration";
|
composedWebviewTag += " nodeintegration";
|
||||||
}
|
}
|
||||||
if (options.webviewAttributes) {
|
if (options.webviewAttributes) {
|
||||||
Object.keys(options.webviewAttributes).forEach((key) => {
|
Object.keys(options.webviewAttributes).forEach((key) => {
|
||||||
composedWebviewTag += ` jq{key}="jq{options.webviewAttributes[key]}"`;
|
composedWebviewTag += ` ${key}="${options.webviewAttributes[key]}"`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
jq('#nav-body-views').append(`jq{composedWebviewTag}></webview>`);
|
$('#nav-body-views').append(`${composedWebviewTag}></webview>`);
|
||||||
// enable reload button
|
// enable reload button
|
||||||
jq('#nav-ctrls-reload').removeClass('disabled');
|
$('#nav-ctrls-reload').removeClass('disabled');
|
||||||
|
|
||||||
// update url and add events
|
// update url and add events
|
||||||
this._updateUrl(this._purifyUrl(url));
|
this._updateUrl(this._purifyUrl(url));
|
||||||
@ -510,10 +511,10 @@ Navigation.prototype.newTab = function (url, options) {
|
|||||||
Navigation.prototype.changeTab = function (url, id) {
|
Navigation.prototype.changeTab = function (url, id) {
|
||||||
id = id || null;
|
id = id || null;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
jq('.nav-views-view.active').attr('src', this._purifyUrl(url));
|
$('.nav-views-view.active').attr('src', this._purifyUrl(url));
|
||||||
} else {
|
} else {
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
jq('#' + id).attr('src', this._purifyUrl(url));
|
$('#' + id).attr('src', this._purifyUrl(url));
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "changeTab();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "changeTab();"]: Cannot find the ID "' + id + '"');
|
||||||
}
|
}
|
||||||
@ -527,11 +528,11 @@ Navigation.prototype.closeTab = function (id) {
|
|||||||
|
|
||||||
var session;
|
var session;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
session = jq('.nav-tabs-tab.active, .nav-views-view.active');
|
session = $('.nav-tabs-tab.active, .nav-views-view.active');
|
||||||
} else {
|
} else {
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
var sessionID = jq('#' + id).data('session');
|
var sessionID = $('#' + id).data('session');
|
||||||
session = jq('.nav-tabs-tab, .nav-views-view').filter('[data-session="' + sessionID + '"]');
|
session = $('.nav-tabs-tab, .nav-views-view').filter('[data-session="' + sessionID + '"]');
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "closeTab();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "closeTab();"]: Cannot find the ID "' + id + '"');
|
||||||
return false;
|
return false;
|
||||||
@ -555,10 +556,10 @@ Navigation.prototype.closeTab = function (id) {
|
|||||||
Navigation.prototype.back = function (id) {
|
Navigation.prototype.back = function (id) {
|
||||||
id = id || null;
|
id = id || null;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
(jq('.nav-views-view.active')[0] as WebviewTag).goBack();
|
($('.nav-views-view.active')[0] as WebviewTag).goBack();
|
||||||
} else {
|
} else {
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
(jq('#' + id)[0] as WebviewTag).goBack();
|
($('#' + id)[0] as WebviewTag).goBack();
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "back();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "back();"]: Cannot find the ID "' + id + '"');
|
||||||
}
|
}
|
||||||
@ -570,10 +571,10 @@ Navigation.prototype.back = function (id) {
|
|||||||
Navigation.prototype.forward = function (id) {
|
Navigation.prototype.forward = function (id) {
|
||||||
id = id || null;
|
id = id || null;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
(jq('.nav-views-view.active')[0] as WebviewTag).goForward();
|
($('.nav-views-view.active')[0] as WebviewTag).goForward();
|
||||||
} else {
|
} else {
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
(jq('#' + id)[0] as WebviewTag).goForward();
|
($('#' + id)[0] as WebviewTag).goForward();
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "forward();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "forward();"]: Cannot find the ID "' + id + '"');
|
||||||
}
|
}
|
||||||
@ -585,10 +586,10 @@ Navigation.prototype.forward = function (id) {
|
|||||||
Navigation.prototype.reload = function (id) {
|
Navigation.prototype.reload = function (id) {
|
||||||
id = id || null;
|
id = id || null;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
(jq('.nav-views-view.active')[0] as WebviewTag).reload();
|
($('.nav-views-view.active')[0] as WebviewTag).reload();
|
||||||
} else {
|
} else {
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
(jq('#' + id)[0] as WebviewTag).reload();
|
($('#' + id)[0] as WebviewTag).reload();
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "reload();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "reload();"]: Cannot find the ID "' + id + '"');
|
||||||
}
|
}
|
||||||
@ -600,10 +601,10 @@ Navigation.prototype.reload = function (id) {
|
|||||||
Navigation.prototype.stop = function (id) {
|
Navigation.prototype.stop = function (id) {
|
||||||
id = id || null;
|
id = id || null;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
(jq('.nav-views-view.active')[0] as WebviewTag).stop();
|
($('.nav-views-view.active')[0] as WebviewTag).stop();
|
||||||
} else {
|
} else {
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
(jq('#' + id)[0] as WebviewTag).stop();
|
($('#' + id)[0] as WebviewTag).stop();
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "stop();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "stop();"]: Cannot find the ID "' + id + '"');
|
||||||
}
|
}
|
||||||
@ -616,7 +617,7 @@ Navigation.prototype.listen = function (id, callback) {
|
|||||||
let webview = null;
|
let webview = null;
|
||||||
|
|
||||||
//check id
|
//check id
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
webview = document.getElementById(id);
|
webview = document.getElementById(id);
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "listen();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "listen();"]: Cannot find the ID "' + id + '"');
|
||||||
@ -644,7 +645,7 @@ Navigation.prototype.send = function (id, channel, args) {
|
|||||||
let webview = null;
|
let webview = null;
|
||||||
|
|
||||||
// check id
|
// check id
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
webview = document.getElementById(id);
|
webview = document.getElementById(id);
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "send();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "send();"]: Cannot find the ID "' + id + '"');
|
||||||
@ -670,9 +671,9 @@ Navigation.prototype.openDevTools = function (id) {
|
|||||||
|
|
||||||
// check id
|
// check id
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
webview = jq('.nav-views-view.active')[0];
|
webview = $('.nav-views-view.active')[0];
|
||||||
} else {
|
} else {
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
webview = document.getElementById(id);
|
webview = document.getElementById(id);
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "openDevTools();"]: Cannot find the ID "' + id + '"');
|
console.log('ERROR[electron-navigation][func "openDevTools();"]: Cannot find the ID "' + id + '"');
|
||||||
@ -699,9 +700,9 @@ Navigation.prototype.printTab = function (id, opts) {
|
|||||||
|
|
||||||
// check id
|
// check id
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
webview = jq('.nav-views-view.active')[0]
|
webview = $('.nav-views-view.active')[0]
|
||||||
} else {
|
} else {
|
||||||
if (jq('#' + id).length) {
|
if ($('#' + id).length) {
|
||||||
webview = document.getElementById(id)
|
webview = document.getElementById(id)
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[electron-navigation][func "printTab();"]: Cannot find the ID "' + id + '"')
|
console.log('ERROR[electron-navigation][func "printTab();"]: Cannot find the ID "' + id + '"')
|
||||||
@ -718,11 +719,11 @@ Navigation.prototype.printTab = function (id, opts) {
|
|||||||
// toggle next available tab
|
// toggle next available tab
|
||||||
//
|
//
|
||||||
Navigation.prototype.nextTab = function () {
|
Navigation.prototype.nextTab = function () {
|
||||||
var tabs = jq('.nav-tabs-tab').toArray();
|
var tabs = $('.nav-tabs-tab').toArray();
|
||||||
var activeTabIndex = tabs.indexOf(jq('.nav-tabs-tab.active')[0]);
|
var activeTabIndex = tabs.indexOf($('.nav-tabs-tab.active')[0]);
|
||||||
var nexti = activeTabIndex + 1;
|
var nexti = activeTabIndex + 1;
|
||||||
if (nexti > tabs.length - 1) nexti = 0;
|
if (nexti > tabs.length - 1) nexti = 0;
|
||||||
jq(jq('.nav-tabs-tab')[nexti]).trigger('click');
|
$($('.nav-tabs-tab')[nexti]).trigger('click');
|
||||||
return false
|
return false
|
||||||
} //:nextTab()
|
} //:nextTab()
|
||||||
//:prevTab()
|
//:prevTab()
|
||||||
@ -730,33 +731,33 @@ Navigation.prototype.nextTab = function () {
|
|||||||
// toggle previous available tab
|
// toggle previous available tab
|
||||||
//
|
//
|
||||||
Navigation.prototype.prevTab = function () {
|
Navigation.prototype.prevTab = function () {
|
||||||
var tabs = jq('.nav-tabs-tab').toArray();
|
var tabs = $('.nav-tabs-tab').toArray();
|
||||||
var activeTabIndex = tabs.indexOf(jq('.nav-tabs-tab.active')[0]);
|
var activeTabIndex = tabs.indexOf($('.nav-tabs-tab.active')[0]);
|
||||||
var nexti = activeTabIndex - 1;
|
var nexti = activeTabIndex - 1;
|
||||||
if (nexti < 0) nexti = tabs.length - 1;
|
if (nexti < 0) nexti = tabs.length - 1;
|
||||||
jq(jq('.nav-tabs-tab')[nexti]).trigger('click');
|
$($('.nav-tabs-tab')[nexti]).trigger('click');
|
||||||
return false
|
return false
|
||||||
} //:prevTab()
|
} //:prevTab()
|
||||||
// go to a tab by index or keyword
|
// go to a tab by index or keyword
|
||||||
//
|
//
|
||||||
Navigation.prototype.goToTab = function (index) {
|
Navigation.prototype.goToTab = function (index) {
|
||||||
let jqactiveTabAndView = jq('#nav-body-tabs .nav-tabs-tab.active, #nav-body-views .nav-views-view.active');
|
let $activeTabAndView = $('#nav-body-tabs .nav-tabs-tab.active, #nav-body-views .nav-views-view.active');
|
||||||
let jqtabAndViewToActivate;
|
let $tabAndViewToActivate;
|
||||||
|
|
||||||
if (index == 'previous') {
|
if (index == 'previous') {
|
||||||
jqtabAndViewToActivate = jqactiveTabAndView.prev('#nav-body-tabs .nav-tabs-tab, #nav-body-views .nav-views-view');
|
$tabAndViewToActivate = $activeTabAndView.prev('#nav-body-tabs .nav-tabs-tab, #nav-body-views .nav-views-view');
|
||||||
} else if (index == 'next') {
|
} else if (index == 'next') {
|
||||||
jqtabAndViewToActivate = jqactiveTabAndView.next('#nav-body-tabs .nav-tabs-tab, #nav-body-views .nav-views-view');
|
$tabAndViewToActivate = $activeTabAndView.next('#nav-body-tabs .nav-tabs-tab, #nav-body-views .nav-views-view');
|
||||||
} else if (index == 'last') {
|
} else if (index == 'last') {
|
||||||
jqtabAndViewToActivate = jq('#nav-body-tabs .nav-tabs-tab:last-of-type, #nav-body-views .nav-views-view:last-of-type');
|
$tabAndViewToActivate = $('#nav-body-tabs .nav-tabs-tab:last-of-type, #nav-body-views .nav-views-view:last-of-type');
|
||||||
} else {
|
} else {
|
||||||
jqtabAndViewToActivate = jq('#nav-body-tabs .nav-tabs-tab:nth-of-type(' + index + '), #nav-body-views .nav-views-view:nth-of-type(' + index + ')');
|
$tabAndViewToActivate = $('#nav-body-tabs .nav-tabs-tab:nth-of-type(' + index + '), #nav-body-views .nav-views-view:nth-of-type(' + index + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jqtabAndViewToActivate.length) {
|
if ($tabAndViewToActivate.length) {
|
||||||
jq('#nav-ctrls-url').blur();
|
$('#nav-ctrls-url').blur();
|
||||||
jqactiveTabAndView.removeClass('active');
|
$activeTabAndView.removeClass('active');
|
||||||
jqtabAndViewToActivate.addClass('active');
|
$tabAndViewToActivate.addClass('active');
|
||||||
|
|
||||||
this._updateUrl();
|
this._updateUrl();
|
||||||
this._updateCtrls();
|
this._updateCtrls();
|
||||||
|
@ -42,7 +42,7 @@ export async function open_preview(url: string) {
|
|||||||
global_window.setMenuBarVisibility(false);
|
global_window.setMenuBarVisibility(false);
|
||||||
global_window.setMenu(null);
|
global_window.setMenu(null);
|
||||||
global_window.loadFile(path.join(__dirname, "html", "index.html")).then(() => {
|
global_window.loadFile(path.join(__dirname, "html", "index.html")).then(() => {
|
||||||
global_window.webContents.openDevTools();
|
//global_window.webContents.openDevTools();
|
||||||
});
|
});
|
||||||
global_window.on('close', event => {
|
global_window.on('close', event => {
|
||||||
global_window = undefined;
|
global_window = undefined;
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"start-d": "electron . --disable-hardware-acceleration --debug -t -u http://clientapi.teaspeak.dev/",
|
"start-d": "electron . --disable-hardware-acceleration --debug -t -u http://clientapi.teaspeak.dev/",
|
||||||
"start-wd": "electron . --disable-hardware-acceleration --debug -t -s -u http://localhost/TeaWeb/client-api/environment/",
|
"start-wd": "electron . --disable-hardware-acceleration --debug -t -s -u http://localhost/TeaWeb/client-api/environment/",
|
||||||
"start-d1": "electron . --disable-hardware-acceleration --debug -t --gdb -s -u=http://clientapi.teaspeak.dev/ --updater-ui-loader_type=0",
|
"start-d1": "electron . --disable-hardware-acceleration --debug -t --gdb -s -u=http://clientapi.teaspeak.dev/ --updater-ui-loader_type=0",
|
||||||
"start-n": "electron . -t --disable-hardware-acceleration --no-single-instance -u=https://clientapi.teaspeak.de/ -d --updater-ui-loader_type=0",
|
"start-n": "electron . -t --disable-hardware-acceleration --no-single-instance -u=https://clientapi.teaspeak.de/ -d",
|
||||||
|
"start-nd": "electron . -t --disable-hardware-acceleration --no-single-instance -u=http://clientapi.teaspeak.dev/ -d",
|
||||||
"start-01": "electron . --updater-channel=test -u=http://dev.clientapi.teaspeak.de/ -d --updater-ui-loader_type=0 --updater-local-version=1.0.1",
|
"start-01": "electron . --updater-channel=test -u=http://dev.clientapi.teaspeak.de/ -d --updater-ui-loader_type=0 --updater-local-version=1.0.1",
|
||||||
"start-s": "electron . --disable-hardware-acceleration --debug --updater-ui-ignore-version -t -u http://localhost:8081/",
|
"start-s": "electron . --disable-hardware-acceleration --debug --updater-ui-ignore-version -t -u http://localhost:8081/",
|
||||||
"dtest": "electron . dtest",
|
"dtest": "electron . dtest",
|
||||||
|
Loading…
Reference in New Issue
Block a user