inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,824
January 2015
msg
|
Post by Lynx on Dec 21, 2015 10:21:33 GMT -8
FYI, Peter - I actually haven't given up hope completely. I just can't find a way to make it work with what I've got. I've been bouncing back and forth between my code and your code, trying to figure out what I can do with my code (since I can't use your code - because then it's not my code to submit) to get it to work. I've found where I had array indices messed up, so I fixed them. I even found a variable error (had mag_mqr_spd instead of msg_mqr_spd in the declaration, but used the intended one for the comparisons). I did use your var marquee= jQuery line, but I'm thinking that it's going to that first so it's never actually reading anything in. Here's the mess I've made of it so far:
If I can just figure out where I need to fix things, I might be able to do something with it. I know it's not the nice-looking code you've done. But, like I said, I can't use yours because then it's not really mine to submit - hence why I'm trying to find a way to make mine work. Hope that makes sense. Thanks.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Dec 22, 2015 5:13:34 GMT -8
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,824
January 2015
msg
|
Post by Lynx on Dec 22, 2015 7:30:20 GMT -8
Thanks, Peter! I'll start going through this to see if I can work this out the rest of the way.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,824
January 2015
msg
|
Post by Lynx on Dec 26, 2015 10:39:25 GMT -8
Well, I thought I got all of the issues, but it's still not showing. I've moved things around in my attempt to fix this. I've also renamed the for variable from a to z (and changed them where referenced) to stop them from coming up as BBCode anchor tags when posting here. This is where I'm at:
// Forum Marquee // Version 2.0.0 // Authored By: // This heading is to remain intact.
$('document').ready(function() { if (pb.data('route') && pb.data('route').name && pb.data('route').name == "home") // Only run on the Home page { var msg_mqr = ""; // Set our marquee to an empty string var msg_mqr_tlr = "#000000"; // Set our default text color to black var msg_mqr_spd = (parseInt(pb.plugin.get('msg_forum_marquee').settings.marquee_speed)); // Set speed to setting value, then check range if (msg_mqr_spd < 1) { msg_mqr_spd = 1; } else if (msg_mqr_spd > 10) { msg_mqr_spd = 10; } if (pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[0].text_line != undefined) // See if user filled in the first text line { for (var z = 0; z < pb.plugin.get('msg_forum_marquee').settings.marquee_and_links.length; z++) // Start going through all the forms and adding them in { msg_mqr += "<font color='"+pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[z].text_color+"'>"+pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[z].text_line+"</font>"; if (pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[z].link != undefined && pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[z].link_url != undefined) // Do we have links? If not, skip { msg_mqr += " Link: <a href='"+pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[z].link_url+"'>"+pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[z].link+"</a>"; } if (pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[z+1].text_line != undefined) { msg_mqr += " "+pb.plugin.get('msg_forum_marquee').settings.separator_indicator+" "; } else { msg_mqr += " <<<>>> "; } } } else if (pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[0].text_line == undefined) { msg_mqr = "<font color="+msg_mqr_tlr+">Thank you for using the Forum Marquee 2.0.0</font>"; } var marquee = $("<marquee direction='left' scrolldelay='" + msg_mqr_spd + "' onmouseover='"this.stop()"' onmouseout='"this.start()"'>" + msg_mqr + "</marquee>"); $('#content').prepend(marquee); } });
Again, I'm more than happy to try and work this out - I just need pointing in the right direction please.
Thanks!
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Dec 27, 2015 16:54:48 GMT -8
Lynx, Soon as I can (sometime this week hopefully), I'll take a look at it. Thought I would just post so you don't feel like you are being ignored
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,824
January 2015
msg
|
Post by Lynx on Dec 27, 2015 16:57:35 GMT -8
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,824
January 2015
msg
|
Post by Lynx on Jan 1, 2016 17:40:37 GMT -8
For those interested: I've now got a couple of "Learning JavaScript" books that cover a lot of stuff (I do better with books to learn - but I've still got MDN quick-linked ). The 1st book is for learning the basics and includes info about the DOM, JSON, HTML5, CSS / CSS3 and other stuff as well. The 2nd book I have goes into (I think) advanced stuff and includes things like OOP, API's and so forth. So, by the time I finish both of these books (hopefully), I'll be able to make some cool plugins. Oh, and I've posted this here because, in an earlier post, Peter was saying that my marquee V3.0.0 should be just JS and CSS (no more using the <marquee> tag). If all goes well with my learning - it will be just JS and CSS. Until then, though, 2.0.0 may have the <marquee> tag in it. This somewhat depends on when Peter (or maybe even Chris) might be able to look at my latest listing above to point me to where my error(s) are, as I still can't get it to work. Either way, the Forum Marquee is still being worked on for an update to it.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,986
December 2005
horace
Wormo's Mini-Profile
|
Post by Chris on Jan 2, 2016 16:06:56 GMT -8
If you're referring to the code listed in this post then there is something funky going on with quotation marks in line 38 and line 40. Rather than trying to eyeball the code line by line let the browser do the work and tell you where the error is located, it is so much easier if I copy the code and run it in a console. If your plugin is not running then first check the console for error messages, there should be one complaining about a syntax error in: msg_mqr = "<font color=\"+msg_mqr_tlr+\">Thank you for using the Forum Marquee 2.0.0</font>";I patched that by adding the escape but you could have used single quotes instead, you cannot include an unescaped quote in a string of the same type that is being used to delineate that string. For completeness you should know that HTML will also accept the quote entity (color="red") in addition to single or double quotes as an attribute delimiter.Once you fix that then the browser will complain about another line that also has syntax errors: var marquee = $("<marquee direction='left' scrolldelay='" + msg_mqr_spd + "' onmouseover='"this.stop()"' onmouseout='"this.start()"'>" + msg_mqr + "</marquee>");remove those red double quotes, you already have single quotes as the delimiterIn the future, if a code is not functioning properly check your console for errors and if you cannot make heads or tails of the wording for that error then post a link to where the code can be observed issuing the error, it is a heck of a lot faster than going line by line through a code. If there are other errors then they are not of the type syntax since nothing jumps into the console, reference errors for example would depend on the environment in which it is running. It is better to post a link than a code listing if you're trying to track down errors.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,824
January 2015
msg
|
Post by Lynx on Jan 2, 2016 16:18:57 GMT -8
Thanks, Chris! I didn't realize you could throw code in the console that had variables in it that reference plugin settings.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,986
December 2005
horace
Wormo's Mini-Profile
|
Post by Chris on Jan 2, 2016 16:33:44 GMT -8
You would normally get reference errors because the code is referencing something that doesn't exist in the context where you have opened the console (such as actual plugin settings installed on a different forum) which is why I prefer a LINK instead of a CODE LISTING when asking for debugging assistance, this is why I said if there are reference errors then a link not a code listing is needed. Syntax errors on the other hand, such as the ones I pointed out, need no context, they are either correct syntax or incorrect syntax and if they exists within a code then the code won't even get to the execution stage (where reference errors are determined). Syntax errors are a non-starter and are always checked first by the browser and that is why I used the console to check for correct syntax. If there are other errors (runtime) then an actual LINK would be required so the plugin can be observed while running.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,824
January 2015
msg
|
Post by Lynx on Jan 3, 2016 7:56:35 GMT -8
Feel free to take a look if you want to, Chris. Here's a link to my enabled, but non-functioning marquee. I reloaded the home page with the console running and got a document.ready error - so I've no clue what's even wrong there. I'm getting frustrated, I've lost sleep over trying to fix the plugin, I'm losing patience with it and I'm about to just throw in the towel and say "screw it" to v2. Maybe people should just use Peter's code. They wouldn't be allowed to submit it to the library, but they'd at least have a working plugin / code. I'm at rope's end with it.
|
|
inherit
162752
0
Apr 19, 2024 11:31:08 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Jan 3, 2016 12:50:59 GMT -8
Don't give up! We all get to places that frustrate us and then all of a sudden it'll all 'click'! Have a look at the image/text scroller here: pebbleplugins.proboards.com/It may not be what you are looking for but if it is, you can have an editable copy ( anyone that wants an editable copy of 98% of my plugins and has shown willing in the past can have one, just let me know. I don't log in here very often but do get messages ) It's way more complicated than what you're trying to do and doesn't use marquee, pure javascript apart from some stuff that I changed when it was ported over from Proboards V4 ( wow! How long ago was that? ) but feel free to look at it, rip what you want etc etc. It's not the greatest bit of coding ( far from it ) but it was the first one I wrote that had more than 20 or so lines of code. Just an offer and don't feel you have to take it. Just trying to help you continue your quest to write plugins. *thumbup*
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,986
December 2005
horace
Wormo's Mini-Profile
|
Post by Chris on Jan 3, 2016 19:11:06 GMT -8
The error in my console is TypeError: Cannot read property 'text_line' of undefined and that appears to be something Peter already pointed out but it was never fixed - Incrementing an index to get the next element from an array needs checking for existence if (pb.plugin.get('msg_forum_marquee').settings.marquee_and_links[z+1].text_line != undefined) edited to reflect newer codeBasically, since you currently have TWO entries in the plugin settings, when z equals 1 and you check for z+1 (which doesn't exist == undefined) you are asking for the value of 'text_line' on something that is undefined. Simplest solution is to check to be sure the array has something at z+1 first before looking for a value from it. There is nothing wrong with doing like that but it might be easier to add the separator before adding the text_line, just check if msg_mqr has a length (therefore already has entries) and add a separator before add the new line. Looking ahead in an array can lead to errors such as this unless you go on the assumption that nothing else is ahead and you'll be going over the cliff if you do not check with your hands on the brakes.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,824
January 2015
msg
|
Post by Lynx on Jan 5, 2016 13:32:28 GMT -8
Thank you Pebble and Chris! Yeah, Chris. I had a DORT! moment (apparently) on that part. However, thanks to your patience and re-pointing that part out to me, I was able to get that one fixed. You can see Version 2.0.0 now running (link in sig for forum running on). Thanks to EVERYONE who was patience with me with this. It is MUCH appreciated.
|
|