Fixed the navigation tab

This commit is contained in:
WolverinDEV 2020-04-02 16:51:12 +02:00
parent cd83ef4b7d
commit e1b2752fb6
4 changed files with 113 additions and 109 deletions

View File

@ -463,7 +463,7 @@ async function load_cached_or_remote_ui_pack(channel: string, stats_update: (mes
let remote_version_dropped = false;
/* remote version gathering */
{
remote_loader: {
stats_update("Loading remote info", .25);
let remote_versions: local_ui_cache.UIPackInfo[];
try {
@ -472,6 +472,7 @@ async function load_cached_or_remote_ui_pack(channel: string, stats_update: (mes
if(available_versions.length === 0)
throw "failed to query remote UI packs: " + error;
console.error("Failed to query remote UI packs: %o", error);
break remote_loader;
}
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;
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);
if(required_version.newer_than(client_version) && !is_debug) {
const result = await electron.dialog.showMessageBox({

View File

@ -21,7 +21,8 @@ import WebviewTag = Electron.WebviewTag;
/**
* DEPENDENCIES
*/
var jq = require('jquery');
//@ts-ignore
var $ = require('jquery');
var Color = require('color.js');
var urlRegex = require('url-regex');
const contextMenu = require('electron-context-menu')
@ -65,27 +66,27 @@ function Navigation(options) {
* ADD ELEMENTS
*/
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) {
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) {
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) {
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) {
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
*/
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 {
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
@ -93,15 +94,15 @@ function Navigation(options) {
//
// switch active view and tab on click
//
jq('#nav-body-tabs').on('click', '.nav-tabs-tab', function () {
jq('.nav-tabs-tab, .nav-views-view').removeClass('active');
$('#nav-body-tabs').on('click', '.nav-tabs-tab', function () {
$('.nav-tabs-tab, .nav-views-view').removeClass('active');
var sessionID = jq(this).data('session');
jq('.nav-tabs-tab, .nav-views-view')
var sessionID = $(this).data('session');
$('.nav-tabs-tab, .nav-views-view')
.filter('[data-session="' + sessionID + '"]')
.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._updateUrl((session as WebviewTag).getURL());
NAV._updateCtrls();
@ -110,8 +111,8 @@ function Navigation(options) {
// close tab and view
//
}).on('click', '.nav-tabs-close', function() {
var sessionID = jq(this).parent('.nav-tabs-tab').data('session');
var session = jq('.nav-tabs-tab, .nav-views-view').filter('[data-session="' + sessionID + '"]');
var sessionID = $(this).parent('.nav-tabs-tab').data('session');
var session = $('.nav-tabs-tab, .nav-views-view').filter('[data-session="' + sessionID + '"]');
if (session.hasClass('active')) {
if (session.next('.nav-tabs-tab').length) {
@ -130,7 +131,7 @@ function Navigation(options) {
//
// 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;
if(typeof options.newTabParams === "function"){
params = options.newTabParams();
@ -148,20 +149,20 @@ function Navigation(options) {
//
// go back
//
jq('#nav-body-ctrls').on('click', '#nav-ctrls-back', function () {
$('#nav-body-ctrls').on('click', '#nav-ctrls-back', function () {
NAV.back();
});
//
// go forward
//
jq('#nav-body-ctrls').on('click', '#nav-ctrls-forward', function () {
$('#nav-body-ctrls').on('click', '#nav-ctrls-forward', function () {
NAV.forward();
});
//
// reload page
//
jq('#nav-body-ctrls').on('click', '#nav-ctrls-reload', function () {
if (jq(this).find('#nav-ready').length) {
$('#nav-body-ctrls').on('click', '#nav-ctrls-reload', function () {
if ($(this).find('#nav-ready').length) {
NAV.reload();
} else {
NAV.stop();
@ -170,10 +171,10 @@ function Navigation(options) {
//
// highlight address input text on first select
//
jq('#nav-ctrls-url').on('focus', function (e) {
jq(this)
$('#nav-ctrls-url').on('focus', function (e) {
$(this)
.one('mouseup', function () {
jq(this).select();
$(this).select();
return false;
})
.select();
@ -181,7 +182,7 @@ function Navigation(options) {
//
// 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.shiftKey) {
NAV.newTab(this.value, {
@ -189,7 +190,7 @@ function Navigation(options) {
icon: NAV.TAB_ICON
});
} else {
if (jq('.nav-tabs-tab').length) {
if ($('.nav-tabs-tab').length) {
NAV.changeTab(this.value);
} else {
NAV.newTab(this.value, {
@ -207,22 +208,22 @@ function Navigation(options) {
// update controls like back, forward, etc...
//
this._updateCtrls = function () {
let webview = jq('.nav-views-view.active')[0] as WebviewTag;
let webview = $('.nav-views-view.active')[0] as WebviewTag;
if (!webview) {
jq('#nav-ctrls-back').addClass('disabled');
jq('#nav-ctrls-forward').addClass('disabled');
jq('#nav-ctrls-reload').html(this.SVG_RELOAD).addClass('disabled');
$('#nav-ctrls-back').addClass('disabled');
$('#nav-ctrls-forward').addClass('disabled');
$('#nav-ctrls-reload').html(this.SVG_RELOAD).addClass('disabled');
return;
}
if (webview.canGoBack()) {
jq('#nav-ctrls-back').removeClass('disabled');
$('#nav-ctrls-back').removeClass('disabled');
} else {
jq('#nav-ctrls-back').addClass('disabled');
$('#nav-ctrls-back').addClass('disabled');
}
if (webview.canGoForward()) {
jq('#nav-ctrls-forward').removeClass('disabled');
$('#nav-ctrls-forward').removeClass('disabled');
} else {
jq('#nav-ctrls-forward').addClass('disabled');
$('#nav-ctrls-forward').addClass('disabled');
}
if (webview.isLoading()) {
this._loading();
@ -230,9 +231,9 @@ function Navigation(options) {
this._stopLoading();
}
if (webview.getAttribute('data-readonly') == 'true') {
jq('#nav-ctrls-url').attr('readonly', 'readonly');
$('#nav-ctrls-url').attr('readonly', 'readonly');
} else {
jq('#nav-ctrls-url').removeAttr('readonly');
$('#nav-ctrls-url').removeAttr('readonly');
}
} //:_updateCtrls()
@ -243,11 +244,11 @@ function Navigation(options) {
tab = 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');
jq('#nav-ctrls-reload').html(this.SVG_CLEAR);
$('#nav-ctrls-reload').html(this.SVG_CLEAR);
} //:_loading()
//
// stop loading animations
@ -256,11 +257,11 @@ function Navigation(options) {
tab = tab || null;
if (tab == null) {
tab = jq('.nav-tabs-tab.active');
tab = $('.nav-tabs-tab.active');
}
tab.find('.nav-tabs-favicon').css('animation', '');
jq('#nav-ctrls-reload').html(this.SVG_RELOAD);
$('#nav-ctrls-reload').html(this.SVG_RELOAD);
} //:_stopLoading()
//
// auto add http protocol to url input or do a search
@ -292,8 +293,8 @@ function Navigation(options) {
// add event listeners to current webview
//
this._addEvents = function (sessionID, options) {
let currtab = jq('.nav-tabs-tab[data-session="' + sessionID + '"]');
let webview = jq('.nav-views-view[data-session="' + sessionID + '"]') as JQuery<WebviewTag>;
let currtab = $('.nav-tabs-tab[data-session="' + sessionID + '"]');
let webview = $('.nav-views-view[data-session="' + sessionID + '"]') as JQuery<WebviewTag>;
webview.on('dom-ready', function () {
if (options.contextMenu) {
@ -323,26 +324,26 @@ function Navigation(options) {
NAV._stopLoading(currtab);
});
webview.on('enter-html-full-screen', function () {
jq('.nav-views-view.active').siblings().not('script').hide();
jq('.nav-views-view.active').parents().not('script').siblings().hide();
$('.nav-views-view.active').siblings().not('script').hide();
$('.nav-views-view.active').parents().not('script').siblings().hide();
});
webview.on('leave-html-full-screen', function () {
jq('.nav-views-view.active').siblings().not('script').show();
jq('.nav-views-view.active').parents().siblings().not('script').show();
$('.nav-views-view.active').siblings().not('script').show();
$('.nav-views-view.active').parents().siblings().not('script').show();
});
webview.on('load-commit', function () {
NAV._updateCtrls();
});
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);
});
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);
});
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);
});
webview[0].addEventListener("new-window", (res) => {
@ -353,10 +354,10 @@ function Navigation(options) {
}
});
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) => {
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=' +
'<div style="background-color:whitesmoke;padding:40px;margin:20px;font-family:consolas;">' +
'<h2 align=center>Oops, this page failed to load correctly.</h2>' +
@ -377,10 +378,10 @@ function Navigation(options) {
//
this._updateUrl = function (url) {
url = url || null;
let urlInput = jq('#nav-ctrls-url');
let urlInput = $('#nav-ctrls-url');
if (url == null) {
if (jq('.nav-views-view').length) {
url = (jq('.nav-views-view.active')[0] as WebviewTag).getURL();
if ($('.nav-views-view').length) {
url = ($('.nav-views-view.active')[0] as WebviewTag).getURL();
} else {
url = '';
}
@ -438,12 +439,12 @@ Navigation.prototype.newTab = function (url, options) {
}
// validate options.id
jq('.nav-tabs-tab, .nav-views-view').removeClass('active');
if (jq('#' + options.id).length) {
$('.nav-tabs-tab, .nav-views-view').removeClass('active');
if ($('#' + options.id).length) {
console.log('ERROR[electron-navigation][func "newTab();"]: The ID "' + options.id + '" already exists. Please use another one.');
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.');
return false;
}
@ -470,29 +471,29 @@ Navigation.prototype.newTab = function (url, options) {
// finish tab
tab += '</span>';
// add tab to correct position
if (jq('#nav-body-tabs').has('#nav-tabs-add').length) {
jq('#nav-tabs-add').before(tab);
if ($('#nav-body-tabs').has('#nav-tabs-add').length) {
$('#nav-tabs-add').before(tab);
} else {
jq('#nav-body-tabs').append(tab);
$('#nav-body-tabs').append(tab);
}
// 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) {
composedWebviewTag += ` id=jq{options.id}`;
composedWebviewTag += ` id=${options.id}`;
}
if (options.node) {
composedWebviewTag += " nodeintegration";
}
if (options.webviewAttributes) {
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
jq('#nav-ctrls-reload').removeClass('disabled');
$('#nav-ctrls-reload').removeClass('disabled');
// update url and add events
this._updateUrl(this._purifyUrl(url));
@ -510,10 +511,10 @@ Navigation.prototype.newTab = function (url, options) {
Navigation.prototype.changeTab = function (url, id) {
id = 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 {
if (jq('#' + id).length) {
jq('#' + id).attr('src', this._purifyUrl(url));
if ($('#' + id).length) {
$('#' + id).attr('src', this._purifyUrl(url));
} else {
console.log('ERROR[electron-navigation][func "changeTab();"]: Cannot find the ID "' + id + '"');
}
@ -527,11 +528,11 @@ Navigation.prototype.closeTab = function (id) {
var session;
if (id == null) {
session = jq('.nav-tabs-tab.active, .nav-views-view.active');
session = $('.nav-tabs-tab.active, .nav-views-view.active');
} else {
if (jq('#' + id).length) {
var sessionID = jq('#' + id).data('session');
session = jq('.nav-tabs-tab, .nav-views-view').filter('[data-session="' + sessionID + '"]');
if ($('#' + id).length) {
var sessionID = $('#' + id).data('session');
session = $('.nav-tabs-tab, .nav-views-view').filter('[data-session="' + sessionID + '"]');
} else {
console.log('ERROR[electron-navigation][func "closeTab();"]: Cannot find the ID "' + id + '"');
return false;
@ -555,10 +556,10 @@ Navigation.prototype.closeTab = function (id) {
Navigation.prototype.back = function (id) {
id = id || null;
if (id == null) {
(jq('.nav-views-view.active')[0] as WebviewTag).goBack();
($('.nav-views-view.active')[0] as WebviewTag).goBack();
} else {
if (jq('#' + id).length) {
(jq('#' + id)[0] as WebviewTag).goBack();
if ($('#' + id).length) {
($('#' + id)[0] as WebviewTag).goBack();
} else {
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) {
id = id || null;
if (id == null) {
(jq('.nav-views-view.active')[0] as WebviewTag).goForward();
($('.nav-views-view.active')[0] as WebviewTag).goForward();
} else {
if (jq('#' + id).length) {
(jq('#' + id)[0] as WebviewTag).goForward();
if ($('#' + id).length) {
($('#' + id)[0] as WebviewTag).goForward();
} else {
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) {
id = id || null;
if (id == null) {
(jq('.nav-views-view.active')[0] as WebviewTag).reload();
($('.nav-views-view.active')[0] as WebviewTag).reload();
} else {
if (jq('#' + id).length) {
(jq('#' + id)[0] as WebviewTag).reload();
if ($('#' + id).length) {
($('#' + id)[0] as WebviewTag).reload();
} else {
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) {
id = id || null;
if (id == null) {
(jq('.nav-views-view.active')[0] as WebviewTag).stop();
($('.nav-views-view.active')[0] as WebviewTag).stop();
} else {
if (jq('#' + id).length) {
(jq('#' + id)[0] as WebviewTag).stop();
if ($('#' + id).length) {
($('#' + id)[0] as WebviewTag).stop();
} else {
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;
//check id
if (jq('#' + id).length) {
if ($('#' + id).length) {
webview = document.getElementById(id);
} else {
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;
// check id
if (jq('#' + id).length) {
if ($('#' + id).length) {
webview = document.getElementById(id);
} else {
console.log('ERROR[electron-navigation][func "send();"]: Cannot find the ID "' + id + '"');
@ -670,9 +671,9 @@ Navigation.prototype.openDevTools = function (id) {
// check id
if (id == null) {
webview = jq('.nav-views-view.active')[0];
webview = $('.nav-views-view.active')[0];
} else {
if (jq('#' + id).length) {
if ($('#' + id).length) {
webview = document.getElementById(id);
} else {
console.log('ERROR[electron-navigation][func "openDevTools();"]: Cannot find the ID "' + id + '"');
@ -699,9 +700,9 @@ Navigation.prototype.printTab = function (id, opts) {
// check id
if (id == null) {
webview = jq('.nav-views-view.active')[0]
webview = $('.nav-views-view.active')[0]
} else {
if (jq('#' + id).length) {
if ($('#' + id).length) {
webview = document.getElementById(id)
} else {
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
//
Navigation.prototype.nextTab = function () {
var tabs = jq('.nav-tabs-tab').toArray();
var activeTabIndex = tabs.indexOf(jq('.nav-tabs-tab.active')[0]);
var tabs = $('.nav-tabs-tab').toArray();
var activeTabIndex = tabs.indexOf($('.nav-tabs-tab.active')[0]);
var nexti = activeTabIndex + 1;
if (nexti > tabs.length - 1) nexti = 0;
jq(jq('.nav-tabs-tab')[nexti]).trigger('click');
$($('.nav-tabs-tab')[nexti]).trigger('click');
return false
} //:nextTab()
//:prevTab()
@ -730,33 +731,33 @@ Navigation.prototype.nextTab = function () {
// toggle previous available tab
//
Navigation.prototype.prevTab = function () {
var tabs = jq('.nav-tabs-tab').toArray();
var activeTabIndex = tabs.indexOf(jq('.nav-tabs-tab.active')[0]);
var tabs = $('.nav-tabs-tab').toArray();
var activeTabIndex = tabs.indexOf($('.nav-tabs-tab.active')[0]);
var nexti = activeTabIndex - 1;
if (nexti < 0) nexti = tabs.length - 1;
jq(jq('.nav-tabs-tab')[nexti]).trigger('click');
$($('.nav-tabs-tab')[nexti]).trigger('click');
return false
} //:prevTab()
// go to a tab by index or keyword
//
Navigation.prototype.goToTab = function (index) {
let jqactiveTabAndView = jq('#nav-body-tabs .nav-tabs-tab.active, #nav-body-views .nav-views-view.active');
let jqtabAndViewToActivate;
let $activeTabAndView = $('#nav-body-tabs .nav-tabs-tab.active, #nav-body-views .nav-views-view.active');
let $tabAndViewToActivate;
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') {
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') {
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 {
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) {
jq('#nav-ctrls-url').blur();
jqactiveTabAndView.removeClass('active');
jqtabAndViewToActivate.addClass('active');
if ($tabAndViewToActivate.length) {
$('#nav-ctrls-url').blur();
$activeTabAndView.removeClass('active');
$tabAndViewToActivate.addClass('active');
this._updateUrl();
this._updateCtrls();

View File

@ -42,7 +42,7 @@ export async function open_preview(url: string) {
global_window.setMenuBarVisibility(false);
global_window.setMenu(null);
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 = undefined;

View File

@ -10,7 +10,8 @@
"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-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-s": "electron . --disable-hardware-acceleration --debug --updater-ui-ignore-version -t -u http://localhost:8081/",
"dtest": "electron . dtest",