"use strict"; /* global document window alert */ var sentDiag = (function(){ var can, elDragged, diag = { showing: false

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

"use strict"; /* global document window alert */ var sentDiag = (function(){ var can, elDragged, diag = { showing: false

Post by answerhappygod »

"use strict";
/* global document window alert */
var sentDiag = (function(){
var can,
elDragged,
diag = {
showing: false,
base: 0.4,
crossLoc: 0.5,
crossLocA: 0.3,
crossLocB: 0.6,
},
sentence = "Diligent farmers .#$,? delivered fresh beets.",
wordButtons,
words;
/* processChoice will process the choice made on the sentence
diagramming page, but for now just pops up an alert indicating
processChoice was entered. */
function convertSentence() {
var i, len, noPunct, singleSpace;
noPunct = sentence.replace(/[^\w\s]/g, ""); // remove
punctuation
singleSpace = noPunct.replace(/\s{2,}/g, " "); // collapse white
space to single space
words = singleSpace.split(/\s/); // create array elements from
words between spaces
}
sentence = singleSpace;
document.getElementById("curSent").innerHTML = sentence;
// create HTML for draggable word buttons
len = words.length;
wordButtons = "";
for (i = 0; i < len; i = i + 1) {
wordButtons +=
'<input type="button" value="' +
words +
'" class="word" draggable="true" ondrag ="sentDiag.elDragged='
+
(i + 4) +
'"><br>';
}
}
function validScore(ev);{
var e = document.getElementById("scoreErr"),
preScore = document.getElementById("score").value;
}
try {
if (preScore === "") {
throw "Please enter what you expect to earn.";
}
if (isNaN(preScore)) {
throw "Please enter a number for the score you think you'd
earn.";
}
if (preScore < 0) {
throw "Please enter a score greater than or equal to 0.";
}
if (preScore > 100) {
throw "Please enter a score less than or equal to 100.";
}
} catch (err) {
e.innerHTML = err;
e.style.display = "inline";
document.getElementById("score").focus();
} finally {
if (
preScore !== "" &&
isNaN(preScore) === false &&
preScore >= 0 &&
preScore <= 100
) {
e.innerHTML = "";
e.style.display = "none";
displayDiagram();
}
}
function validInput() {
var input = document.getElementById("fn"),
err = document.getElementById("fnameErr");
if (input.checkValidity() === false) {
err.innerHTML = input.validationMessage;
err.style.display = "inline";
input.focus();
return false;
} else {
// valid name, so proceed
document.getElementById("fnameEntered").innerHTML =
input.value;
err.innerHTML = "";
err.style.display = "none";
validScore();
return true;
}
const item =sentDiag.elDragged('.item');
item.addeventListener('elDragged', elDragged);
function elDragged(e){
console.log('drag starts...');
}
function processChoice(ev) {
alert("processChoice entered");
}
if (true) {
drawMainSentence();
} else if (true) {
// direct object structure
/* call drawDirectObjectLine */
} else if (true) {
// modifier structure (adj or adv)
if (true) {
// modifier structure (adj)
/* call drawAdjLine */
} else {
// modifier structure (adv)
/* call drawAdvLine */
}
} else {
// word
/* set idx equal to e - 4 */ // shift values, so idx is in range
[0,4]
if (true) {
// bottom
if (true) {
// left (adj)
drawAdj(words[idx]); // call drawAdj and send it the value
stored at location
} else {
drawAdj= "idx";
// right (adv)
/* call drawAdv and send it the value stored at location idx of
words */
}
} else {
// top
if (true) {
// left (subject)
/* call drawSubject and send it the value stored at location idx
of
words[idx] */
} else {
// right (predicate or direct object)
if (true) {
// predicate (diagram with no direct object)
/* call drawPredicate and send it the value stored at location
idx of
words[idx] */
} else {
// diagram with direct object (predicate or direct object)
if (true) {
// predicate
/* call drawPredicate and send it the value stored at location
idx of
words[idx] */
} else {
drawDirectObject
// direct object
/* call drawDirectObject and send it the value stored at
location idx of
words[idx] */
}
}
}
}
}
function checkProposal() {
alert("Check Answer clicked");
}
function resetAll() {
alert("Reset clicked");
}
convertSentence();
can = document.getElementById("myCanvas");
can.width = window.innerWidth / 2 - 10;
can.height = window.innerHeight / 2;
return {
validInput: validInput,
processChoice: processChoice,
resetAll: resetAll,
checkProposal: checkProposal,
}
}
please help me figure out why I keep getting this error
in java script

Use Strict Global Document Window Alert Var Sentdiag Function Var Can Eldragged Diag Showing False 1
Use Strict Global Document Window Alert Var Sentdiag Function Var Can Eldragged Diag Showing False 1 (8.2 KiB) Viewed 26 times
')' expected. ts(1005) [43, 3]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply