From 5e73a8964c51b92111d635f702456bf53a20c5db Mon Sep 17 00:00:00 2001 From: Sebastian Delmont Date: Sat, 24 Oct 2020 08:03:15 -0400 Subject: [PATCH] Improve developer experience by enabling context menus when possible --- README.md | 25 ++++ macos/run.sh | 17 ++- package.nw/GridTracker.html | 4 +- package.nw/gt_bandactivity.html | 11 +- package.nw/gt_chat.html | 2 + package.nw/gt_conditions.html | 6 +- package.nw/gt_popup.html | 6 +- package.nw/gt_roster.html | 4 +- package.nw/lib/gt.js | 20 +-- package.nw/lib/roster.js | 216 ++++++++++++++++---------------- package.nw/lib/stats.js | 6 +- 11 files changed, 182 insertions(+), 135 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..6765ff80 --- /dev/null +++ b/README.md @@ -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. diff --git a/macos/run.sh b/macos/run.sh index 62c28900..4431973c 100755 --- a/macos/run.sh +++ b/macos/run.sh @@ -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 diff --git a/package.nw/GridTracker.html b/package.nw/GridTracker.html index 83238cd2..821997db 100644 --- a/package.nw/GridTracker.html +++ b/package.nw/GridTracker.html @@ -153,7 +153,7 @@
waiting for message
-
+

...no data yet...
  @@ -1839,4 +1839,4 @@
- \ No newline at end of file + diff --git a/package.nw/gt_bandactivity.html b/package.nw/gt_bandactivity.html index 6d67e52d..63ad3281 100644 --- a/package.nw/gt_bandactivity.html +++ b/package.nw/gt_bandactivity.html @@ -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) { - +

...no data yet...
@@ -51,4 +52,4 @@ document.addEventListener('contextmenu', function(ev) {
- \ No newline at end of file + diff --git a/package.nw/gt_chat.html b/package.nw/gt_chat.html index 0094bef4..7f38476e 100644 --- a/package.nw/gt_chat.html +++ b/package.nw/gt_chat.html @@ -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); diff --git a/package.nw/gt_conditions.html b/package.nw/gt_conditions.html index 92b008b8..d089790f 100644 --- a/package.nw/gt_conditions.html +++ b/package.nw/gt_conditions.html @@ -37,8 +37,10 @@ table, th, td { diff --git a/package.nw/gt_roster.html b/package.nw/gt_roster.html index 5b0aa835..118a6a8f 100644 --- a/package.nw/gt_roster.html +++ b/package.nw/gt_roster.html @@ -212,7 +212,9 @@
-
+
+
+