cordova-diagnostic-plugin: cordova.plugins.diagnostic.isLocationAuthorized Always returns NOT_REQUESTED Android 14

I am using cordova-diagnostic-plugin to ask the customer to allow their location access. But it always returns NOT_REQUESTED. I think there is a problem with my s. Here is the list of my I can’t find what is missing

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
     <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"/>
     <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>

Node js cookie parser, i am not getting cookies

I am having problem that I cannot find the cookies after sending them to the frontend.

//server js
const express = require('express');
const app = express()
const connect = require('./backend/db/dbConnect')
const cors = require('cors');
const cookieParser = require('cookie-parser');
connect()

app.use(cors({
    origin: 'http://localhost:5173',
    credentials: "include",
})); 
app.use(express.json());
app.use(cookieParser());
app.use(function(req, res, next) {
    res.header('Access-Control-Allow-Origin', 'http://localhost:5173');
    res.header('Access-Control-Allow-Credentials', true);
    res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    next();
  });

app.use('/api/v1', require('./backend/routes/route') )

app.listen(3000, ()=>{console.log('server on http://localhost:3000');})
//route js
const {refreshToken} = require('../controller/userController');
router.route('/refreshtoken').post(refreshToken);

controller.js

// @ for login user
const loginUser = asyncHandler(async (req, res) => {
    console.log(req.body);
    try {
        const { userEmail, password } = req.body;
        
        const foundUser = await userScema.findOne({ email: userEmail });
        if (!foundUser) return res.status(400).json({ success: false, message: "Useremail or password is incorrect." });


        const isPasswordMatch = await bcrypt.compare(password, foundUser.password);
        if (!isPasswordMatch) return res.status(400).json({ success: false, message: "Useremail or password is incorrect." });

        const accessToken = jwt.sign({ userId: foundUser._id }, JWT_SECRET_KEY, { expiresIn: '15m' });
        const refreshToken = jwt.sign({ userId: foundUser._id }, JWT_REFRESH_KEY, { expiresIn: '7d' });


        res.cookie('refreshToken', refreshToken);  // i cannot find this cookis
        res.cookie("hello","world") // also this cookies

        res.status(201).json({ success: true, accessToken: accessToken, });
        console.log("Set-Cookie Headers: ", res.getHeaders()['set-cookie']);

    } catch (err) {
        res.status(400).json({ success: false, error: "Server error." });
    }
});




const refreshToken = (req, res) => {
    const { refreshToken } = req.cookies;
    console.log(req);
    if (!refreshToken) return res.status(401).json({ error: "Unauthorized" });

    jwt.verify(refreshToken, JWT_REFRESH_KEY, (err, user) => {
        if (err) return res.status(403).json({success:false, error: "Invalid refresh token" });

        const newAccessToken = jwt.sign({ userId: user.userId }, JWT_SECRET_KEY, { expiresIn: '15m' });
        res.json({ accessToken: newAccessToken });
    });
};

this is the log of when logging in

// @logs on console
# [nodemon] starting `node server.js`
# server on http://localhost:3000
# enstablish db connection on 127.0.0.1
# { userEmail: '[email protected]', password: 'dave' }
# Set-Cookie Headers:  [ 'refreshToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NmY4MDEzOGRjZGY1NWM2ZTUwODI2MTIiLCJpYXQiOjE3Mjc1MzU4OTQsImV4cCI6MTcyODE0MDY5NH0.5rOiG0JrKPnD8rzXf8M77PjPtkHJ41hB2Rif_L-aZhE; Path=/', 'hello=world; Path=/']

this is the console log when try to go to the route “/refreshtoken” from frontend

# cookies: [Object: null prototype] {},
#  signedCookies: [Object: null prototype] {},
#  route: Route {
#    path: '/refreshtoken',
#    stack: [ [Layer] ],
#    methods: { post: true }
#  },

enter image description here

first i am trying to get cookies in the front end and it is not genarating, i think somthing is worng in server, the cookie is sending but not getting,Can anyone help me please!!!

A Ruler component Made with vuejs is glitchy and markers appear and disappear

i was making a ruler component to use in a simple photo editing tool and i implemented the zooming part it is supposed to get more detailed when you zoom in like fractals and less detailed when you zoom out but for some reason the elements appear and disappear when you zoom in in different zoom levels what i have noticed is that the div elements are still there but there width seems to become 0 so suddenly could this i don’t have a single clue that is happening
here is my component

<script setup>
import { onMounted, ref, watch, computed } from "vue";
import { canvasContainer, tabsContainer } from "../cglobals";

const MIN_ZOOM = 0.5;
const MAX_ZOOM = 10;
const MIN_INTERVAL = 10; // Minimum interval for numbers

const props = defineProps({
  horizontal: {
    type: Boolean,
    default: true,
  },
  zoom: {
    type: Number,
    default: 1,
  },
});

const rulerBody = ref(null);
const markers = ref([]);

function clampZoom(zoom) {
  return Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, zoom));
}

const computedMarkers = computed(() => {
  const zoomLevel = clampZoom(props.zoom);
  const interval = MIN_INTERVAL * zoomLevel;
  const rulerWidth = rulerBody.value ? rulerBody.value.getBoundingClientRect().width : 0;
  const maxStepCount = Math.floor(rulerWidth / interval);
  const stepValue = 100 / zoomLevel; // Adjust step value based on zoom level

  const newMarkers = [];
  for (let i = 0; i <= maxStepCount; i++) {
    newMarkers.push({
      isNumbered: i % 10 === 0,
      value: (i * stepValue).toFixed(0),
      marginLeft: i === 0 ? '0px' : `${interval}px`,
    });
  }
  return newMarkers;
});

onMounted(() => {
  watch(canvasContainer, (newVal) => {
    if (newVal && rulerBody.value) {
      rulerBody.value.style.width = `${canvasContainer.value.offsetWidth}px`;
      rulerBody.value.style.marginTop = `${tabsContainer.value.offsetHeight}px`;
    }
  });
  watch(props, () => {
    markers.value = computedMarkers.value;
  });
  watch(() => props.zoom, () => {
    markers.value = computedMarkers.value;
  });
});
</script>

<template>
  <div ref="rulerBody" class="rulerBody h-7 absolute">
    <div v-for="(marker, index) in markers" :key="index" :class="['smallmarker', { numberedmarker: marker.isNumbered }]" :style="{ marginLeft: marker.marginLeft }">
      <div v-if="marker.isNumbered" class="numbermarker">{{ marker.value }}</div>
    </div>
  </div>
</template>

<style lang="scss">
@import "../../styles/colors";

.rulerBody {
  background: transparent;
  @apply border-b border-gray-400 relative flex ;
  .smallmarker {
    @apply h-3 bg-white;
    width: 1px !important; // Ensure the width is 1px
    position: relative;
  }
  .numberedmarker {
    height: 5px !important; // Make numbered markers longer
  }
  .numbermarker {
    position: absolute;
    top: -20px; // Adjust as needed
    left: -5px; // Adjust as needed
    color: white;
    font-size: 10px;
    height: 30px;
  }
}
</style>

sometimes its like this
sometimes like this in some zoom levels
some times its like this
sometimes like this in other zoom levels

if anyone has a fix or a problem they see help me out

i was expecting for the ruler to resize its detail level based on the zoom property and become detailed like 100,120,140,160 and when you zoom out it should be like 100, 1000, 2000, 3000

Define preferred position for line break

Is there any way, preferably using CSS, to define a preferred place for a line break under the condition that the whole text will not break into more than 2 lines?

Let’s say we have a sentence like this:

This is the rather lengthy main clause, but here's a sub clause.

I want to break the sentence at the comma.

But I do not want to have it break into a third line if there’s not enough horizontal space. In this case, my forced line break should just be ignored.

// wide screen (perfect):

| This is the rather lengthy main clause,                 |
| but here's a sub clause.                                |


// narrow screen (bad):

| This is the rather lengthy main  |
| clause,                          |
| but here's a sub clause.         |


// narrow screen (good):

| This is the rather lengthy main  |
| clause, but here's a sub clause. |

How would I go about this?

Visibility of data in shared array buffer after using postMessage() with web worker

I am using a web worker to process some data for me. The flow goes like this: main thread writes to a shared array buffer, then once done writing, uses postMessage to send the buffer to the webworker. The main thread then waits (does not read from or write to the buffer) until receiving a message back from the worker. The web worker upon receiving the message with the shared array buffer reads the data, does some processing, writes the processed data to the shared array buffer, then uses postMessage to post the shared array buffer back to the main thread. The main thread upon receiving the message, reads from the buffer.

My question is, does postMessage guarantee that the shared array buffer has up to date information visible on the worker and main threads without using atomics? I know atomics are needed for simultaneous read and writes, but in my case there are no simultaneous read and writes, and my understanding is that postMessage ensures that the state of the data at that point in time is made up-to-date and visible on the receiving end without needing atomics. Is my understanding correct?

In the application, the reading and writing is performance critical, so while I know using atomics for each read and write will for sure work, if I can avoid the overhead of atomics that would be ideal.

Tabular JS how to get pagination click from AJAX/FETCH

I would like to know how to get the current filters and the clicked page when I click on the pagination area, so that they can be sent as “params” via AJAX?

When I filter my options, it correctly generates an AJAX fetch with the data (but the current page is missing).

However, when I click on the pagination, no fetch is triggered, and I can’t figure out where the issue comes from.

Thank you for your valuable help.
Doc: https://tabulator.info/examples/4.1#pagination

I would like to get the filters + the clicked page via fetch when I click on either the pagination or the filters.

This is my code:

let table = new Tabulator("#example-table", {
    height:"100%",
    placeholder:"No Datas",
    layout:"fitColumns",
    sortMode:"remote",
    filterMode:"remote",
    headerFilterLiveFilterDelay:600,
    pagination:"remote",
    ajaxURL:"http://127.0.0.1:5500/file.json",
    ajaxParams:{token:"ABC123"},
    ajaxConfig:"GET",
    ajaxContentType:"json",
    persistence:false,
    columnDefaults:{
        tooltip:true,
    },
    paginationSize:5,
    paginationButtonCount:4,
    paginationSizeSelector:[5,10,20,50,100,200],
    rowHeader:{headerSort:false, resizable: false, frozen:true, headerHozAlign:"center", hozAlign:"center", formatter:"rowSelection", titleFormatter:"rowSelection", cellClick:function(e, cell){
      cell.getRow().toggleSelect();
    }},
    paginationCounter:function(pageSize, currentRow, currentPage, totalRows, totalPages){
        //console.log(pageSize, currentRow, currentPage, totalRows, totalPages)
    },
    ajaxURLGenerator:function(url, config, params){
        return url + "?params=" + encodeURI(JSON.stringify(params));
    },
    movableColumns:false,
    movableRows: false,
    columns:[
        {title:"id", field:"id", width:150, headerFilter:"input"},
        {title:"Name", field:"name", width:150, headerFilter:"input"},
        {title:"Progress", field:"progress", sorter:"number", hozAlign:"left", formatter:"progress", editable:true, headerSort:true, headerFilter:"input"},
        {title:"Couleurs", field:"col", headerFilter:"input"},
        {title:"Dates", field:"dob", headerFilter:"input"}
    ],
    printAsHtml:true,
    printHeader:"<h1>Example Table Header<h1>",
    printFooter:"<h2>Example Table Footer<h2>",
    langs:{
        "fr":{
            "pagination":{
                "first":"Premier",
                "first_title":"Première Page",
                "last":"Dernier",
                "last_title":"Dernière Page",
                "prev":"Précédent",
                "prev_title":"Page Précédente",
                "next":"Suivant",
                "next_title":"Page Suivante",
                "all":"Toute",
                "page_size":"Affichage",
            },
        }
    }
});

/**
 * Trigger Actions Table
 */
document.getElementById("print-table").addEventListener("click", function(){
    table.print(false, true);
});

/**
 * Initialize table after is fully loaded
 */
table.on("tableBuilt", () => {
    table.setLocale("fr");
      //  console.log(table.getPage());
});

Use ajax generator for send pagination.. or detect click + filters nothing see

Supabase,Postgresql. How to filter array of objects stored as JSON in a column

I have a column in a view called all_devices of type json. Each row stores arrays of objects that have this structure:

[
  {
    "id": 1,
    "device_type": 3,
    "device_name": "AC",
    "is_on": false
  },
  {
    "id": 1,
    "device_type": 0,
    "device_name": "Light Bulb",
    "is_on": false
  },
  {
    "id": 1,
    "device_type": 2,
    "device_name": "TV",
    "is_on": false
  },
  {
    "id": 1,
    "device_type": 1,
    "device_name": "Carbon Dioxide Alarm",
    "is_on": false
  }
]

I use js supabase client and what I want to achieve is to filter array of objects to get devices with device_type that equal 0. I want to get this done for each row so I will get only devices with a certain type for each room.

I tried with something like this:

const { data } = await supabase.from(xyz).select(`id,label,all_devices`).eq('all_devices ->> device_type', 0);
   ```
   but it just returns me an empty array.

Async/Await Not Working with Redux Dispatch Function in React

in this code snippet I want to know async and await not working why

this code in my component I am sure that is no errors

  const {success, loading, error} = useSelector(
    (state) => state.loginReducer
  );


 const formik = useFormik({
    initialValues,
    validationSchema,
    onSubmit: async (values) => {
      await dispatch(login(values));
      console.log(success);
    },
  });

this is the slice

import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import axios from "axios";

const initialState = {
  token: localStorage.getItem("token"),
  loading: false,
  error: null,
  success: false,
};

export const login = createAsyncThunk("login/login", async (values) => {
  const { data } = await axios.post(
    "https://note-sigma-black.vercel.app/api/v1/users/signIn",
    values
  );
  return data;
});

const loginSlice = createSlice({
  name: "login",
  initialState,
  extraReducers: function (builder) {
    builder.addCase(login.pending, (state) => {
      state.loading = true;
    });
    builder.addCase(login.rejected, (state, action) => {
      state.loading = false;
      state.error = action.error.message;
    });
    builder.addCase(login.fulfilled, (state, action) => {
      state.loading = false;
      state.token = action.payload.token;
      state.success = true;
      localStorage.setItem("token", action.payload.token);
    });
  },
});

export default loginSlice.reducer;

i expect that while i dispatch a promise function async and await should wor

HTML5 enable Previous/Next track when playing Video/Audio

I’m trying to build a custom video player with HTML/JS. I’ve already made two buttons that will load the previous/next track by using <button> tag. However, I want the system to recognize that there are previous/next tracks available as well.

That is, when I’m playing music from Spotify or videos from YouTube, my Chrome browser shows things like this with prev/next button enabled.

screenshot1

Or something like this appears on my Mac’s status bar, again with prev/next button enabled.

screenshot2

However, when I load videos with my HTML these buttons are greyed out and disabled.

I’ve tried adding multiple sources inside a <video> tag, and making a playlist with <ul>/<li> tags with no luck. I’m not even sure if that’s related to my problem. Is it even true that I need to build a playlist to accomplish what I want? I want to know in what condition the system recognizes that there are previous/next track available.

Problem with onlick() or any other function is not working on exact section [closed]

Please, have a look at website. first.
https://www.one65sf.com/index2_upwork.html

Now. Read my below text to help me better.

Client Requirements..

The logos should open up a modal, similar to the “Order Now” modal, and all the information for each logo location that is currently in frame should be within the modal.


if you click on Order now button at homepage, pop-up modal appears. I want exact same thing, when someone click on image logos, right side to the building.

and why? right side logos getting disturbed on some phones like, Iphone XR and some others, rest are fine.
I don’t understand why?

Any help would be appreciated. thanks,

I tried every onclick and Js functions nothings, works for me.
I want to open-up a modal when someone clicks on right side of building logos.

How do you mix the conditional operator ( ? : ) and deconstructed function returns?

I have a function in a CLASS

MyClass.prototype.fn = function(){
    /* ... some impressive code */
    return {isA: value1, isB: value2};
}

All that is important is it returns an object {isA: ?, isB: ?} ready for deconstructing.

Later I will have an instance of my class:

MyClass myC;

However, when I use it there is a chance the MyClass object myC is null.

So I want to use the conditional operator, just in case myC is null.

My question is, is there a better way of getting the default than just creating a temporary object on the fly with isA and isB set to false?

Ie, is this the best way to do it?

let {isA, isB} = myC ? myC.fn() : {isA: false, isB: false};

XForms Refresh not working? (XSLTForms 1.7)

I need to alter XForms instance data from inside Javascript.
The actual modification to the XML seems to work – but the UI doesn’t update – despite me explicitly refreshing XForms – I tried both the ‘xf:refresh’ element and the manual JS to do this – neither result in the UI being updated – this is in despite that fact that I can see changes have taken place on the model.

<?xml
    version="1.0"
    encoding="UTF-8"?>
<?xml-stylesheet
    href="xsltforms-1.7/xsltforms.xsl"
    type="text/xsl"?>
<?xsltforms-options
    debug="no"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ht="http://www.w3.org/1999/xhtml"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:xf="http://www.w3.org/2002/xforms"   
      xmlns:ev="http://www.w3.org/2001/xml-events"
      lang="en">
<head>
    <script type="text/javascript">
        <![CDATA[
            function js_xforms() {
                console.log("js_xforms called");
                var xmodel=document.querySelector('#model');
                var person=xmodel.getInstanceDocument();
                var fname=person.querySelector('fname');
                console.log(fname.textContent);

                fname.textContent='Fred';
                fname.setAttribute("js", "value");
                
                xmodel.rebuild();
                xmodel.recalculate();
                xmodel.revalidate();
                xmodel.refresh();   
            }
        ]]>
    </script>
    <xf:model id="model">
        <xf:instance id="person">
            <person xmlns="">
                <fname js="initial">Joe</fname>
                <lname>Bloggs</lname>
                <tel>1234-5678</tel>
            </person>
        </xf:instance>
    </xf:model>
</head>
<body>
    <xf:input ref="fname"/>
    <xf:input ref="lname"/>
    <xf:input ref="tel"/>

    <xf:trigger>
        <xf:label>JS</xf:label>
        <xf:action ev:event="DOMActivate">
            <xf:load resource="javascript:js_xforms()"/>
            <xf:refresh model="model"/>
        </xf:action>
    </xf:trigger>
</body>
</html>

Neither the ‘xf:refresh’ nor the explicit JS call ‘xmodel.refresh()’ (etc) appear to work?
What am I doing wrong here?

I am 99% sure this is just an issue with the UI not refreshing – since if I click the ‘JS’ button twice (or use fleur("instance('person')") from the console) – I can see the modification to the Xf:model has happened.

Same result on both Chromium and Firefox.

How to make Rollup.js preserve module exports with multiple entry points

I have a project with two modules chart.js and slider.js, and slider imports a class from chart. Now I want to bundle both with Rollup.js.
My rollup config looks like this

export default {
    input: [
        'src/chart.js',
        'src/slider.js'
    ],
    output: {
        format: 'es',
        dir: 'dist'
    },
};

When I run Rollup, it produces 3 files instead of 2: chart.js, slider.js, and additionally, chart-DqLRgW92.js. The last file actually contains my Chart class exporting it under a different name:

export { Chart as a };

And then chart.js only renames the export back to Chart:

export { a as Chart } from './chart-DqLRgW92.js';

There is nothing else in the chart.js except this single line.

slider.js imports Chart from chart-DqLRgW92.js:

import { C as Chart } from './chart-DqLRgW92.js';

On the other hand, if I run Rollup separately on each entry file, it produces a single output for each entry. Is there a way to setup Rollup to generate two output files and export the Chart class from chart.js without renaming it back and forth?

Click button on loading inside YouTube iFrame API using JavaScript

I need to automatically click on the “Playlist Menu Button” when an embedded YouTube playlist is first loaded (in a iFrame). I understand that this needs to be done using the YouTube iFrame API and have that script working (have installed Google’s Example 1 on their API documentation which enables different border colours depending on status).

YouTube have given the button I want to click the classes “ytp-playlist-menu-button ytp-button”.

I was hoping that adding document.getElementsByClassName("ytp-playlist-menu-button").click(); to the code below would work:

  tag.id = 'iframe-demo';
  tag.src = 'https://www.youtube.com/iframe_api';
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;
  function onYouTubeIframeAPIReady() {
    player = new YT.Player('player_2', {
        events: {
          'onReady': onPlayerReady,
          'onStateChange': onPlayerStateChange
        }
    });
  }
  function onPlayerReady(event) {
    document.getElementById('player_2').style.borderColor = '#FF6D00';
    document.getElementsByClassName("ytp-playlist-menu-button").click();
  }

but it doesn’t!

Can anyone let me know what it should be to have the button clicked on when the iframe loads? You can view the page where I’m trying to do this here

Cannot POST /v1/oauth/token when fetching access token from Notion API

I’m trying to integrate with Notion’s OAuth API, but I’m running into an issue when attempting to fetch the access token using a POST request. My code snippet is as follows:

const authHeader = Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`).toString("base64");
const tokenResponse = await fetch("https://api.notion.com/v1/oauth/token", {
  method: "POST",
  headers: {
    Authorization: `Basic ${authHeader}`,
    "Content-Type": "application/json",
    "Notion-Version": "2022-06-28",
    Accept: "application/json",
  },
  body: JSON.stringify({
    grant_type: "authorization_code",
    code: authCode,
    redirect_uri: "http://localhost:3000/api/notion/callback",
  }),
});

if (!tokenResponse.ok) {
  // Log response details to help with debugging
  const text = await tokenResponse.text(); // Read response as plain text
  console.error("Error response: ", text);
  throw new Error(`Request failed with status ${tokenResponse.status}`);
}

However, I’m getting the following error:

Error response:  
<!DOCTYPE html> 
<html lang="en"> 
<head> <meta charset="utf-8"> <title>Error</title> </head> 
<body> <pre>Cannot POST /v1/oauth/token</pre> </body> 
</html> 
  • Made sure the URL https://api.notion.com/v1/oauth/token is correct based on Notion’s API documentation.
  • Confirmed that CLIENT_ID and CLIENT_SECRET are correctly populated and encoded in base64.
  • Verified that grant_type, code, and redirect_uri parameters are correctly set in the request body.