FIle.WriteAllText not adding text

I have html/javascript code that I am trying to write in c sharp on a windows forms application. It looks like this

<html>
<body>
<button onclick = "Clicker()">Click Me </button>
<script src = "clicker.js"></script>
</body>
</html>

here is what clicker.js looks like


function Clicker(){
    document.body.innerHtml += "adding to document";
}

I was able to setup the onclick event in c sharp, but when I click the button, the file that I am writing to is not continuing to add “adding to document” to the document. It only does it once. Here is what the event looks like

void ButtonClick(object k, EventArgs e){
   File.WriteAllText(location,"adding to document");
}

Why is this not working?

How to reuse object from JS and reuse back in the foreach taglib [duplicate]

1.Currently, i have 2 pieces of code. I need to pass filterFactory object below to foreach items in JSP. Im very new on this as this is my first time tackle JSP:

2.Is it possible in the taglib i can call the object, example: filterFactory.lineName

const lookupFilterLine = ${lookupFilterLine};
const filterFactory = lookupFilterLine.filter(function (x) {
                          return x.factoryName === factory;
                          });

output from filterFactory:
   {factoryName: 'TEST', type: 'line', lineName: 'This is line B'},
   {factoryName: 'TEST', type: 'line', lineName: 'This is line C'},
   {factoryName: 'TEST', type: 'line', lineName: 'This is line A'}

To below code:

$("#lineId").html('<c:forEach items="filterFactory" var="filterFactory">'
                    '<c:if test="${fn:contains(filterFactory, factory)}">'
                      +'<option value="${filterFactory}" label="${filterFactory}" />'
                     </c:if>'
                  +'</c:forEach>');

How to zoom in on Object on click with React Three

I hope everyone is having a good day, and before I go any further I would like to say that I have looked hours into this and tried a lot of options but none of them are working so far.

I am trying to make the camera zoom into the screen that is being played which is curently the box behind the test button. (I know this is ugly this is just for this test). I have the camera position at 0,20,120. I have tried a state like this (not full code just a brief hitting core details):

const [active, setActive] = useState(false)

<canvas
camera={position: active ? [0,20,120] : [0,10,10] />

This renders no errors but doesn’t actually work.

enter image description here

How can I remove all text inside parentheses inside a div inside an iframe triggered by a modal? [closed]

I have a modal that loads an iframe with dynamic content and I would like to remove any text that appears inside parentheses?

$(document).ready(function() {
    $('iframe').on('load', function() {
        $("iframe").contents().find("#myDiv") /// = then remove all text inbetween () parentheses in that div id content text? ///
    });
}); 

I have tried a few ways like above, but nothing seems to work.

The iframe is on the same domain (my site).

My vue progress bar did not make different color with api

Hello friend may i ask something. I want to ask about making progress bar on vue. I had make it with vue bootstrap. If just input a value, it work. But, when i input two or more value it did not work. Honestly i want make progress bar like github, like this:

enter image description here

And i use an rest api from github to get value. i get language value from repositories.

i hope you can help me, this is my code

mounted() {
    axios
      .get(
        "https://api.github.com/repos/dimaswntech/" +
          this.$route.params.name +
          "/languages",
        {
          headers: {
            Authorization: "token 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",
          },
        }
      )
      .then((response) => {
        this.setValue(response.data);
      });
      
      //this is the mounted method to get data from github rest api
 <b-progress :max="max" class="mb-3">
                <b-progress-bar
                  v-for="(nilai, index) in value"
                  :key="nilai[index]"
                  variant="primary"
                  :value="nilai"
                  :label="`${((nilai / max) * 100).toFixed(2)}%`"
                ></b-progress-bar>
              </b-progress>
              
              // this is the bootstrap element on vue template

If you want more my code, please comment bellow, then i add it

Map through firebase firestore collectiongroup, Not working

const [theposts, setThePosts] = useState([]);

const myPosts = query(collectionGroup(db, 'posts'));
const unsub = onSnapshot(myPosts, (querySnapshot) => {
  querySnapshot.forEach((doc) => setThePosts({
    post: doc.data()
  }))
  return unsub;
})

const Posts = theposts.post;

return (
<>
  <StatusBar barStyle = "dark-content" backgroundColor = {'#b300b3'} />
  <SafeAreaView style={[styles.container, {marginTop: 5}]}>
  <Header navigation = {navigation} />
  <Stories />
  <ScrollView>
  {Posts.map((post, index) => (
  <Post post={post} key = {index} />
  ))}
  </ScrollView> 
    { /* <BottomTabs icons={bottomTabsIcons} /> */ }
  </SafeAreaView> 
  </>
)

It seems like there’s no better way to write this, but still, it either gives an error(1): undefined is not a function (near’…Post.map’)
OR
error(2): theposts.postes is not a function. theposts.postes is undefined

Parallax Scroll showing extra whitespace after scrolling

I recently started on a personal project for myself and used the Parallax component from the react-scroll-parallax package. Here is the documentation in advance: https://react-scroll-parallax.damnthat.tv/docs/intro

I successfully applied it, but the problem is that there is extra whitespace whenever I'm scrolling it.

This is the page [before you scroll](https://imgur.com/a/h6WA7BH)
The page [after you scroll](https://imgur.com/a/SA5vSR3)
And here is the [result I want](https://imgur.com/a/eozU6Qk)

I get the result whenever I disable the `Parallax` component.
This is the code I use:
```<Parallax speed={25}>
        <div className="header-image h-screen">
          <div
            id="welcomeMessage"
            className="welcomeMessage relative text-9xl font-bold text-center text-white antialiased cursor-pointer tracking-wide shadow-text top-1/2 left-1/2 z-1">
            <Typewriter
              onInit={(typewriter) => {
                typewriter
                  .typeString('Welconr!')
                  .changeDelay(175)
                  .pauseFor(200)
                  .deleteChars(3)
                  .changeDelay(150)
                  .pauseFor(150)
                  .typeString('me!')
                  .changeDelay(175)
                  .start();
              }}
            />
          </div>
        </div>
        <div className="header-svg-clip">
          <svg
            xmlns="http://www.w3.org/2000/svg"
            className="h-5 w-5 text-white arrowDown"
            viewBox="0 0 20 20"
            fill="currentColor">
            <path
              fillRule="evenodd"
              d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v3.586L7.707 9.293a1 1 0 00-1.414 1.414l3 3a1 1 0 001.414 0l3-3a1 1 0 00-1.414-1.414L11 10.586V7z"
              clipRule="evenodd"
            />
          </svg>
        </div>
      </Parallax>
```
I hope there is someone who can help me. If you need anything more, just comment and I'll come back to you.
Thanks in advance!

JavaScript – Merge sorted array and cut to length k

I’ve been studying for possible interview questions and one that might come up is to merge sorted array and cut to length k.

I’ve already figured out how to merge the sorted arrays with this Leet code question:

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.

Merge nums1 and nums2 into a single array sorted in non-decreasing order.

The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length of n.

    //iterate through the arrays 
    for (let i = m; i <= m + n; i++) {
        //if i in nums1 is equal to 0
        if (nums1[i] === 0) {
            //if this is true, change the value to nums2
            nums1[i] = nums2[i - m];
        }
    }
    //sort the array again 
    nums1.sort((a, b) => a-b)
};

Haven’t found any specific questions or examples where I would also have to cut to a length of k. Can someone pls help me implement this, given the final sorted array?

Why am I getting Firebase ‘Uncaught TypeError: Cannot read properties of undefined (reading ‘getAuth’) at HTMLFormElement.’?

I have set up Google Firebase for a site hosted elsewhere. I am getting an error that says “Uncaught TypeError: Cannot read properties of undefined (reading ‘getAuth’) at HTMLFormElement.” when trying to initialize the Auth library from Firebase. I have tried many various alternate versions of the command to no avail. It appears as though the regular Firebase app initializes properly, however.

The line causing the error is in auth.js “const autho = auth.getAuth(app);” Here is my setup.

HTML file calls require.js library:

<script src="../components/scripts/require.js" data-main="../components/scripts/auth"></script>

auth.js using require.js’s require to import libraries:

require.config({
    paths: {
       'firebase': 'https://www.gstatic.com/firebasejs/8.10.1/firebase-app',
        'auth': 'https://www.gstatic.com/firebasejs/8.10.1/firebase-auth',
        //'firestore': 'https://www.gstatic.com/firebasejs/8.10.1/firebase-firestore'
    }
});

require(['firebase'], function (firebase) {
    require(['auth'], function (auth) {
            const registerForm = document.querySelector('#register-form');
            const continueButton = document.getElementById("continueButton");
            var email = "";
            var username ="";
            var alphaNumeric = /^([0-9]|[a-z])+([0-9a-z]+)$/i;

            const firebaseConfig = {
                                  apiKey: "AIzaSyB4L71q-5qsAD2RbzYkPI8S66t1-gPmLlc",
                                  authDomain: "milkywaymedium.firebaseapp.com",
                                  databaseURL: "https://milkywaymedium.firebaseio.com",
                                  projectId: "milkywaymedium",
                                  storageBucket: "milkywaymedium.appspot.com",
                                  messagingSenderId: "165659589186",
                                  appId: "1:165659589186:web:14f35c3010b2e5600c0bdb",
                                  measurementId: "G-WGKXQT89RQ"
                                    };

                    // Initialize Firebase
                    
                    //const autho = auth.getAuth(app);
                    //const autho = firebase.getAuth();
                    //const autho = firebase.auth();
                    //const db = firebase.default.firestore;

                    function passCreds() {
                        console.log("Passing credentials...");
                        email = document.getElementById("email").value;
                        username = document.getElementById("username").value;
                            
                        if (email != "" &&
                            email.includes("@") &&
                            email.includes(".") &&
                            email.length > 5 &&
                            !email.includes(" ") &&
                            username != "" &&
                            username.length > 2 &&
                            username.match(alphaNumeric)) {
                                
                                console.log("Requirements met...");
                                
                                const labelEmail = document.getElementById("label-email");
                                const labelUsername = document.getElementById("label-username");
                                const captionEmail = document.getElementById("caption-email");
                                const captionUsername = document.getElementById("caption-username");
                                const box1 = document.getElementById("box1");
                                const box2 = document.getElementById("box2");
                                const button1 = document.getElementById("button1");
                                
                                labelEmail.innerHTML = "<b>Password</b>";
                                labelUsername.innerHTML = "<b>Confirm Password</b>";
                                captionEmail.innerHTML = "Please enter a password that includes a number or symbol with at least eight characters...";
                                captionUsername.innerHTML = "Please retype your password to confirm it is correct...";
                                box1.innerHTML = `<input type="password" placeholder="Example: Andr0meda" id="password" name="password" required>`;
                                box2.innerHTML = `<input type="password" placeholder="Example: Andromed@" id="confirmPassword" name="confirmPassword" required>`;
                                button1.innerHTML = `<button class="button-login" style="width: 100%; height: 55px;" type="submit">CONTINUE</button>`;
                                console.log("Credentials passed...");
                        }
                        
                        else {
                            console.log("Your credentials do not meet the standards.");
                            email = "";
                            username ="";
                        }
                    }

            continueButton.addEventListener('click', (e) => {
                passCreds();
                });

            registerForm.addEventListener('submit', (e) => {
                // Create account
                e.preventDefault();
                const password = registerForm['password'].value;
                const confirmPassword = registerForm['confirmPassword'].value;
                console.log(email, username, password, confirmPassword);
                
                const app = firebase.initializeApp(firebaseConfig);
                const autho = auth.getAuth(app);
                
                createUserWithEmailAndPassword(auth, email, password)
                  .then((userCredential) => {
                    // Signed in 
                    const user = userCredential.user;
                    // ...
                  })
                  .catch((error) => {
                    const errorCode = error.code;
                    const errorMessage = error.message;
                    // ..
                  });
                
                //autho.createUserWithEmailAndPassword(email, password).then(cred => {
                //console.log(cred);
                //});
                
                //autho.createUserWithEmailAndPassword(email, password)
                //  .then((userCredential) => {
                //  // Signed in 
                //  var user = userCredential.user;
                //  console.log(userCredential);
                //  // ...
                 // })
                 // .catch((error) => {
                //  var errorCode = error.code;
                //  var errorMessage = error.message;
                    // ..
                //  });
            });
    });         
});

Mapping (modifying) a deeply nested structure of arrays and objects

I have a deeply nested array (list) of objects. Each object has an array, that can be empty or can contain another object. I need to map through them and output a result that will represent a string made from the values of the names of each item.

The result should be ‘name 1, name 2, name 3’.

So far I have this and I am definitely not getting what I need:

const list = [
  {id: 1, Item: []},
  {id: 2, Item: [{name: 'name1'}]},
  {id: 3, Item: [{name: 'name2'}, {name: 'name3'}]},
  {id: 4, Item: []}
];

const getNames = (list) => {
  const list = [];
  _.forEach(list, (child) => {
      list.push(child.Item);
  });
  const filteredList = list.filter(value => JSON.stringify(value) !== '[]');
  const mappedList = _.map(filteredList, (el) => {
     return el.name;
  });
  return _.join(mappedList, ', ');
};

const result= getNames(list); 
//expected output: 'name 1, name 2, name 3' (string)

Any ideas?

titleBarOverlay option breaks draggable window in Electron.js

I’m trying to use the titleBarOverlay option in electron.js but when I try to drag the window, it won’t drag. When I remove the option, the dragging feature works like normal. Is there a workaround for this?

index.js:

const { app, BrowserWindow } = require('electron');
let mainWindow;

app.on('ready', () => {
     mainWindow = new BrowserWindow({
          height: 600,
          width: 800,
          title: "Last Horizon",
          titleBarStyle: 'hidden',
          titleBarOverlay: {
              color: '#2e2e2e',
              symbolColor: '#ff6d4b'
          },
          webPreferences: {
             nodeIntegration: true
          }
     });
     mainWindow.removeMenu()
     mainWindow.loadFile('src/index.html');
});

index.html:

<!DOCTYPE html>
<html lang="en">
     <head>
          <link rel="stylesheet" href="styles.css"/>
     </head>
     <body>
          <div class="titleBar"></div>
          <div class="main">
               <h1>Hello World!</h1>
          </div>
     </body>
</html>

styles.css

html, body {
     -webkit-app-region: drag;
     background-color: #2e2e2e;
     color: white;
}

.titleBar {
     /* -webkit-app-region: drag; */
     background-color: #ffffff;
     width: 100%;
     height: 32px;
}

JavaScript using indexOf and lastIndexOf to put setattribuit

I want to use indexOf() and lastIndex() to add attributes by setAttribute after customizing the URL.

I try this code but not working:

<!DOCTYPE html>
<html>
    <head>
        <style>
          #two {
              position: absolute;
              width: 100%;
              height: 100%;
              left: 0px;
              top: 50px;
          }
        </style>
        
        <title></title>
    </head>
    <body>
        <select onchange="check()" id="selectbox" name="">
            <option hidden value="empty"></option>
            <option value="first">1</option>
            <option value="second">2</option>
        </select>
        <div id="two">
            <div id="de6854">
                <div style="width: 100%;height: 100%">
                    <iframe id="4526d" src="https://www.ask.com/wp-content/uploads/sites/3/2022/02/PowerOfDogPromo.jpeg?resize=200,100" style="width: 100%; height: 100%">
                    </iframe>
                    <iframe id="3ad34" src="https://www.ask.com/wp-content/uploads/sites/3/2022/02/PowerOfDogPromo.jpeg?resize=200,100" style="width: 100%; height: 100%">
                    </iframe>
                </div>
            </div>
        </div>

    </body>
    <script>
        function check(){
            var val = document.getElementById("selectbox").value
            var pic =  document.querySelector("#two iframe")
            var s = val.substring(0, val.indexOf('?resize='));
            var ss= val.substring(val.lastIndexOf(',10'));
            var f = s + ?resize= + '400' + ss;
            var s = s + ?resize= + '500' + ss;
            if(val==="first"){
            pic.setAttribute('src','f')
            } else if(val==="second"){
            pic.setAttribute('src','s')
            }
        }
    </script>
</html>

Any one can find solution of that problem:

I test write that code in JavaScript and running good:

var s = 'https://www.ask.com/wp-content/uploads/sites/3/2022/02/PowerOfDogPromo.jpeg?resize=200,100';
s = s.substring(0, s.indexOf('?resize='));
document.write(s);

document.write('<br>');
document.write('<br>');

var ss = 'https://www.ask.com/wp-content/uploads/sites/3/2022/02/PowerOfDogPromo.jpeg?resize=200,100';
ss = ss.substring(ss.lastIndexOf(',10'));
document.write(ss);

document.write('<br>');
document.write('<br>');

rr = s+"?resize="+"500"+ss
document.write(rr);

this code give result: https://www.ask.com/wp-content/uploads/sites/3/2022/02/PowerOfDogPromo.jpeg?resize=500,100

change 200 and add 500.

Is it possible to add a keyup listener to a form tag to trigger the submit event even if there is no submit button?

Consider a HTML-form, which includes several input fields and an icon from the material-icons library. I have added a click-listener to the icon, such that the form is submitted when clicking on the icon.

Now I want to go ahead and also add a keyup-Listener, such that the form will be submitted whenever I hit the ‘Enter’-key. I was trying to just add this listener to the form-element. This doesn’t work, however.

I am afraid that I might have to add this event-listener to each of my input fields and am curious on as there is another way of achieving what I want? Note, though, that I don’t have a submit-button, I only have the icon.