Improve developer experience by enabling context menus when possible

merge-requests/31/head
Sebastian Delmont 2020-10-24 08:03:15 -04:00
rodzic c48e927834
commit 5e73a8964c
11 zmienionych plików z 182 dodań i 135 usunięć

25
README.md 100644
Wyświetl plik

@ -0,0 +1,25 @@
# About GridTracker
# Developing GridTracker
GridTracker runs using [NWJS](https://nwjs.io/), a tools that wraps both Chrome windows and node processes into a native application.
To work on GridTracker you need to clone this git repository and then invoke NWJS with the contents of `package.nw`.
NWJS comes in two flavors, "normal" and "sdk". GridTracker is distributed with the normal flavor, but for development work
we recommend the SDK flavor because it provides access to Chrome's Developer Tools, among other things.
## Developing on Windows
To access the Developer Tools, right-click on an unused area of a window, or press F12.
## Developing on Linux
To access the Developer Tools, right-click on an unused area of a window, or press F12.
## Developing on Mac
We suggest using the `macos/run.sh` script to launch GridTracker while developing. It will download the sdk flavor of NWJS if needed,
and use it to run the app.
To access the Developer Tools, right-click on an unused area of a window, or press F12.

Wyświetl plik

@ -1,16 +1,21 @@
NWJS_VERSION=0.49.0
NWJS_FULL_NAME=nwjs-sdk-v$NWJS_VERSION-osx-x64
if [ ! -e build/macos/nwjs-v$NWJS_VERSION-osx-x64/nwjs.app ]; then
echo "Downloading NWJS $NWJS_VERSION"
if [ ! -e build/macos/$NWJS_FULL_NAME/nwjs.app ]; then
echo "Downloading NWJS $NWJS_VERSION ($NWJS_FULL_NAME)"
mkdir -p build/macos
cd build/macos
curl -O https://dl.nwjs.io/v$NWJS_VERSION/nwjs-v$NWJS_VERSION-osx-x64.zip
unzip nwjs-v$NWJS_VERSION-osx-x64.zip
curl -O https://dl.nwjs.io/v$NWJS_VERSION/$NWJS_FULL_NAME.zip
unzip $NWJS_FULL_NAME.zip
cd ../..
fi
# Disable `product_string` before running nwjs (see https://github.com/nwjs/nw.js/issues/7253)
sed -i "" -e s/\"product_string\"/\"ignore_product_string\"/g package.nw/package.json
build/macos/nwjs-v$NWJS_VERSION-osx-x64/nwjs.app/Contents/MacOS/nwjs ./package.nw
# Give time (15 seconds) for nwjs to start and then restore `product_string`
( sleep 15 ; sed -i "" -e s/\"ignore_product_string\"/\"product_string\"/g package.nw/package.json ) &
build/macos/$NWJS_FULL_NAME/nwjs.app/Contents/MacOS/nwjs ./package.nw
sed -i "" -e s/\"ignore_product_string\"/\"product_string\"/g package.nw/package.json

Wyświetl plik

@ -153,7 +153,7 @@
<div id="txrxdec" style="background-color:Green;border-style:outset;border-color:yellow;border-width:3px" class="roundBorder">waiting for message</div>
</div>
<div id="pskReporterBandActivityDiv" class="roundBorder" style="position:relative;background-color:#000;border:1px solid purple;margin:1px;height:49px;margin-bottom:1px;padding:0px" title="PSK-Reporter Band Activity" oncontextmenu="toggleBaWindow()" >
<div id="pskReporterBandActivityDiv" class="roundBorder" style="position:relative;background-color:#000;border:1px solid purple;margin:1px;height:49px;margin-bottom:1px;padding:0px" title="PSK-Reporter Band Activity" oncontextmenu="toggleBaWindow(event)" >
<div id="graphDiv" style="bottom:0;position: absolute;width:100%;padding:0px;margin-bottom:2px">
<br />...no data yet...<br />
&nbsp;
@ -1839,4 +1839,4 @@
<div id="selectNodeDiv" style="-webkit-user-select:text;display:block;zIndex:-10000"></div>
</div>
</body>
</html>
</html>

Wyświetl plik

@ -33,9 +33,10 @@ document.addEventListener("drop", function (event) {
});
document.addEventListener('contextmenu', function(ev) {
window.opener.openBaWindow(false);
ev.preventDefault();
window.opener.toggleBaWindow(ev);
if (process.versions['nw-flavor'] != "sdk") {
ev.preventDefault();
}
});
@ -43,7 +44,7 @@ document.addEventListener('contextmenu', function(ev) {
<script src="./lib/screens.js"></script>
</head>
<body id='mainBody' style="-webkit-app-region:drag;margin:0px;right:0px;left:0px;bottom:0px;top:0px;display:block;background-color:#000000FF;padding:0px;text-align:center;vertical-align:middle;position:absolute;z-index:600;" oncontextmenu="window.opener.showBaWindow(false)" >
<body id='mainBody' style="-webkit-app-region:drag;margin:0px;right:0px;left:0px;bottom:0px;top:0px;display:block;background-color:#000000FF;padding:0px;text-align:center;vertical-align:middle;position:absolute;z-index:600;">
<div id="pskReporterBandActivityDiv" style="position:relative;background-color:#000;border:1px solid purple;margin:1px;height:49px;margin-bottom:1px;padding:0px" title="PSK-Reporter Band Activity">
<div id="graphDiv" style="bottom:0;position: absolute;width:100%;padding:0px;margin-bottom:2px">
<br />...no data yet...<br />
@ -51,4 +52,4 @@ document.addEventListener('contextmenu', function(ev) {
</div>
</div>
</body>
</html>
</html>

Wyświetl plik

@ -262,6 +262,8 @@ function openIdCid( from )
function openLookupCid( from )
{
from.preventDefault();
if ( typeof window.opener.g_gtFlagPins[from.currentTarget.id] != "undefined" )
{
doLookup(window.opener.g_gtFlagPins[from.currentTarget.id].call);

Wyświetl plik

@ -37,8 +37,10 @@ table, th, td {
</style>
<script>
document.oncontextmenu = function() {
return false;
document.oncontextmenu = function(event) {
if (process.versions['nw-flavor'] != "sdk") {
ev.preventDefault();
}
}
document.addEventListener("dragover", function (event) {

Wyświetl plik

@ -66,8 +66,10 @@ function onMyKeyDown(event)
window.opener.onMyKeyDown(event);
}
document.oncontextmenu = function() {
return false;
document.oncontextmenu = function(event) {
if (process.versions['nw-flavor'] != "sdk") {
ev.preventDefault();
}
}
</script>

Wyświetl plik

@ -212,7 +212,9 @@
<div id="instancesDiv" style="display:none;" ></div>
</div>
<div id="rosterTable" style="overflow:auto;overflow-x:hidden;" ></div>
<div oncontextmenu="handleContextMenu(event);">
<div id="rosterTable" style="overflow:auto;overflow-x:hidden;"></div>
</div>
</div>
<div id="editView" class="roundBorder" style="height:100%;border:3px solid #066;padding:10px;margin:10px;display:none;">
<div style='display:block;font-size:larger'>Callsign, CQ and DXCC Ignores</div><br/>

Wyświetl plik

@ -39,6 +39,8 @@ if (g_platform == "windows")
var gui = require('nw.gui');
var win = gui.Window.get();
var g_developerMode = (process.versions['nw-flavor'] == "sdk");
var g_popupWindowHandle = null;
var g_callRosterWindowHandle = null;
var g_conditionsWindowHandle = null;
@ -4789,6 +4791,7 @@ function initMap() {
//mapDiv.addEventListener('mouseout', mapLoseFocus, false);
mapDiv.addEventListener('mouseleave', mapLoseFocus, false);
mapDiv.addEventListener('contextmenu', function(event) { event.preventDefault(); })
g_map.on('pointerdown', function (event) {
@ -4836,7 +4839,6 @@ function initMap() {
mouseOutOfDataItem();
});
document.getElementById("menuDiv").style.display = "block";
dayNight.init(g_map);
@ -6720,12 +6722,13 @@ function resetSearch()
function showWorkedByCall(callsign, evt)
{
evt.preventDefault();
resetSearch();
g_searchWB = callsign;
if ( event.shiftKey == true )
g_filterQSL = "true";
openInfoTab('qsobox', 'workedBoxDiv', showWorkedBox);
}
function showWorkedSearchChanged(object, index) {
@ -7546,8 +7549,9 @@ function showSettingsBox() {
}
}
function toggleBaWindow()
{
function toggleBaWindow(event) {
event.preventDefault();
if (g_baWindowHandle == null)
{
openBaWindow(true);
@ -11199,9 +11203,11 @@ function loadAdifSettings()
function startupVersionInit() {
document.body.addEventListener('contextmenu', function(ev) {
ev.preventDefault();
});
if (!g_developerMode) {
document.body.addEventListener('contextmenu', function(ev) {
ev.preventDefault();
});
}
imSureCheck.checked = false;
stopAskingCheckbox.checked = g_appSettings.stopAskingVersion;

Wyświetl plik

@ -42,6 +42,7 @@ var g_callsignDatabaseDXCC = {};
var g_callsignDatabaseUS = {}
var g_callsignDatabaseUSplus = {};
var g_developerMode = (process.versions['nw-flavor'] == "sdk");
var g_modeColors = {};
g_modeColors["FT4"] = '1111FF';
@ -3036,113 +3037,6 @@ function init()
});
g_dxccMenu.append(item);
document.body.addEventListener('contextmenu', function(ev) {
ev.preventDefault();
if ( editView.style.display == "inline-block" )
return false;
var len = Object.keys(g_blockedCalls).length;
if ( len > 0 )
{
g_clearIgnores.enabled = true;
g_clearIgnores.label = "Clear Call Ignore" + ((len > 1 )?"s ("+len+")":"");
g_clearIgnoresCall.enabled = true;
g_clearIgnoresCall.label = "Clear Ignore" + ((len > 1 )?"s ("+len+")":"");
}
else
{
g_clearIgnores.label = "Clear Call Ignore";
g_clearIgnores.enabled = false;
g_clearIgnoresCall.label = "Clear Ignore";
g_clearIgnoresCall.enabled = false;
}
len = Object.keys(g_blockedDxcc).length;
if ( len > 0 )
{
g_clearDxccIgnoreMainMenu.enabled = true;
g_clearDxccIgnoreMainMenu.label = "Clear DXCC Ignore" + ((len > 1 )?"s ("+len+")":"");
g_clearDxccIgnore.enabled = true;
g_clearDxccIgnore.label = "Clear Ignore" + ((len > 1 )?"s ("+len+")":"");
}
else
{
g_clearDxccIgnoreMainMenu.label = "Clear DXCC Ignore";
g_clearDxccIgnoreMainMenu.enabled = false;
g_clearDxccIgnore.label = "Clear Ignore";
g_clearDxccIgnore.enabled = false;
}
len = Object.keys(g_blockedCQ).length;
if ( len > 0 )
{
g_clearCQIgnoreMainMenu.enabled = true;
g_clearCQIgnoreMainMenu.label = "Clear CQ Ignore" + ((len > 1 )?"s ("+len+")":"");
g_clearCQIgnore.enabled = true;
g_clearCQIgnore.label = "Clear Ignore" + ((len > 1 )?"s ("+len+")":"");
}
else
{
g_clearCQIgnoreMainMenu.label = "Clear CQ Ignore";
g_clearCQIgnoreMainMenu.enabled = false;
g_clearCQIgnore.label = "Clear Ignore";
g_clearCQIgnore.enabled = false;
}
if ( typeof ev.target != 'undefined' )
{
var name = ev.target.getAttribute("name");
if ( name == "Callsign" )
{
g_targetHash = ev.target.parentNode.id;
g_callMenu.popup(ev.x, ev.y);
}
else if ( name == "Calling" )
{
g_targetHash = ev.target.parentNode.id;
g_callingMenu.popup(ev.x, ev.y);
}
else if ( name == "CQ" )
{
if ( callRoster[ev.target.parentNode.id].DXcall != "CQ" )
{
g_targetCQ = ev.target.parentNode.id;
g_CQMenu.popup(ev.x, ev.y);
}
}
else if ( name && name.startsWith("DXCC") )
{
var dxcca = name.split("(");
var dxcc = parseInt(dxcca[1]);
g_targetDxcc = dxcc;
g_dxccMenu.popup(ev.x, ev.y);
}
else
{
if ( g_rosterSettings.compact == false )
{
g_menu.popup(ev.x, ev.y);
}
else
{
g_compactMenu.popup(ev.x, ev.y);
}
}
}
else
{
if ( g_rosterSettings.compact == false )
{
g_menu.popup(ev.x, ev.y);
}
else
{
g_compactMenu.popup(ev.x, ev.y);
}
}
return false;
});
callsignNeed.value = g_rosterSettings.callsign;
huntMode.value = g_rosterSettings.hunting;
huntNeed.value = g_rosterSettings.huntNeed;
@ -3192,6 +3086,114 @@ function init()
}
function handleContextMenu(ev) {
if ( editView.style.display == "inline-block" )
return false;
var len = Object.keys(g_blockedCalls).length;
if ( len > 0 )
{
g_clearIgnores.enabled = true;
g_clearIgnores.label = "Clear Call Ignore" + ((len > 1 )?"s ("+len+")":"");
g_clearIgnoresCall.enabled = true;
g_clearIgnoresCall.label = "Clear Ignore" + ((len > 1 )?"s ("+len+")":"");
}
else
{
g_clearIgnores.label = "Clear Call Ignore";
g_clearIgnores.enabled = false;
g_clearIgnoresCall.label = "Clear Ignore";
g_clearIgnoresCall.enabled = false;
}
len = Object.keys(g_blockedDxcc).length;
if ( len > 0 )
{
g_clearDxccIgnoreMainMenu.enabled = true;
g_clearDxccIgnoreMainMenu.label = "Clear DXCC Ignore" + ((len > 1 )?"s ("+len+")":"");
g_clearDxccIgnore.enabled = true;
g_clearDxccIgnore.label = "Clear Ignore" + ((len > 1 )?"s ("+len+")":"");
}
else
{
g_clearDxccIgnoreMainMenu.label = "Clear DXCC Ignore";
g_clearDxccIgnoreMainMenu.enabled = false;
g_clearDxccIgnore.label = "Clear Ignore";
g_clearDxccIgnore.enabled = false;
}
len = Object.keys(g_blockedCQ).length;
if ( len > 0 )
{
g_clearCQIgnoreMainMenu.enabled = true;
g_clearCQIgnoreMainMenu.label = "Clear CQ Ignore" + ((len > 1 )?"s ("+len+")":"");
g_clearCQIgnore.enabled = true;
g_clearCQIgnore.label = "Clear Ignore" + ((len > 1 )?"s ("+len+")":"");
}
else
{
g_clearCQIgnoreMainMenu.label = "Clear CQ Ignore";
g_clearCQIgnoreMainMenu.enabled = false;
g_clearCQIgnore.label = "Clear Ignore";
g_clearCQIgnore.enabled = false;
}
if ( typeof ev.target != 'undefined' )
{
var name = ev.target.getAttribute("name");
if ( name == "Callsign" )
{
g_targetHash = ev.target.parentNode.id;
g_callMenu.popup(ev.x, ev.y);
}
else if ( name == "Calling" )
{
g_targetHash = ev.target.parentNode.id;
g_callingMenu.popup(ev.x, ev.y);
}
else if ( name == "CQ" )
{
if ( callRoster[ev.target.parentNode.id].DXcall != "CQ" )
{
g_targetCQ = ev.target.parentNode.id;
g_CQMenu.popup(ev.x, ev.y);
}
}
else if ( name && name.startsWith("DXCC") )
{
var dxcca = name.split("(");
var dxcc = parseInt(dxcca[1]);
g_targetDxcc = dxcc;
g_dxccMenu.popup(ev.x, ev.y);
}
else
{
if ( g_rosterSettings.compact == false )
{
g_menu.popup(ev.x, ev.y);
}
else
{
g_compactMenu.popup(ev.x, ev.y);
}
}
}
else
{
if ( g_rosterSettings.compact == false )
{
g_menu.popup(ev.x, ev.y);
}
else
{
g_compactMenu.popup(ev.x, ev.y);
}
}
if (!g_developerMode) {
ev.preventDefault();
}
return false;
}
function getTypeFromMode(mode)
{
if (mode in g_modes)

Wyświetl plik

@ -1,8 +1,8 @@
// GridTracker ©2020 N0TTL
document.oncontextmenu = function() {
return false;
document.oncontextmenu = function(event) {
event.preventDefault();
}
document.addEventListener("dragover", function (event) {
@ -201,4 +201,4 @@ function reloadInfo( bandOrMode )
if (waswaczoneBoxDiv.style.display == "block") {
window.opener.showWASWACzoneBox();
}
}
}