What are some of the Javascript discrepancies between iOS, Android and Desktop browsers?

My website has Javascript code that executes perfectly on desktop and android browsers, but won’t execute properly on any iOS browsers. Why is this and what are some of the Javascript discrepancies between iOS, Android and Desktop browsers that i should look out for when writing javascript code so that it will work on all browsers?

The Javascript still runs but it misses crucial functions/code which otherwise work fine on other devices. I can’t pinpoint where in my code it stops working because of that. My javscript is ES6 and uses webpack and firebase.

Any help would be appreciated.

Write to google sheet through javascript API not working with Google Identity Services

I’m using a google sheet API and I can read just fine from the google sheet, but I can’t write to it. From what I read, I needed to use Google Identity Services to login so I tried integrating it, but I still can’t get it to write to the sheet. I’m fairly sure I have everything setup correctly on console.cloud.google.com. Any help I can get would be greatly appreciated.

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<button id="authorize_button" onclick="handleAuthClick()">Authorize</button>
<button id="signout_button" onclick="handleSignoutClick()">Sign Out</button>
<pre id="content" style="white-space: pre-wrap;"></pre>
<form id="violationForm">
    <h3>Detention Report</h3>
    <label for="duration">Select Duration:</label>
    <select id="duration" name="duration">
        <option value="15">15 minutes</option>
        <option value="30">30 minutes</option>
    </select>
    <br><br>

    <label>Reasons for Report:</label>
    <ul>
        <li>
            <input type="checkbox" id="tardy" name="reason" value="tardy">
            <label for="followDirections">Tardy</label>
        </li>
        <li>
            <input type="checkbox" id="other" name="reason" value="Other">
            <label for="other">Other:</label>
            <input type="text" id="otherDescription" name="otherDescription" placeholder="Describe other reason">
        </li>
    </ul>
    <br>
    <input type="button" id="submitDetention" name="submitDetention" value="Submit Detention">
</form>

<script>
const CLIENT_ID = 'the client ID';
const SCOPES = 'https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email';
const discoveryUrl = 'https://sheets.googleapis.com/$discovery/rest?version=v4';
const redirectUri = 'https://thewebsiteImusing.com/callback';
const API_KEY = 'theAPIKey';
const SHEET_ID = 'theSheetID';
let tokenClient;
let gapiInited = false;
let gisInited = false;
var detentionStudents = []

////////////Authentication and Google API Specific Code///////////////
function gapiLoaded() {
    gapi.load('client', initializeGapiClient);
}
async function initializeGapiClient() {
    await gapi.client.init({
        apiKey: API_KEY,
    client_id: CLIENT_ID,
        discoveryDocs: [discoveryUrl],
        scope: SCOPES,
        redirect_uri: redirectUri,
    });
    gapiInited = true;
}

function gisLoaded() {
    tokenClient = google.accounts.oauth2.initTokenClient({
        client_id: CLIENT_ID,
        scope: SCOPES,
        callback: '', // defined later
    });
    gisInited = true;
}

function handleAuthClick() {
    tokenClient.callback = async (resp) => {
        if (resp.error !== undefined) {
            throw (resp);
        }
        document.getElementById('signout_button').style.visibility = 'visible';
        document.getElementById('authorize_button').innerText = 'Refresh';
        console.log('User signed in:', resp);
        // Continue with your logic after sign-in
    };

    if (gapi.client.getToken() === null) {
        // Prompt the user to select a Google Account and ask for consent to share their data
        // when establishing a new session.
        tokenClient.requestAccessToken({ prompt: 'consent' });
    } else {
        // Skip display of account chooser and consent dialog for an existing session.
        tokenClient.requestAccessToken({ prompt: '' });
    }
}

function handleSignoutClick() {
    const token = gapi.client.getToken();
    if (token !== null) {
        google.accounts.oauth2.revoke(token.access_token);
        gapi.client.setToken('');
        document.getElementById('authorize_button').innerText = 'Authorize';
        document.getElementById('signout_button').style.visibility = 'hidden';
    }
}

function submitDetentionRecord() {
    const rowData = ["John Doe", "today", "30", "tardy", "1st Period"];

    // Append values to the "detentionRecords" sheet
    appendValues(SHEET_ID, 'detentionRecords', 'RAW', [rowData], (response) => {
        console.log('Detention record submitted to Google Sheet:', response);
        // Optionally, you can clear the form or perform other actions after submission.
        alert(`The detention for ${currentStudent} was submitted`);
    });
}

function appendValues(spreadsheetId, range, valueInputOption, _values, callback) {
    let values = _values;
    const body = {
        values: values,
    };
    try {
        gapi.client.sheets.spreadsheets.values.append({
            spreadsheetId: spreadsheetId,
            range: range,
            valueInputOption: valueInputOption,
            resource: body,
        }).then((response) => {
            const result = response.result;
            console.log(`${result.updates.updatedCells} cells appended.`);
            if (callback) callback(response);
        });
    } catch (err) {
        console.error('Error appending values to Google Sheet:', err);
        alert('There was an error submitting the detention');
    }
}

// Attach the submitDetentionRecord function to the submit button
document.getElementById('submitDetention').addEventListener('click', submitDetentionRecord);

</script>


<script async defer src="https://apis.google.com/js/api.js" onload="gapiLoaded()"></script>
<script async defer src="https://accounts.google.com/gsi/client" onload="gisLoaded()"></script>
</body>
</html>

Discord bot says “The application did not respond” when using a command

I’m coding a discord bot and when running /ping:

const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Replies with Pong!'),
    async execute(interaction) {
        interaction.reply('Pong!');
    },
};

Whenever I run /ping, the bot says: The application did not respond.

The bot is supposed to reply Pong!. I’ve tried readding the bot but that did nothing. I have also tried changing the intents list.

How to detect end of an overflow on mobile when scrolling quickly?

On mobile you can “pull” the scrollable content and it keeps moving for a while by itself. How to detect when such movement has stopped?
ontouchmove event doesn’t get triggered while the content moves by itself.

Here is an example, I need to remove the “more content” banner when the user has scrolled to the left till the end.
I’m reading how much of the scrollable area is left by using the ontouchmove event. But since the event only gets triggered while the user is actually actively touch-moving the content, there is no way to read how much scrollable area is left.

If I scroll till the end while pressing the content, everything is good:

enter image description here

If I quickly “pull” it and it keeps scrolling by itself, the ontouchmove event doesn’t fire when reaching the end, so it’s impossible to detect that the end is reached:

enter image description here

function onTouchMove() {
  const node = document.getElementById("scroll-container");
  const overflownOnRight = Math.ceil(node.scrollLeft + node.offsetWidth) < node.scrollWidth;
  if (!overflownOnRight) {
    document.getElementById("info-banner").style.display = "none";
  } else {
    document.getElementById("info-banner").style.display = "block";
  }
}
.scroll-container {
  margin-top: 100px;
  width: 100%;
  height: 40px;
  overflow-y: auto;

  &::-webkit-scrollbar {
    height: 0;
    width: 0;
    display: none;
  }
}

.reference-point {
  height: 30px;
  width: 100%;
  border: 5px dotted pink;
}

.scrollable {
  width: 1200px;
  height: 100%;
  background: blue;
  display: flex;
}
<div id="scroll-container" ontouchmove="onTouchMove(event)" class="scroll-container shadowed">
  <div class="scrollable">
    <div class="reference-point">
    </div>
  </div>
</div>

<div id="info-banner">
  Scroll Right For More Content
</div>

Are numbers converted to strings by insertAdjacentHTML?

I’m using insertAdjacentHTML to inject forms containing values that are checked, upon post, by a server side function to ensure the values are numbers. This check is failing, and I’m trying to determine whether the issue is due to insertAdjacentHTML.

Based on its documentation, the insertAdjacentHTML text parameter holds “The string to be parsed as HTML or XML and inserted into the tree.”

Does this mean variables storing numbers are converted to strings? If so, what would be the proper approach for what I’ve attempted below?

I have a custom context menu that, on right-click, gets values related to the clicked object:

let selector = document.querySelector("#c-menu");
        
$(".cmenu").contextmenu(function() {
 dataID = parseInt($(this).attr("data-id"));
            
 dataTemplate = parseInt($(this).attr("data-template"));
            
 dataParent = encodeURIComponent($(this).attr("data-parent"));
 let dataParent_int = parseInt(dataParent);
            
 dataIndex = encodeURIComponent($(this).attr("data-index"));
 let dataIndex_int = parseInt(dataIndex);
            
 dataTitle = encodeURIComponent($(this).attr("data-title"));
 var dataTitle_decoded = decodeURIComponent(dataTitle);

Then, using a template condition related to the clicked object (which represents a webpage), form values are built:

  // Construct Query String to EDIT existing library node of Template 26
        
   var params_edit_tpl26 = { parent: dataParent_int, index: dataIndex_int, title: dataTitle_decoded, template: dataTemplate, };
   var queryString_edit_tpl26 = $.param(params_edit_tpl26);
            
  // Construct Query String to ADD a new library node of Template 26

  var params_add_tpl26 = { parent: dataID, };
  var queryString_add_tpl26 = $.param(params_add_tpl26);
            
 // Construct URL strings with parameters

 var formURLEdit_26     = 'edit-library-node?' + queryString_edit_tpl26;
 var formURLAdd_26      = 'add-library-node?' + queryString_add_tpl26;

Then the form HTML is concatenated and injected:

if (typeof dataTemplate === "number") { 
            
  if  ( dataTemplate === 26 ) {
                    
    selector.insertAdjacentHTML("afterbegin",  "<ul class='context-menu__items no-indent no-bullets'><li class='context-menu__item' data-role='edit'><form action='" + formURLEdit_26 + "' method='post' class='np_button_form' style='right:auto; bottom: auto;'><input type='hidden' name='np_existing' value='true'><input type='hidden' name='np_doc_id' value='" + dataID + "'><input type='submit' class='np_edit_this_button' name='submit' value='Edit Category'></form></li><li class='context-menu__item' data-role='add'><form action='" + formURLAdd_26 + "' method='post' class='np_button_form' style='right:auto; bottom: auto;'><input type='hidden' name='np_existing' value='false'><input type='hidden' name='np_doc_id' value='" + dataID + "'><input type='submit' class='np_edit_this_button' name='submit' value='Add Node'></form></li></ul>");
  
  // checks            
  console.log(typeof(dataID));
                    
  } else if ( dataTemplate === 29 ) {
                
    ...
                
  }
 }
});

How to pass modified data from child component to parent component in Next.js?

I’m currently learning Next.js and working on a small project. I have a Canvas component and a child component called Preview. In the Preview component, I’m manipulating data received from the parent (Canvas) and obtaining a new result. My question is, how can I pass this modified data back from the Preview component to the Canvas component?

Code Examples:

Canvas component:

// Canvas.js
'use client'
import Preview from '@/components/Preview'

const Canvas = (props) => {
    
    const demoData = {
        width: 50,
        height: 50
    }
    return(
        <div>
            <div><Preview data={demoData} /></div>
            {props.children}
        </div>
    )
}

export default Canvas

Preview component:

// Preview.js
const Preview = (props) => {
    /*
Manipulate data received from Canvas to obtain a new result
...
...
*/
    return (
        <div>
            {props.width}
            {props.height}
        </div>
    )
}

export default Preview

I’ve created a Canvas component with a child Preview component. In the Preview component, I manipulate the data received from the Canvas component. Now, I want to send this modified data back to the Canvas component.

JSDoc description not showing on function returned in object

I have a problem that when i return the border function inside the style object the parameter descriptions just say ANY. I know it works when returning just the function by itself but i want to organize by returning objects with a group of functions. Is there any way to to that?

var GDL = (function () {
    
    //border defualt
    let border_style = ["solid"]
    let border_width = [2]
    let border_color = "black"
    let border_radius = 0

    //style functions
    /**
     * Add border style to canvas. Array are 1 [all], 2 [sides, top and bottom] or 4 [left, top, right, bottom] long
     * @param {[String]} style 
     * @param {[Number]} width 
     * @param {string} color 
     * @param {Number} borderRadius 
     */
    function border(style = border_style, width = border_width, color = border_color, borderRadius = border_radius){

    }

    style = {border}
    return {style}
})()

let f = GDL
f.style.border()

I have tried to google if there is any way to keep JSDoc params when returning an object with functions but i couldn’t find anything. Also looked through simular questions but i could not get it to work

How do you disable change in radio button selection using keyboard arrows?

I have an HTML form with 6 radio buttons. Each radio button, when selected, makes an API call to the backend and fetches some data to populate the next select input in the form. If one selects a radio button and then holds the up or down arrow key, then the radio button selection cycles very rapidly and we see a massive number of API calls being made to the backend. Is there a way to disable the radio selection using either the up/down arrows? or do I have to prevent it through JavaScript?

Pagination with Nuxt UI

I’m trying to implement the pagination component from Nuxt UI, but I am unable to make it work..

I tried to read the docs and youtube, but nothing to be found. I don’t understand how to bind my data to the component.

<template>
        <div>
            <ul class="p-5">
            <li v-for="creator in creators" class="mb-5">
                <nuxt-link
                :key="creator.id"
                :to="`/creator/${creator.slug}`">
                <div class="creatorCard" :style="{ background: `url(${creator.banner}) center center no-repeat`, backgroundSize: `100% auto` }">
                    <div class="glassEffect">
                        <div class="text pl-5 items-end h-1 pb-2">
                            <p class="font-bold">{{ creator.label }}</p>
                            <p class="italic">{{ creator.ig }}</p>
                        </div>
                    </div>
                </div>
            </nuxt-link>
        </li>
    </ul>
    <div class="pb-4">
        <UPagination :ui="{ wrapper: 'justify-center'}" v-model="page" :page-count="7" :total="creators.length" />
    </div>
</div>
</template>


<script setup lang="ts">
const page = ref(1);

const creators = useCreators();

useHead({
  title: 'Creators',
})
</script>

How do I use standard HTML form validation while submitting a form with jQuery?

In a WordPress plugin, I am using jQuery to freeze the ‘Submit’ button once it’s been clicked, until loading is complete.
The code works, my issue is that I am then sending the form via jQuery and it skips the standard HTML checks (required fields, lengths, types,…).
I could code the form verification into my jQuery function but I would like to avoid that if possible.

Is there a better way to approach this?

My form looks something like this:

<form method="POST">
    <input type="text" name="account_name" value="Some Value" required>
    <button type="submit" onclick="my_function(this,'Saving...');">Save</button>
</form>

…and my JS:

function my_function(el,txt) {
    $(el).prop("disabled",true);
    $(el).html(txt);
    el.form.submit();
}

What happens here is that the “required” value in my input has no effect and the form is submitted also when that field is empty.
I’ve simplified things here, but this also applies to all other HTML checks, like minlength.

State value is resetting to its initalState when a new value is set using React

I have a simple App component that is handling the state of a value to show a header. App looks like:

function App() {
    const [isHeaderVisible, setIsHeaderVisible] = useState(false);

  return (
    <>
      <Router>
          <div>
              <Header isHeaderVisible={isHeaderVisible} />
              <Routes>
                  <Route path="/" element={<Home setIsHeaderVisible={setIsHeaderVisible} />} />
                  <Route path="/page" Component={SomeComponent} />
              </Routes>
          </div>
      </Router>
    </>
  )
}

export default App

This is the Header component:

interface HeaderProps {
  isHeaderVisible: boolean;
}
const Header: React.FC<HeaderProps> = ({ isHeaderVisible }) => {
  console.log("HERE", isHeaderVisible)

  return (
    <>
      {isHeaderVisible && (
        <header>
          <nav>
            <ul>
                <a href="/">Home</a>
                <a href="/about">About</a>
                <a href="/contact">Contact</a>
            </ul>
          </nav>
        </header>
      )}
    </>
  );
};

export default Header;

I’m using an onClick function to toggle if isHeaderVisible is True in the Home component:

interface HomeProps {
  setIsHeaderVisible: React.Dispatch<React.SetStateAction<boolean>>;
}
const Home: React.FC<HomeProps> = ({ setIsHeaderVisible }) => {

    const handleLogoClick = () => {
    setIsHeaderVisible(true);
  };


  return (
      <div>
        <a href="/here" onClick={handleLogoClick}>
          <img src={logo} alt="Logo" />
        </a>
      </div>
  );
};

export default Home;

When the logo is clicked, I can see isHeaderVisible being set to true but it then changes back to the initialState of false. Is this caused by the rendering the header when isHeaderVisible is set to True?

Angular 7 build failed

Angular 7, npm 5.5.1 node 8.9.0
terminal

npm run build:test

[email protected] build:test C:Projectsfff
ng build –aot –build-optimizer –output-hashing=all

11% building modules 10/17 modules 7 active …fffsrclibcsscomponent.cssBrowserslist: caniuse-lite is outdated. Please run next command npm update
92% after chunk asset optimization SourceMapDevToolPlugin vendor.252af5e4ca571811ec29.js generate SourceMap
<— Last few GCs —>

[11300:000002C0DD75A2C0] 164886 ms: Mark-sweep 1412.1 (1557.3) -> 1412.1 (1519.3) MB, 673.1 / 0.0 ms last resort GC in old space requested
[11300:000002C0DD75A2C0] 165582 ms: Mark-sweep 1412.1 (1519.3) -> 1412.1 (1511.3) MB, 696.0 / 0.0 ms last resort GC in old space requested

<— JS stacktrace —>

==== JS stack trace =========================================

Security context: 0000000EC2725EC1
1: /* anonymous */ [C:Projectsfffnode_moduleswebpack-sourcesnode_modulessource-maplibsource-node.js:~342] [pc=00000111AF908CFC](this=000001C78768BE21 ,chunk=000002CFC1F07C09 <String[4]: /**n>,original=0000020414F69E59 )
2: SourceNode_walk [C:Projectsfff…

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed – JavaScript heap out of memory
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! [email protected] build:test: ng build --aot --build-optimizer --output-hashing=all
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the [email protected] build:test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersfffAppDataRoamingnpm-cache_logs2023-11-30T20_35_32_692Z-debug.log

log file

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli   'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build:test' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild:test', 'build:test', 'postbuild:test' ]
5 info lifecycle [email protected]~prebuild:test: [email protected]
6 info lifecycle [email protected]~build:test: [email protected]
7 verbose lifecycle [email protected]~build:test: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build:test: PATH: C:UsersSalamandraAppDataRoamingnvmv8.9.0node_modulesnpmbinnode-gyp-bin;C:Projectsfffnode_modules.bin;C:Usersfffbin;C:Program FilesGitmingw64bin;C:Program FilesGitusrlocalbin;C:Program FilesGitusrbin;C:Program FilesGitusrbin;C:Program FilesGitmingw64bin;C:Program FilesGitusrbin;C:Usersfffbin;C:Program Files (x86)Common FilesOracleJavajavapath;C:Python27;C:Python27Scripts;C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.7bin;C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.7libnvvp;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Filesdotnet;C:Program FilesGitcmd;C:ProgramDatachocolateybin;C:Program FilesNVIDIA CorporationNsight Compute 2022.2.0;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;C:UsersfffAppDataRoamingnvm;C:Program Filesnodejs;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program FilesDockerDockerresourcesbin;C:Program FilesPowerShell7;C:UsersSalamandraAppDataLocalProgramsPythonPython310Scripts;C:UsersSalamandraAppDataLocalProgramsPythonPython310;C:UsersSalamandraanaconda3;C:UsersSalamandraanaconda3Librarymingw-w64bin;C:Usersfffanaconda3Libraryusrbin;C:Usersfffanaconda3Librarybin;C:Usersfffanaconda3Scripts;C:UsersfffAppDataLocalMicrosoftWindowsApps;C:UsersfffAppDataLocalProgramsMicrosoft VS Codebin;C:UsersfffAppDataRoamingnpm;C:UsersfffAppDataLocalGitHubDesktopbin;C:UsersfffAppDataRoamingnvm;C:Program Filesnodejs;C:Usersfff.dotnettools;C:Program Files (x86)Nmap;C:Program FilesGitusrbinvendor_perl;C:Program FilesGitusrbincore_perl
9 verbose lifecycle [email protected]~build:test: CWD: C:ProjectsSoldOutgitlab_soldout_frontsoldout_front
10 silly lifecycle [email protected]~build:test: Args: [ '/d /s /c',
10 silly lifecycle   'ng build  --aot --build-optimizer --output-hashing=all' ]
11 silly lifecycle [email protected]~build:test: Returned: code: 3  signal: null
12 info lifecycle [email protected]~build:test: Failed to exec build:test script
13 verbose stack Error: [email protected] build:test: `ng build  --aot --build-optimizer --output-hashing=all`
13 verbose stack Exit status 3
13 verbose stack     at EventEmitter.<anonymous> (C:UsersfffAppDataRoamingnvmv8.9.0node_modulesnpmnode_modulesnpm-lifecycleindex.js:280:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:UsersfffAppDataRoamingnvmv8.9.0node_modulesnpmnode_modulesnpm-lifecyclelibspawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd C:Projectsfff
16 verbose Windows_NT 10.0.22631
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build:test"
18 verbose node v8.9.0
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 3
22 error [email protected] build:test: `ng build  --aot --build-optimizer --output-hashing=all`
22 error Exit status 3
23 error Failed at the [email protected] build:test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 3, true ]

angular.json
"build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/browser", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.app.json", "assets": [ { "glob": "**/*", "input": "node_modules/leaflet/dist/images", "output": "leaflet/" }, "src/favicon.ico", "src/assets", "src/robots.txt", "src/sp-push-worker-fb.js" ], "styles": [ "node_modules/slick-carousel/slick/slick.scss", "node_modules/snazzy-info-window/dist/snazzy-info-window.css", "src/scss/styles.scss", "node_modules/leaflet/dist/leaflet.css", "src/lib/css/component.css", "node_modules/swiper/css/swiper.css", "node_modules/aos/dist/aos.css" ], "scripts": [ "node_modules/jquery/dist/jquery.min.js", "node_modules/slick-carousel/slick/slick.min.js", "node_modules/bootstrap/dist/js/bootstrap.js", "src/lib/js/modernizr.custom.js", "src/lib/js/jquery.dlmenu.js", "node_modules/swiper/js/swiper.min.js" ] }, "configurations": { "production": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" }, { "replace": "src/index.html", "with": "src/index.prod.html" } ], "optimization": true, "outputHashing": "all", "sourceMap": false, "extractCss": true, "namedChunks": false, "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, "budgets": [ { "type": "initial", "maximumWarning": "2mb", "maximumError": "5mb" } ] } }
deps
"private": true, "dependencies": { "@agm/core": "^1.0.0-beta.5", "@agm/snazzy-info-window": "^1.0.0-beta.5", "@angular/animations": "^7.0.4", "@angular/cdk": "~7.3.7", "@angular/common": "~7.0.0", "@angular/compiler": "~7.0.0", "@angular/core": "~7.0.0", "@angular/forms": "~7.0.0", "@angular/http": "~7.0.0", "@angular/material": "~7.3.7", "@angular/platform-browser": "~7.0.0", "@angular/platform-browser-dynamic": "~7.0.0", "@angular/platform-server": "~7.0.0", "@angular/router": "~7.0.0", "@asymmetrik/ngx-leaflet": "^5.0.2", "@biesbjerg/ngx-translate-extract": "^2.3.4", "@ngrx/effects": "^7.4.0", "@ngrx/store": "^7.4.0", "@ngrx/store-devtools": "^7.4.0", "@nguniversal/common": "^8.2.6", "@nguniversal/express-engine": "^7.1.1", "@nguniversal/module-map-ngfactory-loader": "0.0.0", "@ngx-translate/core": "^11.0.1", "@ngx-translate/http-loader": "^4.0.0", "@types/google.accounts": "^0.0.14", "@types/leaflet": "^1.5.2", "@types/moment": "^2.13.0", "angular2-multiselect-dropdown": "^4.6.3", "angular2-text-mask": "^9.0.0", "aos": "^3.0.0-beta.6", "bootstrap": "^4.3.1", "core-js": "^2.5.4", "express": "^4.15.2", "hammerjs": "^2.0.8", "jquery": "^3.4.0", "leaflet": "^1.5.1", "localstorage-polyfill": "^1.0.1", "moment": "^2.24.0", "net": "^1.0.2", "ngx-barcode": "^0.2.4", "ngx-image-cropper": "^1.3.9", "ngx-pinch-zoom": "^1.2.5", "ngx-plyr": "^1.1.1", "ngx-slick-carousel": "^0.4.4", "node-sass": "^4.13.1", "panzoom": "^9.2.1", "plyr": "^3.4.7", "rxjs": "~6.3.3", "saturn-datepicker": "7.3.0", "sitemap-generator-cli": "^4.3.0", "slick-carousel": "^1.8.1", "snazzy-info-window": "^1.1.1", "sockjs-client": "^1.3.0", "stompjs": "^2.3.3", "svg-pan-zoom": "github:ariutta/svg-pan-zoom", "swiper": "^5.2.1", "zone.js": "~0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.10.0", "@angular/cli": "~7.0.3", "@angular/compiler-cli": "~7.0.0", "@angular/language-service": "~7.0.0", "@types/jasmine": "~2.8.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "~4.5.0", "custom-cursor.js": "^1.0.6", "husky": "^1.3.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~3.0.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~1.1.2", "karma-jasmine-html-reporter": "^0.2.2", "ngrx-store-freeze": "^0.2.4", "protractor": "~5.4.0", "ts-loader": "^5.2.0", "ts-node": "~7.0.0", "tslint": "~5.11.0", "tslint-eslint-rules": "^5.4.0", "typescript": "~3.1.1", "webpack-cli": "^3.1.0" } }

node –max_old_space_size=4096 is not working
build with –prod is working

Apps Script Time Based Conditional Formatting

My apologies if I don’t word this perfectly as I am a novice coder. Using Googles Apps Script I am trying to setup a system to conditionally format cells within Google Sheets. This is for a system that will check admission dates of physicians from a .CSV and check the most recent MD or NP treatment date. For the first 90 days since admission a visit needs to occur in the 0-30 range, the 30-60 range, and the 60-90 range. My problem is with writing code that will check whether the last MD treatment date is within a range of 30-60 days from the admission.

function applyFilter(p, data) {
//setting up the admission days by pulling from the .csv and then calculating how many days since 
let dateAdmissionDate = new Date(p.admissionDate);
console.log('dateAdmissionDate:', dateAdmissionDate);
let today = new Date();
let AdmissionDays = Math.floor((today.getTime() - dateAdmissionDate.getTime()) / (24 * 60 * 60 * 1000));

//setting up the MDtreatmentdays and NP treatment days by pulling the last treatment dates from the .csv and then seeing how many days from today its been
let dateLastMDTreatmentDate = new Date(p.lastMDTreatmentDate);
let dateLastNPTreatmentDate = new Date(p.lastNPTreatmentDate ? p.lastNPTreatmentDate : p.admissionDate);
var MDTreatmentDays = Math.floor((today.getTime() - dateLastMDTreatmentDate.getTime()) / (24 * 60 * 60 * 1000));
  var NPTreatmentDays = Math.floor((today.getTime() - dateLastNPTreatmentDate.getTime()) / (24 * 60 * 60 * 1000));

//if its past admission day 40 and before day 50 and there is a there is only an MD treatment day in the admission days 0-30 then its time to warn the MD cell so the MD will know to start a visit

  if (AdmissionDays >= 40 && AdmissionDays <= 50 && MDTreatmentDays >= 10 && MDTreatmentDays <= 20) {
    console.log('filter rule 4 activated');
    out.colors[p.lastMDTreatmentDateCol] = color_warn;
    out.notes[p.lastMDTreatmentDateCol] = 'A visit needs to occur every 30 days for the initial 90 days. Admission ' + AdmissionDays + ' days ago. It has been ' + MDTreatmentDays + ' days since the last MD visit';
    out.skip = false;
  }

My issue with the code as it stands is if its admission day 45 and a MD visit occurred 11 days ago on day 34 this code would erroneously highlight it. Or if its admission day 40 and there was a MD visit 10 days ago it would erroneously highlight it. I figure I need some sort of iterative way of going about this but again given my coding novice I cant figure out a solution. The code does run in its current aspect I’m just finding conditional formatting logic rules to be beyond my understanding.

What is the correct syntax to execute a SQL Like statement with param using sql-template-tag?

What is the correct synatx in order to perform a LIKE statement using sql-template-tag and with a param?

This is an example statement:

export function deleteTickets(ticketId: string) {
  const query = sql`DELETE FROM ticket.tickets WHERE tickets.uuid LIKE ${ticketId}%`;
  return execute(ticketDb, query);
}

However, the above statement throws an error stating you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%' at line 1

When I then try to wrap in quotes the param the and % like so, then it doesn’t acknowledge the param, it replaces the param values as a ? so it won’t delete the correct entry as it’s looking for ? as ticketId.

export function deleteTickets(ticketId: string) {
  const query = sql`DELETE FROM ticket.tickets WHERE tickets.uuid LIKE '${ticketId}%'`;
  return execute(ticketDb, query);
}

How to compare two objects of array?

I have two objects of array as follows:

var before = [
  {ComputerName: "A", inX: true, inY: true},
  {ComputerName: "B", inX: true, inY: true},
]

var after = [
  {ComputerName: "A", inX: true, inY: true},
  {ComputerName: "B", inX: false, inY: true},
  {ComputerName: "C", inX: true, inY: true},
]

I want to detect the new computer. At the same time, I want to compare the “same ComputerName” and find the difference.

In the above example, the result is:

// New Computer Found
{ComputerName: "C", inX: true, inY: true}

// Changed
{ComputerName: "B", inX: false, inY: true}

Here is what I have done:

if(before.length < after.length) {
  newAssets = after.filter((afterAsset) => !before.some((beforeAsset) => beforeAsset.ComputerName === afterAsset.ComputerName)
} else {
  // Compare inX
  // Compare inY
  // Find diff
}

Please advise.