From 4f6c4bbdf48739a8694c45ca21c33bd0388f21c9 Mon Sep 17 00:00:00 2001 From: Divjot Singh Date: Tue, 30 Jan 2018 13:52:22 +0530 Subject: [PATCH 01/88] Revert "Merge changes of master to dev (#281)" (#282) This reverts commit 81a4ab599e047ed365a9bef58d1d3e72514added. --- package-lock.json | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index c7e593552..00e753dfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,16 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "JSONStream": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz", + "integrity": "sha1-kWV9/m/4V0gwZhMrRhi2Lo9Ih70=", + "dev": true, + "requires": { + "jsonparse": "0.0.5", + "through": "2.3.8" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -4251,15 +4261,6 @@ } } }, - "string_decoder": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", - "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -4271,6 +4272,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", + "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", @@ -5506,16 +5516,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "JSONStream": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz", - "integrity": "sha1-kWV9/m/4V0gwZhMrRhi2Lo9Ih70=", - "dev": true, - "requires": { - "jsonparse": "0.0.5", - "through": "2.3.8" - } - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -7964,15 +7964,6 @@ "xtend": "4.0.1" } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -7995,6 +7986,15 @@ "function-bind": "1.1.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", From 8243ddd100065cfdccabaa1a5053f122cfe89acd Mon Sep 17 00:00:00 2001 From: Divjot Singh Date: Wed, 31 Jan 2018 02:42:37 +0530 Subject: [PATCH 02/88] Use fetch over jQuery.ajax (#280) --- src/js/search.js | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/js/search.js b/src/js/search.js index 957bb98a0..99f0b1fa9 100644 --- a/src/js/search.js +++ b/src/js/search.js @@ -1,13 +1,14 @@ const $searchResults = document.querySelector('.search-results'); -const loadResults = ({ source, type, q, offset = null }) => - fetch(Khajana.buildApiUrl({ q, type, source, offset })) +function loadResults({ source, type, q, offset = null }) { + + return fetch(Khajana.buildApiUrl({ q, type, source, offset })) .then(r => r.json()) .then(({ pageinfo: { pageresults, nextpageoffset }, shabads }) => { [...document.querySelectorAll('h3.loading, li.load-more')] .forEach(el => el && el.parentNode - ? el.parentNode.removeChild(el) + ? el.parentNode.removeChild() : el.remove() ); @@ -17,7 +18,7 @@ const loadResults = ({ source, type, q, offset = null }) => break; } - // I'm feeling lucky + // I'm feeling lucky case 1: { document.body.classList.remove('loading'); const [{ shabad }] = shabads; @@ -27,9 +28,14 @@ const loadResults = ({ source, type, q, offset = null }) => default: { document.body.classList.remove('loading'); +<<<<<<< HEAD shabads.forEach(({ shabad }) => addSearchResult({ shabad, q, type, source })); +======= + + shabads.forEach(({ shabad }) => addSearchResult({ shabad, q, type, source })); +>>>>>>> Use fetch over jQuery.ajax (#280) if (nextpageoffset) { const loadMore = e => { @@ -50,7 +56,11 @@ const loadResults = ({ source, type, q, offset = null }) => }; $searchResults.appendChild( +<<<<<<< HEAD
  • +======= +
  • +>>>>>>> Use fetch over jQuery.ajax (#280) Load More
  • ); @@ -83,6 +93,10 @@ const loadResults = ({ source, type, q, offset = null }) => ); console.error(error); }); +<<<<<<< HEAD +======= +} +>>>>>>> Use fetch over jQuery.ajax (#280) function getShabadHyperLink({ shabad, q, type, source }) { return `/shabad?id=${shabad.shabadid}&q=${q}${type ? `&type=${type}` : ''}${source ? `&source=${source}` : ''}`; @@ -121,8 +135,13 @@ function addSearchResult({ shabad, q, type, source }) { {shabad.writer.english} {shabad.raag.english === 'No Raag' || shabad.raag.english === null +<<<<<<< HEAD ? '' : {shabad.raag.english} +======= + ? '' + : {shabad.raag.english} +>>>>>>> Use fetch over jQuery.ajax (#280) } @@ -134,10 +153,20 @@ function noResults() { $searchResults.appendChild(

    No results found

    ); } +<<<<<<< HEAD function fetchSearchResults() { const params = ['type', 'source', 'q']; const [type = 0, source = 'all', q = ''] = params.map(v => getParameterByName(v)); +======= +function fetchSearchResults () { + const params = ['type', 'source', 'q']; + const [type = 0, source = 'all', q = ''] = params.map(v => getParameterByName(v)); + + [...$searchResults.querySelectorAll('a.load')] + .forEach(el => el && el.addEventListener('click', () => loadResults({ source, type, q, offset: el.dataset.nextpage }))); + +>>>>>>> Use fetch over jQuery.ajax (#280) if (q === '') { $searchResults.appendChild(

    Please enter your query in the search bar above

    ); return; @@ -145,7 +174,11 @@ function fetchSearchResults() { document.body.classList.toggle('loading'); +<<<<<<< HEAD return loadResults({ type, source, q }); +======= + loadResults({ type, source, q }); +>>>>>>> Use fetch over jQuery.ajax (#280) } fetchSearchResults(); From 38b362056daccad4943a640a2baa8130a2182d0a Mon Sep 17 00:00:00 2001 From: Manjot Singh Date: Tue, 30 Jan 2018 18:10:46 -0800 Subject: [PATCH 03/88] Fix #148 help section (#277) * added help - still broken * working on help * completed help section * Use JSX for composition * added feedback link --- src/js/help.js | 110 +++++++++++++++++++++++--------------------- src/scss/style.scss | 3 +- 2 files changed, 59 insertions(+), 54 deletions(-) diff --git a/src/js/help.js b/src/js/help.js index e188c63cc..5cade2102 100644 --- a/src/js/help.js +++ b/src/js/help.js @@ -1,19 +1,20 @@ function Help() { const content = { Web: [ - [ 'How do I search for a shabad?', + [ + "How do I search for a shabad?", `After launching SikhiToTheMax, by default you can search for a shabad by entering the first letter of each word. For example, if the shabad is ਗੁਰੁ ਮੇਰੈ ਸੰਗਿ ਸਦਾ ਹੈ ਨਾਲੇ , you ' would enter "gmsshn". Alternatively, you can click on the gurmukhi keyboard icon and type in the letters manually.` ], [ - 'Can I separate the Gurbani from the English translations?', + "Can I separate the Gurbani from the English translations?", `When viewing a shabad or ang, click "Display Options" and then the "Split View" button in the drop down menu.` ], [ - 'What does the unicode button do?', + "What does the unicode button do?", `Unicode allows the Gumukhi text to be viewed without needing a pre-installed font. It will also allow you to copy and paste the text into vast variety of applications that you normally wouldn’t be able to do.` @@ -21,7 +22,7 @@ function Help() { ], Desktop: [ [ - 'Video Tutorial', + "Video Tutorial", `
    @@ -32,7 +33,7 @@ function Help() { ` ], [ - 'How do I install the desktop application?', + "How do I install the desktop application?", `You can install SikhiToTheMax (STTM) by visiting this website and choosing the Windows or macOS download link. After that, open the installer and follow @@ -41,7 +42,7 @@ function Help() { ` ], [ - 'How do I search for a shabad?', + "How do I search for a shabad?", ` After launching STTM, by default you can search for a shabad by entering the first letter of each word. For example, if the shabad is ਗੁਰੁ ਮੇਰੈ ਸੰਗਿ ਸਦਾ ਹੈ ਨਾਲੇ , you would enter "gmsshn".'" @@ -51,7 +52,7 @@ function Help() { ` ], [ - 'What do the different search types do?', + "What do the different search types do?", `
    • First Letter (Start) @@ -96,7 +97,7 @@ function Help() {
    ` ], [ - 'How do I connect STTM to a projector?', + "How do I connect STTM to a projector?", ` Plug in your computer to the projector or TV. Once you do this, go to your computer's display settings and change it to "Extended Desktop" (NOT mirroring). After that, launch @@ -106,93 +107,98 @@ function Help() { ` ], [ - 'How do I change the background color?', + "How do I change the background color?", `After launching STTM, click the icon for settings, and choose your theme. ` ], [ - 'Can you view the Gurbani in Larivaar?', + "Can you view the Gurbani in Larivaar?", `Yes! After launching STTM, click the icon for settings, and choose the Larivaar option. ` ], [ - 'How can I make the fonts on the screen smaller?', + "How can I make the fonts on the screen smaller?", `After launching STTM, click the icon for settings, and scroll down for options to adjust the font size. ` ], [ - 'Where can I see my previous shabads?', + "Where can I see my previous shabads?", `When using STTM in “Presenter View”, your history will appear in the bottom right quadrant. You can click any of the shabads in the list to bring them back up as your primary one. ` ], [ - 'How do I report a mistake?', + "How do I report a mistake?", `Visit SikhiToTheMax.org and click "Feedback" at the bottom of the page.` ] ] }; - const getTitle = question => question.split(' ').join('-').toLowerCase().replace(/[^a-z.\-]/g, '').substr(0, 50); + const getTitle = question => + question + .split(" ") + .join("-") + .toLowerCase() + .replace(/[^a-z.\-]/g, "") + .substr(0, 50); - const contentWithTitle = Object - .keys(content) - .reduce((o, header) => ({ + const contentWithTitle = Object.keys(content).reduce( + (o, header) => ({ ...o, - [header]: content[header].map(([question, answer]) => [getTitle(question), question, answer]), - }), {}); + [header]: content[header].map(([question, answer]) => [ + getTitle(question), + question, + answer + ]) + }), + {} + ); const help = ( -
    +

    Help

    -
    - { - Object.keys(contentWithTitle).map((header) => ( -
    -

    {header}

    - { - contentWithTitle[header].map(([title, question, answer]) => ( -
    -

    # {question}

    -
    {answer}
    -
    - )) - } -
    - )) - } + {Object.keys(contentWithTitle).map(header => ( +
    +

    {header}

    + {contentWithTitle[header].map(([title, question, answer]) => ( +
    +

    + # {question} +

    +
    {answer}
    +
    + ))} +
    + ))}
    -
    ); - document.getElementById('content-root').appendChild(help); + document.getElementById("content-root").appendChild(help); } Help(); diff --git a/src/scss/style.scss b/src/scss/style.scss index 8675d87c8..5d574fae2 100644 --- a/src/scss/style.scss +++ b/src/scss/style.scss @@ -15,8 +15,7 @@ "spinner", "help"; -html, -body { +html, body { scroll-behavior: smooth; } From c2e6a160e0555738021855c88081f64c0bd88bca Mon Sep 17 00:00:00 2001 From: prebhdevsingh Date: Wed, 31 Jan 2018 09:35:12 -0800 Subject: [PATCH 04/88] Fix #124 #196 - Add a copy button to the share menu & fix copy/tweet buttons * Fix #124 - adds a copy button to the share menu to copy short URL * Fix #124 - adds a copy button to the share menu to copy short URL added a utility function in main.js for copy text * Fix #124 - updated click handler * Use toast notifications, generic functions Fixes #196 * Style fixes --- src/js/main.js | 46 ++++++++++++++++++++++++++++++++++++++++ src/js/renderControls.js | 2 +- src/scss/_sharing.scss | 6 +++--- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/js/main.js b/src/js/main.js index 2aea7aedc..42040d915 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -298,6 +298,52 @@ const showToast = (text, delay = 2500) => new Promise((resolve) => { copyURLconfirm.innerText = text; copyURLconfirm.classList.remove('hidden'); +$search.onkeyup = function () { + const value = this.value; + const clearSearchToggle = document.querySelector('.clear-search-toggle'); + if (value.length > 0) { + clearSearchToggle.classList.add('active'); + } else { + clearSearchToggle.classList.remove('active'); + } + // Remove non-numeric characters for Ang search + if (parseInt($searchType.value, 10) === 5) { + forceSearchNumeric(); + } +}; + +const copyToClipboard = text => new Promise((resolve, reject) => { + try { + const textarea = document.createElement('textarea'); + textarea.textContent = text; + document.body.appendChild(textarea); + + const selection = document.getSelection(); + const range = document.createRange(); + range.selectNode(textarea); + selection.removeAllRanges(); + selection.addRange(range); + + const result = document.execCommand('copy'); + + selection.removeAllRanges(); + document.body.removeChild(textarea); + + if (result) { + resolve(); + } else { + throw new Error('Failed to copy'); + } + } catch (e) { + reject(e); + } +}); + +const showToast = (text, delay = 2500) => new Promise(resolve => { + const copyURLconfirm = document.getElementById('toast-notification'); + copyURLconfirm.innerText = text; + copyURLconfirm.classList.remove('hidden'); + setTimeout(() => { copyURLconfirm.classList.add('hidden'); resolve(); diff --git a/src/js/renderControls.js b/src/js/renderControls.js index d6ae3aaa9..41ca896ee 100644 --- a/src/js/renderControls.js +++ b/src/js/renderControls.js @@ -1,6 +1,6 @@ function renderControls() { return ( -