Announcement

Collapse
No announcement yet.

Help with some HTML code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with some HTML code

    Dear HTML coder types.

    I have a weather station on a property in the Great Southern. The station updates info to the net every 10 mins using a template provided by a weather station software provider (Cumulus).

    This information is accessed by me (naturally) along with other adjoining farm owners for their own personal interest and/or farm requirements.

    I have set the weather station to display the wind speed information in knots (because thats how wind speed should be displayed IMO being a boaty/aviator type person) however the local bushfire brigade who also access the station info to help with fighting local fires have no idea what a knot is and would like wind speed displayed in kph. Wigga preeez! Learn to 1.85 times table n00bz!!

    Anyhoo, I have no intention in changing the setting from knots to kph just to keep them happy but, and here is the question finally,.... would anyone here know what code I could add to the following existing code which would grab the knot information, and multiply it by 1.852, and then display the kph in brackets next to knots?

    By way of example, this is the current display from the Weather station:

    Wind
    Wind Speed (gust) 11 kts Wind Speed (avg) 5 kts
    Wind Bearing 306° NW Beaufort F2 Light breeze
    This is the code that seems to make it happen:


    PHP Code:
    </tr>
      <
    tr class="td_wind_data">
        <
    td>Wind&nbsp;Speed&nbsp;(gust)</td>
        <
    td><#wgust>&nbsp;<#windunit></td>
        
    <td>Wind&nbsp;Speed&nbsp;(avg)</td>
        <
    td><#wspeed>&nbsp;<#windunit></td>
      
    </tr
    This is what I would like it to display:

    Wind
    Wind Speed (gust) 11 kts (20 kph) Wind Speed (avg) 5 kts (9 kph)
    Wind Bearing 306° NW Beaufort F2 Light breeze
    ...with the kph info in the brackets self calculating from the info grabbed from #wgust and #wspeed.

    Anyone know if the above code can be amended to easily (read: really easily for poison fingers Deej) achieve this? and if so, what would the code be?

    Deejus

    So on the eight day, after wasting time faffing about with unimportant guff like heaven & earth & the waters & sky & creatures [& having a wee kip] & man.... God created PSB (GenesiSX-R1000)

  • #2
    I had a look around and changed something I found, you might need to do a bit of modifying yourself to get it into the right files etc:

    Code:
    <script type="text/javascript">
    var speed = "<#wgust>"; 			//new variable called speed, from #wgust
    var speedkms = Math.abs(speed*1.852);		//creates new variable and converts to kms
    document.write(speedkms.toFixed(3));		//displays output to 3 decimal places
    </script>&nbsp;kms
    If it doesn't work try this Sandaysoft &bull; View topic - Auto-refresh Website Index Page Without Using Meta Refresh as it might make more sense to you than me.
    Last edited by Visitor; 28-04-2011, 01:55 AM.
    Tomorrow: A mystical land where 99% of all human productivity, motivation, and achievement is stored.


    Avatar used with permission from Mekon

    Comment


    • #3
      print out a conversion chart for them to put next to their computers?
      For LAMS information and resources - http://www.perthstreetbikes.com/foru...thread-156358/
      For LAMS discussion and to ask questions - http://www.perthstreetbikes.com/foru...thread-143289/

      Comment


      • #4
        Originally posted by jbb View Post
        I had a look around and changed something I found, you might need to do a bit of modifying yourself to get it into the right files etc:

        Code:
        <script type="text/javascript">
        var speed = "<#wgust>"; 			//new variable called speed, from #wgust
        var speedkms = Math.abs(speed*1.852);		//creates new variable and converts to kms
        document.write(speedkms.toFixed(3));		//displays output to 3 decimal places
        </script>&nbsp;kms
        If it doesn't work try this Sandaysoft &bull; View topic - Auto-refresh Website Index Page Without Using Meta Refresh as it might make more sense to you than me.
        Thanks JBB, I'll give it a try tonight.

        So on the eight day, after wasting time faffing about with unimportant guff like heaven & earth & the waters & sky & creatures [& having a wee kip] & man.... God created PSB (GenesiSX-R1000)

        Comment


        • #5
          Think you might be out of luck mate, those pages are generated by your weather station and uploaded/overwritten regularly, you would have to modify the code on the weather station that generates them.

          Comment


          • #6
            dumb noob here asking if you could fix it with an excel worksheet and would anybody use it if you could?
            sigpic

            Comment


            • #7
              XSLT on another page (hosted elsewhere) which scrapes the station page for data and throws up its own presentation maybe?
              "Once upon a time we would obey in public, but in private we would be cynical; today, we announce cynicism, but in private we obey."

              Comment


              • #8
                XSLT?

                lc
                sigpic

                Comment


                • #9
                  See later post..
                  Last edited by Visitor; 29-04-2011, 01:20 AM.
                  Tomorrow: A mystical land where 99% of all human productivity, motivation, and achievement is stored.


                  Avatar used with permission from Mekon

                  Comment


                  • #10
                    :chortle: @ PSB Member.
                    "Once upon a time we would obey in public, but in private we would be cynical; today, we announce cynicism, but in private we obey."

                    Comment


                    • #11
                      Originally posted by Nath View Post
                      Think you might be out of luck mate, those pages are generated by your weather station and uploaded/overwritten regularly, you would have to modify the code on the weather station that generates them.
                      yup I found the file that it uses before it inserts the variables so should be able to amend the template. of course.... I could be very wrong.

                      So on the eight day, after wasting time faffing about with unimportant guff like heaven & earth & the waters & sky & creatures [& having a wee kip] & man.... God created PSB (GenesiSX-R1000)

                      Comment


                      • #12
                        Passion what?

                        Comment


                        • #13
                          Nope, sounds like you have it under control.

                          Comment


                          • #14
                            Originally posted by Deej View Post
                            yup I found the file that it uses before it inserts the variables so should be able to amend the template. of course.... I could be very wrong.
                            Not sure if you got it yet.. but if not here is what I did and it worked:

                            - Edit indexT.htm or whatever your template file is (maybe back it up first)
                            - Replace the </head> tag with the following:
                            Code:
                            <script type="text/javascript">
                            var speed_wgust = "<#wgust>"; 			//new variable, from #wgust
                            var speed_wspeed = "<#wspeed>";			//new variable, from #wspeed
                            </script>
                            </head>
                            - Place these wherever you want the data to show:
                            Code:
                            (<script>document.write(Math.abs(speed_wgust*1.852).toFixed(3));</script>&nbsp;kms)
                            (<script>document.write(Math.abs(speed_wspeed*1.852).toFixed(3));</script>&nbsp;kms)
                            For example:
                            Code:
                            <tr class="td_wind_data">
                                <td>Wind&nbsp;Speed&nbsp;(gust)</td>
                                <td><#wgust>&nbsp;<#windunit> (<script>document.write(Math.abs(speed_wgust*1.852).toFixed(3));</script>&nbsp;kms)</td>
                                <td>Wind&nbsp;Speed&nbsp;(avg)</td>
                                <td><#wspeed>&nbsp;<#windunit> (<script>document.write(Math.abs(speed_wspeed*1.852).toFixed(3));</script>&nbsp;kms)</td>
                              </tr>
                            #NB - toFixed(3) is for 3 decimal places
                            Last edited by Visitor; 29-04-2011, 02:00 AM.
                            Tomorrow: A mystical land where 99% of all human productivity, motivation, and achievement is stored.


                            Avatar used with permission from Mekon

                            Comment

                            Working...
                            X