Why redux store deletes when click on tag?

I want to replace the tag element with something else if possible in such a way to be able to keep the redux store. I tried Link or NavLink but it is not working. I want to keep the redux store without a persistent feature.
My app works fine on all screens without a persistent store but when I click on a tag the store is deleted and I have to login back.

How to show YouTube settings menu with custom button?

I want to show YouTube settings menu with custom button, how can i do that?

chrome.runtime.onMessage.addListener((obj, sender, response) => {
const { type, value, videoId } = obj;

if (type === 'UPPER') {
  const upper = document.querySelector('.ytp-settings-menu');
  upper.style.removeProperty('display');
}

});

Can’t scroll to field when call field.focus() in ios browsers in web application

I create a form validation for my app. Now I test it for mobile devices. There is form with several fields and a “Submit” button below. When I click the button and the required field is empty, field.focus() method invoked. Focus causes scrolling to the field by design. It works fine on android devices on any browser, but there’s no scroll to field on ios browsers (safari and chrome as well), only when I already focused on this field. When field was not focused originally, it works fine.

There’s a picture to better understand the problementer image description here

  1. Tap on ‘name’ field

  2. Keyboard opens so field goes beyond view

  3. Tap on ‘submit’ and app call field.focus()

  4. I expect view scroll to ‘name’ field (that’s how .focus() should work and it work on android or desktop, but not in ios) but it doesn’t happen

I tried to call field.scrollIntoView(), but it cancells field.focus(). I cant find a way to make them works together

What should I do?

Thank you in advance!

i want to create a 2 mode Go game, currently i want to have a game mode with AI using minimax or pruning Alpha-beta with javascript

The code starts as follows

This code to define the table if possible can you give me a reference to the html code. Thank you

const BLACK = 'black'
const WHITE = 'white'
const PREVIOUS = 'previous'
const L = 'l'
const O = 'o'


let previousStone

let boardState = [
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
    L, L, L, L, L, L, L, L, L, O, O, O, O, O, O, O, O, O,
]

I tried the code and Ai doesn’t work when running with html

MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster even though Allow Access from anywhere is set

I’m getting this error while trying to connect to mongoose.

/home/runner/SkrivInBussar/node_modules/mongoose/lib/connection.js:755
    err = new ServerSelectionError();
          ^

MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist/

The thing is that it worked yesterday, and I haven’t changed anything. I have Allow access from anywhere enabled, and my password + user both works. Is the problem due to some rate limit or something?

I’m using a free shared cluster on mongoDB.

await mongoose.connect("mongodb+srv://<user>:<pw>@Bussar.s5cyugd.mongodb.net/bussdb?retryWrites=true&w=majority"

How to find total views in a YouTube PlayList

I am trying to find the total number of views of all videos in a playlist I own in YouTube. I can see that a “total views” number is posted under the playlist name. However this appears to be the number of views generated by entering the playlist first. When I add up the number of views of individual videos I get a substantially larger number because, I assume, most of videos are watched by following a link other than the playlist.

In searching for an answer I see two suggestions

  1. using the following JS in the YT console
ytInitialData.header.playlistHeaderRenderer.viewCountText.simpleText

But this just gives the same number that is available under the playlist name.

  1. using the following
var totalViews = 0;
var videos = document.querySelectorAll('ytd-playlist-video-renderer');
for (var i= 0; i < videos.length; i++)  {
    var viewsElement = videos[i].querySelector('#metadata > span:nth- child(1)');
    if (viewsElement !== null) {
        var views = viewsElement.textContent.trim().replace(/D/g,'');
        totalViews += parseInt(views);
    }
}
console.log('Total views of all videos in the playlist: ' + totalViews);

But this gives a total count of 0.

Oblique responsive line between 2 divs

I would like to draw two oblique lines that would join two corners of two different divs. I need these lines to be responsive. My project currently uses angular but my problem, I think, can be solved with css. I also can’t use external libraries. enter image description here

I tried svg and I don’t know if I used it wrong but it was not responsive.

 <svg width="220" height="240" class="roadLink"><line x1="50" y1="60" x2="530" y2="220" stroke="black"/></svg>
        <div class="mb-2 d-flex">
            <div class=" d-flex justify-content-between roadSize topAnrpBlock">
            </div>
        </div>
        <svg width="140" height="100" class="roadLink"><line x1="50" y1="50" x2="500" y2="200" stroke="black"/></svg>

in BootstrapVue table, can only drag and drop table header, the table items are not changing

I want to implement a drag and drop feature on my BootstrapVue table. By using the code below, I can only drag and drop the table header but table items are not changing. I console logged updatedHeaders which is undefined.

<template>
  <div class="container mt-5">
    <div class="row">
      <h3>Managing Existing Accounts</h3>
    </div>
    <div class="row mt-3">
      This section shows all accounts you currently manage.<br>
      Click on a row to open up details about that account.<br>
      Accounts that have expired will have all their personally identifiable information scrubbed in 90 days.
    </div>

    <!--toggle for column customization-->
    <div>
      <b-button v-b-toggle.column-collapse variant="primary">Column</b-button>
      <b-collapse id="column-collapse" class="mt-2">
        <b-card>
          <p class="card-text">Choose the column</p>
          <b-form-checkbox-group v-model="selectedColumns">
            <b-form-checkbox value="Renew Date">Renew Date</b-form-checkbox>
            <b-form-checkbox value="Account Name">Account Name</b-form-checkbox>
            <b-form-checkbox value="Location">Location</b-form-checkbox>
            <b-form-checkbox value="Type">Type</b-form-checkbox>
            <b-form-checkbox value="Account Type">Account Type</b-form-checkbox>
          </b-form-checkbox-group>
        </b-card>
      </b-collapse>

      <div>
        <table class="table table-striped">
          <thead class="thead-dark">
          <draggable v-model="updatedHeaders" tag="tr" @end="dragged">
            <th v-for="header in headers" :key="header" scope="col">
              {{ header }}
            </th>
          </draggable>
          </thead>
          <tbody>
          <tr v-model="updatedHeaders" v-for="item in items" :key="item.gymID">
            <td v-for="header in headers" :key="header">{{ item[header] }}</td>
          </tr>
          </tbody>
        </table>

      </div>
      <rawDisplayer class="col-2" :value="items" title="Items"/>

      <rawDisplayer class="col-2" :value="updatedHeaders" title="Headers"/>
    </div>
  </div>
</template>

<script>
import draggable from 'vuedraggable';

export default {
  components: {
    draggable,
  },
  data() {
    return {
      dataLoaded: false,
      accountList: [],
      items: [],
      selectedColumns: ['Renew Date', 'Account Name', 'Location', 'Type', 'Account Type'],
      _xsrf: "",
    };
  },
  created() {
    // Load the saved column order from local storage
    const headers = localStorage.getItem('tableHeaders');

    if (headers !== "undefined") {
      const selectedFields = JSON.parse(headers);
      this.selectedColumns = selectedFields.map(field => field.label);
    }

    fetch('/distributor/api/managing-existing-accounts')
        .then(response => response.json())
        .then(data => {
          this.accountList = data.accountList;
          this.items = data.accountList;
          this.dataLoaded = true;
          this._xsrf = data._xsrf;
        })
        .catch(error => {
          console.error('Error fetching data:', error);
        });
  },
  computed: {
    filteredFields() {
      if (this.dataLoaded) {
        return Object.keys(this.items[0] ? this.items[0] : {})
            .filter(field => this.selectedColumns.includes(field))
            .map(field => ({
              key: field,
              label: field
            }));
      }
    },
    headers() {
      console.log(this.updatedHeaders);
      return this.updatedHeaders ? this.updatedHeaders : this.filteredFields?.map(field => field.key);
    },
  },

  methods: {
    dragged() {
      // Map the new order of headers to their corresponding labels
      const updatedLabels = this.updatedHeaders?.map(header => this.filteredFields.find(field => field.key === header).label);
      // Save the new order of headers to local storage
      localStorage.setItem('tableHeaders', JSON.stringify(this.headers));
    }
  }
}
</script>

<style>
/* Add your styles here */
</style>

I want to have checkboxes to select the column I want to show and I can drag and drop the table columns.

regex for string with. fixed PREFIX/SUFFIX words at rear ends

I am trying to make a regex for JS. following are inputs

PREFIX hello SUFFIX
PREFIX PREFIX SUFFIX
PREFIX SUFFIX SUFFIX
PREFIX var+2 SUFFIX

Note: PREFIX and SUFFIX are kind of fixed. in between these words, we can have any number. of words.

I came up with this regex

(PREFIX(?=(?<spaces>[sS]+SUFFIX))k<spaces>)

but this one was reported as polynomial

https://regex101.com/r/YCbU0f/1 has attack string which causes more backtracking.. Can we make it safe from tool above meeting above requirements.

Redirect(to specific page) Background notifications in react js web

in web react js we catch the background notification event in ‘firebase-messaging-sw’ this file but for redirection and some data pass there is no option so please tell me how we can pass data or catch event in the application other than this file

we add redirection in ‘firebase-messaging-sw’ but packages are not imported there so i want to catch event in root files like index.js

How to update modal information without reopening the modal in react native?

I have a modal which opens when a product is clicked and details of that product are displayed in modal there is also a you might also like section of products which have the same view as product now I want that when a you might like product is clicked the modal should update the information without opening a modal above existing modal. How can I do that?

const cartProducts = useSelector(state => state.cart.cartProducts);
const dispatch = useDispatch();
const [MyProducts,setProducts] = useState([]);
const prodCode = product.ItemCode;
const {user} = useSelector(state=>state.auth);

async function fetchProducts(){
 //console.log(prodCode);
 await axios({
               method:'GET',
               url:`${BASE_URL}/items/${prodCode}`,
               headers:{
                   'Authorization': AUTH_KEY,
               }
           })
           .then((response)=>{  
             setIsLoading(false);
             const status = response.data[0]['status'];
             //console.log(status);
             if(status=='success'){
               const items = response.data[0]['body']['related'];
               if(items){
                 //console.log(items);
                 setProducts(items);
               }
               //console.log(Products);
               }
               if(status=='error'){
                 MyToast(status);
               }
           }).catch((error)=>{
             setIsLoading(false);
               MyToast('Error: '+error.message);
               //console.log('Error is: ',error.message);
           });
}

useEffect(()=>{
 if(MyProducts.length === 0 && visible){
 fetchProducts();
 }
},[MyProducts]);

return (
 <Modal
   animationType="slide"
   transparent={true}
   visible={visible}>
   <View style={styles.centeredView}>
     <View style={styles.modalView}>
       <View style={styles.modalClose}>
         <TouchableOpacity style={styles.button} onPress={() => { handlePinClick()}}>
           <IconPin name={isPin ? 'pushpin' : 'pushpino'} size={responsiveWidth(6)} color={Colors.primary} />
         </TouchableOpacity>
         <TouchableOpacity style={styles.button} onPress={() => { handleFavoriteClick() }}>
           <IconFavorite style={{ padding: responsiveWidth(1.5) }} name={'ios-heart'} size={responsiveWidth(8)} color={isFavorite ? 'red' : Colors.grey} />
         </TouchableOpacity>
         <IconClose style={[styles.button, { padding: responsiveWidth(1.5) }]} name='cross' size={responsiveWidth(8.5)} color={Colors.black} onPress={() => onClose()} />
       </View>
       <ScrollView style={{ paddingBottom: responsiveHeight(7) }}>
         <Image style={styles.modalImage} source={{ uri: isFromAll ? product.feature_image : product['item_details'].feature_image }} />
         <Text style={styles.modalProdName}>{isFromAll ? product.ItemName : product['item_details'].ItemName}</Text>
         <ExpandableComponent product={product} isFromAll={isFromAll}/>
           {MyProducts.length !== 0 && 
           <View style={{ paddingVertical: responsiveHeight(1) }}>
           <Text style={styles.youMightText}>You might also Like</Text>
           {isLoading ?
             <View style={{height:responsiveHeight(28),flexWrap:'wrap' }}>
                 {widthList.map((item, index) => <ShimmerItem key={index} item={item} />)}
             </View> :
             <FlatList
               horizontal
               data={MyProducts}
               renderItem={({ item }) => <Product key={item.key} product={item} isFromAll={true}/>}
               ListEmptyComponent={()=><EmptyComponent height={30} text={'No Product!'}/>}
             />
             }
             </View>
             }
       </ScrollView>
       <View style={styles.bottomView}>
         {cartProducts && <BottomSheetScreen itemsCount={cartProducts.length} />}
       </View>
     </View>
   </View>
 </Modal>
)
}


How to decode base64 text to binary file?

I am converting binary file’s buffer to base64 text before storing to mongodb. I am using multer to get image alongside with with other field. I am sending those data in FormData and the back end is

app.post('/image', multer().single('image'), (req, res) => {
    const image = Buffer.from(req.file.buffer).toString('base64')
    database.collection('images').insertOne({image})
}

Now, how do I decode this base64 text to binary image?

I tried this in the front end after getting the json from the back end

URL.createObjectURL(new Blob([window.atob(data.image)]))

But I think the binary file is corrupted.