<commit_before>
$(document).ready(function(){/* jQuery toggle layout */
    $('#btnToggle').click(function(){
        if ($(this).hasClass('on')) {
            $('#main .col-md-6').addClass('col-md-4').removeClass('col-md-6');
            $(this).removeClass('on');
        }
        else {
            $('#main .col-md-4').addClass('col-md-6').removeClass('col-md-4');
            $(this).addClass('on');
        }
    });

    for(var i = 0; i < logcontainer.length; i++){
        var log = logcontainer[i];
        if (log.indexOf("INFO:") === 0)
            alertify.success(log.substring(log.indexOf(":") + 1));
        else if (log.indexOf("ERROR:") === 0)
            alertify.error(log.substring(log.indexOf(":") + 1));
        else alertify.log(log.substring(log.indexOf(":") + 1));
    }
});

 function detailsServer(name){

    var URL = "/OpenZUI/KeyValueServlet?action=server&name="+name;
    $.getJSON(URL, function(result){
        $("#srv-upd-name").val(name);
        $("#srv-upd-ip").val(result.response.address);
        $("#tmc-upd-port").val(result.response.port);
        $("#tmc-upd-user").val(result.response.user);
        $("#tmc-upd-pass").val(result.response.passwd);
        $("#tmc-upd-status").val(result.response.status);

        var StatsURL = "http://" + result.response.address + ":" + result.response.port + "/ServerResources/resources/manage";
        $.getJSON(StatsURL, function(sresult){
            $("#stats-cpu").val("" + Math.floor(sresult.cpu.systemCpuLoad * 100.0) + " %");
            $("#stats-mem").val("" + Math.floor(sresult.mem.physicalFree / 1024 / 1024) + " MB free / " + Math.floor(sresult.mem.physicalTotal / 1024 / 1024) + " MB total");
            $("#stats-disc").val("" + Math.floor(sresult.space.free / 1024 / 1024) + " MB free / " + Math.floor(sresult.space.total / 1024 / 1024) + " MB total");
        });

        $('#detailsModal').modal('show');
    });
 };

 function detailsWarfile(comp_id){

    var URL = "/OpenZUI/KeyValueServlet?action=war&name="+comp_id;
    $.getJSON(URL, function(result){
        $("#war-upd-compoid").val(comp_id);
        $("#war-upd-name").val(result.response.name);
        $("#war-upd-servpath").val(result.response.service_path);
        $("#war-upd-descr").val(result.response.description);
        $("#war-upd-filename").val(result.response.filename);
        $("#war-upd-version").val(result.response.version);
        $("#war-upd-status").val(result.response.status);
        $('#detailsModal').modal('show');
    });
 };

 function detailsTopology(name){

    var URL = "/OpenZUI/KeyValueServlet?action=topology&name="+name;
    $.getJSON(URL, function(result){
        $("#topo-upd-name").val(name);
        $("#topo-upd-descr").val(result.response.description);
        $("#topo-upd-rhost").val(result.response.rabbit.host);
        $("#topo-upd-rport").val(result.response.rabbit.port);
        $("#topo-upd-ruser").val(result.response.rabbit.user);
        $("#topo-upd-rpass").val(result.response.rabbit.passwd);
        $("#topo-upd-mhost").val(result.response.mongo.host);
        $("#topo-upd-mport").val(result.response.mongo.port);
        $("#topo-upd-muser").val(result.response.mongo.user);
        $("#topo-upd-mpass").val(result.response.mongo.passwd);

        switch (result.response.status)
        {
            case 'CREATED':
                $("#deleteBtn").show();
                $("#deployBtn").hide();
                $("#undeployBtn").hide();
                $("#startBtn").hide();
                $("#stopBtn").hide();
                break;
            case 'DESIGNED':
                $("#deleteBtn").show();
                $("#deployBtn").show();
                $("#undeployBtn").hide();
                $("#startBtn").hide();
                $("#stopBtn").hide();
                break;
            case 'SEMIDEPLOYED':
                $("#deleteBtn").hide();
                $("#deployBtn").show();
                $("#undeployBtn").show();
                $("#startBtn").hide();
                $("#stopBtn").hide();
                break;
            case 'DEPLOYED':
                $("#deleteBtn").hide();
                $("#deployBtn").hide();
                $("#undeployBtn").show();
                $("#startBtn").show();
                $("#stopBtn").hide();
                break;
            case 'SEMISTARTED':
                $("#deleteBtn").hide();
                $("#deployBtn").hide();
                $("#undeployBtn").hide();
                $("#startBtn").show();
                $("#stopBtn").show();
                break;
            case 'STARTED':
                $("#deleteBtn").hide();
                $("#deployBtn").hide();
                $("#undeployBtn").hide();
                $("#startBtn").hide();
                $("#stopBtn").show();
                break;
        }

        $('#detailsModal').modal('show');
    });
 };

 function detailsService(name){

    $('#detailsModal').modal('show');
 };

 $('#deleteBtn').on('click',function(){

    $("#post-action").val('delete');
 });

 $('#updateBtn').on('click',function(){

    $("#post-action").val('update');
 });

 $('#startBtn').on('click',function(){

    $("#post-action").val('start');
 });

 $('#stopBtn').on('click',function(){

    $("#post-action").val('stop');
 });

 $('#deployBtn').on('click',function(){

    //$("#post-action").val('deploy');
    $("#post-action").val('create_config');
 });

 $('#undeployBtn').on('click',function(){

    $("#post-action").val('undeploy');
 });

function fetchServicesList(callback){
    var url = "/OpenZUI/KeyValueServlet?action=war";

  $.getJSON(url,function(result){
        var listItems= "";
        //var services =[];
        localStorage["WAR"] = JSON.stringify(result['response']);

        $.each(result['response'], function(key, val){

            var svc={};
            var svc_in=[];
            var svc_out=[];

            if (val.workers.length>0){
                for (var i = 0; i < val.workers.length; i++){
                    for(var x = 0; x < val.workers[i].endpoints.length; x++){
                        if (val.workers[i].endpoints[x].type == 'in'){
                            svc_in.push(val.workers[i].worker_id + ":" + val.workers[i].endpoints[x].endpoint_id)
                        }
                        else if (val.workers[i].endpoints[x].type == 'out'){
                            svc_out.push(val.workers[i].worker_id + ":" + val.workers[i].endpoints[x].endpoint_id)
                        }
                    }
                }

                svc={name:val.component_id, in_ep:svc_in, out_ep:svc_out, type:val.type}
                //svc={ in_ep:svc_in, out_ep:svc_out}
                listItems+= "<option value='" + val.component_id + "'>" + val.component_id + "</option>";
                //console.log(svc);
                localStorage[val.component_id] = JSON.stringify(svc);
                //services.push(svc);
            }
        });

        $("#openzooServiceSelect").html(listItems);
    }).complete(function(){
        callback();
    });

};

<commit_msg>New version of Chrome (48) removes a feature that is core to JointJS/Rappid. Fixed.<commit_after>
$(document).ready(function(){/* jQuery toggle layout */
    $('#btnToggle').click(function(){
        if ($(this).hasClass('on')) {
            $('#main .col-md-6').addClass('col-md-4').removeClass('col-md-6');
            $(this).removeClass('on');
        }
        else {
            $('#main .col-md-4').addClass('col-md-6').removeClass('col-md-4');
            $(this).addClass('on');
        }
    });

    for(var i = 0; i < logcontainer.length; i++){
        var log = logcontainer[i];
        if (log.indexOf("INFO:") === 0)
            alertify.success(log.substring(log.indexOf(":") + 1));
        else if (log.indexOf("ERROR:") === 0)
            alertify.error(log.substring(log.indexOf(":") + 1));
        else alertify.log(log.substring(log.indexOf(":") + 1));
    }
});

 function detailsServer(name){

    var URL = "/OpenZUI/KeyValueServlet?action=server&name="+name;
    $.getJSON(URL, function(result){
        $("#srv-upd-name").val(name);
        $("#srv-upd-ip").val(result.response.address);
        $("#tmc-upd-port").val(result.response.port);
        $("#tmc-upd-user").val(result.response.user);
        $("#tmc-upd-pass").val(result.response.passwd);
        $("#tmc-upd-status").val(result.response.status);

        $("#stats-cpu").val("");
        $("#stats-mem").val("");
        $("#stats-disc").val("");

        var StatsURL = "http://" + result.response.address + ":" + result.response.port + "/ServerResources/resources/manage";
        $.getJSON(StatsURL, function(sresult){
            $("#stats-cpu").val("" + Math.floor(sresult.cpu.systemCpuLoad * 100.0) + " %");
            $("#stats-mem").val("" + Math.floor(sresult.mem.physicalFree / 1024 / 1024) + " MB free / " + Math.floor(sresult.mem.physicalTotal / 1024 / 1024) + " MB total");
            $("#stats-disc").val("" + Math.floor(sresult.space.free / 1024 / 1024) + " MB free / " + Math.floor(sresult.space.total / 1024 / 1024) + " MB total");
        });

        $('#detailsModal').modal('show');
    });
 };

 function detailsWarfile(comp_id){

    var URL = "/OpenZUI/KeyValueServlet?action=war&name="+comp_id;
    $.getJSON(URL, function(result){
        $("#war-upd-compoid").val(comp_id);
        $("#war-upd-name").val(result.response.name);
        $("#war-upd-servpath").val(result.response.service_path);
        $("#war-upd-descr").val(result.response.description);
        $("#war-upd-filename").val(result.response.filename);
        $("#war-upd-version").val(result.response.version);
        $("#war-upd-status").val(result.response.status);
        $('#detailsModal').modal('show');
    });
 };

 function detailsTopology(name){

    var URL = "/OpenZUI/KeyValueServlet?action=topology&name="+name;
    $.getJSON(URL, function(result){
        $("#topo-upd-name").val(name);
        $("#topo-upd-descr").val(result.response.description);
        $("#topo-upd-rhost").val(result.response.rabbit.host);
        $("#topo-upd-rport").val(result.response.rabbit.port);
        $("#topo-upd-ruser").val(result.response.rabbit.user);
        $("#topo-upd-rpass").val(result.response.rabbit.passwd);
        $("#topo-upd-mhost").val(result.response.mongo.host);
        $("#topo-upd-mport").val(result.response.mongo.port);
        $("#topo-upd-muser").val(result.response.mongo.user);
        $("#topo-upd-mpass").val(result.response.mongo.passwd);

        switch (result.response.status)
        {
            case 'CREATED':
                $("#deleteBtn").show();
                $("#deployBtn").hide();
                $("#undeployBtn").hide();
                $("#startBtn").hide();
                $("#stopBtn").hide();
                break;
            case 'DESIGNED':
                $("#deleteBtn").show();
                $("#deployBtn").show();
                $("#undeployBtn").hide();
                $("#startBtn").hide();
                $("#stopBtn").hide();
                break;
            case 'SEMIDEPLOYED':
                $("#deleteBtn").hide();
                $("#deployBtn").show();
                $("#undeployBtn").show();
                $("#startBtn").hide();
                $("#stopBtn").hide();
                break;
            case 'DEPLOYED':
                $("#deleteBtn").hide();
                $("#deployBtn").hide();
                $("#undeployBtn").show();
                $("#startBtn").show();
                $("#stopBtn").hide();
                break;
            case 'SEMISTARTED':
                $("#deleteBtn").hide();
                $("#deployBtn").hide();
                $("#undeployBtn").hide();
                $("#startBtn").show();
                $("#stopBtn").show();
                break;
            case 'STARTED':
                $("#deleteBtn").hide();
                $("#deployBtn").hide();
                $("#undeployBtn").hide();
                $("#startBtn").hide();
                $("#stopBtn").show();
                break;
        }

        $('#detailsModal').modal('show');
    });
 };

 function detailsService(name){

    $('#detailsModal').modal('show');
 };

 $('#deleteBtn').on('click',function(){

    $("#post-action").val('delete');
 });

 $('#updateBtn').on('click',function(){

    $("#post-action").val('update');
 });

 $('#startBtn').on('click',function(){

    $("#post-action").val('start');
 });

 $('#stopBtn').on('click',function(){

    $("#post-action").val('stop');
 });

 $('#deployBtn').on('click',function(){

    //$("#post-action").val('deploy');
    $("#post-action").val('create_config');
 });

 $('#undeployBtn').on('click',function(){

    $("#post-action").val('undeploy');
 });

function fetchServicesList(callback){
    var url = "/OpenZUI/KeyValueServlet?action=war";

  $.getJSON(url,function(result){
        var listItems= "";
        //var services =[];
        localStorage["WAR"] = JSON.stringify(result['response']);

        $.each(result['response'], function(key, val){

            var svc={};
            var svc_in=[];
            var svc_out=[];

            if (val.workers.length>0){
                for (var i = 0; i < val.workers.length; i++){
                    for(var x = 0; x < val.workers[i].endpoints.length; x++){
                        if (val.workers[i].endpoints[x].type == 'in'){
                            svc_in.push(val.workers[i].worker_id + ":" + val.workers[i].endpoints[x].endpoint_id)
                        }
                        else if (val.workers[i].endpoints[x].type == 'out'){
                            svc_out.push(val.workers[i].worker_id + ":" + val.workers[i].endpoints[x].endpoint_id)
                        }
                    }
                }

                svc={name:val.component_id, in_ep:svc_in, out_ep:svc_out, type:val.type}
                //svc={ in_ep:svc_in, out_ep:svc_out}
                listItems+= "<option value='" + val.component_id + "'>" + val.component_id + "</option>";
                //console.log(svc);
                localStorage[val.component_id] = JSON.stringify(svc);
                //services.push(svc);
            }
        });

        $("#openzooServiceSelect").html(listItems);
    }).complete(function(){
        callback();
    });

};

SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(toElement) {
return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM());
};<|endoftext|>


<commit_before>
const fs = require('fs');
const Excel = require('exceljs');
const crypto = require('crypto');
const sha256 = x => crypto.createHash('sha1').update(x, 'utf8').digest('hex');

const inputCrawlerDir = 'crawler.data.json';
const inputContactsDir = '../../../../../Kontakt.xlsx'; // only *.xlsx files
const outputDir = 'sc.contact.stub.contacts.xlsx';

const headers = new Set(['Title', 'First Name', 'Last Name', 'Birthday', 'E-Mail', 'E-Mail 2', 'Url', 'Web Page', 'LinkedIn URL', 'Home Country', 'Home State', 'Home Street', 'Home Zip Code', 'Home City', 'Telephone Home', 'Telephone Mobile', 'Fax Home', 'Company', 'Business Country', 'Business State', 'Business Zip Code', 'Business City', 'Business Street', 'Telephone Business', 'Telephone Assistant', 'Fax Business', 'Department', 'Job Title', 'Groups']);
const map = new Map(); //<colNr, header>

if(!fs.existsSync(inputCrawlerDir))
  console.log('Input Crawler file not found!')
const crawlerJson = JSON.parse(fs.readFileSync(inputCrawlerDir));

if(!fs.existsSync(inputContactsDir))
  console.log('Input Contacts file not found!')

let workbook = new Excel.Workbook();
workbook.xlsx.readFile(inputContactsDir)
    .then(()=> {
        var worksheet = workbook.getWorksheet(1);
        return worksheet.eachRow((row, rowNumber)=>{
          if(rowNumber == 1){
            row.values.forEach((header, i) => {
              if(headers.has(header))
                map.set(i, header);
            });
          }else{
            //console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
            const crawlerContact = crawlerJson[rowNumber-2];
            row.values.forEach((value, i) => {
              let newValue = null;
              if(map.has(i)){
                if(value != null){
                  const field = map.get(i);
                  console.log(field, value)
                  if(field == 'Title'){
                    newValue = value;
                  }else if(field == 'First Name'){
                    newValue = crawlerContact.name;
                  }else if(field == 'Last Name'){
                    newValue = crawlerContact.surname;
                  }else if(field == 'Birthday'){
                    newValue = 'anonymized value';
                  }else if(field == 'E-Mail'){
                    newValue = crawlerContact.email;
                  }else if(field == 'E-Mail 2'){
                    newValue = crawlerContact.email.replace('@','2@');
                  }else if(field == 'Url'){
                    newValue = 'anonymized value';
                  }else if(field == 'Web Page'){
                    newValue = 'anonymized value';
                  }else if(field == 'LinkedIn URL'){
                    newValue = 'anonymized value';
                  }else if(field == 'Home Country'){
                    newValue = value;
                  }else if(field == 'Home State'){
                    newValue = value;
                  }else if(field == 'Home Street'){
                    newValue = 'anonymized value';
                  }else if(field == 'Home Zip Code'){
                    newValue = 'anonymized value';
                  }else if(field == 'Home City'){
                    newValue = 'anonymized value';
                  }else if(field == 'Telephone Home'){
                    newValue = 'anonymized value';
                  }else if(field == 'Telephone Mobile'){
                    newValue = 'anonymized value';
                  }else if(field == 'Fax Home'){
                    newValue = 'anonymized value';
                  }else if(field == 'Company'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business Country'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business State'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business Zip Code'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business City'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business Street'){
                    newValue = 'anonymized value';
                  }else if(field == 'Telephone Business'){
                    newValue = 'anonymized value';
                  }else if(field == 'Telephone Assistant'){
                    newValue = 'anonymized value';
                  }else if(field == 'Fax Business'){
                    newValue = 'anonymized value';
                  }else if(field == 'Department'){
                    newValue = 'anonymized value';
                  }else if(field == 'Job Title'){
                    newValue = 'anonymized value';
                  }else if(field == 'Groups'){
                    newValue = value;
                  }
                }
              }
              row.getCell(i).value = newValue;
            });
            console.log(crawlerContact)
          }
        });
    })
    .then(()=>{
      workbook.xlsx.writeFile(outputDir)
    })
    .then(()=>{
      console.log('Pseudomizer finished!')
    })
    .catch(err=>{
      console.log(err);
    })

  <commit_msg>pseudomizer with titles<commit_after>
const fs = require('fs');
const Excel = require('exceljs');
const crypto = require('crypto');
const sha256 = x => crypto.createHash('sha1').update(x, 'utf8').digest('hex');

const inputCrawlerDir = 'crawler.data.json';
const inputContactsDir = '../../../../../Kontakt.xlsx'; // only *.xlsx files
const outputDir = 'sc.contact.stub.contacts.xlsx';

const headers = new Set(['Kontakt', 'Title', 'First Name', 'Last Name', 'Birthday', 'E-Mail', 'E-Mail 2', 'Url', 'Web Page', 'LinkedIn URL', 'Home Country', 'Home State', 'Home Street', 'Home Zip Code', 'Home City', 'Telephone Home', 'Telephone Mobile', 'Fax Home', 'Company', 'Business Country', 'Business State', 'Business Zip Code', 'Business City', 'Business Street', 'Telephone Business', 'Telephone Assistant', 'Fax Business', 'Department', 'Job Title', 'Groups']);
const map = new Map(); //<colNr, header>

if(!fs.existsSync(inputCrawlerDir))
  console.log('Input Crawler file not found!')
const crawlerJson = JSON.parse(fs.readFileSync(inputCrawlerDir));

if(!fs.existsSync(inputContactsDir))
  console.log('Input Contacts file not found!')

let workbook = new Excel.Workbook();
workbook.xlsx.readFile(inputContactsDir)
    .then(()=> {
        var worksheet = workbook.getWorksheet(1);
        return worksheet.eachRow((row, rowNumber)=>{
          if(rowNumber == 1){
            row.values.forEach((header, i) => {
              if(headers.has(header))
                map.set(i, header);
            });
          }else{
            //console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
            const crawlerContact = crawlerJson[rowNumber-2];
            row.values.forEach((value, i) => {
              let newValue = null;
              if(map.has(i)){
                if(value != null){
                  const field = map.get(i);
                  //console.log(field, value)
                  if(field == 'Kontakt'){
                    console.log(row.values[1])
                    let title = "";
                    Array.from(map.keys()).forEach(key=>{
                      if(map.get(key) == 'Title' && row.values[key])
                        title = row.values[key] + " ";
                    });
                    newValue = title + crawlerContact.name+" "+crawlerContact.surname;
                  }else if(field == 'Title'){
                    newValue = value;
                  }else if(field == 'First Name'){
                    newValue = crawlerContact.name;
                  }else if(field == 'Last Name'){
                    newValue = crawlerContact.surname;
                  }else if(field == 'Birthday'){
                    newValue = 'anonymized value';
                  }else if(field == 'E-Mail'){
                    newValue = crawlerContact.email;
                  }else if(field == 'E-Mail 2'){
                    newValue = crawlerContact.email.replace('@','2@');
                  }else if(field == 'Url'){
                    newValue = 'anonymized value';
                  }else if(field == 'Web Page'){
                    newValue = 'anonymized value';
                  }else if(field == 'LinkedIn URL'){
                    newValue = 'anonymized value';
                  }else if(field == 'Home Country'){
                    newValue = value;
                  }else if(field == 'Home State'){
                    newValue = value;
                  }else if(field == 'Home Street'){
                    newValue = 'anonymized value';
                  }else if(field == 'Home Zip Code'){
                    newValue = 'anonymized value';
                  }else if(field == 'Home City'){
                    newValue = 'anonymized value';
                  }else if(field == 'Telephone Home'){
                    newValue = 'anonymized value';
                  }else if(field == 'Telephone Mobile'){
                    newValue = 'anonymized value';
                  }else if(field == 'Fax Home'){
                    newValue = 'anonymized value';
                  }else if(field == 'Company'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business Country'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business State'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business Zip Code'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business City'){
                    newValue = 'anonymized value';
                  }else if(field == 'Business Street'){
                    newValue = 'anonymized value';
                  }else if(field == 'Telephone Business'){
                    newValue = 'anonymized value';
                  }else if(field == 'Telephone Assistant'){
                    newValue = 'anonymized value';
                  }else if(field == 'Fax Business'){
                    newValue = 'anonymized value';
                  }else if(field == 'Department'){
                    newValue = 'anonymized value';
                  }else if(field == 'Job Title'){
                    newValue = 'anonymized value';
                  }else if(field == 'Groups'){
                    newValue = value;
                  }
                }
              }
              row.getCell(i).value = newValue;
            });
          }
        });
    })
    .then(()=>{
      workbook.xlsx.writeFile(outputDir)
    })
    .then(()=>{
      console.log('Pseudomizer finished!')
    })
    .catch(err=>{
      console.log(err);
    })

  <|endoftext|>


<commit_before>(function(){

    xtag.register('widget-DAQ', {
        extends: 'div',
        lifecycle: {
            created: function() {
                var xString, option, title, deckWrap;

                this.width = this.offsetWidth;
                this.height = window.innerHeight*0.6;

                //get the DAQ structure
                XHR('http://' + this.MIDAS + '/?cmd=jcopy&odb=/DAQ&encoding=json-nokeys',
                    function(res){
                        this.buildDAQ(res);
                    }.bind(this),
                    'application/json');

                //build DOM
                this.navBlock = document.createElement('div');
                this.navBlock.setAttribute('class', 'DAQnav');
                this.appendChild(this.navBlock);

                title = document.createElement('h1');
                title.innerHTML = 'DAQ';
                this.navBlock.appendChild(title);

                this.cardNav = document.createElement('select');
                this.cardNav.setAttribute('id', 'DAQnav')
                this.cardNav.setAttribute('class', 'stdin');
                this.cardNav.onchange = function(){
                    document.getElementById('DAQdeck').shuffleTo(selected('DAQnav'));
                }.bind(this)
                this.navBlock.appendChild(this.cardNav);

                option = document.createElement('option');
                option.value = 0;
                option.innerHTML = 'Master'
                this.cardNav.appendChild(option);

                deckWrap = document.createElement('div');
                this.appendChild(deckWrap);

                xString = '<x-deck id="DAQdeck" selected-index=0>';
                xString += '<x-card id="DAQmasterCard"></x-card></x-deck>';
                xtag.innerHTML(deckWrap, xString);
                this.nCards = 1

                this.masterBlock = document.createElement('div');
                this.masterBlock.setAttribute('class', 'DAQheadNode');
                document.getElementById('DAQmasterCard').appendChild(this.masterBlock);

                this.collectorBlock = document.createElement('div');
                this.collectorBlock.setAttribute('id', 'collectorBlock');
                document.getElementById('DAQmasterCard').appendChild(this.collectorBlock);

                ////////////////////////////
                //Kinetic.js setup
                ////////////////////////////

                //indices for these arrays correspond to the x-card index on display
                this.stage = [];
                this.mainLayer = [];
                this.scaleLayer = [];
                this.tooltipLayer = [];
                this.TTbkg = [];
                this.text = [];
            },
            inserted: function() {},
            removed: function() {},
            attributeChanged: function() {}
        },
        events: {

        },
        accessors: {
            'MIDAS':{
                attribute: {} //this just needs to be declared
            }
        },
        methods: {
            'buildDAQ' : function(response){
                var data = JSON.parse(response),
                    i, j, k, option,
                    collectorGutter = this.width*0.02,
                    collectorWidth = (this.width - collectorGutter*16) / 16,
                    xLength = collectorGutter/2,
                    xLeft, xRight;

                this.collectors = [];
                this.digitizers = [];
                this.collectorCells = [];

                //determine what collectors are present and instantiate x-cards for each one
                for(i=0; i<16; i++){
                    this.collectors[i] = data.hosts['collector0x' + i.toString(16)];

                    if(this.collectors[i]){
                        document.getElementById('DAQdeck').innerHTML += '<x-card id="collector'+i+'">

</x-card>';
                        option = document.createElement('option');
                        option.value = this.nCards;
                        option.innerHTML = 'Collector 0x' + i.toString(16).toUpperCase();
                        this.cardNav.appendChild(option);
                        this.nCards++;

                    }
                }

                //now that the xdeck is built, paint master canvas:
                //collectors:
                this.setupKinetic('collectorBlock');
                for(i=0; i<16; i++){
                    if(this.collectors[i]){
                        this.collectorCells[i] = new Kinetic.Rect({
                            x:collectorGutter/2 + i*this.width/16,
                            y:this.height*0.6,
                            width: collectorWidth,
                            height:this.height*0.2,
                            fill:'#555555',
                            stroke: '#000000',
                            strokeWidth: 4
                        });
                        this.mainLayer[0].add(this.collectorCells[i]);
                    } else{
                        //terminate loose cord with red x
                        xLeft = new Kinetic.Line({
                            points: [(collectorGutter + collectorWidth)/2 + i*(collectorGutter+collectorWidth) - xLength, 0.6*this.height - xLength, (collectorGutter + collectorWidth)/2 + i*(collectorGutter+collectorWidth) + xLength, 0.6*this.height + xLength],
                            stroke: '#FF0000',
                            strokeWidth: 8
                        });
                        xRight = new Kinetic.Line({
                            points: [(collectorGutter + collectorWidth)/2 + i*(collectorGutter+collectorWidth) + xLength, 0.6*this.height - xLength, (collectorGutter + collectorWidth)/2 + i*(collectorGutter+collectorWidth) - xLength, 0.6*this.height + xLength],
                            stroke: '#FF0000',
                            strokeWidth: 8
                        });
                        this.mainLayer[0].add(xLeft);
                        this.mainLayer[0].add(xRight);
                    }
                }

                //cabling:
                this.masterCables = [[],[],[],[]]; //1-to-4 cables: outer index counts master port, inner index counts collector
                for(i=0; i<4; i++){
                    this.masterCables[i][0] = new Kinetic.Line({
                        points: [collectorWidth*2 + collectorGutter*1.75 + i*(collectorWidth + collectorGutter)*4,0, collectorWidth*2 + collectorGutter*1.75 + i*(collectorWidth + collectorGutter)*4, 0.3*this.height],
                        stroke: '#000000',
                        strokeWidth: 4
                    });
                    this.mainLayer[0].add(this.masterCables[i][0]);
                    this.masterCables[i][0].moveToBottom();
                    for(j=1; j<5; j++){
                        this.masterCables[i][j] = new Kinetic.Line({
                            points: [collectorWidth*2 + collectorGutter*1.75 + i*(collectorWidth + collectorGutter)*4, 0.3*this.height, (collectorGutter + collectorWidth)/2 + (4*i+j-1)*(collectorGutter+collectorWidth), 0.6*this.height],
                            stroke: '#000000',
                            strokeWidth: 4
                        });
                        this.mainLayer[0].add(this.masterCables[i][j]);
                        this.masterCables[i][j].moveToBottom();
                    }
                }
                this.mainLayer[0].draw();

                //and again for each collector card
                this.digitizerCells = [];
                this.collectorCables = [];
                for(i=0; i<16; i++){
                    this.digitizerCells[i] = [];

                    if(!this.collectors[i]) continue;

                    this.setupKinetic('digitizerBlock'+i);
                    for(j=0; j<16; j++){
                        if(data.hosts['collector0x' + i.toString(16)].digitizers[j]){
                            this.digitizerCells[i][j] = new Kinetic.Rect({
                                x:collectorGutter/2 + j*this.width/16,
                                y:this.height*0.6,
                                width: collectorWidth,
                                height:this.height*0.2,
                                fill:'#555555',
                                stroke: '#000000',
                                strokeWidth: 4
                            });
                            this.mainLayer[i+1].add(this.digitizerCells[i][j]);
                        } else{
                            //terminate loose cord with red x
                            xLeft = new Kinetic.Line({
                                points: [(collectorGutter + collectorWidth)/2 + j*(collectorGutter+collectorWidth) - xLength, 0.6*this.height - xLength, (collectorGutter + collectorWidth)/2 + j*(collectorGutter+collectorWidth) + xLength, 0.6*this.height + xLength],
                                stroke: '#FF0000',
                                strokeWidth: 8
                            });
                            xRight = new Kinetic.Line({
                                points: [(collectorGutter + collectorWidth)/2 + j*(collectorGutter+collectorWidth) + xLength, 0.6*this.height - xLength, (collectorGutter + collectorWidth)/2 + j*(collectorGutter+collectorWidth) - xLength, 0.6*this.height + xLength],
                                stroke: '#FF0000',
                                strokeWidth: 8
                            });
                            this.mainLayer[i+1].add(xLeft);
                            this.mainLayer[i+1].add(xRight);
                        }

                    }

                    //cabling:
                    this.collectorCables[i] = [];
                    for(j=0; j<4; j++){
                        this.collectorCables[i][j] = [];
                        this.collectorCables[i][j][0] = new Kinetic.Line({
                            points: [collectorWidth*2 + collectorGutter*1.75 + j*(collectorWidth + collectorGutter)*4,0, collectorWidth*2 + collectorGutter*1.75 + j*(collectorWidth + collectorGutter)*4, 0.3*this.height],
                            stroke: '#000000',
                            strokeWidth: 4
                        });
                        this.mainLayer[i+1].add(this.collectorCables[i][j][0]);
                        this.collectorCables[i][j][0].moveToBottom();
                        for(k=1; k<5; k++){
                            this.collectorCables[i][j][k] = new Kinetic.Line({
                                points: [collectorWidth*2 + collectorGutter*1.75 + j*(collectorWidth + collectorGutter)*4, 0.3*this.height, (collectorGutter + collectorWidth)/2 + (4*j+k-1)*(collectorGutter+collectorWidth), 0.6*this.height],
                                stroke: '#000000',
                                strokeWidth: 4
                            });
                            this.mainLayer[i+1].add(this.collectorCables[i][j][k]);
                            this.collectorCables[i][j][k].moveToBottom();
                        }
                    }
                    this.mainLayer[i+1].draw();
                }

            },

            'setupKinetic' : function(targetID){
                var i = this.stage.length;
                //point kinetic at the div and set up the staging and layers:
                this.stage[i] = new Kinetic.Stage({
                    container: targetID,
                    width: this.width,
                    height: this.height
                });
                this.mainLayer[i] = new Kinetic.Layer();       //main rendering layer
                this.scaleLayer[i] = new Kinetic.Layer();      //layer for scales / legends
                this.tooltipLayer[i] = new Kinetic.Layer();    //layer for tooltip info

                //tooltip background:
                this.TTbkg[i] = new Kinetic.Rect({
                    x:-1000,
                    y:-1000,
                    width:100,
                    height:100,
                    fill:'rgba(0,0,0,0.8)',
                    stroke: 'rgba(0,0,0,0)',
                    listening: false
                });
                this.tooltipLayer[i].add(this.TTbkg[i]);

                //tooltip text:
                this.text[i] = new Kinetic.Text({
                    x: -1000,
                    y: -1000,
                    fontFamily: 'Arial',
                    fontSize: 16,
                    text: '',
                    lineHeight: 1.2,
                    fill: '#EEEEEE',
                    listening: false
                });
                this.tooltipLayer[i].add(this.text[i]);

                this.stage[i].add(this.mainLayer[i]);
                this.stage[i].add(this.scaleLayer[i]);
                this.stage[i].add(this.tooltipLayer[i]);
            }
        }
    });

})();<commit_msg>master/collector onclick<commit_after>(function(){

    xtag.register('widget-DAQ', {
        extends: 'div',
        lifecycle: {
            created: function() {
                var xString, option, title, deckWrap;

                this.width = this.offsetWidth;
                this.height = window.innerHeight*0.6;

                //get the DAQ structure
                XHR('http://' + this.MIDAS + '/?cmd=jcopy&odb=/DAQ&encoding=json-nokeys',
                    function(res){
                        this.buildDAQ(res);
                    }.bind(this),
                    'application/json');

                //build DOM
                this.navBlock = document.createElement('div');
                this.navBlock.setAttribute('class', 'DAQnav');
                this.appendChild(this.navBlock);

                title = document.createElement('h1');
                title.innerHTML = 'DAQ';
                this.navBlock.appendChild(title);

                this.cardNav = document.createElement('select');
                this.cardNav.setAttribute('id', 'DAQnav')
                this.cardNav.setAttribute('class', 'stdin');
                this.cardNav.onchange = function(){
                    document.getElementById('DAQdeck').shuffleTo(selected('DAQnav'));
                }.bind(this)
                this.navBlock.appendChild(this.cardNav);

                option = document.createElement('option');
                option.value = 0;
                option.innerHTML = 'Master'
                this.cardNav.appendChild(option);

                deckWrap = document.createElement('div');
                this.appendChild(deckWrap);

                xString = '<x-deck id="DAQdeck" selected-index=0>';
                xString += '<x-card id="DAQmasterCard"></x-card></x-deck>';
                xtag.innerHTML(deckWrap, xString);
                this.nCards = 1

                this.masterBlock = document.createElement('div');
                this.masterBlock.setAttribute('class', 'DAQheadNode');
                document.getElementById('DAQmasterCard').appendChild(this.masterBlock);

                this.collectorBlock = document.createElement('div');
                this.collectorBlock.setAttribute('id', 'collectorBlock');
                document.getElementById('DAQmasterCard').appendChild(this.collectorBlock);

                ////////////////////////////
                //Kinetic.js setup
                ////////////////////////////

                //indices for these arrays correspond to the x-card index on display
                this.stage = [];
                this.mainLayer = [];
                this.scaleLayer = [];
                this.tooltipLayer = [];
                this.TTbkg = [];
                this.text = [];
            },
            inserted: function() {},
            removed: function() {},
            attributeChanged: function() {}
        },
        events: {

        },
        accessors: {
            'MIDAS':{
                attribute: {} //this just needs to be declared
            }
        },
        methods: {
            'buildDAQ' : function(response){
                var data = JSON.parse(response),
                    i, j, k, option,
                    collectorGutter = this.width*0.02,
                    collectorWidth = (this.width - collectorGutter*16) / 16,
                    xLength = collectorGutter/2,
                    xLeft, xRight;

                this.collectors = [];
                this.digitizers = [];
                this.collectorCells = [];

                //determine what collectors are present and instantiate x-cards for each one
                for(i=0; i<16; i++){
                    this.collectors[i] = data.hosts['collector0x' + i.toString(16)];

                    if(this.collectors[i]){
                        document.getElementById('DAQdeck').innerHTML += '<x-card id="collector'+i+'">

</x-card>';
                        option = document.createElement('option');
                        option.value = this.nCards;
                        option.innerHTML = 'Collector 0x' + i.toString(16).toUpperCase();
                        this.cardNav.appendChild(option);
                        this.nCards++;

                    }
                }

                //now that the xdeck is built, paint master canvas:
                //collectors:
                this.setupKinetic('collectorBlock');
                for(i=0; i<16; i++){
                    if(this.collectors[i]){
                        this.collectorCells[i] = new Kinetic.Rect({
                            x:collectorGutter/2 + i*this.width/16,
                            y:this.height*0.6,
                            width: collectorWidth,
                            height:this.height*0.2,
                            fill:'#555555',
                            stroke: '#000000',
                            strokeWidth: 4
                        });
                        this.collectorCells[i].on('click', this.clickCollector.bind(i+1));
                        this.mainLayer[0].add(this.collectorCells[i]);
                    } else{
                        //terminate loose cord with red x
                        xLeft = new Kinetic.Line({
                            points: [(collectorGutter + collectorWidth)/2 + i*(collectorGutter+collectorWidth) - xLength, 0.6*this.height - xLength, (collectorGutter + collectorWidth)/2 + i*(collectorGutter+collectorWidth) + xLength, 0.6*this.height + xLength],
                            stroke: '#FF0000',
                            strokeWidth: 8
                        });
                        xRight = new Kinetic.Line({
                            points: [(collectorGutter + collectorWidth)/2 + i*(collectorGutter+collectorWidth) + xLength, 0.6*this.height - xLength, (collectorGutter + collectorWidth)/2 + i*(collectorGutter+collectorWidth) - xLength, 0.6*this.height + xLength],
                            stroke: '#FF0000',
                            strokeWidth: 8
                        });
                        this.mainLayer[0].add(xLeft);
                        this.mainLayer[0].add(xRight);
                    }
                }

                //cabling:
                this.masterCables = [[],[],[],[]]; //1-to-4 cables: outer index counts master port, inner index counts collector
                for(i=0; i<4; i++){
                    this.masterCables[i][0] = new Kinetic.Line({
                        points: [collectorWidth*2 + collectorGutter*1.75 + i*(collectorWidth + collectorGutter)*4,0, collectorWidth*2 + collectorGutter*1.75 + i*(collectorWidth + collectorGutter)*4, 0.3*this.height],
                        stroke: '#000000',
                        strokeWidth: 4
                    });
                    this.mainLayer[0].add(this.masterCables[i][0]);
                    this.masterCables[i][0].moveToBottom();
                    for(j=1; j<5; j++){
                        this.masterCables[i][j] = new Kinetic.Line({
                            points: [collectorWidth*2 + collectorGutter*1.75 + i*(collectorWidth + collectorGutter)*4, 0.3*this.height, (collectorGutter + collectorWidth)/2 + (4*i+j-1)*(collectorGutter+collectorWidth), 0.6*this.height],
                            stroke: '#000000',
                            strokeWidth: 4
                        });
                        this.mainLayer[0].add(this.masterCables[i][j]);
                        this.masterCables[i][j].moveToBottom();
                    }
                }
                this.mainLayer[0].draw();

                //and again for each collector card
                this.digitizerCells = [];
                this.collectorCables = [];
                for(i=0; i<16; i++){
                    this.digitizerCells[i] = [];

                    if(!this.collectors[i]) continue;

                    this.setupKinetic('digitizerBlock'+i);
                    for(j=0; j<16; j++){
                        if(data.hosts['collector0x' + i.toString(16)].digitizers[j]){
                            this.digitizerCells[i][j] = new Kinetic.Rect({
                                x:collectorGutter/2 + j*this.width/16,
                                y:this.height*0.6,
                                width: collectorWidth,
                                height:this.height*0.2,
                                fill:'#555555',
                                stroke: '#000000',
                                strokeWidth: 4
                            });
                            this.mainLayer[i+1].add(this.digitizerCells[i][j]);
                        } else{
                            //terminate loose cord with red x
                            xLeft = new Kinetic.Line({
                                points: [(collectorGutter + collectorWidth)/2 + j*(collectorGutter+collectorWidth) - xLength, 0.6*this.height - xLength, (collectorGutter + collectorWidth)/2 + j*(collectorGutter+collectorWidth) + xLength, 0.6*this.height + xLength],
                                stroke: '#FF0000',
                                strokeWidth: 8
                            });
                            xRight = new Kinetic.Line({
                                points: [(collectorGutter + collectorWidth)/2 + j*(collectorGutter+collectorWidth) + xLength, 0.6*this.height - xLength, (collectorGutter + collectorWidth)/2 + j*(collectorGutter+collectorWidth) - xLength, 0.6*this.height + xLength],
                                stroke: '#FF0000',
                                strokeWidth: 8
                            });
                            this.mainLayer[i+1].add(xLeft);
                            this.mainLayer[i+1].add(xRight);
                        }

                    }

                    //cabling:
                    this.collectorCables[i] = [];
                    for(j=0; j<4; j++){
                        this.collectorCables[i][j] = [];
                        this.collectorCables[i][j][0] = new Kinetic.Line({
                            points: [collectorWidth*2 + collectorGutter*1.75 + j*(collectorWidth + collectorGutter)*4,0, collectorWidth*2 + collectorGutter*1.75 + j*(collectorWidth + collectorGutter)*4, 0.3*this.height],
                            stroke: '#000000',
                            strokeWidth: 4
                        });
                        this.mainLayer[i+1].add(this.collectorCables[i][j][0]);
                        this.collectorCables[i][j][0].moveToBottom();
                        for(k=1; k<5; k++){
                            this.collectorCables[i][j][k] = new Kinetic.Line({
                                points: [collectorWidth*2 + collectorGutter*1.75 + j*(collectorWidth + collectorGutter)*4, 0.3*this.height, (collectorGutter + collectorWidth)/2 + (4*j+k-1)*(collectorGutter+collectorWidth), 0.6*this.height],
                                stroke: '#000000',
                                strokeWidth: 4
                            });
                            this.mainLayer[i+1].add(this.collectorCables[i][j][k]);
                            this.collectorCables[i][j][k].moveToBottom();
                        }
                    }
                    this.mainLayer[i+1].draw();
                }

            },

            'setupKinetic' : function(targetID){
                var i = this.stage.length;
                //point kinetic at the div and set up the staging and layers:
                this.stage[i] = new Kinetic.Stage({
                    container: targetID,
                    width: this.width,
                    height: this.height
                });
                this.mainLayer[i] = new Kinetic.Layer();       //main rendering layer
                this.scaleLayer[i] = new Kinetic.Layer();      //layer for scales / legends
                this.tooltipLayer[i] = new Kinetic.Layer();    //layer for tooltip info

                //tooltip background:
                this.TTbkg[i] = new Kinetic.Rect({
                    x:-1000,
                    y:-1000,
                    width:100,
                    height:100,
                    fill:'rgba(0,0,0,0.8)',
                    stroke: 'rgba(0,0,0,0)',
                    listening: false
                });
                this.tooltipLayer[i].add(this.TTbkg[i]);

                //tooltip text:
                this.text[i] = new Kinetic.Text({
                    x: -1000,
                    y: -1000,
                    fontFamily: 'Arial',
                    fontSize: 16,
                    text: '',
                    lineHeight: 1.2,
                    fill: '#EEEEEE',
                    listening: false
                });
                this.tooltipLayer[i].add(this.text[i]);

                this.stage[i].add(this.mainLayer[i]);
                this.stage[i].add(this.scaleLayer[i]);
                this.stage[i].add(this.tooltipLayer[i]);
            },

            'clickCollector' : function(index){
                document.getElementById('DAQdeck').shuffleTo(index+1);
            }
        }
    });

})();<|endoftext|>


<commit_before><commit_msg>bugfix<commit_after><|endoftext|>


<commit_before>import PropTypes from 'prop-types';
import React, { Component } from 'react';
import './FilterSidebar.less';
import fuzzysearch from 'fuzzysearch';

export default
class FilterSidebar extends Component {
  constructor(props) {
    super(props);
    this.state = {
      filterInputValue: ''
    };
    this.handleClickOutside = this.handleClickOutside.bind(this);
  }

  componentDidMount() {
    document.body.addEventListener('click', this.handleClickOutside);
    this.refs.searchInput.focus();
  }

  componentWillUnmount() {
    document.body.removeEventListener('click', this.handleClickOutside);
  }

  filterComponentsLists(componentsInfo, filterText) {
    return componentsInfo.filter(component => {
      return fuzzysearch(filterText.toLowerCase(), component.name.toLowerCase());
    });
  }

  handleFilterInputChange(e) {
    this.setState({ filterInputValue: e.target.value });
  }

  collapseBy(list, by) {
    return list.reduce((results, current) => {
      return results.some(result => result[by] === current[by]) ? results : results.concat([current]);
    }, []);
  }

  handleClickOutside(event) {
    if (!this.props.hideOnOutsideClick) {
      return false;
    }
    let hasParent = (node, parent) => {
      if (node.parentNode) {
        return node.parentNode === parent || hasParent(node.parentNode, parent);
      }
      return false;
    };
    if (event.target !== this._container && !hasParent(event.target, this._container)) {
      this.props.onHide();
    }
    return false;
  }

  handleComponentSelection = (componentName) => {
    this.props.onComponentChange(componentName);
  }

  render() {
    let { currentComponent } = this.props;
    let preparedComponentsList = this.filterComponentsLists(this.props.componentsInfo, this.state.filterInputValue);
    preparedComponentsList = this.collapseBy(preparedComponentsList, 'name');
    preparedComponentsList = preparedComponentsList.sort(
      (component1, component2) => component1.name > component2.name ? 1 : -1
    );

    return (

 { this._container = container }}
        className="filter-sidebar"
      >

          <input
            className="filter-sidebar__filter-input form-control"
            type="text"
            ref="searchInput"
            placeholder="Component name"
            onChange={(e) => this.handleFilterInputChange(e)}
          />

            {preparedComponentsList.map((component, index) => (

 this.handleComponentSelection(component.name)}
                className={`
                  filter-sidebar__components-list-item
                  ${currentComponent && (currentComponent.name === component.name) ? 'filter-sidebar__component-list-item--current' : ''}
                `}
              >

                  {component.name}

            ))}

    )
  }
}

FilterSidebar.propTypes = {
  currentComponent: PropTypes.object,
  componentsInfo: PropTypes.arrayOf(PropTypes.object).isRequired,
  onComponentChange: PropTypes.func,
  onHide: PropTypes.func,
  hideOnOutsideClick: PropTypes.bool
};
FilterSidebar.defaultProps = {
  currentComponent: {},
  componentsInfo: [],
  hideOnOutsideClick: false
};
<commit_msg>Fix lint<commit_after>import PropTypes from 'prop-types';
import React, { Component } from 'react';
import './FilterSidebar.less';
import fuzzysearch from 'fuzzysearch';

export default
class FilterSidebar extends Component {
  constructor(props) {
    super(props);
    this.state = {
      filterInputValue: ''
    };
    this.handleClickOutside = this.handleClickOutside.bind(this);
  }

  componentDidMount() {
    document.body.addEventListener('click', this.handleClickOutside);
    this.refs.searchInput.focus();
  }

  componentWillUnmount() {
    document.body.removeEventListener('click', this.handleClickOutside);
  }

  filterComponentsLists(componentsInfo, filterText) {
    return componentsInfo.filter(component => {
      return fuzzysearch(filterText.toLowerCase(), component.name.toLowerCase());
    });
  }

  handleFilterInputChange(e) {
    this.setState({ filterInputValue: e.target.value });
  }

  collapseBy(list, by) {
    return list.reduce((results, current) => {
      return results.some(result => result[by] === current[by]) ? results : results.concat([current]);
    }, []);
  }

  handleClickOutside(event) {
    if (!this.props.hideOnOutsideClick) {
      return false;
    }
    let hasParent = (node, parent) => {
      if (node.parentNode) {
        return node.parentNode === parent || hasParent(node.parentNode, parent);
      }
      return false;
    };
    if (event.target !== this._container && !hasParent(event.target, this._container)) {
      this.props.onHide();
    }
    return false;
  }

  handleComponentSelection = (componentName) => {
    this.props.onComponentChange(componentName);
  }

  render() {
    let { currentComponent } = this.props;
    let preparedComponentsList = this.filterComponentsLists(this.props.componentsInfo, this.state.filterInputValue);
    preparedComponentsList = this.collapseBy(preparedComponentsList, 'name');
    preparedComponentsList = preparedComponentsList.sort(
      (component1, component2) => component1.name > component2.name ? 1 : -1
    );

    return (

 { this._container = container }}
        className="filter-sidebar"
      >

          <input
            className="filter-sidebar__filter-input form-control"
            type="text"
            ref="searchInput"
            placeholder="Component name"
            onChange={(e) => this.handleFilterInputChange(e)}
          />

            {preparedComponentsList.map((component, index) => (

 this.handleComponentSelection(component.name)}
                className={`
                  filter-sidebar__components-list-item
                  ${
                    currentComponent && (currentComponent.name === component.name) ?
                    'filter-sidebar__component-list-item--current' :
                    ''
                  }
                `}
              >

                  {component.name}

            ))}

    )
  }
}

FilterSidebar.propTypes = {
  currentComponent: PropTypes.object,
  componentsInfo: PropTypes.arrayOf(PropTypes.object).isRequired,
  onComponentChange: PropTypes.func,
  onHide: PropTypes.func,
  hideOnOutsideClick: PropTypes.bool
};
FilterSidebar.defaultProps = {
  currentComponent: {},
  componentsInfo: [],
  hideOnOutsideClick: false
};
<|endoftext|>


<commit_before>(function() {
  // To be used as the local storage key
  var loginTokenKey = "Meteor.loginToken";
  var userIdKey = "Meteor.userId";

  // Call this from the top level of the test file for any test that does
  // logging in and out, to protect multiple tabs running the same tests
  // simultaneously from interfering with each others' localStorage.
  Accounts._isolateLoginTokenForTest = function () {
    loginTokenKey = loginTokenKey + Meteor.uuid();
    userIdKey = userIdKey + Meteor.uuid();
  };

  Accounts._storeLoginToken = function(userId, token) {
    localStorage.setItem(userIdKey, userId);
    localStorage.setItem(loginTokenKey, token);

    // to ensure that the localstorage poller doesn't end up trying to
    // connect a second time
    Accounts._lastLoginTokenWhenPolled = token;
  };

  Accounts._unstoreLoginToken = function() {
    localStorage.removeItem(userIdKey);
    localStorage.removeItem(loginTokenKey);

    // to ensure that the localstorage poller doesn't end up trying to
    // connect a second time
    Accounts._lastLoginTokenWhenPolled = null;
  };

  Accounts._storedLoginToken = function() {
    return localStorage.getItem(loginTokenKey);
  };

  Accounts._storedUserId = function() {
    return localStorage.getItem(userIdKey);
  };
})();

// Login with a Meteor access token
//
Meteor.loginWithToken = function (token, callback) {
  Accounts.callLoginMethod({
    methodArguments: [{resume: token}],
    userCallback: callback});
};

if (!Accounts._preventAutoLogin) {
  // Immediately try to log in via local storage, so that any DDP
  // messages are sent after we have established our user account
  var token = Accounts._storedLoginToken();
  if (token) {
    // On startup, optimistically present us as logged in while the
    // request is in flight. This reduces page flicker on startup.
    var userId = Accounts._storedUserId();
    userId && Meteor.default_connection.setUserId(userId);
    Meteor.loginWithToken(token, function (err) {
      if (err) {
        Meteor._debug("Error logging in with token: " + err);
        Accounts._makeClientLoggedOut();
      }
    });
  }
}

// Poll local storage every 3 seconds to login if someone logged in in
// another tab
Accounts._lastLoginTokenWhenPolled = token;
Accounts._pollStoredLoginToken = function() {
  if (Accounts._preventAutoLogin)
    return;

  var currentLoginToken = Accounts._storedLoginToken();

  // != instead of !== just to make sure undefined and null are treated the same
  if (Accounts._lastLoginTokenWhenPolled != currentLoginToken) {
    if (currentLoginToken)
      Meteor.loginWithToken(currentLoginToken); // XXX should we pass a callback here?
    else
      Meteor.logout();
  }
  Accounts._lastLoginTokenWhenPolled = currentLoginToken;
};

// Semi-internal API. Call this function to re-enable auto login after
// if it was disabled at startup.
Accounts._enableAutoLogin = function () {
  Accounts._preventAutoLogin = false;
  Accounts._pollStoredLoginToken();
};

setInterval(Accounts._pollStoredLoginToken, 3000);
<commit_msg>Wrap all of accounts-base/localstorage_token.js in a closure.<commit_after>(function() {
  // To be used as the local storage key
  var loginTokenKey = "Meteor.loginToken";
  var userIdKey = "Meteor.userId";

  // Call this from the top level of the test file for any test that does
  // logging in and out, to protect multiple tabs running the same tests
  // simultaneously from interfering with each others' localStorage.
  Accounts._isolateLoginTokenForTest = function () {
    loginTokenKey = loginTokenKey + Meteor.uuid();
    userIdKey = userIdKey + Meteor.uuid();
  };

  Accounts._storeLoginToken = function(userId, token) {
    localStorage.setItem(userIdKey, userId);
    localStorage.setItem(loginTokenKey, token);

    // to ensure that the localstorage poller doesn't end up trying to
    // connect a second time
    Accounts._lastLoginTokenWhenPolled = token;
  };

  Accounts._unstoreLoginToken = function() {
    localStorage.removeItem(userIdKey);
    localStorage.removeItem(loginTokenKey);

    // to ensure that the localstorage poller doesn't end up trying to
    // connect a second time
    Accounts._lastLoginTokenWhenPolled = null;
  };

  Accounts._storedLoginToken = function() {
    return localStorage.getItem(loginTokenKey);
  };

  Accounts._storedUserId = function() {
    return localStorage.getItem(userIdKey);
  };

  // Login with a Meteor access token
  //
  Meteor.loginWithToken = function (token, callback) {
    Accounts.callLoginMethod({
      methodArguments: [{resume: token}],
      userCallback: callback});
  };

  if (!Accounts._preventAutoLogin) {
    // Immediately try to log in via local storage, so that any DDP
    // messages are sent after we have established our user account
    var token = Accounts._storedLoginToken();
    if (token) {
      // On startup, optimistically present us as logged in while the
      // request is in flight. This reduces page flicker on startup.
      var userId = Accounts._storedUserId();
      userId && Meteor.default_connection.setUserId(userId);
      Meteor.loginWithToken(token, function (err) {
        if (err) {
          Meteor._debug("Error logging in with token: " + err);
          Accounts._makeClientLoggedOut();
        }
      });
    }
  }

  // Poll local storage every 3 seconds to login if someone logged in in
  // another tab
  Accounts._lastLoginTokenWhenPolled = token;
  Accounts._pollStoredLoginToken = function() {
    if (Accounts._preventAutoLogin)
      return;

    var currentLoginToken = Accounts._storedLoginToken();

    // != instead of !== just to make sure undefined and null are treated the same
    if (Accounts._lastLoginTokenWhenPolled != currentLoginToken) {
      if (currentLoginToken)
        Meteor.loginWithToken(currentLoginToken); // XXX should we pass a callback here?
      else
        Meteor.logout();
    }
    Accounts._lastLoginTokenWhenPolled = currentLoginToken;
  };

  // Semi-internal API. Call this function to re-enable auto login after
  // if it was disabled at startup.
  Accounts._enableAutoLogin = function () {
    Accounts._preventAutoLogin = false;
    Accounts._pollStoredLoginToken();
  };

  setInterval(Accounts._pollStoredLoginToken, 3000);
})();

<|endoftext|>


<commit_before>// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

'use strict';

module.exports = {
  opts: {
    readme: './README.md',
    package: './package.json',
    template: './node_modules/jsdoc-fresh',
    recurse: true,
    verbose: true,
    destination: './docs/'
  },
  plugins: [
    'plugins/markdown',
    'jsdoc-region-tag'
  ],
  source: {
    excludePattern: '(^|\\/|\\\\)[._]',
    include: [
      'build/src'
    ],
    includePattern: '\\.js$'
  },
  templates: {
    copyright: 'Copyright 2018 Google, LLC.',
    includeDate: false,
    sourceFiles: false,
    systemName: '@google-cloud/speech',
    theme: 'lumen'
  },
  markdown: {
    idInHeadings: true
  }
};
<commit_msg>chore: update jsdoc.js (#540)<commit_after>// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

'use strict';

module.exports = {
  opts: {
    readme: './README.md',
    package: './package.json',
    template: './node_modules/jsdoc-fresh',
    recurse: true,
    verbose: true,
    destination: './docs/'
  },
  plugins: [
    'plugins/markdown',
    'jsdoc-region-tag'
  ],
  source: {
    excludePattern: '(^|\\/|\\\\)[._]',
    include: [
      'build/src'
    ],
    includePattern: '\\.js$'
  },
  templates: {
    copyright: 'Copyright 2019 Google, LLC.',
    includeDate: false,
    sourceFiles: false,
    systemName: '@google-cloud/speech',
    theme: 'lumen',
    default: {
      "outputSourceFiles": false
    }
  },
  markdown: {
    idInHeadings: true
  }
};
<|endoftext|>