Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6101987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:33:45+00:00 2026-05-23T13:33:45+00:00

I’m making a websites that displays noise measurement data from different locations. The data

  • 0

I’m making a websites that displays noise measurement data from different locations. The data for each location is captured on a sound level meter device and it is then read with a windows-based application. The application then uploads data on a web server as a .js file with an array variable in it. This .js files are refreshed every 5 minutes.
I first created a javascript application that displays live data for a single measuring unit. But now I need to display data on a map for all the locations. The problem is that the windows application on each location makes a file with the same name and same variables only on another location. I’m having some trouble with reading the correct data.
This is what I did so far:

    function removejscssfile(filename, filetype){
         var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from
         var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for
         var allsuspects=document.getElementsByTagName(targetelement)
         for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
          if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)
           allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
         }
        }

    function updateData(){
    var numberOfNoiseSniffers = noiseSniffers.length-1;
    var j = 0;
    for (i=0;i<=numberOfNoiseSniffers;i++) {
        file = '../'+ noiseSniffers[i] + "/" + "CurrentMeasurement.js";
        $.include(file,function(){
            laeq[j] = currentMeas[1][1];
            lastUpdate[j] = currentMeas[0][1];
            if (j==numberOfNoiseSniffers){
                updateMarkers();
            }
            removejscssfile(file[0], "js");
            j++;
        });
    }

    t=setTimeout(function() { updateData() }, 300000);
}


    $(function (){
    map = new google.maps.Map(document.getElementById("gMap"), myOptions);
    //noiseSniffers is an array where I have save all the folder names of different measurement locations
    var numberOfNoiseSniffers = noiseSniffers.length-1;
    var j = 0;
    for (i=0;i<=numberOfNoiseSniffers;i++) {
        var file = '../'+ noiseSniffers[i] + "/" + "CurrentMeasurement.js";
        //I am using include plugin for jquery to include files because it has a callback for when a file is actually loaded
        $.include(file,function(){
            //a set of global arrays that keep the data from the loaded file and this data is then displayed in google maps markers
            laeq[j] = currentMeas[1][1];
            lastUpdate[j] = currentMeas[0][2];
            latitude[j] = systemstats[12][5];
            longitude[j] = systemstats[11][6];
            //checking to see if I am in the process of including the last file
            if (j==numberOfNoiseSniffers){
                //a function that creates google maps markers
                createMarkers();
            }
            //after that I remove the files that were just included and read
            removejscssfile(file, "js");
            j++;
        });
    }
    setTimeout(function() { updateData() }, 300000);
    });

I got the function for removing my .js file here: Dynamically removing an external JavaScript or CSS file.
And this is the jquery plugin for loading the .js file: Include File On Demand.
The initial load usually works (sometimes it happens that only one or no markers get loaded. But the update function mostly returns the same data for both locations.
So what I want to know is, how can I firstly make my code working and how to optimize it. I posted just the main parts of the javascript code, but I can provide all the code if it is needed. Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:33:46+00:00Added an answer on May 23, 2026 at 1:33 pm

    I think you need some sort of JSONP-like solution.

    Basically load data on the server side, then wrap it in a method call before returning it to client side. Your response should look something like this:

    var location_data = [1,2,3,4]
    updateLocation('location_id', location_data) 
    

    Now you define an updateLocation() function in your client side script. Now, every time you need new data, you create new ‘script’ tag with src pointing to your server side. When the response is loaded, your updateLocation() will be invoked with correct params.

    I hope this is clear enough

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.