Jump to content

gw1500se

Members
  • Posts

    1,041
  • Joined

  • Last visited

  • Days Won

    17

Everything posted by gw1500se

  1. For testing, config_data.excludes has one entry: Array(1) 0: "/FRENCH*/" length: 1 items.title has many entries but these are typical: skipping Pick a Youtube thumbnail/title (~10 seconds) skipping Survey for $0.25 (~4 Minutes)(~ 4 minutes) skipping 2-minute study for $0.30(~ 2 minutes) skipping 2023 Plans As you can see the code is "skipping" even though 'FRENCH*' does not exist in those strings.
  2. This is not working as expected. Perhaps I am missing something. First I do this: regexes=[] for (let item in config_data.excludes) { regexes.push(new RegExp(item)); } 'config_data.excludes' is an array of strings representing regexps. Then I do this in a loop: if (regexes.some(re=>re.test(item.title))) { console.log("skipping "+item.title) continue; } This block is in a loop (item.title) so the 'continue' will skip to the next item in the loop. Unfortunately, it finds the 'if' is always true although none of the items contain any of the rexexps. I didn't let it run long enough to actually encounter a title that does match but is the return boolean backwards from what I expected?
  3. I don't want to write the loop myself if I don't have to which was what I was trying to say. I don't think I understand what you did. First don't you need to run 'regexes' through the 'RegExp' function? Then is 'test' a function of 'some'? I was not able to follow the link you provided as it relates to this question. I assume from the documentation that 'any' will be either 'true' or 'false', right?
  4. I have an array of regular expressions that I want to check against a string. I need to know if the string matches any of those regexps. Is there a way to do that without using a loop? TIA.
  5. Thanks. That was what I was missing.
  6. To clarify, 'excludes' is not in the object (yes it is a json array/object) at this point but I want it to be an empty array for future use: json_array.excludes.push(<some string>);
  7. I have an object that contains arrays and other elements. I need to add an array to that object but I cannot figure out how to do that. This is what I tried: json_array.push(excludes[]); Can someone give me the correct syntax? TIA.
  8. I'm a bit confused about regexp in Javascript. If I have a string that is in the form of a regexp do I need to create a regexp object to use it? If so do I just do: expr=new RegExp(str); TIA.
  9. Yep. There you go. It is a permissions error or wrong password for root or root is the wrong MySQL user for that database.
  10. Then it must be a permissions issue resulting from the change. Check the httpd/error log.
  11. You need to show your code but off hand I would say that there is no database named 'phplogin'. I'm guessing that is a table name and the database itself is named something else.
  12. You need to post your code. What did you try? What error did you get or what did you get that was not expected?
  13. This appears to be related to special restrictions imposed by Chrome extensions. I've moved to stackoverflow for help.
  14. Are you trying to get 3 levels deep? myArr[0][0][0]
  15. That is the entire script and no, I am not getting an error. The big difference is that my code is running as a Chrome extension.
  16. Except that didn't work either originally.
  17. If your conditional fails then that variable is not set. You only set it in the else clause. You need to initialize it to something or test if it exists before using it.
  18. Now that I have another issue fixed, I am back to the problem of no cookie being written. This is my current code: function create_cookie(obj=null) { var json_array=[]; if (obj==null) { json_array=[{none:true}]; } else { json_array=obj; } Cookies.set("Auto_Select_0519669",JSON.stringify(json_array),{expires:3650}); } var json_str=Cookies.get("Auto_Select_051969"); if (typeof(json_str)=="undefined") { create_cookie(); json_str=[{none:true}]; console.log("set new cookie"); } console.log(json_str); Each time I run this code I get the output "set new cookie". When I search for the cookie it it not found. Apparently 'Cookies.set' is not writing the cookie but I get no errors.
  19. I finally got it working but I can't explain how/why. I did: console.log(typeof(json_str)=="undefined"); The output was "true" which I expected. I then edited the line by changing 'console.log' to 'if' and changed the ';' to '{' and the thing started to work.
  20. Yes. With or without the parens, I get the same result.
  21. I an trying to determine if a cookie exists using the following code: const json_str=Cookies.get("Auto_Select_051969"); if (!(json_str in window)) { create_cookie(); json_str=Cookies.get("Auto_Select_051969"); } json=JSON.parse(json_str); When it gets to the parse I get the error: Uncaught SyntaxError: "undefined" is not valid JSON at JSON.parse (<anonymous>) at cookie_mgmt.js:16:11 'create_cookie()' is not executed. If 'json_str' is undefined, per the error, how can it fail the 'if' test? I also tried: if (typeof(json_str)=="undefined") { Which also fails the 'if' test.
  22. Deleted for now.
  23. Using that library, at least the way I read it, does not work. This is my function which produces "undefined" in the console log (no errors): function create_cookie(obj=null) { var json_array=[]; if (obj==null) { json_array=[{filter:false}]; } else { json_array=obj; } Cookies.set("Auto_Select_0519669",JSON.stringify(json_array),{expires:2147483647}); } console.log(Cookies.get("Auto_Select_0519669"));
  24. I have to let my javascript ignorance show here. It seems that package required 'imports'. Since I am writing a Chrome extension, imports are not permitted. I need the js file(s) themselves and I don't see that in the git tree.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.