From 41f0534383a3613aff093de89a7ea4bb273db3c5 Mon Sep 17 00:00:00 2001 From: inderpreet singh Date: Tue, 11 Jun 2019 19:50:44 -0700 Subject: [PATCH 1/7] extends history support to banis and ceremonies --- www/js/search.js | 59 ++++++++++++++++++++++++++++++++---------------- www/js/viewer.js | 12 ++++++---- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/www/js/search.js b/www/js/search.js index 3a7784653..70821e47a 100644 --- a/www/js/search.js +++ b/www/js/search.js @@ -575,18 +575,32 @@ module.exports = { } }, - clickResult(e, ShabadID, LineID, Line) { - document.body.classList.remove('home'); - this.closeGurmukhiKB(); + addToHistory(SearchID, LineID, SearchTitle, type) { const sessionItem = h( - `li#session-${ShabadID}`, + `li#session-${type}-${SearchID}`, {}, h( 'a.panktee.current', { - onclick: ev => this.clickSession(ev, ShabadID, LineID), + onclick: ev => { + const $panktee = ev.target; + switch (type) { + case 'bani': + this.loadBani(SearchID, LineID, true); + break; + case 'ceremony': + this.loadCeremony(SearchID, true); + break; + default: + this.loadShabad(SearchID, LineID); + } + const sessionLines = this.$session.querySelectorAll('a.panktee'); + Array.from(sessionLines).forEach(el => el.classList.remove('current')); + $panktee.classList.add('current'); + this.navPage('shabad'); + }, }, - Line.Gurmukhi, + SearchTitle, ), ); // get all the lines in the session block and remove the .current class from them @@ -594,16 +608,22 @@ module.exports = { Array.from(sessionLines).forEach(el => el.classList.remove('current')); // if the ShabadID of the clicked Panktee isn't in the sessionList variable, // add it to the variable - if (sessionList.indexOf(ShabadID) < 0) { - sessionList.push(ShabadID); + if (sessionList.indexOf(SearchID.toString()) < 0) { + sessionList.push(SearchID.toString()); } else { // if the ShabadID is already in the session, just remove the HTMLElement, // and leave the sessionList - const line = this.$session.querySelector(`#session-${ShabadID}`); + const line = this.$session.querySelector(`#session-${type}-${SearchID}`); this.$session.removeChild(line); } // add the line to the top of the session block this.$session.insertBefore(sessionItem, this.$session.firstChild); + }, + + clickResult(e, ShabadID, LineID, Line) { + document.body.classList.remove('home'); + this.closeGurmukhiKB(); + this.addToHistory(ShabadID, LineID, Line.Gurmukhi); // are we in APV const apv = document.body.classList.contains('akhandpaatt'); // load the Shabad into the controller @@ -647,7 +667,7 @@ module.exports = { } }, - async loadCeremony(ceremonyID) { + async loadCeremony(ceremonyID, historyReload = false) { const $shabadList = this.$shabad || document.getElementById('shabad'); $shabadList.innerHTML = ''; $shabadList.dataset.bani = ''; @@ -678,13 +698,17 @@ module.exports = { }), ); const flatRows = [].concat(...rows); + const nameOfCeremony = rowsDb[0].Ceremony.Gurmukhi; + if (!historyReload) { + this.addToHistory(ceremonyID, null, nameOfCeremony, 'ceremony'); + } return this.printShabad(flatRows); } catch (error) { throw error; } }, - loadBani(BaniID, LineID = null) { + loadBani(BaniID, LineID = null, historyReload = false) { const $shabadList = this.$shabad || document.getElementById('shabad'); const baniLength = store.get('userPrefs.toolbar.gurbani.bani-length'); const mangalPosition = store.get('userPrefs.toolbar.gurbani.mangal-position'); @@ -708,6 +732,10 @@ module.exports = { banidb.loadBani(BaniID, baniLengthCols[baniLength]).then(rowsDb => { // create a unique shabadID for whole bani, and append it with length const shabadID = `${rowsDb[0].Token || rowsDb[0].Bani.Token}-${baniLength}`; + const nameOfBani = rowsDb[0].Gurmukhi || rowsDb[0].Bani.Gurmukhi; + if (!historyReload) { + this.addToHistory(BaniID, LineID, nameOfBani, 'bani'); + } const rows = rowsDb .filter(rowDb => rowDb.MangalPosition !== blackListedMangalPosition) .map(rowDb => { @@ -921,15 +949,6 @@ module.exports = { } }, - clickSession(e, ShabadID, LineID) { - const $panktee = e.target; - this.loadShabad(ShabadID, LineID); - const sessionLines = this.$session.querySelectorAll('a.panktee'); - Array.from(sessionLines).forEach(el => el.classList.remove('current')); - $panktee.classList.add('current'); - this.navPage('shabad'); - }, - checkAutoPlay(LineID = null) { clearTimeout(autoplaytimer); if (LineID === null && document.body.querySelector('#shabad li')) { diff --git a/www/js/viewer.js b/www/js/viewer.js index 8d037ae5c..e4032cee4 100644 --- a/www/js/viewer.js +++ b/www/js/viewer.js @@ -87,11 +87,13 @@ const castShabadLine = lineID => { }); castToReceiver(); - const activeSlide = document.querySelector('.deck.active .slide.active').children; - Array.prototype.forEach.call(activeSlide, element => { - const icons = iconsetHtml(`icons-${element.classList[0]}`, element.innerHTML); - if (icons) document.querySelector('.viewer-controls').appendChild(icons); - }); + const activeSlide = document.querySelector('.deck.active .slide.active'); + if (activeSlide) { + Array.prototype.forEach.call(activeSlide.children, element => { + const icons = iconsetHtml(`icons-${element.classList[0]}`, element.innerHTML); + if (icons) document.querySelector('.viewer-controls').appendChild(icons); + }); + } } }; From cb28f7a0e4d90c6afc05668a8c11181768e976e9 Mon Sep 17 00:00:00 2001 From: Inder Singh Date: Wed, 19 Jun 2019 07:50:33 -0700 Subject: [PATCH 2/7] History support 2 (#666) * extends history support to banis and ceremonies * retains shabad status for bani, ceremony and shabad * trying to be polite --- README.md | 25 +++++++++++-------- www/js/search.js | 65 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 67 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index acb623af5..7a21b6551 100644 --- a/README.md +++ b/README.md @@ -13,28 +13,31 @@ Acknowledgements: Bhai Tarsem Singh UK, SHARE UK, Khalis Foundation, Khalsa Foun Powered by [](http://banidb.com) - [![Build Status](https://api.travis-ci.org/KhalisFoundation/sttm-desktop.svg?branch=release)](https://travis-ci.org/KhalisFoundation/sttm-desktop) [![Build Status](https://ci.appveyor.com/api/projects/status/github/khalisfoundation/sttm-desktop?branch=release&svg=true)](https://ci.appveyor.com/project/navdeepsinghkhalsa/sttm-desktop) ## Prerequisites - 1. [Node](https://nodejs.org/en/download/) - 2. [Github SSH Key Setup](https://help.github.com/articles/connecting-to-github-with-ssh/) + +1. [Node](https://nodejs.org/en/download/) +2. [Github SSH Key Setup](https://help.github.com/articles/connecting-to-github-with-ssh/) ## Installation - * Clone repository - * Run `npm install` in the repository root + +- Clone repository +- Run `npm install` in the repository root ## Running - * Run `npm start` in the repository root + +- Run `npm start` in the repository root ## Packaging Create the app package for your system: - * **macOS** - Run `npm run pack:mac` - * **Windows 64-bit** - Run `npm run pack:win` - * **Windows 32-bit** - Run `npm run pack:win32` - * **Linux/Ubuntu 64-bit** - Run `npm run pack:linux` +- **macOS** - Run `npm run pack:mac` +- **Windows 64-bit** - Run `npm run pack:win` +- **Windows 32-bit** - Run `npm run pack:win32` +- **Linux/Ubuntu 64-bit** - Run `npm run pack:linux` ## Contributing -See [CONTRIBUTING.md](CONTRIBUTING.md) + +Please see [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/www/js/search.js b/www/js/search.js index 70821e47a..deb5d0a87 100644 --- a/www/js/search.js +++ b/www/js/search.js @@ -22,6 +22,7 @@ const allowedKeys = [ 46, // Delete ]; const sessionList = []; +const sessionStatesList = {}; const currentShabad = []; const kbPages = []; let currentMeta = {}; @@ -575,7 +576,8 @@ module.exports = { } }, - addToHistory(SearchID, LineID, SearchTitle, type) { + addToHistory(SearchID, MainLineID, SearchTitle, type = 'shabad') { + const sessionKey = `${type}-${SearchID}`; const sessionItem = h( `li#session-${type}-${SearchID}`, {}, @@ -584,15 +586,16 @@ module.exports = { { onclick: ev => { const $panktee = ev.target; + const { resumePanktee } = sessionStatesList[sessionKey]; switch (type) { case 'bani': - this.loadBani(SearchID, LineID, true); + this.loadBani(SearchID, resumePanktee, true); break; case 'ceremony': - this.loadCeremony(SearchID, true); + this.loadCeremony(SearchID, resumePanktee, true); break; default: - this.loadShabad(SearchID, LineID); + this.loadShabad(SearchID, resumePanktee); } const sessionLines = this.$session.querySelectorAll('a.panktee'); Array.from(sessionLines).forEach(el => el.classList.remove('current')); @@ -608,8 +611,13 @@ module.exports = { Array.from(sessionLines).forEach(el => el.classList.remove('current')); // if the ShabadID of the clicked Panktee isn't in the sessionList variable, // add it to the variable - if (sessionList.indexOf(SearchID.toString()) < 0) { - sessionList.push(SearchID.toString()); + if (sessionList.indexOf(sessionKey) < 0) { + sessionList.push(sessionKey); + sessionStatesList[sessionKey] = { + resumePanktee: null, + mainPanktee: MainLineID, + seenPanktees: new Set(), + }; } else { // if the ShabadID is already in the session, just remove the HTMLElement, // and leave the sessionList @@ -667,7 +675,7 @@ module.exports = { } }, - async loadCeremony(ceremonyID, historyReload = false) { + async loadCeremony(ceremonyID, LineID = null, historyReload = false) { const $shabadList = this.$shabad || document.getElementById('shabad'); $shabadList.innerHTML = ''; $shabadList.dataset.bani = ''; @@ -694,6 +702,7 @@ module.exports = { row = banidb.loadVerses(rowDb.VerseIDRangeStart, rowDb.VerseIDRangeEnd); } + row.sessionKey = `ceremony-${ceremonyID}`; return row; }), ); @@ -702,7 +711,7 @@ module.exports = { if (!historyReload) { this.addToHistory(ceremonyID, null, nameOfCeremony, 'ceremony'); } - return this.printShabad(flatRows); + return this.printShabad(flatRows, null, LineID); } catch (error) { throw error; } @@ -734,7 +743,7 @@ module.exports = { const shabadID = `${rowsDb[0].Token || rowsDb[0].Bani.Token}-${baniLength}`; const nameOfBani = rowsDb[0].Gurmukhi || rowsDb[0].Bani.Gurmukhi; if (!historyReload) { - this.addToHistory(BaniID, LineID, nameOfBani, 'bani'); + this.addToHistory(BaniID, null, nameOfBani, 'bani'); } const rows = rowsDb .filter(rowDb => rowDb.MangalPosition !== blackListedMangalPosition) @@ -750,6 +759,8 @@ module.exports = { row.shabadID = rowDb.Bani.Token; } + row.sessionKey = `bani-${BaniID}`; + return row; }); return this.printShabad(rows, shabadID, LineID); @@ -798,15 +809,29 @@ module.exports = { return false; } + let seenClasses = ''; + const shabadState = sessionStatesList[line.sessionKey || `shabad-${line.ShabadID}`]; + if (shabadState && shabadState.resumePanktee) { + if (shabadState.seenPanktees.has(line.ID)) { + seenClasses = '.seen_check'; + } + if (shabadState.resumePanktee === line.ID) { + seenClasses += '.current'; + } + if (shabadState.mainPanktee === line.ID && !mainLineExists) { + seenClasses += '.main.seen_check'; + } + } else if (line.mainLine && !mainLineExists) { + seenClasses += '.main.current.seen_check'; + } + const shabadLine = h( `li#li_${line.lineCount}`, { 'data-line-count': line.lineCount, }, h( - `a#line${line.ID}.panktee.${englishHeading ? 'roman' : 'gurmukhi'}${ - line.mainLine && !mainLineExists ? '.current.main.seen_check' : '' - }`, + `a#line${line.ID}.panktee.${englishHeading ? 'roman' : 'gurmukhi'}${seenClasses}`, { 'data-line-id': line.ID, 'data-main-letters': line.MainLetters, @@ -819,6 +844,7 @@ module.exports = { }, printShabad(rows, ShabadID, LineID, start = 0) { + const shabadState = sessionStatesList[rows[0].sessionKey || `shabad-${ShabadID}`]; let lineID = LineID || rows[0].ID; const shabadID = ShabadID || rows[0].shabadID || (rows[0].Shabads ? rows[0].Shabads[0].ShabadID : ''); @@ -900,10 +926,17 @@ module.exports = { } }); + if (shabadState && !shabadState.mainPanktee) { + shabadState.mainPanktee = mainLine.ID; + } + // if there is a lineIDConflict make lineID the very first line in shabad. if (lineIDConflict) { lineID = document.querySelector(`#shabad > li:first-child > a`).dataset.lineId; shabad.querySelector(`#line${lineID}`).classList.add('current', 'main', 'seen_check'); + if (sessionStatesList[shabadID]) { + sessionStatesList[shabadID].seenPanktees.add(lineID); + } } const totalLines = rows.length; @@ -946,6 +979,10 @@ module.exports = { while (this.$session.firstChild) { this.$session.removeChild(this.$session.firstChild); sessionList.splice(0, sessionList.length); + // clear object and its properties + Object.getOwnPropertyNames(sessionStatesList).forEach(shabadID => { + delete sessionStatesList[shabadID]; + }); } }, @@ -976,11 +1013,13 @@ module.exports = { } */ const lines = this.$shabad.querySelectorAll('a.panktee'); + const shabadState = sessionStatesList[Line.sessionKey || `shabad-${ShabadID}`]; if (e.target.classList.contains('fa-home')) { // Change main line const $panktee = e.target.parentNode; Array.from(lines).forEach(el => el.classList.remove('main')); $panktee.classList.add('main', 'seen_check'); + shabadState.seenPanktees.add(LineID); } else if (e.target.classList.contains('panktee')) { // Change line to click target const $panktee = e.target; @@ -990,6 +1029,8 @@ module.exports = { Array.from(lines).forEach(el => el.classList.remove('current')); // Add 'current' and 'seen-check' to selected Panktee $panktee.classList.add('current', 'seen_check'); + shabadState.seenPanktees.add(LineID); + shabadState.resumePanktee = LineID; } this.checkAutoPlay(LineID); }, From 7d7b50ef31c946eaedbf62c84ea4dc91ef692980 Mon Sep 17 00:00:00 2001 From: inderpreet singh Date: Fri, 21 Jun 2019 18:31:36 -0700 Subject: [PATCH 3/7] changes if/else conditions for showing only one ceremony --- www/js/toolbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/toolbar.js b/www/js/toolbar.js index b884cab9d..e05ce1c6c 100644 --- a/www/js/toolbar.js +++ b/www/js/toolbar.js @@ -121,7 +121,7 @@ const getEnglishExp = token => { const printCeremonies = rows => { rows.forEach(row => { - if (row.Token !== 'anand' && row.Token !== 'death') { + if (row.Token == 'anandkaraj') { const $ceremony = h( `div.ceremony-pane#${row.Token}`, { From 0c0aa1091898a627e43f6a94d731d927fac8e14d Mon Sep 17 00:00:00 2001 From: inderpreet singh Date: Fri, 21 Jun 2019 18:32:27 -0700 Subject: [PATCH 4/7] fixes linting issue --- www/js/toolbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/toolbar.js b/www/js/toolbar.js index e05ce1c6c..c6f285430 100644 --- a/www/js/toolbar.js +++ b/www/js/toolbar.js @@ -121,7 +121,7 @@ const getEnglishExp = token => { const printCeremonies = rows => { rows.forEach(row => { - if (row.Token == 'anandkaraj') { + if (row.Token === 'anandkaraj') { const $ceremony = h( `div.ceremony-pane#${row.Token}`, { From 068704c9180d074917a6cc510f5d23cb9489be3b Mon Sep 17 00:00:00 2001 From: inderpreet singh Date: Fri, 21 Jun 2019 19:34:27 -0700 Subject: [PATCH 5/7] fixes the bug in SG with second display --- www/js/controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/controller.js b/www/js/controller.js index b106d210c..1f3a2d9c4 100644 --- a/www/js/controller.js +++ b/www/js/controller.js @@ -553,7 +553,7 @@ module.exports = { if (document.body.classList.contains('livefeed')) { showLinePayload.live = true; } - if (start === 0 || start === undefined) { + if (start === 0 || start === undefined || mode === 'append') { global.platform.ipc.send('show-line', showLinePayload); } }, From b497c88cb7619ebc740bdef9e6fb54def94721a1 Mon Sep 17 00:00:00 2001 From: Inder Singh Date: Mon, 24 Jun 2019 19:04:39 -0700 Subject: [PATCH 6/7] Viewer window edits (#674) * removes viewer window from full screen when presenter view is off * brings up viewer window in full screen everytime you switch to presenter mode * removes extra comment --- app.js | 11 +++++++++++ www/js/controller.js | 1 + 2 files changed, 12 insertions(+) diff --git a/app.js b/app.js index 67843d6ef..699910e23 100644 --- a/app.js +++ b/app.js @@ -459,6 +459,17 @@ ipcMain.on('show-text', (event, arg) => { } }); +ipcMain.on('presenter-view', (event, arg) => { + if (viewerWindow) { + if (!arg) { + viewerWindow.hide(); + } else { + viewerWindow.show(); + viewerWindow.setFullScreen(true); + } + } +}); + ipcMain.on('scroll-from-main', (event, arg) => { if (viewerWindow) { viewerWindow.webContents.send('send-scroll', arg); diff --git a/www/js/controller.js b/www/js/controller.js index 1f3a2d9c4..d7aba56ab 100644 --- a/www/js/controller.js +++ b/www/js/controller.js @@ -437,6 +437,7 @@ function checkPresenterView() { document.querySelector('#presenter-view-toggle').checked = inPresenterView; // hide header-tabs for non presenter view document.querySelector('.nav-header-tabs').classList.toggle('hidden', !inPresenterView); + global.platform.ipc.send('presenter-view', inPresenterView); } function reloadBani(resume = false) { From bf6624742b71dbc3f974eb3b2ff71c43949d4d57 Mon Sep 17 00:00:00 2001 From: maneetpaul Date: Mon, 24 Jun 2019 22:09:10 -0400 Subject: [PATCH 7/7] Update Changelog (#663) * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 196cd544f..330ca4250 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,9 @@ ## New Updates -### 5.2 - _190611_ +### 5.2 - _190617_ ### Added: -- We've made it easier than ever to have every shabad you need for an Anand Kaaraj in one place! Check out the new Ceremonies tab! - ![](./assets/img/help_images/desktop-ceremonies.png) - - Did you know SikhiToTheMax has keyboard shortcuts? - CTRL (or CMD for Mac) + / = Search bar - CTRL (or CMD for Mac) + 1 = Waheguru Slide @@ -15,6 +12,10 @@ - CTRL (or CMD for Mac) + 4 = Anand Sahib (Bhog) - CTRL (or CMD for Mac) + 5 = Help Menu - CTRL (or CMD for Mac) + 6 = Shortcut Legend + + +- Check out the new Ceremonies tab - we've put every Shabad you need for an Anand Kaaraj in one place! + ![](./assets/img/help_images/desktop-ceremonies.png) - Make your live streams stand out with all new Bani Overlay themes! ![](./assets/img/help_images/desktop-overlay-themes.png) @@ -23,6 +24,7 @@ ### Improved: - Expanded Vishraams to be supported on all themes +- If you switch back and forth between Shabads (or Banis), history will now remember where you left off - Fixed several bugs when using Chromecast - Bug fixes & UI enhancements