Placeholder in TextInput is not displaying any texts

My placeholder is not displaying the Placeholder text. Text input is displayed.
Placeholder text is also displayed while i am running on emulator. But when i install and run the code on my device. It doesnot display any placeholder text.

Here is my code

<View style={styles.root}>
<Text style={styles.title}>Create an account</Text>
            <CustomInput
                placeholder="Username"
                value={userName}
                setValue={setUserName}
            />
</View>

Stylesheet looks like this:

const styles = StyleSheet.create({
    root: {
        alignItems: 'center',
        padding: 20
    },
    title:{
        fontSize: 24,
        fontWeight: 'bold',
        color: '#051c60',
        margin:10
    }
})

;

Custom Input section looks like this:

<View style={styles.container}>
        <TextInput
            placeholder={placeholder}
            value={value}
            onChangeText={setValue}
            style={styles.input}
            secureTextEntry={secureTextEntry}
        />
    </View>

CSS for custom Input

const styles = StyleSheet.create({
    container:{
        backgroundColor:'white',
        width: '100%',
        borderColor:'#e8e8e8',
        borderWidth:1,
        borderRadius:5,
        paddingHorizontal:10,
        marginVertical:5,
    },
    input:{
        fontSize:16,
        color:'#000',
        paddingVertical:10,
    }
})

Creating comments and adding it into a comment box

Absolute beginner programmer here. I’m trying to create a comments box where whatever you type in the comments, will be stored in another div. I got some of it to work, it was able to append however, it disappears straight after. I want it to store the comments in the #comment-box div and when you enter another comment it stores it underneath. Here is my code so far

<div class="container">
    <h2>Leave us a comment</h2>
    <form>
       <textarea id="" placeholder="Add Your Comment" value=" "></textarea>
       <div class="btn">
           <input id="submit" type="submit" value="Comment">
           <button id="clear">  
            &#128591;</button>
       </div> 
    </form>
</div>
<div class="comments">
    <h2>Comments</h2>
    <div id="comment-box" value="submit">
    </div>
</div>

and my JS is

const field = document.querySelector('textarea');
const backUp = field.getAttribute('placeholder')
const btn = document.querySelector('.btn');
const clear = document.getElementById('clear')
const submit = document.querySelector('#submit')
// const comments = document.querySelector('#comment-box')
const comments = document.getElementById('comment-box')

field.onfocus = function(){
    this.setAttribute('placeholder','')
    this.style.borderColor = '#333'
    btn.style.display = 'block'
} // when clicking on this, placeholder changes into ' '.

field.onblur = function(){
    this.setAttribute('placeholder',backUp)
} //click away, placeholder returns

clear.onclick = function(){
    btn.style.display = 'none';
    field.value = ' '

submit.onclick = function(){
    submit.style.display = 'none';
    const content = document.createTextNode(field.value)
    comments.appendChild(content)

Where am I going wrong guys? Any feedback would be appreciated. Thank You

Test Stack in JavaScript – Pop and Peek and Swap returning error

I am trying to practice a stack test in javascript. I am returning what the test is asking for: 46 in the array of storage in the var stackHolder. However, the test result is not showing pop() and peek() functions correctly.

As you can see my consoles match the answer they are expecting, I want to check if I am incorrect or if there is a possible error on the validation to check the answers on their end.

Regarding the swap() – I am asking for a solution that works to get the result they are looking for, which is to swap 1,'{id: 1,value: "obj"}

Here is the code

export function stack( stackOperation, stackValue ) {
var stackHolder = {
count: 4,
storage : [
  1,
  '{id: 1,value: "obj"}',
  "stringHolder",
  46
]
};

var push = function(value) {
stackHolder.storage[stackHolder.count] = value;
return stackHolder.storage;
}

var pop = function() {
if (stackHolder.count === 0) {
  return [];
}

var poppedItem = stackHolder.storage[stackHolder.count];
delete stackHolder.storage[stackHolder.count];
stackHolder.count;

return poppedItem;
}

var peek = function() {
return [stackHolder.storage[0]];
}

var swap = function() {
return stackHolder.storage[1,0];
} 

switch(stackOperation) {
case 'push' : push(stackValue);
return stackHolder.storage;
break;
case 'pop': pop();  
return stackHolder.storage[3];
break;
case 'swap': swap();
return stackHolder.storage;
break;
case 'peek': peek();
return stackHolder.storage[3];
break; 
default:
console.log("DefaultResult", stackHolder.storage);
console.log("POP", stackHolder.storage[3]);
console.log("PEEK", stackHolder.storage[3]);
  return stackHolder.storage;
  }
}

-screen shot of computer validation for answers
enter image description here

–screen shot of console logs
enter image description here

-screen shot of Swap function error
enter image description here

Divide the html page into several pages automatically like MS WORD

Is ther any way to divide a html context contained div, p and table tages into separated pages in separated div tages (or at least just separated) for a defined height? (like ms word but online)

I want to create an html template for formal letters that might have multiple pages.
Expected a solution by using php or javascript or just html and css.

I use a persian font not english !

By the way, is there any other ways for creating those types of templates? (not using third party websites)… If yes, please give an example.

Note that I want to create pdf and image and ms word doc from that html too!

Thanks 🙂

Using Bootstrap inside a WordPress [header/footer.php ok] but got: ReferenceError: bootstrap is not defined @ functions.php

I have the following at header.php

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

And the following at footer.php

<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>

At functions.php, i have added a bootstrap modal inside wpb_hook_javascript (id=”tiopatinhas”)

All I want at this point is to show the modal programatically.

Also inside wpb_hook_javascript, I have the following

<script>
   var merda = document.getElementById("tiopatinhas");

The above one works fine, but then I try the following:

merda.show();   //Doesn't work

var merda = new bootstrap.Modal(document.getElementById('tiopatinhas')); //Doesn't work

$("#tiopatinhas").modal('show');  // Doesn't work

I know there’s something related to “childs”.
I know the last one is related to something called jQuery, which I read is deprecated. So, I don’t want to use it.

Any ideas how can I call the modal programatically?

PS I have a somehow good logic. In the past, I was an experienced C, C++ and ASM… in the 80s and 90s! :).
But, nowadays I know close to nothing about all of those frameworks, layers and so on.

Any help will be deeply appreciated.

How to access id of the modal globally using JavaScript Laravel Laravel

I’m have an html table with modal column (see image below for your reference)
Order Modal

Upon click the Order modal, I can access the its ID using onclick event in JavaScript
(var customer_id = $(this).val();)

I wanted to access and used it in my Add function using ajax but I’m having an error of “customer_id is not defined” when I tried to use it. Is there a way to fix it or do it properly.

This is my script

<script>
        $(document).ready(function () {
            // START OPEN CART MODAL FUNCTION
                $(document).on('click', '.viewCart', function (e) {
                    e.preventDefault();
                    var customer_id = 0;
                    var customer_id = $(this).val();
                    console.log(customer_id);

                    $.ajax({
                        type: "GET",
                        url: "/get-cart/"+customer_id,
                        dataType: "json",
                        success: function (response) {

                            if (response.data != null) {
                                console.log(response);
                                $('.OrderTbody').html("");
                                $.each(response.data, function (key, item) {
                                    $('.OrderTbody').append('<tr>
                                        <td>' + item.p_name + '</td>
                                        <td>' + item.c_qty + '</td>
                                        <td class="total">' + item.p_amt + '</td>
                                    <td><button type="button" value="' + item.c_id + '" class="btn btn-danger deleteListBtn btn-sm">Delete</button></td>
                                    </tr>');

                                });


                            }
                        }
                    });
                });
            // END OPEN CART MODAL FUNCTION

            // START ADD DATA FUNCTION
                    $(document).on('click', '.addToCart', function (e) {
                        e.preventDefault();
                        var data = {
                            'store': $('.sel_store').val(),
                            'product': $('.sel_product').val(),
                            'quantity': $('.sel_qty').val(),
                            // HOW TO INPUT Customer ID here, I tried this but im having an error of
                            // customer_id is not defined
                            'customer_id': customer_id,

                        }
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });
                        $.ajax({
                            type: "POST",
                            url: "/cart-list",
                            data: data,
                            dataType: "json",
                            success: function (response) {

                            }
                        });

                    });
            // END ADD DATA FUNCTION

        });
        </script>

loop a var key in a res.json response

so this is the portion of my code :

var roomid= roomIds[i] 
const Availabilitydata = await AvailResponse.json();
    availableroomsArray.push(Availabilitydata);
    
        app.get("/api/availability", (req, res) => {
            res.json({ indicateur: availableroomsArray});});
    }

so the variable indicateur looping 3 rooms Ids in an array
so when you visit /api/availability it will print the availibility of the 3 rooms in 2022-03-20 this way

{"indicateur":[{"20220320":{"i":1,"p1":"74.00","p2":"78.00","p3":"70.3000","p4":"122.4600"},"20220320"{"i":0,"p1":"74.00","p2":"77.00","p3":"70.3000","p4":"120.8900"},"20220320":{"i":0,"p1":"65.00","p2":"68.00","p3":"61.7500","p4":"106.7600"}}]}

and it is working fine .

What i am trying to achieve is displaying the roomId of each room in front of its availability like this :

{"1212":[{"20220320":{"i":1,"p1":"74.00","p2":"78.00","p3":"70.3000","p4":"122.4600"}]},
{"1213":[{"20220320"{"i":0,"p1":"74.00","p2":"77.00","p3":"70.3000","p4":"120.8900"}]},
{"1214":[{""20220320":{"i":0,"p1":"65.00","p2":"68.00","p3":"61.7500","p4":"106.7600"}}]}

I tried to replace indicateur in res.json({ indicateur: availableroomsArray});}); by roomid but it will be printed as it is

How to activate animation on Animate on Scroll library on up scroll

I want the animation to be triggered in both down and up scroll but AOS b default on triggers animation on down scroll.

This is my code

 <div className={css.arrow} data-aos="fade-up">
     <Image src={img5} alt="img5" />
 </div>

I tried putting data-aos-mirror=”true” as per this stackoverflow enter link description here but it did not work.



<div className={css.arrow} data-aos="fade-up data-aos-mirror="true">
     <Image src={img5} alt="img5" />
 </div>

Also did this but its not working

useEffect(()=>{
AOS.init({
  debounceDelay: 50, // the delay on debounce used while resizing window (advanced)
  once: false, // whether animation should happen only once - while scrolling down
  mirror: true, // whether elements should animate out while scrolling past them

});
}
,[])

findByupIdAndUpdate – update only fields that are provided

I have this mutation editItem that is used for editing of an item:

{
  "data": {
    "addItem": {
      "id": "623720fafdb2581bb7e0b41e",
      "itemDate": "2022-03-20T13:41:30",
      "itemName": "item",
      "itemCategory": {
        "categoryName": "item",
        "categoryType": "category"
      },
      "itemPrice": {
        "price": "100",
        "currency": "GBP"
      },
      "itemUpdated": {
        "isUpdated": false,
        "updatedBy": null,
        "updateStamp": null
      },
      "createdBy": {
        "username": "username",
        "name": "Name",
        "date": "2022-03-20T12:41:30.132"
      }
    }
  }
}

Mutation code:

type Mutation {
   editItem(itemID: ID!, itemInput: ItemInput): Item!
}

editItem: async (_, args, context) => {
      const currentUser = await checkAuthorization(context)
      let { itemDate, itemName, itemCategory, itemPrice, itemUpdated } =
        args.itemInput

      if (itemDate) {
        itemDate = dayjs(itemDate).format('YYYY-MM-DDTHH:mm:ss')
      }
      if (itemPrice) {
        itemPrice = { ...itemPrice, price: itemPrice.price }
      }
      if (itemCategory) {
        itemCategory = {
          ...itemCategory,
          categoryType: itemCategory.categoryType,
        }
      }
      if (itemDate || itemName || itemCategory || itemPrice) {
        const currentDate = dayjs(new Date()).format('YYYY-MM-DDTHH:mm:ss')
        itemUpdated = {
          ...itemUpdated,
          isUpdated: true,
          updatedBy: currentUser.username,
          updateStamp: currentDate,
        }

        const itemBody = await Item.findByIdAndUpdate(
          args.itemID,
          {
            $set: {
              itemDate: itemDate,
              itemName: itemName,
              'itemCategory.categoryName': itemName,
              'itemCategory.categoryType': itemCategory.categoryType,
              'itemPrice.price': itemPrice.price,
              itemUpdated: itemUpdated,
            },
          },
          { upsert: true, new: true },
        )
        return itemBody
      }
    },

Let’s say that I need to edit only itemDate, so I send a request accordingly

{
  "itemId": "623624d0eb73fc77853c520b",
  "itemInput": {
    "itemDate": "2022-03-01"
  }
}

However, I’m getting an error referring to the editItem mutation:

"message": "Cannot read properties of undefined (reading 'categoryType')",

So it seems that the $set request requires all fields to be filled in. When all are provided in the request, it works just fine.

I tried to do it similarly without using the $set, however then it would just overwrite the not provided fields to null.
Is the findByIdAndUpdate not suitable for this activity or what do I need to do to achieve $set not requiring everything to be provided?

why i am getting NaN as anwer [duplicate]

I want to apply prototype inheritance so my code should console logging 18 instead it is giving NaN

  'use strict';
    
    const Person= function(firstName,birthYear){
        this.name=firstName;
        this.year=birthYear;
    }
    
    const mahir=new Person("mahir",2003);
    console.log(mahir);
    
    // to check if mahir is instance of person
    
    console.log(mahir instanceof Person)
    
    // prototype inheritance
    
    Person.prototype.calcAge=()=>{
        console.log (2020-this.year);
    }
    mahir.calcAge();

Stringify a Javascript class that also includes objects within an array

Using JSON I am constructing a Javascript class that keep data of a players goals over a season.

Within the Constructor of the class the season is an array but the goals are contained in and additional object within the array.

class BuildGoalsDetail {
    constructor(a){
        this.season         = [];
        this.season         = new Object([]); // The problem is that this isn't getting included in when using stringify
        this.season.goals       = [];   
    }
    buildPlayerData(a0, a1){
        this.season.push(a0);
        this.season.goals.push(a1);
    }
}
    
player = new Array();
    
player.push();
player[0] = new BuildGoalsDetail();
player[0].buildPlayerData(1971,7);
player[0].season.goals.push(12);
player[0].season.goals.push(8);
player[0].season.goals.push(9);
document.write("Season: "+player[0].season+"    Goals: "+player[0].season.goals+"<br/><br/>");
    
player.push();
player[1] = new BuildGoalsDetail();
player[1].buildPlayerData(1974,7);
player[1].season.goals.push(10);
player[1].season.goals.push(12);
document.write("Season: "+player[1].season+"    Goals: "+player[1].season.goals+"<br/><br/>");
    
a0 = JSON.stringify(player);
document.write("Output of JSON:<br/>"+a0);

The output works fine but I then want to save this as JSON, when I use Stringify it only serialises the year array and not the object with the goals array.

If Stringify isn’t the best method is there another way I should be looking at?

How to sort a timeseries GridDB table according to timestamps?

I’m using JavaScript (NodeJS) to run GridDB NodeJS client on my Ubuntu machine. I have stored my time series database in a griddb container. I need to find a way to select a table and sort it by the timestamps. It returns the table with the sorted rows where the timestamps are sorted in a descending order, or the most recent time comes last. Do you think there’s a way to do that?
Below is a code snippet for a sample time series database as I stored mine in the GridDB container:

// preliminary codes have been deleted
let time_series;
        store.putContainer(timeConInfo, false)
            .then(ts => {
                time_series = ts;
                return ts.put([new Date(), 60, 'resting']);
            })
            .then(() => {
                query = time_series.query(" "); // the query goes here
                return query.fetch();
            })
            .then(rowset => {
                while (rowset.hasNext()) {
                    var row = rowset.next();
                    console.log("Time =", row[0], "Value =", row[1].toString());
                }
            })
    // catch the exception  
            .catch(err => {
                if (err.constructor.name == "GSException") {
                    for (var i = 0; i < err.getErrorStackSize(); i++) {
                        console.log("[", i, "]");
                        console.log(err.getErrorCode(i));
                        console.log(err.getMessage(i));
                    }
                } else {
                    console.log(err);
                }
            });