Parsing error whilst making dropdowns (.js .html .css) - javascript

I'm attempting to make some dropdown menus however when writing code to make it so you don't click out of the dropdown when trying to click the option in the dropdown I got this parsing error and I cannot figure out why.
Here is the script.js:
document.addEventListener("click", e => {THE ERROR IS ON THIS LINE: Parsing Error: Unexpected Token >
const isDropdownButton = e.target.matches("[data-dropdown-button]")
if (!isDropdownButton && e.target.closest("[data-dropdown]") != null) return
let currentDropdown
if (isDropdownButton) {
currentDropdown = e.target.closest("[data-dropdown]")
currentDropdown.classList.toggle("active")
}
document.querySelectorAll("[data-dropdown].active").forEach(dropdown => {
if (dropdown === currentDropdown) return
dropdown.classList.remove("active")
})
})
I've tried checking all spellings, even copy pasting all the code from a github to replace it but it still won't work. I have also been following along this video: https://www.youtube.com/watch?v=S-VeYcOCFZw&t

Related

Editor extension onDidCloseTerminal() causes editor to freeze

I am trying to write an extension for vscode, and I am trying to handle closing of the terminal, but whenever I click on the trash on the terminal to delete the terminal, the editor freezes. Here is how I am handling how the editor is closed. Am I doing something wrong?
I have multiple terminals, and I am opening one that is not named Server Terminal, it is called Add Package so it doesn't go into the if statement which is what I want in this case. So, what is causing the editor to freeze? I tried adding an else { t.dispose() } but the editor still freezes.
export function activate(context: ExtensionContext) {
window.onDidCloseTerminal(t => {
// Watch for when the server terminal closes.
if (t.name === 'Server Terminal') {
Serve.server = undefined
showMessage(`The server has been stopped on "http://${Serve.host}:${Serve.port}"`)
}
})
}
So, for me, it seems as if to solve this issue I need to first kill the process manually, then I can set Serve.server to undefined. This seems to solve the issue of the editor freezing:
window.onDidCloseTerminal(async t => {
// Watch for when the server terminal closes.
if (t.name === 'Server Terminal') {
const id = await t.processId
id && kill(id)
Serve.server = undefined
}
})

Weird behavior in Node REPL when pasting text (Windows OS) - Crashes

I'm sorry if this has already been posted but I have no idea how to search for what I am experiencing.
This be might Windows OS specific I don't know.
I use VS code as my IDE and when testing node code I open the integrated terminal and run node from there. I then copy and paste a lot of my code to run them line by line and do testing etc. I noticed that it would completely lock up node when pasting sometimes. After a painstakingly long time I finally found it only happens when I copied and pasted large amounts of text. IE I could highlight my whole code, copy and paste and it would lock up node. But then if I tried copying only half and executed it then the second half and executed it, it would work.
I thought this was VS code related until recently I did it directly in the node REPL outside of VS code and it crashed there also.
Has anyone else experienced this? I did a google and found some reported bugs ages ago similar to what I'm experiencing but they were meant to be fixed.
To make this even weirder, sometimes I CAN execute the large amount of text under certain conditions. It seems to work if I copy and paste in small batches first, ie split the code into 3 parts and execute them individually, then if I now go back and highlight it all and copy and paste, it executes it fine. But then I load a new node up, copy and paste all code again and it fails. Not really sure what's going on.
EDIT: Here is the code below. If you open the node REPL and paste of this, it will freeze on the first line (so don't worry about the requires not being able to find the modules). NOTE; the code has been changed to take out the IP so IF does execute it will error as I just replaced some keywords with random text. Ignore this, the point of it is to show that it won't copy and paste past the first line, it will freeze. Any help appreciated!
//{"_id":"56aba3108d6d183da42403c2"}
//placeholder
const request = require('request');
var mongoose = require ("mongoose");
var lodash = require ("lodash");
var myFuncs = require("./functions");
var item_urls;
var options = {
json: true
};
var test = [] ;
function updateDB (){
var url = "get stuff";
request(url, options, (error, res, body) =>{
if (error) {
return console.log(error)
};
if (!error && res.statusCode == 200) {
console.log("executing cb1");
item_urls = body.payload.items;
myFuncs.fixItemIDs (item_urls);
var primes = item_urls.filter(item => item.item_name.includes("Strun Wraith Set"));
for (item in primes)
{
let url = `https://get more stuff/v1/items/${primes[item].url_name}`;
// console.log (url);
request(url, options, (error, res, body) =>{
if (error) {
return console.log(error)
};
if (!error && res.statusCode == 200) {
console.log(`Getting item ${url}`);
test.push(body.payload.item);
myFuncs.fixItemIDs (test);
}
});
};
console.log ("done");
};
});
}
updateDB();
I logged it as a Bug on Github and someone else tested and reproduced the issue. It is now a confirmed bug they are going to look into. It is even present in beta/latest version.
https://github.com/nodejs/node/issues/32999

Inserting Editable content control in Word online add-in

In my Word Add-In, I want my user to be able to insert a template, with editable content controls. Works fine in Word client, but in Word online, I can't get it to work properly.
You'll find my code below. I get a debug error saying The action isn't supported in Word Online. Error location : ContentControl.placeholderText.
Indeed when I comment out the line setting placeholderText, I get no error. But then my add-in only adds lines of empty text, which is not my purpose obviously.
Word.run(function (context) {
var thisDocument = context.document,
range = thisDocument.getSelection();
case "ProtagonistsIntroduction":
var paragraph = range.insertParagraph("Customer", Word.InsertLocation.before);
paragraph.styleBuiltIn = "Heading1";
setTemplateContentControlProperties(range, "Mr/Ms. and name", true);
//I insert here many other content controls
break;
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
function setTemplateContentControlProperties(container, placeholderText, lineBreakAfter) {
var contentControl = container.insertContentControl();
contentControl.appearance = "BoundingBox";
contentControl.removeWhenEdited = true;
contentControl.placeholderText = placeholderText;
if (lineBreakAfter) {
contentControl.insertBreak("Line", Word.InsertLocation.after);
}
return contentControl;
}
As this tool is here to provide the user with a document template with all the information that he should include, I need these placeholders.
Is there a way around this ?
I would be OK with a way of just adding lines of text instead of content controls when in Word Online ; but adding the content controls when I'm in a compatible environment (Word client) ; if there isn't anything better than that.
Cheers !
The inability to set placeholderText in Word Online is a known limitation of the Word API, as described in this GitHub issue: https://github.com/OfficeDev/office-js/issues/53. I'd suggest that you subscribe to notifications for that GitHub issue to be notified of any updates there from the product team.

spawn in javascript : delayed stdout , how to disable buffer?

I'm trying to execute a program (binary), that is printing values regularly on the stdout.
with exec, it works fine, but with spawn, results only comes after a while, why ? what can I do about that ?
const opcv=spawn("myprog",["-L","2","-o","pairs","-r"], { shell:false, stdio:"pipe" })
opcv.stdout.on('data', (data) => {
node.log("opcdata stdout=" + data);
});
opcv.stderr.on('data', (data) => {
node.log("opcdata stderr=" + data);
});
I tried whith the option {stdio:"inherit"}, in that case I see the data directly, but I'm not able to work with ".stdout.on(" anymore :
TypeError: Cannot read property 'on' of null
EDIT
It seems to be linked with the program I'm trying to run, but unfortunately its not possible to disable stdout buffering in the program, is it possible to execute it with another shell than cmd , or are they other tricks ?

Getting JS runtime error ONLY when debugging in VS 2010

For some reason when I am trying to debug my site in VS I get the error
JavaScript runtime error: Unable to set property 'value' of undefined
or null reference
when using a date picker. I can hit continue and everything works perfectly fine. If I run the site without debugging everything works fine, the exact same code running in production works fine so why is VS complaining about this only when I debug?
function SetDate(formName, id, newDate, postBack) {
var theform = document.getElementById(formName);
popUp.close();
theform.elements[id].value = newDate;
if (id = "txtDate3") {
theform.elements['txtDate4'].value = newDate
}
if (postBack) __doPostBack(id, '');
}
if (id = "txtDate3")
assignment is improper here, use conditional
if (id == "txtDate3")
or
if (id === "txtDate3")

Categories