Ojet uses encoded URL when params are used in router.go

When I use router.go in Ojet like below

self.args.router.go({ path: serverData.nextViewUrl, params: { c: serverData.sessionId } });

I get the following URL

?ojr=start_form%3Bc%3D63A4CC7E647582AF7E6C634B7FBF82F2

Above is the encoded URL. How do I get the correct decoded url by default in Ojet like below:

?ojr=start_form&c=D63A4CC7E647582AF7E6C634B7FBF82F2

Additional info:
Following is my router setup:

// Router setup
      let router = new CoreRouter(navData, {
        urlAdapter: new UrlParamAdapter()
      });
      router.sync();

      this.moduleAdapter = new ModuleRouterAdapter(router);

      this.selection = new KnockoutRouterAdapter(router);

      // Setup the navDataProvider with the routes, excluding the first redirected
      // route.
      this.navDataProvider = new ArrayDataProvider(navData.slice(1), { keyAttributes: "path" });

I am using the latest OJet v11

How to check if element has any attributes in it?

I’m trying to make a conditional checker check whether the element has any attributes or not.

var result = parentElm.hasAttribute(); i tried using this but I’m not sure I want a specific attribute by name, I just want to check whether the element has any attributes or attribute like length, size, or idk.

copyFormatCommand.js

    const model = this.editor.model;
    const selection = model.document.selection;
    const parentElm = selection.focus.parent;
    this.isEnabled = !!parentElm;
  

Here is the HTML I’m using to test if there are multiple nested elements and want to check whether the textNode‘s parent element has any attributes
HTML

<p style="font: 11pt Times New Roman, Times, Serif; margin: 0;" xvid="c0fc3b7176d15af5d8c5c488a7fa675e"><span xvid="6f8db94eb5824fc90d39a2d9a127a98d">Annual Fund Operating Expenses</span></p>
<p style="font: 11pt Times New Roman, Times, Serif; margin: 0;" xvid="c0fc3b7176d15af5d8c5c488a7fa675e">
    <span xvid="6f8db94eb5824fc90d39a2d9a127a98d"><span xvid="1">hello</span></span>
</p>
<p>hello</p>

how can i can fix my leaftlat map problems?

I have a div with id map for leatleft and its only show one tile of map
i really have problem to show full map
please help me

enter image description here

my css style is

#map {
        height: 350px;
        width: 100%;
    }

and my code is

var mymap = L.map('map').setView([35.7336466, 51.3458287], 12);

    L.tileLayer('https://b.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
        attribution: 'hello world',
        maxZoom: 18,
    }).addTo(mymap);

mymap.locate({
        setView: true,
        maxZoom: 12
    });

How do I check if object property is true/false and output based on true/false [closed]

I’ve been trying to figure this one out – if someone has some pointers I would appriciate it. Basically I got an object which has 3 properties, I need to check if one of those properties is true or false, and return based true/false.
So far, made this code but as I understand it doesn’t recognize object.properties..

const library = [
  {
    title: "Bill Gates",
    author: "The Road Ahead",
    isRead: true
  },
  {
    title: "Steve Jobs",
    author: "Walter Isaacson",
    isRead: true
  },
  {
    title: "Mockingjay: The Final Book of The Hunger Games",
    author: "Suzanne Collins",
    isRead: false
  }
];

const showStatus = (arg) => {
  let book = arg;
  for(let i = 0;i < book.length; i++){
    if(book.isRead === true){
       console.log(`Already read ${book.title} by ${book.author}.`)
    } else {
      console.log(`You still need to read ${book.title} by ${book.author}`)
    }

  }

};

showStatus(library);

Getting all the objects in the JavaScript from Django

I want to get all my object models from the database and store them in someway, the model I have is:

class Device (models.Model):
    patientId = models.IntegerField(unique=True)
    deviceId = models.CharField(unique=True,max_length=100)
    hour = models.DateTimeField()
    type = models.IntegerField()
    glucoseValue = models.IntegerField()

I’m sending them in views.py:

device_list = list(Device.objects.all())
context = {"filename": filename,
           "deviceList": device_list,
               }

In JS I managed to get each object like that:

{% for item in deviceList%}
console.log( "{{item}}" );
{% endfor %}

What I want is to store those objects in some way, but I don’t really know how, because they are coming like that Model object (1).

Dimension Converter

Trying to make a website with multiple different dimension conversions. have successfully completed length however with almost the exact same code weight is not working. Here is my code:

    <section class="inputsW">
                <input type="number"  name="tonne" id="tonne" class="inputW" placeholder="Tonnes">
                
                <input type="number" name="kilo" id="kilo" class="inputW" placeholder="Kilograms">
                
                <input type="number" name="gram" id="gram" class="inputW" placeholder="Grams">
                
                <input type="number" name="milligram" id="milligram" class="inputW" placeholder="Milligrams">
                
                <input type="number" name="ton" id="ton" class="inputW" placeholder="US Tons">
                
                <input type="number" name="stone" id="stone" class="inputW" placeholder="Stone">
                
                <input type="number" name="pound" id="pound" class="inputW" placeholder="Pounds">
                
                <input type="number" name="ounce" id="ounce" class="inputW" placeholder="Ounces">
                
            </section>

I am pretty happy with my html, I believe the problem lies within the (e.target.name) for the switch statement as this code works perfectly well for the first converter.

const tonneInput = document.getElementById("tonne");
const kiloInput = document.getElementById("kilo");
const gramInput = document.getElementById("gram");
const milligramInput = document.getElementById("milligram");
const tonInput = document.getElementById("ton");
const stoneInput = document.getElementById("stone");
const poundInput = document.getElementById("pound");
const ounceInput = document.getElementById("ounce");
const inputs = document.getElementsByClassName("input");


for (let i = 0; i < inputsL.length; i++) {
  let input = inputsL[i];

    input.addEventListener("input", function (e) {
        let value = parseFloat(e.target.value);
    
    
        switch (e.target.name) {
            case "tonne":
            
                kiloInput.value = (value*1000).toPrecision(4);
                gramInput.value = (value*1e+6).toPrecision(4);
                milligramInput.value = (value*1e+9).toPrecision(4);
                tonInput.value = (value*1.102).toPrecision(4);
                stoneInput.value = (value*157).toPrecision(4);
                poundInput.value = (value*2205).toPrecision(4);
                ounceInput.value = (value*35274).toPrecision(4);
               break; 

            case "kilo":
                tonneInput.value = (value/1000).toPrecision(4);
                gramInput.value = (value*1000).toPrecision(4);
                milligramInput.value = (value*1e+6).toPrecision(4);
                tonInput.value = (value/907).toPrecision(4);
                stoneInput.value = (value/6.35).toPrecision(4);
                poundInput.value = (value*2.2046).toPrecision(4);
                ounceInput.value = (value*35.274).toPrecision(4);
                break; 

            case "gram":
                tonneInput.value = (value/1e+6).toPrecision(4);
                kiloInput.value = (value/1000).toPrecision(4);
                milligramInput.value = (value*1000).toPrecision(4);
                tonInput.value = (value/907185).toPrecision(4);
                stoneInput.value = (value/6350).toPrecision(4);
                poundInput.value = (value/454).toPrecision(4);
                ounceInput.value = (value/28.35).toPrecision(4);
                break; 

            case "milligram":
                tonneInput.value = (value/1e+9).toPrecision(4);
                kiloInput.value = (value/1e+6).toPrecision(4);
                gramInput.value = (value/1000).toPrecision(4);
                tonInput.value = (value/9.072e+8).toPrecision(4);
                stoneInput.value = (value/ 6.35e+6).toPrecision(4);
                poundInput.value = (value/453592).toPrecision(4);
                ounceInput.value = (value/28350).toPrecision(4);
                break; 

            case "ton":
                tonneInput.value = (value/1.102).toPrecision(4);
                kiloInput.value = (value*907).toPrecision(4);
                gramInput.value = (value*907185).toPrecision(4);
                milligramInput.value = (value*9.072e+8).toPrecision(4);
                stoneInput.value = (value*143).toPrecision(4);
                poundInput.value = (value*2000).toPrecision(4);
                ounceInput.value = (value*32000).toPrecision(4);
                break; 

            case "stone":
                tonneInput.value = (value/157).toPrecision(4);
                kiloInput.value = (value*6.35).toPrecision(4);
                gramInput.value = (value*6350).toPrecision(4);
                milligramInput.value = (value*6.35e+6).toPrecision(4);
                tonInput.value = (value/143).toPrecision(4);
                poundInput.value = (value*14).toPrecision(4);
                ounceInput.value = (value*224).toPrecision(4);
                break; 
    
            case "pound":
                tonneInput.value = (value/2205).toPrecision(4);
                kiloInput.value = (value/2.205).toPrecision(4);
                gramInput.value = (value*454).toPrecision(4);
                milligramInput.value = (value*453592).toPrecision(4);
                tonInput.value = (value/2000).toPrecision(4);
                stoneInput.value = (value/14).toPrecision(4);
                ounceInput.value = (value*16).toPrecision(4);
                break; 
    
            case "ounce":
                tonneInput.value = (value/35274).toPrecision(4);
                kiloInput.value = (value/35.274).toPrecision(4);
                gramInput.value = (value*28.35).toPrecision(4);
                milligramInput.value = (value*28350).toPrecision(4);
                tonInput.value = (value/32000).toPrecision(4);
                stoneInput.value = (value/224).toPrecision(4);
                poundInput.value = (value/16).toPrecision(4);
                break; 
            default:
    }
  });
}

JavaScript On-click Function to start and stop Intervals

I have two onclick functions that performing start and stop functions using socket when i click start it start requesting images from server(i am using intervals) when i click stop the server is stopped but the request keep coming to the server. the intervals seems not stopped after clicking kindly review my code

Code:

  var interval;
  
  function onclick() {
    interval = setInterval(() => {
      socket.emit("get_image", "Click");
      socket.on('send_image', (message) => {
        setImage(message.image); 
      });
    }, 350)
  }

  function onclicks() {
    clearInterval(interval);
    setImage(blanked);

  }

I have tried to add clearInterval function but it seems not working

how to filter based on two values from the array of array

I have a bunch array of objects with participants and messages, I want to filter the object with the below array of two participants, can anyone help with this

this is the example participnats of array :

["61badffe4ccf060b329441e0","61bc33a84ccf060b32944354"]

bunch of sample messages and participants :

  {
    "messages": [],
    "participants": [
      "61badffe4ccf060b329441e0",
      "61bae01b4ccf060b329441ef"
    ],
    "_id": "61bae0394ccf060b329441fb",
  },
  {
    "messages": [],
    "participants": [
      "61bae1014ccf060b3294420e",
      "61bae01b4ccf060b329441ef"
    ],
    "_id": "61bb230c4ccf060b3294421c"
  },
  {
    "messages": [],
    "participants": [
      "61badffe4ccf060b329441e0",
      "61bc33a84ccf060b32944354"
    ],
    "_id": "61d476dff651471663a72971",
  },
  {
    "messages": [],
    "participants": [
      "61badffe4ccf060b329441e0",
      "61e54b82eab592e7fef65656"
    ],
    "_id": "61e54ba3eab592e7fef6567a",
]





**expected below object after filter participants:** 

```{
    "messages": [],
    "participants": [
      "61badffe4ccf060b329441e0",
      "61bc33a84ccf060b32944354"
    ],
    "_id": "61d476dff651471663a72971",
  },

how to add number to field in every doucment in monogdb using nodejs

my collection has phonenumber field. i want to add 91 infront of phonenumber.

{
"_id": "6137392141bbb7723",
"email": "[email protected]",
"lastname": "Cagle",
"firstname": "Brooke",
"phonenumber":9000000001
},
{
"_id": "6137392141bbe30723",
"email": "[email protected]",
"lastname": "Cagle",
"firstname": "Brooke",
"phonenumber":9000000002
}

i want to update my collection like this.

{
"_id": "6137392141bbb7723",
"email": "[email protected]",
"lastname": "Cagle",
"firstname": "Brooke",
"phonenumber":919000000001
},
{
"_id": "6137392141bbe30723",
"email": "[email protected]",
"lastname": "Cagle",
"firstname": "Brooke",
"phonenumber":919000000002
}

im trying with this code but its not updating the field.

var x = await User.find({});
        x.forEach(async function(d)
            { 
                var phone = d.phonenumber;  
                var newPhoneNumber = 910000000000+phone;
                console.log(newPhoneNumber);

                //update 
            await User.updateMany({},{$set:{phonenumber:newPhoneNumber}},
                {
                    new: true, 
                    runValidators : true
                });
            })

im getting only one value for all documents like this:

{
"_id": "6137392141bbb7723",
"email": "[email protected]",
"lastname": "Cagle",
"firstname": "Brooke",
"phonenumber":919000000001
},
{
"_id": "6137392141bbe30723",
"email": "[email protected]",
"lastname": "Cagle",
"firstname": "Brooke",
"phonenumber":919000000001
},
{
"_id": "6137392141bbe30723",
"email": "[email protected]",
"lastname": "Cagle",
"firstname": "Brooke",
"phonenumber":919000000001
}

i don’t know whether this approach is correct or not.Thank you

How to get numbers out of a 2D array to a 1D array

I have an argument that passes me a 2D array and I want to get the numbers from that array and put them on a normal array.

The argument passed to me = ([1, 3, 2], [5, 2, 1, 4], [2, 1])
What I want to do = [1, 3, 2, 5, 2, 1, 4, 2, 1]

Thanks in advance, I think I’m having a brain fart over here!

Build an application to eliminate time-lag that arises during inter device data transfer

I have to develop an application for smart-cities. traffic updates are given to the cops so that they can solve it immediately. There are existing technologies which address this issue, but a time-lag is involved which reduces the tackling efficiency. the app has to eliminate this time lag.
Usage of Cloud and IoT is what has been asked. enter code here

Chrome Extension doesn’t work with MV3, getting “Insecure CSP value “‘unsafe-eval'” in directive ‘script-src’.”

I’m trying to make a simple Chrome extension that replaces all images with another one (img.jpg).

Main folder

  • clrimgs.js
  • img.jpg
  • manifest.json
  • window.html

window.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ClrImgs</title>
    <script type="text/javascript" src="clrimgs.js"></script>
</head>
<body>
    <button onclick="clrimgs()"></button>
</body>
</html>

clrimgs.js:

function clrimgs(){
    images = document.getElementsByTagName("img")
    for(image in images){
        image.src = "img.jpg";
    }
}

manifest.json:

{
    "manifest_version": 3,
    "name": "ClrImgs",
    "description": "Description",
    "version": "1.0",
    "minimum_chrome_version": "46",
    "content_security_policy": {
        "extension_pages": "script-src 'self' 'unsafe-eval'; object-src 'self'",
        "sandbox": "..."
       },
    "action": {
    "default_icon": "img.jpg",
    "default_popup": "window.html"
    }
    }

When I try to reload the extension, I get this error:

‘content_security_policy.extension_pages’: Insecure CSP value
“‘unsafe-eval'” in directive ‘script-src’. Could not load manifest.

Is there any way to use MV3 and still use such code? If yes, what am I doing wrong? I have tried doing numerous things, but I keep getting an error or the other.

Regex expression to match numbers that don’t contain percentage

I have a requirement where in a user input the regular expression should match only numbers either digits or numbers with decimal points, however if there is a number followed with a percentage symbol then that should be excluded, but numbers followed with alphabets like 100g or 500 grams should be matched without picking up the alphabet part

I have come up with the following:

let numberPart = importValue.match(/d+(?:[.,]d+)?b(?!(?:[.,]d+)|(?:s?%|spercent))/g);

11 grams nutella 1,5% is matched and we get 11 as output

however 11grams nutella 1,5% isn’t matched

how can I change it so it matches numbers followed immediately by an alphabet or alphabets.