Using Regex to find certain string (API Key)

I wanted to use a regular expressions to find if the API key exists or not.

I tried preg_match

^[a-f0-9]{32}$

I have this HTML code as a string.

{"page_data":"<div class="row"> <div class="col-md-6"> <div class="card"> <div class="card-header"><h5>Affiliate API</h5></div> <div class="card-body" style="padding:0px;"> <table class="table"> <thead> </thead> <tbody> <tr><td>User ID</td> <td>372061</td></td><td></tr> <tr><td>MID</td> <td>5132</td></td><td></tr> <tr><td>API Key</td> <td id="api_results"> fbb5e3abe388cab9ef652916fe124316 </td><td> <span class="badge badge-pill badge-secondary" style="cursor: pointer;" onclick="api_update('create')">Generate</span> <span class="badge badge-pill badge-danger" style="cursor: pointer;" onclick="api_update('disable')">Disable</span></td></tr> <tr><td>API Domain</td></tr> </tbody> </table> </div> </div> <div class="card"> <div class="card-header"><h5>API Guide</h5></div> <div class="card-body"></div> </div> </div> </div> ","page_js_register":"function api_update(t){ if(t=='create'){ var r = confirm("Are you sure to Create New API"); }else{ var r = confirm("Are you sure to Disable API"); } if (r == true) { $.ajax({type: "POST", url: "_get?type=api_update&t="+t, data: '', success: function(result){ if(result.api_key){ document.getElementById("api_results").innerHTML = result.api_key; } alert_c(result.txt,result.type,''); }}); } } ","title":"API"}

How to do a this with a component in react native?

I am working with react native and expo.cli and would like to know how I can manage to add a handle to a TouchableOpacity, I have the following component:

function MainModal (){
return(
    <>
      <View style={{flexDirection: 'row'}}>
        <TouchableOpacity
            onPress={this.TouchableOpacity}
            > 
            <Text>Volver</Text>
        </TouchableOpacity>

      </View>
    </>

What I want to do is make a reference to this specific TouchableOpacity when it is selected, but when I use a “this” nested in the component I get the following error: Undefined is not an object (Evaluating ‘this.TouchableOpacity’) I know maybe This question is a bit of a novice and has more to do with how ‘this’ works in javascript than with React Native itself, however I can’t find a way to make a reference to the selected object so that it executes something when selected. How could I do it?

Passed in Vue prop coming in as variable name, not as the string it represents

The parent component which is passing down my string var
The const GET_STARTED = the string "Get Started"

<script setup>
import { GET_STARTED } from '../../constants'
import GreenBtn from '@/components/partials/GreenBtn.vue'

console.log('GET_STARTED', GET_STARTED)
</script>

<template>
  <main>
    <div class="moon-cta">
      <section class="tagline">
        <h1>The Bold Portfolio {{GET_STARTED}} Tracker For Brave Crypto Investors</h1>
        <h2>Start / continue your crypto investing journey with us.</h2>
        <GreenBtn copy={GET_STARTED} url='/sign-up' />
      </section>
    </div>
  </main>
</template>

The partial child component

<script setup>
const props = defineProps(['copy', 'url'])
const { copy, url } = props
console.log('props', props)

const handleGetStartedClick = (msg) => {
  console.log(msg)
  console.log(`Goto url: ${url}`)
}
</script>

<template>
  <button v-on:click="handleGetStartedClick(`${copy} clicked.`)">
    {{ copy }}
  </button>
</template>

^ above I expect copy to be the string value “Get Started”

The result in the UI

copy={GET_STARTED}
enter image description here

if I tried copy=’GET_STARTED’
enter image description here

Expected

enter image description here

My logs

enter image description here

Any thoughts here? This seems like the correct way to pass down string vars in Vue.

Make elements inside div into an unordered list

I am wanting to use CSS or JavaScript to make items inside of a <div> into a <ul>. I have tried a bunch of different ways, but could not find an answer on SO. I am unable to edit the HTML code that I have below, which is the reason to use CSS or JavaScript to make the styling change.

.linklist {
   display: list-item;
    margin-left:25px;
    color: red;
}
<div id="links_88207" class="linklist">
    <p><a href="google.com/" class="tracked" target="_top">Google</a></p>
    <p><a href="https://www.mozilla.org" class="tracked" target="_top">Mozilla</a></p>
    <p><a href="https://www.google.com/" class="tracked" target="_top">Chrome</a></p>

Here is the JSFiddle:
https://jsfiddle.net/g3Ltjkd9/

Not able to add a space after input field

I append an input field into a div. What I want is a single space after the input field.

This is what I have tried:

const el = document.createElement('input');
el.setAttribute('type', 'number');
el.appendChild(document.createTextNode(' '));
/*
  Also tried it with:
  el.appendChild(document.createTextNode('u00A0'));
  el.appendChild(document.createTextNode('&nbsp;'));
  el.innerHTML = el.innerHTML + ' ';
*/

const id = document.getElementById('content');
id.appendChild(el);
id.focus();
<div id="content" contentEditable="true"></div>

Listen to clicks on play/pause in the controls section

I have a video tag and on top, there is a div that contains icons that shows the current state of the video and it works properly. The problem is those icons listen to clicks on the main container div and respond accordingly but if I click on the play and pause button on the controls section the icons won’t respond to the video state. How can I hide and display the icons when clicking on play/pause located in the controls section. Thanks in advance.

const videoElement = document.querySelector("video");

videoElement.addEventListener('loadeddata', (e) => {
  $('.paused .iconCon .fa-spinner').css('display', 'none')
  $('.paused .iconCon').css('background-color', 'rgb(135 117 117 / 40%)')
  if (videoElement.readyState >= 3) {
    var video = $("video").get(0);
    if (video.paused) {
      $('.paused .iconCon').css('background-color', 'rgb(135 117 117 / 40%)')
      $('.paused .iconCon .fa-play').show()
    } else {
      $('.paused .iconCon').css('background-color', 'rgb(135 117 117 / 40%)')
      $('.paused .iconCon .fa-pause').css('display', 'flex')
      $('.paused .iconCon').css('background-color', 'transparent')
      setTimeout(() => {
        $('.paused .iconCon .fa-pause').css('display', 'none')
      }, 500);
    }
    $(".paused").click(function() {
      if (video.paused) {
        $('.paused .iconCon .fa-play').hide()
        $('.paused .iconCon .fa-pause').css('display', 'flex')
        $('.paused .iconCon').css('background-color', 'transparent')
        setTimeout(() => {
          $('.paused .iconCon .fa-pause').css('display', 'none')
        }, 500);
        video.play();
      } else {
        $('.paused .iconCon .fa-pause').css('display', 'none')
        $('.paused .iconCon').css('background-color', 'rgb(135 117 117 / 40%)')
        $('.paused .iconCon .fa-play').show()
        video.pause();
      }

      return false;
    });
  }
});
video {
  width: 100%;
  height: 100%;
}

.paused {
  display: flex;
  position: fixed;
  width: 100%;
  height: 67%;
  z-index: 9999;
  cursor: pointer;
  background-color: transparent;
}

.paused .iconCon {
  display: flex;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin: auto;
  background-color: rgb(78, 78, 78);
}

.paused i {
  font-size: 13vh;
  color: #ffffff;
  margin: auto;
}

.paused .fa-spinner {
  display: flex;
}

.paused .fa-pause {
  display: none;
}

.paused .fa-play {
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v6.0.0/css/all.css" integrity="sha384-3B6NwesSXE7YJlcLI9RpRqGf2p/EgVH8BgoKTaUrmKNDkHPStTQ3EyoYjCGXaOTS" crossorigin="anonymous" />

<div class="paused">
  <div class="iconCon">
    <i class="fa-solid fa-spinner"></i>
    <i class="fa-solid fa-pause"></i>
    <i class="fa-solid fa-play"></i>
  </div>
</div>

<video src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" controls/>

How to Update a JavaScript dApp’s Folder Structure

I am studying how javascript can add html content to html files.

Executive Summary:

The Hashlips NFT dApp is hosted on Github. It uses js to add html content to an index.html file. I would like to change the folder it stores the json, js, and images files in (in the spirit of learning – so you can use a different file structure). I am struggling to isolate what js file I need to change to make it happen (assuming that would do it).

Source / Github Link:
https://github.com/HashLips/hashlips_nft_minting_dapp.

Summary of deployment process:

  • You make a few updates to the json files in the public folder and then “build” the site.
  • Yarn saves the index file, images, and js files into a new folder called build.
  • You upload the build folder to the web server.
  • The index file is basically an empty html shell with a single div.
  • The js files are extremely hard to read I guess to be more efficient.

Problem:
I cannot figure out what javascript file is adding the html content to the index.html file (or where in the javascript file I would need to make the changes). Therefore when I inspect html file using firefox developer I get the following:

  • abi.json: src=config/abi.json. Should be: src=totally_new_directory/abi.json.
  • config.json: src=config/config.json. Should be: src=totally_new_directory.json.

What I have Tried: I have reviewed all of the js files one by one to look for any reference to json or logos. I had to use an online website to make the js chunks more legible. I’m still having trouble making sense of how they work – they seem extremely complex. Any time I found a reference to a json file or logo I would update the file directory and save it. Then I would refresh the index.html file.

Analysis:
The index.html file is a barebones html document structure with your standard stylesheet links, etc. It has a single root element that the js files would select.

 <div id=‘root’></>   

Main.bcca9b65.chunk.js:
I found several sections where I thought I could change the folder structure. I updated and saved but nothing happened.

children: [Object(en.jsx)(on, {
           alt: "logo",
           src: “totally_new_folder/logo.png"
 }


children: Object(en.jsx)(sn, {
           alt: "example",
           src: "totally_new_folder/example.gif"
})

fetch("totally_new_folder/abi.json", {
           headers: {
               "Content-Type": "application/json",
               Accept: "application/json"
           }

fetch("totally_new_folder/config.json", {
               headers: {
               "Content-Type": "application/json",
               Accept: "application/json"                                                                            }

I also tried updating the equivalent directories in the Main.bcca9b65.chunk.js.map file but it made no difference.

Asset-manifest.json: lists out all of the css, js, and map files. This is how I know I ensured I looked at everything.

Main.64431e47.chunk.css:
only see a section to update the directory of the dApp font. But nothing happens when I update and save.

The HTML file at the end of the day still references the same old directories /config/etc….

  • 2.05f….js: seems to be related to the dApp itself. Eth functions, etc.
  • 3.14…..js: I think it’s about page visibility options, form event listeners…
  • runtime..js: It references this.webpackJsonphashlips_nft_minting_dapp… so object of some sort….

It’s the build folder that you are supposed to upload to a webserver so that’s where I need to make my updates right? Since nothing else outside the ‘build’ folder gets uploaded. Is that right?

Conclusion:
Any thoughts? I’ve spent the last several days trying to make sense of all the javascript going through all the lines but I can’t seem to isolate what I need to change and how to do it. Honestly this stuff looks different than anything I’ve seen in my javascript textbooks.

Any help you can provide would be greatly appreciated. Thank you in advance.

Disclaimer:
Copyright (c) 2021 HashLips
Permission is hereby granted, free of charge, to any person….to…modify the Software subject to… conditions.

Firebase JS Uncaught (in promise) TypeError: doc is not a function

I’m working on a web app using firebase and encountered this error. After a few hours of debugging, I still haven’t been able to understand what’s wrong, I’ll leave the code here for anyone who can help me figure out what its is that I’m doing wrong. Any suggestion will be really helpful, thanks!

Code:

    import {
      getFirestore,
      addDoc,
      doc,
      updateDoc,
      collection,
      query,
      where,
      getDocs,
      setDoc,
    } from "firebase/firestore";

const app = initializeApp(firebaseConfig);
const firestore = getFirestore(app);

var files = [....]

getDocs(collection(firestore, "property")).then((querySnapshot) => {
    querySnapshot.forEach((doc) => {
      if (files.includes(decrypt(doc.data().fileno))) {
        if (files.includes(decrypt(doc.data().fileno), 6)) {
          let owner = "ABC";
          const bref = doc(collection(firestore, "property"), doc.id);
          updateDoc(bref,{owner:encrypt(owner)}).then(()=>{
            console.log("updated")
          })

        } else {
          let owner = "XYZ";
          const bref = doc(collection(firestore, "property"), doc.id);
          updateDoc(bref,{owner:encrypt(owner)}).then(()=>{
            console.log("updated")
          })
        }
      }
    });
  });

How to dynamically change input range’s thumb’s background image in angular?

I need to change the thumb background so it shows an icon instead of just a color like in the following image:
input range
So, the problem is that I need to do this dynamically, since the ammount of sliders is n, I’m just creating one slider and with ngFor it creates the n amount of sliders necessary to meet the requirement.

The thing is, is there a way to set the background-image of the input range’s thumb dynamically?

I’m trying to do this with style binding but all I get to do is to change its container’s background, not the thumb:

generated by angular[![][2]][2]][2]

HTML:

<div class="slider-container container">
  <input [style.backgroundImage]="'url(../../assets/customer/startupgrind/ratings/' + {{experience.name}} + ')'" class="slider-range" type="range" value="1" min="0" max="2" name="" id="" #slider (input)="onSliderChange(slider.value, experience.id)">
  <div class="row">
    <div *ngFor="let rating of rates; let j = index;" class="col">
      {{rates[i][j].name}}
    </div>
  </div>
</div>

Slider’s CSS:

input[type=range] {
  height: 34px;
  -webkit-appearance: none;
  margin: 10px 0;
  width: 100%;
  direction: rtl;
}

input[type=range]:focus {
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 24px;
  cursor: pointer;
  animate: 0.2s;
  background: rgb(255, 42, 42);
  background: linear-gradient(90deg, rgba(255, 42, 42, 1) 0%, rgba(253, 172, 16, 1) 15%, rgba(52, 191, 30, 1) 50%, rgba(253, 172, 16, 1) 85%, rgba(255, 42, 42, 1) 100%);
  border-radius: 15px;
  border-style: none;
}

input[type=range]::-webkit-slider-thumb {
  border: 3px solid #C4C4C4;
  height: 50px;
  width: 50px;
  border-radius: 50%;
  background: #FFFFFF;
  cursor: pointer;
  -webkit-appearance: none;
  margin: -13px 0;
}

input[type=range]:focus::-webkit-slider-runnable-track {
  background: #74A9D8;
}

input[type=range]::-moz-range-track {
  width: 100%;
  height: 11px;
  cursor: pointer;
  animate: 0.2s;
  box-shadow: 1px 1px 1px #000000;
  background: #74A9D8;
  border-radius: 1px;
  border: 0px solid #010101;
}

input[type=range]::-moz-range-thumb {
  border: 3px solid #C4C4C4;
  height: 50px;
  width: 50px;
  border-radius: 50%;
  background: #FFFFFF;
  cursor: pointer;
  margin: -13px 0;
}

input[type=range]::-ms-track {
  width: 100%;
  height: 11px;
  cursor: pointer;
  animate: 0.2s;
  background: transparent;
  border-color: transparent;
  color: transparent;
}

input[type=range]::-ms-fill-lower {
  background: #74A9D8;
  border: 0px solid #010101;
  border-radius: 2px;
  box-shadow: 1px 1px 1px #000000;
}

input[type=range]::-ms-fill-upper {
  background: #74A9D8;
  border: 0px solid #010101;
  border-radius: 2px;
  box-shadow: 1px 1px 1px #000000;
}

input[type=range]::-ms-thumb {
  border: 3px solid #C4C4C4;
  height: 50px;
  width: 50px;
  border-radius: 50%;
  background: #FFFFFF;
  cursor: pointer;
  margin: -13px 0;
}

input[type=range]:focus::-ms-fill-lower {
  background: #74A9D8;
}

input[type=range]:focus::-ms-fill-upper {
  background: #74A9D8;
}

Need to implement focus on the creditor in angular

I am is situation where I have no idea how to implement the focus event of ckEditor in angular application
I read many documentation but I don’t get idea about the method that will be call when the user will focus on the edito

I need the way to put the event binding on the html like something this
<ckEditor (focusmethod)=”method that will be calling from here as”>

what is missing in my array.map function?

I have a table with v-for that works. (added to snippet)
But I want to use Array.map to map one array to another. I need my first column networkTeam.source to show a color instead of a number. I tried using .map in method but it isn’t working and I’m not getting any errors in the console.

Can you help me figure out what is wrong in my function? thanks in advance

data(){
  networkTeams: {},
  sources: {
       1: 'green',
       2: 'blue',
       3: 'pink',
       4: 'yellow',
       5: 'orange',
       6: 'blue'
       },

methods: {
        fixedNetworkTeams(teamId)
        {     
            return this.networkTeams(teamId).data.map(u => 
            {
                return { ...u, source: this.sources[u.source]};
            });
        },
<-- table no longer works -->

<tr v-for="networkTeam in fixedNetworkTeams"
    :key="team.id + networkTeam.id"
    :class="{ odd2: networkTeam.id % 2 !== 0 }"
>                    
  <td>
       <span> {{ networkTeam.source }} </span>
  </td>

  <td class="text-center data-column">
      <span> {{ networkTeam.accountId }} </span>
  </td>
  <td class="text-nowrap text-left breakAll">
      <span> {{ networkTeam.name }}</span>
  </td>
</tr>


<-- table before .map that works -->
<tr v-for="(networkTeam) in networkTeams[team.id].data"
    :key="team.id + networkTeam.id"
    :class="{ odd2: networkTeam.id % 2 !== 0 }"
>                    
  <td>
       <span> {{ networkTeam.source }} </span>
  </td>

  <td class="text-center data-column">
      <span> {{ networkTeam.accountId }} </span>
  </td>
  <td class="text-nowrap text-left breakAll">
      <span> {{ networkTeam.name }}</span>
  </td>
</tr>