Page 1 of 2

Wind graph/rose help

Posted: Sun 06 Sep 2020 12:49 pm
by rogerthn
I do have a working wind graph/rose on https://rogerthn.se/cumulusutils/ while https://rogerthn.se/cumulusutils2/ is "empty"
Output from Chrome console

Code: Select all

VM49:16 Uncaught SyntaxError: Invalid or unexpected token
    at b (jquery.min.js:2)
    at Ie (jquery.min.js:2)
    at k.fn.init.append (jquery.min.js:2)
    at k.fn.init.<anonymous> (jquery.min.js:2)
    at _ (jquery.min.js:2)
    at k.fn.init.html (jquery.min.js:2)
    at Object.success (cumulusutils.js:1)
    at c (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at l (jquery.min.js:2)
b @ jquery.min.js:2
Ie @ jquery.min.js:2
append @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
_ @ jquery.min.js:2
html @ jquery.min.js:2
success @ cumulusutils.js:1
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
l @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
load (async)
send @ jquery.min.js:2
ajax @ jquery.min.js:2
LoadUtilsReport @ cumulusutils.js:1
onclick @ (index):1
jquery.min.js:2 jQuery.Deferred exception: RoseAllYearsAllMonths1 is not defined ReferenceError: RoseAllYearsAllMonths1 is not defined
    at eval (eval at SetData (:68:11), <anonymous>:1:1)
    at SetData (<anonymous>:68:11)
    at HTMLDocument.<anonymous> (<anonymous>:4:3)
    at e (https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js:2:29453)
    at t (https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js:2:29755) undefined
k.Deferred.exceptionHook @ jquery.min.js:2
t @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
c @ jquery.min.js:2
add @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
Deferred @ jquery.min.js:2
then @ jquery.min.js:2
k.fn.ready @ jquery.min.js:2
k.fn.init @ jquery.min.js:2
k @ jquery.min.js:2
(anonymous) @ VM47:2
b @ jquery.min.js:2
Ie @ jquery.min.js:2
append @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
_ @ jquery.min.js:2
html @ jquery.min.js:2
success @ cumulusutils.js:1
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
l @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
load (async)
send @ jquery.min.js:2
ajax @ jquery.min.js:2
LoadUtilsReport @ cumulusutils.js:1
onclick @ (index):1
jquery.min.js:2 Uncaught ReferenceError: RoseAllYearsAllMonths1 is not defined
    at eval (eval at SetData ((index):68), <anonymous>:1:1)
    at SetData (<anonymous>:68:11)
    at HTMLDocument.<anonymous> (<anonymous>:4:3)
    at e (jquery.min.js:2)
    at t (jquery.min.js:2)
Log file attached

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 1:38 pm
by HansR
Aha, interesting. :mrgreen:

You made two sites, one in English and one in Swedish if I understand this well.
The English one is OK, the Swedish site goes wrong.

What you see is an error somewhere in the generated javascript. And the most likely cause is that is is somewhere in the language file/translation (because it works in English). Either a string has not been entered in the Swedish file yet or you put a slash or illegal character somewhere or some totally unexpected forgotten colon, semicolon or a single/double quote mismatch. Especially single quotes in a string can be problematic (e.g. "He is" -> "he's" is legal if used in a correct place). They are allowed but there may be a situation which is not covered well.

The Achilles heel of the way I constructed CumulusUtils is the debugging of the generated javascript and then when found feed it back to the code generator. Javasript is already sometimes hard to debug (although modern browsers make life pretty easy), the stairway to result I created can make life tough.

So, I suggest you walk through your language file accurately (do you know your last modifications?) and if you are confident the file is OK, and it still does not work, please send the translation to me and I will make an effort to find the problem. As this is a runtime javascript issue, the logfile will bring no solution. I assume the two sites are fully separated and only share the realtime files. When sending me the translation, I need the inifile as well.

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 3:44 pm
by mcrossley
It's trying to do an eval in SetData() at data1 of "RoseAllYearsAllMonths1"...

Code: Select all

function SetData(thisYear, thisMonth) {
code = thisYear + thisMonth;
textLine = '<b>Period i Vindros:</b><br><b>År: </b>'+ $('#yearRose option:selected').text() +'<br><b>Månad:</b> '+ $('#monthRose option:selected').text();
  data1 = eval('Rose' + code + 1);
  data2 = eval('Rose' + code + 2);
  data3 = eval('Rose' + code + 3);
  data4 = eval('Rose' + code + 4);
  data5 = eval('Rose' + code + 5);
  data6 = eval('Rose' + code + 6);
  ZeroWind = eval('ZeroWind' + code);
}
But that does not exist.
Not sure if that helps!

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 5:45 pm
by HansR
Thanks for analysing, but that indeed is merely an expression of the error.
javascript has the habit of postponing messages.

BUT: having said that I see the Swedish site is working so Roger must have found something :D

Ai: I said it was working but I looked the wrong way :cry:

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 7:33 pm
by HansR
OK. I think I found it.

In the language file, section [Graphs] you will find the (untranslated) line:

Code: Select all

CompassSectors=["N", "NNO", "NO", "ONO", "O", "OZO", "ZO", "ZZO", "Z", "ZZW", "ZW", "WZW", "W", "WNW", "NW", "NNW"]
Those need to be translated. That is what you did:

Code: Select all

['N', 'NNO', 'NO', 'ONO', 'Ö', 'OSO', 'SO', 'SSO', 'S', 'SSV', 'SV', 'VSV', 'V', 'VNV', 'NV', 'NNV']
But while translating you changed the double quotes to single quotes and that is not correct because the text in the language files is taken 1 - 1 to the code. And if it is javascript the string gets injected to, the single quote is escaped to make it possible to have single quotes in titles (as e.g. here and here). And that's where it goes wrong. I don't make exceptions for where I encounter singles quotes, there is no context just is it for javascript or not. In javascript they are escaped as if in strings. Problem is the CompassSectors is actually a complete javascript part of an equation.

However: never changes quotes, just change text ;)
Don't know why you did that btw :lol:

So just change the single quotes back to double quotes and you're fine.
I think.

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 7:54 pm
by HansR
And wow, the confusion gets even bigger, because when checking further, I found that the default in the code is actually with single quotes. So most likely not your error but mine.
The confusion lies in the fact that originally a double quoted line was in the cumulusutils.ini file which had been moved to the language file (I think).

How this ever has been going well for novices is a small riddle to me.
Anyway, some corrective work for me for the next version. :groan:

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 8:00 pm
by HansR
OK. My bad: in version 4.1.0 i had a cleanup action to change redundant \" to ' in the javascript section.
I did the CompasSectors as well. Just corrected it.
Oops :oops:

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 8:02 pm
by rogerthn
Yes, the single quotes was there prior to my translation :o
From a backup

Code: Select all

CompassSectors=['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']
Running ./cumulusutils.exe Graphs right now.
We'll see the result in some minutes

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 8:36 pm
by rogerthn
:P :P
Good night

Re: Wind graph/rose help

Posted: Sun 06 Sep 2020 8:48 pm
by HansR
Ah just saw it. Took a long time to generate so i went away.
Anyway, all is well that ends well. Sorry for the trouble ;)

Re: Wind graph/rose help

Posted: Mon 07 Sep 2020 5:14 am
by rogerthn
Generation time Graphs: 21:56:51 - 22:23:59
Generation time Thrifty Website 01:01:13 - 01:29:53

Case closed :!:

Re: Wind graph/rose help

Posted: Mon 07 Sep 2020 6:43 am
by HansR
OK, case closed from the functional point of view.

But it takes you 30 minutes to generate the graphs/website (so the monthfile reading is taking the time!).
And that is only for 8 years. What Pi are you using? The Sysinfo does not give any detail. Is it a Zero (one processor)?
I have 15 month and it takes 70 seconds to read the monthfiles (on my Pi 3 B+). On a PC that is a lot - A LOT - faster! You are already running against the limit of your RPi for cutils. Maybe the limit for CMX as well.

Re: Wind graph/rose help

Posted: Mon 07 Sep 2020 7:03 am
by rogerthn
HansR wrote: Mon 07 Sep 2020 6:43 am OK, case closed from the functional point of view.

But it takes you 30 minutes to generate the graphs/website (so the monthfile reading is taking the time!).
And that is only for 8 years. What Pi are you using? The Sysinfo does not give any detail. Is it a Zero (one processor)?
I have 15 month and it takes 70 seconds to read the monthfiles (on my Pi 3 B+). On a PC that is a lot - A LOT - faster! You are already running against the limit of your RPi for cutils. Maybe the limit for CMX as well.
From SysInfo
Raspberry Pi Model B Plus Rev 1.2
Fairly old with 1 CPU but not a Zero
From sudo lshw
description: ARMv6-compatible processor rev 7 (v6l)
product: Raspberry Pi Model B Plus Rev 1.2
serial: 00000000f4071208
width: 32 bits
*-core
description: Motherboard
physical id: 0
*-cpu:0
description: CPU
physical id: 0
bus info: cpu@0
size: 700MHz
capacity: 700MHz
capabilities: half thumb fastmult vfp edsp java tls cpufreq
The load is above 1
uptime
08:59:33 up 5 days, 18:19, 7 users, load average: 1.28, 1.25, 1.25
Might consider a replacement

Re: Wind graph/rose help

Posted: Mon 07 Sep 2020 8:20 am
by HansR
Thnx, but you might have assumed I had seen the sysinfo ;) That is why I wonder(ed) is it a zero, 1 or 2?
So, it must be the original version B. Yes, a replacement may be useful in this context, roughly 10-20 times as fast I think. Needs more cooling as well 8-)

Re: Wind graph/rose help

Posted: Mon 07 Sep 2020 11:03 am
by sutne
I have the same RaspBerry

Code: Select all

 System: Raspberry Pi 3 Model B Rev 1.2 
‘Thrifty website’ takes about 2 minutes and it is 8 years of data.

Edit: it is not the same. I was looking at Model B, but in front of that I have number 3.
Mine has 4 CPUs and is considerable faster.

http://www.rjoandveret.no/utils/