portfolio/src/main/webapp/script.js
//Asynchronous function that pings server and gets sentiment from cloud API
Asynchronous function that pings server and gets sentiment from cloud API
Asynchronous function that pings server and gets sentiment from cloud API
async function returnSentiment(text) {
    const responseFromServer = await fetch('/sentimentExtract', {
        method: 'post',
        body: JSON.stringify(text),
    });
    const Response = await responseFromServer.json();
    var sentimentContainer = document.getElementById('FinalSentiment');
    while (sentimentContainer.firstChild) {
        sentimentContainer.removeChild(sentimentContainer.firstChild);
    }
    if (Response < -0.5) {
        insertDiv("Negative", sentimentContainer);
        changestyle(1);
    } else if (Response > -0.5 && Response < 0.5) {
        insertDiv("Neutral", sentimentContainer);
        changestyle(2);
    } else {
        insertDiv("Positive", sentimentContainer);
        changestyle(3);
    }
}
async function returnSentiment ( text ) { const responseFromServer = await fetch ( '/sentimentExtract' , { method : 'post' , body : JSON . stringify ( text ) , } ) ; const Response = await responseFromServer . json ( ) ; var sentimentContainer = document . getElementById ( 'FinalSentiment' ) ; while ( sentimentContainer . firstChild ) { sentimentContainer . removeChild ( sentimentContainer . firstChild ) ; } if ( Response < - 0.5 ) { insertDiv ( "Negative" , sentimentContainer ) ; changestyle ( 1 ) ; } else if ( Response > - 0.5 && Response < 0.5 ) { insertDiv ( "Neutral" , sentimentContainer ) ; changestyle ( 2 ) ; } else { insertDiv ( "Positive" , sentimentContainer ) ; changestyle ( 3 ) ; } }
Asynchronous function that pings server and gets sentiment from cloud API
Asynchronous function that pings server and gets sentiment from cloud API
//To clear div before new data is added