Detect when content overflow

I want to add a specific styling when my content is overflowing. The styling I would like to add is a shadow that will indicate that you can scroll to see more information.

My question is: How can I detect that my content is overflowing to add this style only when it is overflowing?

Reading a text file and converting to form another text file

I have programming experience and am fairly new to JS would like to read a text file line by line into an array. Then convert the array elements and output to another text file. Now I am going through https://www.w3schools.com/js/default.asp

I am thinking of reading one line at a time and putting that line into array and then loop the process to read the whole file .
Lines would like this
saa-ree-|gaa-maa-|paa-daa-|nee-Saa-|

and then have a code to process the array to produce
CD|EF|GA|Bc|

Thank you

Thiru

a very small simple complete example

input

saa-ree-|gaa-maa-|paa-daa-|nee-Saa-|

Saa-nee-|daa-paa-|maa-gaa-|ree-saa-|

output

CD|EF|GA|Bc|

cB|AG|FE|DC

input.type = “number”; but only for specific input field

How I can use my : input.type = "number"; to be used only in specific fields?

            var cell1 = row.insertCell(0);
            var cell2 = row.insertCell(1);
            var cell3 = row.insertCell(2);
            var cell4 = row.insertCell(3); 

I have these inserts, to insert fields into the table. So how can I specify only for the eg. Cell(0)? To have only numbers (0-9) in the specific fields.

Sorry if sounds stupid.
Thank you

why class not render after set state in react js?

I want to add an active class to the indicator after clicking it but the active class doesn’t render even though list.id === active

const [active, setActive] =  useState(1);

const scrollToElement = (id, value) => {
    const element = document.getElementById(`${value}`);
    element.scrollIntoView({ behavior: 'smooth' });

    setActive(prevState => {
      return {
        ...prevState,
        active: id
      }
    });
  }
  
<div
  key={list.id}
  className={`${list.id === active ? `${style.active} ${style.dot}` : `${style.dot}`}`}
  onClick={() => scrollToElement(list.id, list.name)}
/>

Using ngx-translate to display images

I would like to use ngx-translate inside my Angular app to display a language-specific image. In my case its a Logo which is displayed in different languages and styles depending on the used language.

I did already tried with

        <img style="width: 100px" [attr.src]="'branding.logo' | translate" alt="" class="src" />

Where branding.logo refers to a URL of the particular logo in the web.

But Chrome displays, that it couldn’t find the requested ressource at: ‘https://localhost:8100/branding.logo’.

What am I doing wrong?

How to set useReducer initial state using API response?

I’m new to React and trying to build an app with a cart feature where users can add robots to the cart. I’m using Context API to provide cart across the app and useReducer for states. The robots are being fetched from a server and load just fine. But I can’t seem to find a way to set the initial state of the reducer using fetched products. The state always returns an empty array for robots. How to solve this?

const CartProvider = ({ children }) => {
    const [robots, setRobots] = useState([]);

    useEffect(() => {
        fetch('http://localhost:8000/api/robots')
            .then(res => res.json())
            .then(data => setRobots(data?.data))
    }, [])

    const initialState = {
        robots: [...robots],
        cart: []
    }
    const [state, dispatch] = useReducer(cartReducer, initialState);

    return (
        <CartContext.Provider value={{ state, dispatch }}>
            {children}
        </CartContext.Provider>
    );
}
export default CartProvider;

Why Data is missing simultaneously when app script running & sometimes vanished from the whole spreadsheet & found no where

I have some issue where i had written a script that on the basis of a particular value of a row it should move to the specific sheet but dramatically it disappear simultaneously sometimes it work good & sometimes it vanished that row & can’t find anywhere in the spreadsheet where it had gone no one knows & even in some cases it automatically disappear or move the row by itself even if it is not defined to do so. Function is written below please help to rectify it.

function onEdit(e)
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Delhi Calls Asha");
  var values = sheet.getRange(1, 4, sheet.getLastRow(), 1).getValues();
  var moveRows = values.reduce(function(ar, e, i) {
    if (e[0] == "LG") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet = ss.getSheetByName("DELHI Calls Amit");
  moveRows.forEach(function(e) {
    sheet.getRange(e, 1, 1, sheet.getLastColumn()).moveTo(targetSheet.getRange(targetSheet.getLastRow() + 1, 1));
  });
  moveRows.reverse().forEach(function(e) {sheet.deleteRow(e)});
}


{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Delhi Calls Amit");
  var values = sheet.getRange(1, 22, sheet.getLastRow(), 1).getValues();
  var moveRows = values.reduce(function(ar, e, i) {
    if (e[0] == "Cancelled") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet = ss.getSheetByName("Happy Calling Delhi");
  moveRows.forEach(function(e) {
    sheet.getRange(e, 1, 1, sheet.getLastColumn()).moveTo(targetSheet.getRange(targetSheet.getLastRow() + 1, 1));
  });
  moveRows.reverse().forEach(function(e) {sheet.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Delhi Calls Amit");
  var values = sheet.getRange(1, 22, sheet.getLastRow(), 1).getValues();
  var moveRows = values.reduce(function(ar, e, i) {
    if (e[0] == "Closed") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet = ss.getSheetByName("Happy Calling Delhi");
  moveRows.forEach(function(e) {
    sheet.getRange(e, 1, 1, sheet.getLastColumn()).moveTo(targetSheet.getRange(targetSheet.getLastRow() + 1, 1));
  });
  moveRows.reverse().forEach(function(e) {sheet.deleteRow(e)});

}
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Delhi Calls Asha");
  var values = sheet.getRange(1, 22, sheet.getLastRow(), 1).getValues();
  var moveRows = values.reduce(function(ar, e, i) {
    if (e[0] == "Cancelled") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet = ss.getSheetByName("Happy Calling Delhi");
  moveRows.forEach(function(e) {
    sheet.getRange(e, 1, 1, sheet.getLastColumn()).moveTo(targetSheet.getRange(targetSheet.getLastRow() + 1, 1));
  });
  moveRows.reverse().forEach(function(e) {sheet.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet4 = ss.getSheetByName("Delhi Calls Asha");
  var values4 = sheet4.getRange(1, 22, sheet4.getLastRow(), 1).getValues();
  var moveRows4 = values4.reduce(function(ar, e, i) {
    if (e[0] == "Closed") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet4 = ss.getSheetByName("Happy Calling Delhi");
  moveRows4.forEach(function(e) {
    sheet4.getRange(e, 1, 1, sheet4.getLastColumn()).moveTo(targetSheet4.getRange(targetSheet4.getLastRow() + 1, 1));
  });
  moveRows4.reverse().forEach(function(e) {sheet4.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet5 = ss.getSheetByName("MUMBAI Calls");
  var values5 = sheet5.getRange(1, 22, sheet5.getLastRow(), 1).getValues();
  var moveRows5 = values5.reduce(function(ar, e, i) {
    if (e[0] == "Cancelled") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet5 = ss.getSheetByName("Happy Calling Mumbai");
  moveRows5.forEach(function(e) {
    sheet5.getRange(e, 1, 1, sheet5.getLastColumn()).moveTo(targetSheet5.getRange(targetSheet5.getLastRow() + 1, 1));
  });
  moveRows5.reverse().forEach(function(e) {sheet5.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet6 = ss.getSheetByName("MUMBAI Calls");
  var values6 = sheet6.getRange(1, 22, sheet6.getLastRow(), 1).getValues();
  var moveRows6 = values6.reduce(function(ar, e, i) {
    if (e[0] == "Closed") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet6 = ss.getSheetByName("Happy Calling Mumbai");
  moveRows6.forEach(function(e) {
    sheet6.getRange(e, 1, 1, sheet6.getLastColumn()).moveTo(targetSheet6.getRange(targetSheet6.getLastRow() + 1, 1));
  });
  moveRows6.reverse().forEach(function(e) {sheet6.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet7 = ss.getSheetByName("Happy Calling Delhi");
  var values7 = sheet7.getRange(1, 31, sheet7.getLastRow(), 1).getValues();
  var moveRows7 = values7.reduce(function(ar, e, i) {
    if (e[0] == "satisfied") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet7 = ss.getSheetByName("Main Sheet Mix");
  moveRows7.forEach(function(e) {
    sheet7.getRange(e, 1, 1, sheet7.getLastColumn()).moveTo(targetSheet7.getRange(targetSheet7.getLastRow() + 1, 1));
  });
  moveRows7.reverse().forEach(function(e) {sheet7.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet8 = ss.getSheetByName("Happy Calling Delhi");
  var values8 = sheet8.getRange(1, 31, sheet8.getLastRow(), 1).getValues();
  var moveRows8 = values8.reduce(function(ar, e, i) {
    if (e[0] == "SATISFIED") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet8 = ss.getSheetByName("Main Sheet Mix");
  moveRows8.forEach(function(e) {
    sheet8.getRange(e, 1, 1, sheet8.getLastColumn()).moveTo(targetSheet8.getRange(targetSheet8.getLastRow() + 1, 1));
  });
  moveRows8.reverse().forEach(function(e) {sheet8.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet9 = ss.getSheetByName("Happy Calling Mumbai");
  var values9 = sheet9.getRange(1, 31, sheet9.getLastRow(), 1).getValues();
  var moveRows9 = values9.reduce(function(ar, e, i) {
    if (e[0] == "satisfied") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet9 = ss.getSheetByName("Main Sheet Mumbai");
  moveRows9.forEach(function(e) {
    sheet9.getRange(e, 1, 1, sheet9.getLastColumn()).moveTo(targetSheet9.getRange(targetSheet9.getLastRow() + 1, 1));
  });
  moveRows9.reverse().forEach(function(e) {sheet9.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet10 = ss.getSheetByName("Main Sheet Mumbai");
  var values10 = sheet10.getRange(1, 58, sheet10.getLastRow(), 1).getValues();
  var moveRows10 = values10.reduce(function(ar, e, i) {
    if (e[0] == "Reopen") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet10 = ss.getSheetByName("MUMBAI Calls");
  moveRows10.forEach(function(e) {
    sheet10.getRange(e, 1, 1, sheet10.getLastColumn()).moveTo(targetSheet10.getRange(targetSheet10.getLastRow() + 1, 1));
  });
  moveRows10.reverse().forEach(function(e) {sheet10.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet11 = ss.getSheetByName("Happy Calling Mumbai");
  var values11 = sheet11.getRange(1, 31, sheet11.getLastRow(), 1).getValues();
  var moveRows11 = values11.reduce(function(ar, e, i) {
    if (e[0] == "SATISFIED") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet11 = ss.getSheetByName("Main Sheet Mumbai");
  moveRows11.forEach(function(e) {
    sheet11.getRange(e, 1, 1, sheet11.getLastColumn()).moveTo(targetSheet11.getRange(targetSheet11.getLastRow() + 1, 1));
  });
  moveRows11.reverse().forEach(function(e) {sheet11.deleteRow(e)});
}

{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet12 = ss.getSheetByName("Main Sheet Mix");
  var values12 = sheet12.getRange(1, 58, sheet12.getLastRow(), 1).getValues();
  var moveRows12 = values12.reduce(function(ar, e, i) {
    if (e[0] == "Reopen") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet12 = ss.getSheetByName("DELHI Calls Asha");
  moveRows12.forEach(function(e) {
    sheet12.getRange(e, 1, 1, sheet12.getLastColumn()).moveTo(targetSheet12.getRange(targetSheet12.getLastRow() + 1, 1));
  });
  moveRows12.reverse().forEach(function(e) {sheet12.deleteRow(e)});
}

key charCode for virtual keyboard

I have the below code to allow the user input only numbers, this works in browser. But when I access on mobile I think I am not able to get the right key code. So what are the keycodes for the same. Isn’t same as the web.

  // block e char, dot, hiphen and spacebar
  if (event.key === 'e' || [46, 45, 32].includes(event.charCode)) {
    event.preventDefault();
  }else{
   // allow to input logic
}

What are the charCode for dot, hiphen and spacebar which will work for both web and mobile keypad ?

Any help is appreciated

Refreshing UI parts on each loop of an AJAX sync call

Okay, it might be a simple question, but so far I didn’t find anything helpful by searching, so I am giving it a try here.

I am using plain old javascript/jquery on asp.net core on some project I am working on.

I am currently performing some actions on some employees in a foreach loop.
For each employee I am calling synchronously via ajax an API.

What I want is the UI to be updated, showing the current employee being processed in a progress bar.

While on debug, the process seems to work fine, but during normal process, it seems that the UI thread is not updated, only after all the work has been done. As such, as soon as I start processing the employees, the screen is stuck and closes after the work has been done. No progress bar is shown.

I only managed to show the progress animation and the first employee using the below trick

$('#applyYes').click(function (e) {
   e.preventDefault();

   var year = $('#yearCombo').val();

   $('#applyInfo').hide();
   $('#applyLoad').show();
   $('#applyAction').prop('innerText', 'Calculating...');

   setTimeout(function () {

      var employeeIDs = multipleEmployees_Array();
      for (var i = 1; i <= employeeIDs.length; i++) {
         employeeID = employeeIDs[i - 1];
         applyAmount(employeeID, year); //1. Updates progress bar 2. Ajax sync call
      }

   }, 0);

})

As far as I understand the e.preventDefault seems to move the timeout function being processed after UI thread finishes.

What is the optimal way of achieving what I want?

PS: No external libraries if possible. I am working on an third-party platform, that makes it difficult to add external libraries (policies, permissions etc.)

Multiple audios interfering on the same web page in vue.js 2

I have a vue.js 2 frontend on which there are multiple chat bubbles. Each chat bubble is a vue component that has its own speaker subcomponent. When I click on the speaker, the goal is to read the audio corresponding to the text in the bubble.

The speaker is a component that is an HTML Media Element object, and is instantiated like that: this.audio = new Audio('path of the wav audio file on the CDN').

I have almost achieved this goal, but however, sometimes, when I click on the speaker of some bubble, the audio I hear is the one from another bubble. I don’t know how, but they are interfering in some way. How to solve that?

Owl Carousel just show 1 item

i have problem to show a owl carousel and its just show 1 item,
i want to show 2 or more item
this is my code

`function showNowPlay(data)
{
  
  nowplay.innerHTML = '<div class="home__carousel owl-carousel active" id="flixtv-hero">';

  data.forEach(movie => {
    data.splice(8);
    const {backdrop_path,title,release_date} = movie;
    const movieE3 = document.createElement('div');
    movieE3.classList.add('home__card');
    movieE3.innerHTML= '

my html

nowplay.appendChild(movieE3).owlCarousel({
});
});
}`

and html is

<div class="home__carousel owl-carousel" id="flixtv-hero">
        <div class="home__card">
            <a href="details.html">
                <img src="img/home/1.jpg" alt="">
            </a>
            <div>
                <h2>Money Plane</h2>
                <ul>
                    <li>Free</li>
                    <li>Action</li>
                    <li>2021</li>
                </ul>
            </div>
            <button class="home__add" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16,2H8A3,3,0,0,0,5,5V21a1,1,0,0,0,.5.87,1,1,0,0,0,1,0L12,18.69l5.5,3.18A1,1,0,0,0,18,22a1,1,0,0,0,.5-.13A1,1,0,0,0,19,21V5A3,3,0,0,0,16,2Zm1,17.27-4.5-2.6a1,1,0,0,0-1,0L7,19.27V5A1,1,0,0,1,8,4h8a1,1,0,0,1,1,1Z"/></svg></button>
            <span class="home__rating"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22,9.67A1,1,0,0,0,21.14,9l-5.69-.83L12.9,3a1,1,0,0,0-1.8,0L8.55,8.16,2.86,9a1,1,0,0,0-.81.68,1,1,0,0,0,.25,1l4.13,4-1,5.68A1,1,0,0,0,6.9,21.44L12,18.77l5.1,2.67a.93.93,0,0,0,.46.12,1,1,0,0,0,.59-.19,1,1,0,0,0,.4-1l-1-5.68,4.13-4A1,1,0,0,0,22,9.67Zm-6.15,4a1,1,0,0,0-.29.88l.72,4.2-3.76-2a1.06,1.06,0,0,0-.94,0l-3.76,2,.72-4.2a1,1,0,0,0-.29-.88l-3-3,4.21-.61a1,1,0,0,0,.76-.55L12,5.7l1.88,3.82a1,1,0,0,0,.76.55l4.21.61Z"/></svg> 9.1</span>
        </div>

it just show 1 item,
how can i show 2-8 item ?
thanks

I am trying to send id to Controller with a dynamic button but it is not working

I’m trying to send the id of the object to the controller with the button. But it only does this for an item in the first row of the list. The button does not work for other items in the list. How can I solve the problem?

$(document).ready(function(){       
            $("#showTweet").click(function(){
         var tweetId = $(this).parent().attr('id');
        $.ajax({
        
        type: "GET",
        dataType: "json",
        url: "http://localhost:8020/showTweet?tweetId="+tweetId,
        success: function(result){
            var description = result.description;
            $('#tweetText').text(description);
            
             }
        });
    });
    
<table id="myTable" class="table table-striped">
                        <thead>
                            <tr>
                                <th>Kullanıcı</th>
                                <th>Oluşturulma Tarihi</th>
                                <th>Seçenekler</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr th:each="unapprovedTweets: ${unapprovedTweets}">
                                <td th:text="${unapprovedTweets.creative}"></td>
                                <td th:text="${unapprovedTweets.create_date}"></td>
                                <td>
                                
                                    <div th:id="${unapprovedTweets.id}"
                                        style="width: 0px; height: 0px; display: contents;">
                                        <a id="showTweet" class="btn btn-warning">Tweeti Gör</a>
                                        
                                        
                                    </div> <a th:href="@{'/sendTweet/' + ${unapprovedTweets.id}}"
                                    class="btn btn-primary" style="width: 90px; margin-left: 5px;">Onayla</a>
                                    <a th:href="@{'/refuseTweet/' + ${unapprovedTweets.id}}"
                                    class="btn btn-danger" style="width: 90px; margin-left: 5px;">Reddet</a>


                                </td>

                            </tr>
                        </tbody>
                    </table>

JS add event handler using for loop, passing self as parameter not working

I am wondering why the statement “let im = _imgs[i];” is indispensable in this situation.
Essentially, the _imgs are an array of image elements. But if I add the eventhandlers by _imgs[i].addEventListener("click", function(){clickImage(_imgs[i]);}, false);, it won’t work.

Can anyone explain why? Thanks a lot!

function init()
{
    _imgs = document.querySelectorAll("#block2 img");
    console.log(_imgs.length);
    _clicked = new Object();
    for(var i = 0; i < _imgs.length; i++)    
    {      
        let im = _imgs[i];
        _imgs[i].addEventListener("click", function(){clickImage(im);}, false);
        _clicked[_imgs[i].id] = 0;
    }
    console.log("hi");
}

How to add a notification text in an HTML link and remove when clicked?

I’m creating a website which has daily news updates with URL links. I need to add a NEW! text on top of the link and once the user has visited it, need to remove the text. I searched for it everywhere what this feature is called and also went through anchor tag attribute in CSS i.e. a:visited {}, but it’s only CSS, how can I use for the above scenario?

Also if there’s any other way to deal with newly added links and after certain time, the NEW! text is gone, please let me know, I’m unable to find any resources online. Thanks.

fetch http request succeeds in Chrome and Firefox but fails in Safari

If we run the following code in safari it fails saying “failed to load resource: cannot parse response”

fetch('https://mycompanyname/service/contracts-api/operatingMode', {
  method: "GET",
  headers: new Headers({
    'Authorization': 'Basic VGVzdFVzZXIxOlRFU1QhdXNlcjE=',
    'X-mycompanyname-ContractsServer': 'someurl'
  })
}

safari inspect element preview

safari inspect element headers
But if we run the same code in Chrome or Firefox, it succeeds (in the same mac computer).

Is there any quirk in Safari fetch request that I am not considering?