/*
Helper method to create an ear and add it to the dropins directory
421743
public static void addEarToServerDropins(LibertyServer server, String earName, boolean addEarResources,
                                             String warName, boolean addWarResources, String jarName, boolean addJarResources, String... packageNames) throws Exception {
        addEarToServer(server, DIR_DROPINS, earName, addEarResources, warName, addWarResources, jarName, addJarResources,
                       packageNames);
    }
663732
function attachListeners() {
        if(!($this->client instanceof \CharlotteDunois\Livia\Client)) {
            throw new \BadMethodCallException('The client property is not set or not a valid instance of Client');
        }
        
        $this->client->on('commandPrefixChange', array($this, 'callbackCommandPrefixChange'));
        $this->client->on('commandStatusChange', array($this, 'callbackCommandStatusChange'));
        $this->client->on('groupStatusChange', array($this, 'callbackGroupStatusChange'));
        $this->client->on('guildCreate', array($this, 'callbackGuildCreate'));
        $this->client->on('commandRegister', array($this, 'callbackCommandRegister'));
        $this->client->on('commandReregister', array($this, 'callbackCommandRegister'));
        $this->client->on('groupRegister', array($this, 'callbackGroupRegister'));
        $this->client->on('groupReregister', array($this, 'callbackGroupRegister'));
    }
653188
function createListener(db, e, object) {
  function listener(err) {
    if (object.listeners(e).length > 0) {
      object.emit(e, err, db);

      // Emit on all associated db's if available
      for (let i = 0; i < db.s.children.length; i++) {
        db.s.children[i].emit(e, err, db.s.children[i]);
      }
    }
  }
  return listener;
}
773058
protected void initDropzone(Element e, Element template, String previews, Element uploadPreview, Element uploadedFiles) {
        JQueryElement previewNode = $(template);
        previewNode.asElement().setId("");
        String previewTemplate = previewNode.parent().html();
        options.previewTemplate = previewTemplate;
        options.previewsContainer = "#" + previews;
        uploader = new Dropzone(e, options);

        uploader.on(FileUploaderEvents.DROP, event -> {
            fireDropEvent();
            if (preview) {
                $(e).removeClass(CssName.ACTIVE);
            }
            return true;
        });

        uploader.on(FileUploaderEvents.DRAG_START, event -> {
            DragStartEvent.fire(this);
            return true;
        });

        uploader.on(FileUploaderEvents.DRAG_END, event -> {
            DragEndEvent.fire(this);
            return true;
        });

        uploader.on(FileUploaderEvents.DRAG_ENTER, event -> {
            DragEnterEvent.fire(this, null);
            if (preview) {
                $(e).addClass(CssName.ACTIVE);
            }
            return true;
        });

        uploader.on(FileUploaderEvents.DRAG_OVER, event -> {
            DragOverEvent.fire(this);
            return true;
        });

        uploader.on(FileUploaderEvents.DRAG_LEAVE, event -> {
            DragLeaveEvent.fire(this, null);
            if (preview) {
                $(e).removeClass(CssName.ACTIVE);
            }
            return true;
        });

        uploader.on(FileUploaderEvents.ADDED_FILE, file -> {
            AddedFileEvent.fire(this, convertUploadFile(file));
            totalFiles++;

            if (isPreview()) {
                $(uploadedFiles).html("Uploaded files " + totalFiles);
                getUploadPreview().getUploadHeader().getProgress().setPercent(0);
                getUploadPreview().setVisibility(Style.Visibility.VISIBLE);
            }
        });

        uploader.on(FileUploaderEvents.REMOVED_FILE, file -> {
            RemovedFileEvent.fire(this, convertUploadFile(file));
            totalFiles -= 1;
            $(uploadedFiles).html("Uploaded files " + totalFiles);

            if (totalFiles == 0 && isPreview()) {
                getUploadPreview().setVisibility(Style.Visibility.HIDDEN);
            }
        });

        uploader.on("error", (file, response) -> {
            int code = 200;
            String statusText = "";

            if (file.xhr != null) {
                code = file.xhr.status;
                statusText = file.xhr.statusText;
            }

            String body = "";

            if (response instanceof String) {
                body = (String)response;
            } else {
                statusText = getResponseMessage(response);
            }

            if (code == 401) {
                statusText = statusText.isEmpty() ? "Unauthorized. Your session may have expired. Log in and try again." : statusText;
                globalResponse = response;
                UnauthorizedEvent.fire(this, convertUploadFile(file), new UploadResponse(code, statusText, body));
            }

            if (code == 404) {
                statusText = statusText.isEmpty() ? "There is a problem uploading your file." : statusText;
                globalResponse = response;
            }

            if (code == 500) {
                statusText = statusText.isEmpty() ? "There is a problem uploading your file." : statusText;
                globalResponse = response;
            }


            ErrorEvent.fire(this, convertUploadFile(file), new UploadResponse(code, statusText, body));
        });

        uploader.on(FileUploaderEvents.TOTAL_UPLOAD_PROGRESS, (progress, file, response) -> {
            TotalUploadProgressEvent.fire(this, progress);
            if (isPreview()) {
                getUploadPreview().getUploadHeader().getProgress().setPercent(progress);
            }
        });

        uploader.on(FileUploaderEvents.UPLOAD_PROGRESS, (progress, file, response) -> {
            CurrentUploadProgressEvent.fire(this, progress);
            if ($this != null) {
                $this.find(".progress .determinate").css("width", progress + "%");
            }
        });

        uploader.on(FileUploaderEvents.SENDING, file -> {
            SendingEvent.fire(this, convertUploadFile(file),
                    new UploadResponse(file.xhr.status, file.xhr.statusText));
        });

        uploader.on(FileUploaderEvents.SUCCESS, (file, response) -> {
            globalResponse = response;
            String message = getResponseMessage(response);
            SuccessEvent.fire(this, convertUploadFile(file),
                    new UploadResponse(file.xhr.status, file.xhr.statusText, message));
        });

        uploader.on(FileUploaderEvents.COMPLETE, file -> {
            String message = getResponseMessage(globalResponse);
            CompleteEvent.fire(this, convertUploadFile(file),
                    new UploadResponse(file.xhr.status, file.xhr.statusText, message));
        });

        uploader.on(FileUploaderEvents.CANCELED, file -> {
            CanceledEvent.fire(this, convertUploadFile(file));
        });

        uploader.on(FileUploaderEvents.MAX_FILES_REACHED, file -> {
            MaxFilesReachedEvent.fire(this, convertUploadFile(file));
        });

        uploader.on(FileUploaderEvents.MAX_FILES_EXCEEDED, file -> {
            MaterialToast.fireToast("You have reached the maximum files to be uploaded.");
            MaxFilesExceededEvent.fire(this, convertUploadFile(file));
        });
    }
846502
public void addEarCommand(boolean earOn) {
        StringBuilder buf = new StringBuilder();
        buf.append("(ear ");
        if (earOn) {
            buf.append("on");
        } else {
            buf.append("off");
        }
        buf.append(')');
        fifo.add(fifo.size(), buf.toString());
    }
613160
public static void addWarToServerDropins(LibertyServer server, String warName, boolean addWarResources,
                                             String... packageNames) throws Exception {
        addEarToServer(server, DIR_DROPINS, null, false, warName, addWarResources, null, false, packageNames);
    }
91582
function VKI_addListener(elem, type, func, cap) {
    if (elem.addEventListener) {
      elem.addEventListener(type, function(e) { func.call(elem, e); }, cap);
    } else if (elem.attachEvent)
      elem.attachEvent('on' + type, function() { func.call(elem); });
  }
29887
function addEventListeners(target, types, handler) {
    each(splitStr(types), function(type) {
        target.addEventListener(type, handler, false);
    });
}
496563
public static <L, K> void addListener (Map<K, ListenerList<L>> map, K key, L listener)
    {
        ListenerList<L> list = map.get(key);
        if (list == null) {
            map.put(key, list = new ListenerList<L>());
        }
        list.add(listener);
    }
241399
function addListener(event, callback, meta) {
  event.listeners.push(callback);
  event.meta.set(callback, meta);
}
129209
function addListener(object, fName, event, listener) {
		listeners.push({
			object: object[fName](event, listener),
			event: event,
			listener: listener,
		})
	}
1160573
public static boolean addFilelistener(String pResourcename, String pListenerPath)
        throws FileNotFoundException, IOException, ClassNotFoundException {
        mFilelistenerToPaths = new HashMap<String, String>();

        File listenerFilePaths = new File(StorageManager.ROOT_PATH + File.separator + "mapping.data");

        getFileListenersFromSystem(listenerFilePaths);

        mFilelistenerToPaths.put(pResourcename, pListenerPath);

        ByteArrayDataOutput output = ByteStreams.newDataOutput();
        for (Entry<String, String> e : mFilelistenerToPaths.entrySet()) {
            output.write((e.getKey() + "\n").getBytes());
            output.write((e.getValue() + "\n").getBytes());
        }

        java.nio.file.Files.write(listenerFilePaths.toPath(), output.toByteArray(),
            StandardOpenOption.TRUNCATE_EXISTING);

        return true;
    }
915126
private function populateListeners()
    {
        if (isset($GLOBALS['TL_EVENTS']) && is_array($GLOBALS['TL_EVENTS'])) {
            $this->addListeners($GLOBALS['TL_EVENTS']);
        }

        foreach ($this->listenerFiles as $file) {
            // @codeCoverageIgnoreStart
            $events = (array) include $file;
            $this->addListeners($events);
            // @codeCoverageIgnoreEnd
        }
    }
1263581
public void addListeners()
    {
        String strMessage = "Create new user account";
        String strTerms = this.getProperty("terms");    // Terms resource EY
        if (strTerms == null)
            strTerms = "terms";
        if (this.getTask() != null)
            if (this.getTask().getApplication() != null)
        {
            BaseApplication application = (BaseApplication)this.getTask().getApplication();
            strMessage = application.getResources(ResourceConstants.ERROR_RESOURCE, true).getString(strMessage);
        
            strTerms = application.getResources(ResourceConstants.DEFAULT_RESOURCE, true).getString(strTerms);
        }
        this.getScreenRecord().getField(UserScreenRecord.STATUS_LINE).setString(strMessage);
        this.getScreenRecord().getField(UserScreenRecord.TERMS).setString(strTerms);
        
        //x this.readCurrentUser();
        
        super.addListeners();
        
        FieldListener listener = this.getMainRecord().getField(UserInfo.USER_NAME).getListener(MainFieldHandler.class);
        if (listener != null)
            this.getMainRecord().getField(UserInfo.USER_NAME).removeListener(listener, true);   // Don't read current accounts
        
        this.getMainRecord().addListener(new UserPasswordHandler(false));
        
        this.addAutoLoginHandler();
    }
463652
void addFreeTypeListener(List<Type> types, FreeTypeListener ftl) {
        freeTypeListeners.put(ftl, freeVarsIn(types));
    }
345502
function addListener(attr,func,child,update)
        {
          if(typeof func !== 'function') return bind;

          var isInput = (['value','checked'].indexOf(attr) !== -1),
              isStyle = (_allStyles.indexOf(attr) !== -1),
              listeners;

          if(this.toString() !== bind.toString())
          {
            if(child)
            {
              var children = this.querySelectorAll('*'),
                  len = children.length,
                  listenerObj;
              for(var x=0;x<len;x++)
              {
                listenerObj = children[x].attrListeners();
                if(isInput || (attr === _all))
                {
                  if(children[x].addInputBinding !== undefined) children[x].addInputBinding();
                  if(children[x].addInputBoxBinding !== undefined) children[x].addInputBoxBinding();
                }
                if(isStyle)
                {
                  bind.injectStyleProperty(children[x],attr);
                  listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners');
                  if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                  listenerObj[listeners][attr].push({parent:this,func:func});
                }
                else
                {
                  if(attr === _all)
                  {
                    listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners');
                    var len = _allStyles.length;
                    for(var i = 0;i<len;i++)
                    {
                      bind.injectStyleProperty(children[x],_allStyles[i]);
                    }
                    if(listenerObj[listeners][_all] === undefined) listenerObj[listeners][_all] = [];
                      listenerObj[listeners][_all].push({parent:this,func:func});
                  }
                  listeners = (update ? '_parentAttrUpdateListeners' : '_parentAttrListeners');
                  if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                  listenerObj[listeners][attr].push({parent:this,func:func});
                }
              }
            }
            else
            {
              listenerObj = this.attrListeners();
              if(isStyle)
              {
                listeners = (update ? '_styleUpdateListeners' : '_styleListeners');
                bind.injectStyleProperty(this,attr);
                if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                listenerObj[listeners][attr].push(func);
              }
              else
              {
                if(isInput || (attr === _all))
                {
                  if(this.addInputBinding !== undefined) this.addInputBinding();
                  if(this.addInputBoxBinding !== undefined) this.addInputBoxBinding();
                }
                if(attr === _all)
                {
                  listeners = (update ? '_styleUpdateListeners' : '_styleListeners');
                  var len = _allStyles.length;
                  for(var x = 0;x<len;x++)
                  {
                    bind.injectStyleProperty(this,_allStyles[x]);
                  }
                  if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                  listenerObj[listeners][attr].push(func);
                }
                listeners = (update ? '_attrUpdateListeners' : '_attrListeners');
                if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                listenerObj[listeners][attr].push(func);
              }
            }
          }
          else
          {
            if(isInput || (attr === _all))
            {
              var inputs = document.querySelectorAll('input, textarea'),
                  len = inputs.length;
              for(var x=0;x<len;x++)
              {
                if(inputs[x].addInputBinding !== undefined) inputs[x].addInputBinding();
                if(inputs[x].addInputBoxBinding !== undefined) inputs[x].addInputBoxBinding();
              }
            }
            if(isStyle)
            {
              var els = Array.prototype.slice.call(document.body.querySelectorAll('*')),
                  len = (els.length+1);
              els.unshift(document.body);
              for(var x=0;x<len;x++)
              {
                bind.injectStyleProperty(els[x],attr);
              }
              listeners = (update ? _styleUpdateListeners : _styleListeners);
              if(listeners[attr] === undefined) listeners[attr] = [];
              listeners[attr].push(func);
            }
            else
            {
              if(attr === _all)
              {
                var els = Array.prototype.slice.call(document.body.querySelectorAll('*')),
                    len = (els.length+1),
                    lenStyles = _allStyles.length;
                els.unshift(document.body);
                for(var x=0;x<len;x++)
                {
                  for(var i=0;i<lenStyles;i++)
                  {
                    bind.injectStyleProperty(els[x],_allStyles[i]);
                  }
                }
                listeners = (update ? _styleUpdateListeners : _styleListeners);
                if(listeners[attr] === undefined) listeners[attr] = [];
                listeners[attr].push(func);
              }
              listeners = (update ? _attrUpdateListeners : _attrListeners);
              if(listeners[attr] === undefined) listeners[attr] = [];
              listeners[attr].push(func);
            }
          }
        }
464121
def create_listeners(name, listeners, region=None, key=None, keyid=None,
                     profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    if isinstance(listeners, six.string_types):
        listeners = salt.utils.json.loads(listeners)

    _complex_listeners = []
    for listener in listeners:
        _complex_listeners.append(listener_dict_to_tuple(listener))
    try:
        conn.create_load_balancer_listeners(name, [], _complex_listeners)
        log.info('Created ELB listeners on %s', name)
        return True
    except boto.exception.BotoServerError as error:
        log.error('Failed to create ELB listeners on %s: %s', name, error,
                  exc_info_on_loglevel=logging.DEBUG)
        return False