PHP Classes

File: ALogFilter.js

Recommend this page to a friend!
  Classes of Janne   PHP Apache Log Parser and Filter   ALogFilter.js   Download  
File: ALogFilter.js
Role: Auxiliary script
Content type: text/plain
Description: Provides functionality for adding pre-defined filters
Class: PHP Apache Log Parser and Filter
Parse and filter Apache logs to discard crawlers
Author: By
Last change:
Date: 10 years ago
Size: 1,421 bytes
 

Contents

Class file image Download
/*
The BSD 2-Clause
Copyright (c) 2012-2013, Janne Hyytiä
All rights reserved.
*/

function Needles() {
    var
        rootO = this;
   
    rootO.ele = document.getElementById("usingNeedles");
    rootO.URL = {};
    rootO.filters = {
            "pictures": defPictures,
            "crawlers": defCrawlers,
            "HTML": defHTMLs
        };
   
    this.toggle = function (e) {
        e.target.classList.toggle("active");
        if(rootO.filters[e.target.id]) {
            rootO.createURL(e.target.id);
        }
    };
    this.createURL = function (toggleThis) {
        var
            i = 0,
            filterWithDelimiters;
   
        if(rootO.URL[toggleThis]) {
            delete rootO.URL[toggleThis];
        } else {
            rootO.URL[toggleThis] = {};
            rootO.URL[toggleThis] = rootO.filters[toggleThis];
        }
       
        rootO.ele.value = "";
       
        for(filter in rootO.URL) {
            filterWithDelimiters = rootO.filters[filter].join(",");
            rootO.ele.value += filterWithDelimiters+",";
        }
        console.log(rootO.ele.value.length);
        rootO.ele.value = rootO.ele.value.substring(0, rootO.ele.value.length -1);
        console.log(rootO.ele.value);
    };
   
    for(key in this.filters) {
        document.getElementById(key).addEventListener("click", rootO.toggle);
    }
};