> Support for Evil is a new feature but not a breaking change, so in keeping with Semantic Versioning, we’ve incremented JSHint’s minor version. JSHint version 2.12.0 is licensed under the terms of the MIT Expat license.
I admire the commitment to the craft.
I use console.log
to see the generated script element, and it does indeed contain the text of the script. It is also appended to the body, so it is at the end (this is also verifiable by running this and inspecting, as you suggest).
Now, I added these lines to the end of the unloaded script:
const memsq = memo(x => x**2),
cachedsq = Memo(x => x**2);
console.log('With memo: ', memsq);
console.log('With Memo: ', cachedsq);
console.log(memsq(9));
As expected, that code is never executed (neither memsq
nor cachedsq
exist), so as you point out, the script is not being loaded. I ran both scripts through JSHint, but only got warnings about using the ES6 flag in the site (which I don't know how to do); no errors. The unloaded script works quite well on Node, and when pasting it directly into the console, as I already mentioned, so this script has no errors that prevents it from running. :/
I'm not very seasoned, so could you please suggest what sort of printouts I should add? I can only think of console.log(file)
after declaring file
. If I load the problematic script with this added line, I do see its code on the console, so the file
object does indeed contain the text of the code; it just isn't loaded afterwards, even though the <script>
element is appended to the body. Help, please? Thanks! :)
If vscode isn't helping, try jshint.com.
Here is the cleaned up code. You had a missing "," or two, and the syntax for your ternary operation was bad, which I corrected.
You also had a few "eval" and "removeeval" that were unnecessary, which I removed.
I haven't tested it on a sheet, but the syntax is now 100% valid.
JSHint is an excellent JavaScript linter that I recommend that everyone use.
You have opened two arrays in source
, but only closed one. Source only needs to take one array, so you should delete the second [
.
Additionally the object needs to be terminated with a ;
, not a ,
.
You should look at some basic JavaScript Object articles before proceeding, however, otherwise you may make further mistakes.
Are you getting the message that you don't have a valid config.js file after you modify the default modules? Try using something like JSHint to confirm that you don't have issues like missing commas or semi-colons and all your brackets and braces tie together. Also, unless you're using the words true/false or numbers, anything else (not the variables but the values you're wanting) generally needs to be surrounded by either "s or 's. Either work, just be consistent when using them.
If that still doesn't help, if you want to post your current non-functioning config.js (with personal information redacted), we might be able to figure out your issue as well.
Unfortunately even though the polls do have a unique ID, they're dynamically generated and not tied to any particular set of data.
The way the script is structured, the code in else if 1 is actually triggered necessarily because the user isn't presented with the poll until they've chosen a class.
I've done a bunch more reading and the problem may be something specific to Google Apps Scripts, where apparently global variables behave differently. I've tried putting my code into https://jshint.com/ and it throws a whole bunch of "variable is already defined" messages, but when I remove any of the definitions, the script doesn't know what I'm talking about.
This thread shed a lot of light for me, and also gave a potential solution in the form of:
PropertiesService.getScriptProperties().setProperty('mykey', 'myvalue');
I only just found out about this so will have to experiment with it.
Thanks for all your help thinking through this by the way!
I'm also trying to wrap my head around the answer in this thread.
I found links in your comment that were not hyperlinked:
I did the honors for you.
^delete ^| ^information ^| ^<3
Hi u/bass1012dash, thanks for the reply.
The error appears in my Chrome console log so shouldn't the error be because of the Javascript? When I placed my Javascript code in JShint.com, I get an error message that "Expected an identifier and instead saw '<'."
I think the issue is from this? Why was the answer in the Stack Overflow link able to execute the code?
>It could also be that the variable isn’t available? Where is the order_id defined?
order_id appeared on the Thank You Page previously. So I believe it is already available? Or what must I do to make it available? echo
it?
Thank you for your help.
Sorry, I wrote that on my phone and didn't have the time to go over the whole code. You can also put your code though a linter (like JShint.com), as it will tell you about all the lines that have a syntax error. You also need to make the following changes:
SourceList["mndfly"] = {
source : ["mndfly", 0],
} }
(yes, you are missing two closing curly brackets there)Or you can remove the whole SourceList
entry and leave line 31, 68, and 81 as they are now. This is because the source "HB" already exists as "Homebrew" and you shouldn't overwrite it. You can make a new SourceList
entry, but to do that you can only have a string in the square brackets, and no comma or number.
Lastly, to make the weapon entry work, you will need to change its name to something else than "Flayer" so that it matches the regExpSearch
that you gave it (or the other way around, change the regExpSearch to match the name). Note that a weapon can't have a sortname
, so you can delete that entry.
Ok, so I am using JSHint.com (thank you great resource there), it is helping me understand the scripting a little easier.
I am using some other sites as well to help me.
So I have cut down the script a great deal, there was subclasses I had just copied in and such that were not needed, so that has all been removed reducing the total code by a lot.. That leads to some Good news, and some bad"?" news?
Now when I copy the script to the sheet it accepts it, I am able to see it when I open the library of scripts to add, and I am able to add and remove it as needed. Here is where it gets weird..
When it is added to the sheet I no longer have the ability to open the "Set Character Class", when I click on it nothing happens. When I remove the script from the library it works fine.
I was looking at the scripts you wrote but the only thing I am finding are subclasses and this is a new class (at least how its written), so I was hoping to look at how the Basic fighter class is written as this class has no spell abilities, I figure that might be the closest (or possibly a rogue)..
I will also do up a new github post a little later.. One of my table mates who uses the sheets as well and has written his own code has been able to get the subclass to appear without issue on a 12.99 sheet but both of us tried and were unsuccessful at getting it to load on the 13.19 sheets (it doesnt show up in the available cleric subclasses). I will see if I can figure that out but if there is a specific script I should review first it would be appreciated to be pushed that direction? I am more than happy to spend the time learning and reading and reviewing code :D there is just a lot of it to look at and sometimes I really dont know if I am looking at the right stuff or not :D
Thanks again for your help and everyone else who offers help here and else where.. to those of us learning, its awesome so thank you from me!!!