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 6823115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:44:39+00:00 2026-05-26T21:44:39+00:00

I created a javascript document and I want to make this JSlint valid. http://pastebin.com/GvZLyNbV

  • 0

I created a javascript document and I want to make this JSlint valid.

http://pastebin.com/GvZLyNbV

/*jslint browser: true, indent: 2 */
/*global ActiveXObject: true, window: true*/
(function (window) {
  "use strict";
  /**
   * ajax class
   * 
   * ez az objektum fogja kezelni az ajax kérelmeket. lényege hogy nagyon 
   * minimális legyen. nem akarom jobban magyarázni, eléggé bonyolult, mert a
   * különböző böngészők különbözően kezelik az ajax hívásokat.
   */
  var ajax = window.ajax = {};

  ajax.XHR = {
    getXHR: function () {
      var http;
      try {
        http = new XMLHttpRequest();
        this.getXHR = function () {
          return new XMLHttpRequest();
        };
        return http;
      } catch (e) { }

      try {
        http = new ActiveXObject("MSXML2.XMLHTTP.3.0");
        this.getXHR = function () {
          return new ActiveXObject("MSXML2.XMLHTTP.3.0");
        };
        return http;
      } catch (f) { }

      try {
        http = new ActiveXObject("MSXML2.XMLHTTP");
        this.getXHR = function () {
          return new ActiveXObject("MSXML2.XMLHTTP");
        };
        return http;
      } catch (g) { }

      try {
        http = new ActiveXObject("Microsoft.XMLHTTP");
        this.getXHR = function () {
          return new ActiveXObject("Microsoft.XMLHTTP");
        };
        return http;
      } catch (h) { }
    },

    call: function (method, uri, callback, postData) {
      var xhr = this.getXHR();

      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
          if (typeof callback === "function") {
            callback(xhr);
          }
        }
      };

      xhr.open(method, uri, true);

      if (method === "POST") {
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        //xhr.setRequestHeader("Content-length", postData.length);
        //xhr.setRequestHeader("Connection", "close");
        xhr.send(postData);
      } else {
        xhr.send(null);
      }
      return xhr;
    }
  };



  /////////////////////////////////////////////////////////////////////////////
  /////////////////////////////////////////////////////////////////////////////
  /**
   * periodic object
   * 
   * Ez az osztály kezeli a periodikus hívások egyesítését. Hozzá tudunk adni 
   * listenereket
   * @see ajax.ListenerObj
   * 
   * Az a lényege hogy az összes listenert átnézi és egyesíti a requesteket
   * így egy kérelemben egybe elküldi az összes requestet.
   * 
   * @todo Jobban kellene rendezni az osztályt, ne csak így a levegőben lógjon,
   * meg majd bele kell venni a benchmark osztályt is meg jobban kell időzíteni.
   * 
   */

  ajax.periodic = {};


  ajax.periodic.isListen = false;
  ajax.periodic.timer = null;
  ajax.periodic.listenDelay = 5000;
  ajax.periodic.url = "ajax.php";
  ajax.periodic.listeners = [];

  /**
   * Ezzel a függvénnyel indítjuk el a periodikus hívásokat
   */
  ajax.periodic.startListen = function () {
    window.clearTimeout(ajax.periodic.timer);
    ajax.periodic.isListen = true;
    ajax.periodic.listen();
  };

  /**
   * Ezzel a fügvénnyel állítjuk le a periodikus hívásokat 
   */
  ajax.periodic.stopListen = function () {
    window.clearTimeout(ajax.periodic.timer);
    ajax.periodic.isListen = false;
  };

  /**
   * Ezzel a fügvénnyel adhatunk új ListenerObj objektumot a periodic osztályhoz
   * 
   * @see ajax.ListenerObj
   */
  ajax.periodic.addListener = function (obj) {
    if (obj instanceof ajax.ListenerObj) {
      ajax.periodic.listeners.push(obj);
    }
  };

  /**
   * Ezzel a fügvénnyel törölhetünk egy ListenerObj objektumot a periodic
   * osztályból
   * 
   * @see ajax.ListenerObj 
   */
  ajax.periodic.removeListener = function (obj) {
    var i = ajax.periodic.listeners.indexOf(obj);
    if (i >= 0) {
      ajax.periodic.listeners.splice(i, 1);
    }
  };

  /**
   * Ezzel a fügvénnyel kérdezzük le az össze ListenerObj objektum paramját
   * 
   * @param method : Ez "GET" vagy "POST" lehet
   * @param escape : Ez az hogy encodolja-e a tartalmat (default true)
   */
  ajax.periodic.getListenersQueries = function (method, escape) {
    var allQueries = new ajax.QueryCollection(),
      i;
    escape = (escape === false) ? false : true;
    for (i = 0; i < ajax.periodic.listeners.length; i += 1) {
      if (ajax.periodic.listeners[i].isListen()) {
        allQueries.mergeCollection(ajax.periodic.listeners[i].queries);
      }
    }

    return allQueries.queriesToString(method, escape);
  };

  /**
   * Ez a függvény meghíváskor elindul, és periodicc.delay időközönként
   * újrahívja magát. Az AJAX válaszban kapott adatot továbbítja a ListenerObj
   * objektumoknak.
   */
  ajax.periodic.listen = function () {
    if (!ajax.periodic.isListen) {
      return;
    }

    var startTime = (new Date()).getTime(),
      uri = ajax.periodic.url + "?" + ajax.periodic.getListenersQueries("get"),
      postData = ajax.periodic.getListenersQueries("post"),
      i;

    for (i = 0; i < ajax.periodic.listeners.length; i += 1) {
      ajax.periodic.listeners[i].setRequest(true);
    }

    ajax.XHR.call("POST", uri, function (data, status) {
      var i, delay;

      for (i = 0; i < ajax.periodic.listeners.length; i += 1) {
        if (ajax.periodic.listeners[i].isRequest() === true) {
          ajax.periodic.listeners[i].setRequest(false);
          ajax.periodic.listeners[i].parse(data);
        }
      }

      delay = (new Date()).getTime() - startTime;
      ajax.periodic.timer = window.setTimeout(ajax.periodic.listen, ((delay < ajax.periodic.listenDelay) ? ajax.periodic.listenDelay - delay : 0));
    }, postData);
  };

  /**
   * paraméterben megadott listener egyszer requesteli.
   */
  ajax.periodic.request = function (listener, func) {
    func = (typeof func === "function") ? func : function () {};

    ajax.XHR.call("POST", ajax.periodic.url + "?" + listener.queries.queriesToString("GET"), function (data, status) {
      func(data);
    }, ajax.listener.queries.queriesToString("POST"));
  };





  /////////////////////////////////////////////////////////////////////////////
  /////////////////////////////////////////////////////////////////////////////

  /**
   * ajax.QueryCollection class
   * 
   * Ez az osztály a query paramétereket tárolja el.
   */
  ajax.QueryCollection = function () {
    var queryArray = [];

    this.queryArray = queryArray;


    /**
     * Query paraméter hozzáadása
     */
    this.addQuery = function (method, name, value) {
      if (!method || !name) {
        return this;
      }

      method = method.toString().toLowerCase();
      name = name.toString();
      value = (value === undefined) ? "" : value.toString();

      var i;
      for (i = 0; i < queryArray.length; i += 1) {
        if (queryArray[i].method === method && queryArray[i].name === name) {
          queryArray[i].value = value;
          return;
        }
      }
      //if not found then add a new
      queryArray.push({
        "method": method,
        "name": name,
        "value": value
      });
    };

    /**
     * Query paraméter törlése
     */
    this.removeQuery = function (method, name) {
      var i;
      for (i = 0; i < queryArray.length; i += 1) {
        if (queryArray[i].method === method && queryArray[i].name === name) {
          queryArray[i].splice(i, 1);
          return;
        }
      }
    };

    /**
     * Két ilyen osztály egyesítése
     */
    this.mergeCollection = function (obj) {
      if (!obj instanceof ajax.QueryCollection) {
        return;
      }
      var i;
      for (i = 0; i < obj.queryArray.length; i += 1) {
        this.addQuery(obj.queryArray[i].method, obj.queryArray[i].name, obj.queryArray[i].value);
      }
    };

    /*
     * Az argumentumban található osztály querijainak törlése ebből az osztályból
     */
    this.splitCollection = function (obj) {
      if (!obj instanceof ajax.QueryCollection) {
        return;
      }
      var i;
      for (i = 0; i < obj.queryArray.length; i += 1) {
        this.removeQuery(obj.queryArray[i].method, obj.queryArray[i].name);
      }
    };

    /*
     * Queryk egyesítése stringbe
     */
    this.queriesToString = function (method, escape) {
      var str = "",
        cnt = 0,
        i;

      escape = (escape === false) ? false : true;

      for (i = 0; i < queryArray.length; i += 1) {
        if (queryArray[i].method === method) {
          if (cnt !== 0) {
            str += "&";
          }

          cnt += 1;

          str += queryArray[i].name;

          if (queryArray[i].value !== "") {
            str += "=";

            if (escape === true) {
              str += encodeURIComponent(queryArray[i].value);
            }
            else {
              str += queryArray[i].value;
            }
          }
        }
      }
      return str;
    };
  };

  /*
   * ajax.ListenerObj class
   * 
   * Ez az osztály arra való hogy segítségvel csinálhatok listener objektumokat
   * amiknek beállíthatok queriket.
   */
  ajax.ListenerObj = function () {

    var isListen = false,
      isRequest = false,
      parserFunc = function () {};

    this.queries = new ajax.QueryCollection();

    this.setListen = function (a) {
      isListen = (a) ? true : false;
    };
    this.isListen = function () {
      return isListen;
    };

    this.setRequest = function (a) {
      isRequest = (a) ? true : false;
    };

    this.isRequest = function () {
      return isRequest;
    };

    this.setParser = function (a) {
      if (typeof a === "function") {
        parserFunc = a;
      }
      return this;
    };

    this.parse = function (data) {
      parserFunc(data);
    };
  };

}(window));

When i validate this with JSLint, I get this error:

Error:
Unused variable: status 182 'uri', status 203 'GET'

I don’t understand what should I fix. The uri variable is used, and the 'GET' is a string constant, not a variable.

So I am totally confused.

  • 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-26T21:44:40+00:00Added an answer on May 26, 2026 at 9:44 pm

    In your code, starting on line 182, there’s a function you pass into ajax.XHR.call which declares a variable, status, that you never use:

    //                         |-- Function starts here
    //                         V               V-- Variable (argument) `status`, never used
    ajax.XHR.call("POST", uri, function (data, status) {
      var i, delay;
    
      for (i = 0; i < ajax.periodic.listeners.length; i += 1) {
        if (ajax.periodic.listeners[i].isRequest() === true) {
          ajax.periodic.listeners[i].setRequest(false);
          ajax.periodic.listeners[i].parse(data);
        }
      }
    
      delay = (new Date()).getTime() - startTime;
      ajax.periodic.timer = window.setTimeout(ajax.periodic.listen, ((delay < ajax.periodic.listenDelay) ? ajax.periodic.listenDelay - delay : 0));
    }, postData);
    

    You can get rid of the error by removing the argument from the function signature. Or you can ignore it, because it’s very important to remember that JSLint is all about Douglas Crockford’s coding style, which may or may not be what you believe to be appropriate for your own coding style. You might also look at JSHint, which gives you more control over options.

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

Sidebar

Related Questions

I have problem with dynamically created image (JavaScript). I want to change the innerHTML
I'd like to use Javascript to make IE6 download a file. It'll be created
I want to make a new label in mootools 1.3 by this command: new
If I create a cookie in Javascript document.cookie = 'unseen' how do I delete
I created a javascript class as follow: var MyClass = (function() { function myprivate(param)
I've created a javascript function that allows me to validate if one field or
I've created a javascript function that will take a hidden span, copy the text
I've created a Javascript object via prototyping. I'm trying to render a table dynamically.
I've created a JavaScript object to hold onto a value set by a user
I have created two JavaScript files. One file is "validators.js" and the other is

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.