Insert-link popup
195086
function( popup, modify_a_href )
        {
            var textbox = document.createElement('input');
            textbox.placeholder = 'www.example.com';
            if( modify_a_href )
                textbox.value = modify_a_href.href;
            textbox.style.width = '20em';
            textbox.style.maxWidth = parseInt(node_container.offsetWidth *2/3) + 'px';
            textbox.autofocus = true;
            if( modify_a_href )
                addEvent( textbox, 'input', function( e )
                {
                    var url = textbox.value.trim();
                    if( url )
                        modify_a_href.href = url;
                });
            addEvent( textbox, 'keypress', function( e )
            {
                var key = e.which || e.keyCode;
                if( key != 13 )
                    return;
                var url = textbox.value.trim();
                if( modify_a_href )
                    ;
                else if( url )
                {
                    var url_scheme = url;
                    if( ! /^[a-z0-9]+:\/\//.test(url) )
                        url_scheme = "http://" + url;
                    if( commands.getSelectedHTML() )
                        commands.insertLink( url_scheme );
                    else
                    {
                        // Encode html entities - http://stackoverflow.com/questions/5499078/fastest-method-to-escape-html-tags-as-html-entities
                        var htmlencode = function( text ) {
                            return text.replace(/[&<>"]/g, function(tag)
                            {
                                var charsToReplace = { '&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;' };
                                return charsToReplace[tag] || tag;
                            });
                        }
                        commands.insertHTML( '<a href="' + htmlencode(url_scheme) + '">' + htmlencode(url) + '</a>' );
                    }
                }
                commands.closePopup().collapseSelection();
                node_contenteditable.focus();
            });
            popup.appendChild( textbox );
            // set focus
            window.setTimeout( function()
            {
                textbox.focus();
                add_class_focus();
            }, 1 );
        }
237414
function insertSearch(id){
        var imgs = domUtils.getElementsByTagName($G(id),"img"),
            videoObjs=[];
        for(var i=0,img; img=imgs[i++];){
            if(img.getAttribute("selected")){
                videoObjs.push({
                    url:img.getAttribute("ue_video_url"),
                    width:420,
                    height:280,
                    align:"none"
                });
            }
        }
        editor.execCommand('insertvideo',videoObjs);
    }
231589
function show(id) {
    $('#ao' + id).hide();
    $('#ah' + id).show();
    var context = $.extend({id: id}, opts);
    var popup = $(renderTemplate(popupTemplate, context)).hide();
    popup.find('textarea[name="proposal"]').hide();
    popup.find('a.by' + by).addClass('sel');
    var form = popup.find('#cf' + id);
    form.submit(function(event) {
      event.preventDefault();
      addComment(form);
    });
    $('#s' + id).after(popup);
    popup.slideDown('fast', function() {
      getComments(id);
    });
  }
88512
public function replaceElementUsingLink( $execMethod, $args = [ ], $targetDiv, $linkText, $anchorAttrs = [ ] )
    {
        $url = $this->url( $execMethod, $args, true );
        $attrs = [ ];
        foreach ($anchorAttrs as $k => $v) {
            $attrs[ ] = "{$k}='{$v}'";
        }
        $attrsStr = implode( ' ', $attrs );
        return <<<EOS
        <script type="application/javascript">
            if( typeof(execLink) != "function" ){
                var execLink = function( url, targetDiv ){
                    // Send the data using post
                    var posting = $.get( url, $( form ).serialize() );
                 
                    // Put the results in a div
                    posting.done(function( data ) {
                        $( "#"+targetDiv ).replaceWith( data );
                        $("body").css("cursor", "default");
                    });
    
                    // Show optional progress
                    $("body").css("cursor", "progress");
                }
            }
        </script>
        <a href="#" onclick="execLink( '{$url}', '{$targetDiv}' ); return false;" {$attrsStr}>{$linkText}</a>
EOS;
    }
90846
function onLinkClick(event) {
    // Resolve anchor link
    var page = url.format( url.resolve(location, this.getAttribute('href')) );

    // Load new page
    piccolo.loadPage( page );
    event.preventDefault();
    return false;
  }
353505
private void accept(String action, String expected, String popup) {
        try {
            Alert alert = driver.switchTo().alert();
            alert.accept();
        } catch (Exception e) {
            reporter.fail(action, expected, "Unable to click 'OK' on the " + popup + ". " + e.getMessage());
            log.warn(e);
            return;
        }
        reporter.pass(action, expected, "Clicked 'OK' on the " + popup);
    }
815729
function popinOpen(name) {

            // bind overlay on click
            var $overlay = instance.target.childNodes[0];

            addListener(gina, $overlay, 'click', function(event) {

                // don't cancel here, it will corrupt child elements behaviors such as checkboxes and radio buttons

                if ( /gina-popin-is-active/.test(event.target.className) ) {


                    // remove listeners
                    removeListener(gina, event.target, 'click');

                    // binding popin close
                    var $close = [], $buttonsTMP = [];

                    $buttonsTMP = $el.getElementsByTagName('button');
                    if ( $buttonsTMP.length > 0 ) {
                        for(var b = 0, len = $buttonsTMP.length; b < len; ++b) {
                            if ( /gina-popin-close/.test($buttonsTMP[b].className) )
                                $close.push($buttonsTMP[b])
                        }
                    }

                    $buttonsTMP = $el.getElementsByTagName('div');
                    if ( $buttonsTMP.length > 0 ) {
                        for(var b = 0, len = $buttonsTMP.length; b < len; ++b) {
                            if ( /gina-popin-close/.test($buttonsTMP[b].className) )
                                $close.push($buttonsTMP[b])
                        }
                    }

                    $buttonsTMP = $el.getElementsByTagName('a');
                    if ( $buttonsTMP.length > 0 ) {
                        for(var b = 0, len = $buttonsTMP.length; b < len; ++b) {
                            if ( /gina-popin-close/.test($buttonsTMP[b].className) )
                                $close.push($buttonsTMP[b])
                        }
                    }

                    for (var b = 0, len = $close.length; b < len; ++b) {
                        removeListener(gina, $close[b], $close[b].getAttribute('id') )
                    }

                    popinClose(name);
                }
            });


            var id = null, $el = null;
            if ( typeof(name) == 'string' && name != '' ) {
                id = 'gina-popin-' + instance.id +'-'+ name;
                if (id !== $popin.id)
                    throw new Error('Popin `'+name+'` not found !')
            } else if ( typeof(name) == 'undefined' ) {
                id = $popin.id
            }

            $el = document.getElementById(id);

            if ( !/gina-popin-is-active/.test($el.className) )
                $el.className += ' gina-popin-is-active';

            if ( !/gina-popin-is-active/.test(instance.target.firstChild.className) )
                instance.target.firstChild.className += ' gina-popin-is-active';

            // binding popin close
            var $close = [], $buttonsTMP = [];

            $buttonsTMP = $el.getElementsByTagName('button');
            if ( $buttonsTMP.length > 0 ) {
                for(var b = 0, len = $buttonsTMP.length; b < len; ++b) {
                    if ( /gina-popin-close/.test($buttonsTMP[b].className) )
                        $close.push($buttonsTMP[b])
                }
            }

            $buttonsTMP = $el.getElementsByTagName('div');
            if ( $buttonsTMP.length > 0 ) {
                for(var b = 0, len = $buttonsTMP.length; b < len; ++b) {
                    if ( /gina-popin-close/.test($buttonsTMP[b].className) )
                        $close.push($buttonsTMP[b])
                }
            }

            $buttonsTMP = $el.getElementsByTagName('a');
            if ( $buttonsTMP.length > 0 ) {
                for(var b = 0, len = $buttonsTMP.length; b < len; ++b) {
                    if ( /gina-popin-close/.test($buttonsTMP[b].className) )
                        $close.push($buttonsTMP[b])
                }
            }
            var onclickAttribute = null, evt = null;
            for (var b = 0, len = $close.length; b < len; ++b) {
                if ($close[b].tagName == 'A') {
                    onclickAttribute = $close[b].getAttribute('onclick');
                }

                if ( !onclickAttribute ) {
                    $close[b].setAttribute('onclick', 'return false;')
                } else if ( !/return false/) {
                    if ( /\;$/.test(onclickAttribute) ) {
                        onclickAttribute += 'return false;'
                    } else {
                        onclickAttribute += '; return false;'
                    }
                }

                if (!$close[b]['id']) {

                    evt = 'popin.close.'+ uuid.v1();
                    $close[b]['id'] = evt;
                    $close[b].setAttribute( 'id', evt);

                } else {
                    evt = $close[b]['id'];
                }

                var register = function (evt, $close) {
                    // attach submit events
                    addListener(gina, $close, evt, function(event) {

                        cancelEvent(event);

                        popinClose(name);
                        removeListener(gina, event.target, event.type)
                    });
                }


                if ( typeof(gina.events[evt]) == 'undefined' || gina.events[evt] != $close[b].id ) {
                    register(evt, $close[b])
                }
            }


            if ( /gina-popin-is-active/.test(event.target.className) ) {
                removeListener(gina, event.target, event.target.getAttribute('id'))
            }

            $popin.isOpen = true;
            // so it can be forwarded to the handler who is listening
            $popin.target = $el;

            // update toolbar
            var XHRData = document.getElementById('gina-without-layout-xhr-data');
            if ( gina && typeof(window.ginaToolbar) == "object" && XHRData ) {
                try {

                    if ( typeof(XHRData.value) != 'undefined' && XHRData.value ) {
                        XHRData = JSON.parse( decodeURIComponent( XHRData.value ) );
                        // reset data-xhr
                        ginaToolbar.update("data-xhr", null);

                        ginaToolbar.update("data-xhr", XHRData);
                    }

                } catch (err) {
                    throw err
                }
            }

            triggerEvent(gina, instance.target, 'open.'+ $popin.id, $popin);
        }
263085
function() {
  /**
   * Current options values.
   * These are only ever modified by using the {@see #setOptions} call.
   * @type {!Options}
   * @private
   */
  this.options_ = new Options();

  /**
   * Page options JSON strings mapped by UUID.
   * These are used as a lookup for the HTTP header hack.
   * @type {!Object.<string>}
   * @private
   */
  this.pageOptionsBlobs_ = {};

  /**
   * Injected tabs, mapped by tab ID.
   * @type {!Object.<!InjectedTab>}
   * @private
   */
  this.injectedTabs_ = {};

  /**
   * Tracer.
   * @type {Tracer}
   * @private
   */
  this.tracer_ = null;

  /**
   * All popup window tab IDs mapped by opener tab ID.
   * @type {!Object.<number, number>}
   * @private
   */
  this.popupWindows_ = {};

  chrome.tabs.onActivated.addListener(
      this.tabActivated_.bind(this));
  chrome.tabs.onUpdated.addListener(
      this.tabUpdated_.bind(this));

  // Handle tab closes.
  chrome.tabs.onRemoved.addListener((function(tabId) {
    for (var key in this.popupWindows_) {
      if (this.popupWindows_[key] === tabId) {
        delete this.popupWindows_[key];
        break;
      }
    }
    if (tabId in this.injectedTabs_) {
      var injectedTab = this.injectedTabs_[tabId];
      this.injectedTabs_[tabId] = null;
      injectedTab.dispose();
    }
  }).bind(this));

  // Listen for commands from content scripts.
  chrome.extension.onConnect.addListener(function(port) {
    var options = this.getOptions();
    if (port.name == 'injector') {
      // Setup the extended info provider for the page.
      var tab = port.sender.tab;
      if (!tab) {
        // This sometimes happens on about:blank and the new tab page.
        return;
      }
      var pageUrl = URI.canonicalize(tab.url);
      var pageStatus = options.getPageStatus(pageUrl, tab.id);
      var pageOptions = options.getPageOptions(pageUrl);

      _gaq.push(['_trackEvent', 'extension', 'injected']);

      var injectedTab = new InjectedTab(
          this, tab, pageStatus, pageOptions, port);
      this.injectedTabs_[tab.id] = injectedTab;
    } else if (port.name == 'popup') {
      // Get info about the selected tab and send back.
      // Note: port.sender is the popup tab, not the current tab.
      chrome.tabs.getSelected(null, (function(tab) {
        var pageUrl = URI.canonicalize(tab.url);
        if (!pageUrl.length) {
          return;
        }
        this.sendPopupInfo_(pageUrl, tab.id, port);

        // Listen for messages from the popup.
        port.onMessage.addListener((function(data, port) {
          this.popupMessageReceived_(tab, data, port);
        }).bind(this));
      }).bind(this));
    }
  }.bind(this));

  // Detect the application.
  this.detectApplication_();
  var detectApplication = this.detectApplication_.bind(this);
  chrome.management.onInstalled.addListener(detectApplication);
  chrome.management.onUninstalled.addListener(detectApplication);
  chrome.management.onEnabled.addListener(detectApplication);
  chrome.management.onDisabled.addListener(detectApplication);

  // Rescan all open tabs to reload any that are whitelisted.
  this.options_.load(function() {
    var whitelist = this.options_.getWhitelistedPages();
    var whitelistMap = {};
    for (var n = 0; n < whitelist.length; n++) {
      whitelistMap[whitelist[n]] = true;
    }
    chrome.tabs.query({}, (function(tabs) {
      var tabsReloaded = 0;
      for (var n = 0; n < tabs.length; n++) {
        var pageUrl = URI.canonicalize(tabs[n].url);
        if (whitelistMap[pageUrl]) {
          tabsReloaded++;
          this.reloadTab(tabs[n].id, tabs[n].url);
        }
      }
      _gaq.push(['_trackEvent', 'extension', 'tabs_reloaded',
          null, tabsReloaded]);
    }).bind(this));
  }, this);

  // This hacky thing lets people open wtf from the omnibox.
  // HACK(benvanik): https://code.google.com/p/chromium/issues/detail?id=237817
  try {
    chrome.omnibox.setDefaultSuggestion({
      description: '<url><match>%s</match></url> Open trace file'
    });
  } catch (e) {
  }
  chrome.omnibox.onInputChanged.addListener((function(text, suggest) {
    suggest([
      {
        content: 'ui',
        description: 'Open the UI'
      }
    ]);
  }).bind(this));
  chrome.omnibox.onInputEntered.addListener((function(text) {
    chrome.tabs.getSelected(null, (function(tab) {
      text = text.trim();
      if (text == 'ui' || text.length == 0) {
        // Open the UI.
        _gaq.push(['_trackEvent', 'extension', 'omnibox_show_ui']);
        this.showUi_({
          targetTab: tab
        });
      } else {
        // A URL? File path? etc?
        if (text.indexOf('http') == 0) {
          _gaq.push(['_trackEvent', 'extension', 'omnibox_show_file']);
          this.showFileInUi_({
            targetTab: tab
          }, text);
        }
      }
    }).bind(this));
  }).bind(this));

  // FileBrowserHandler requests, on Chrome OS.
  if (chrome.fileBrowserHandler) {
    chrome.fileBrowserHandler.onExecute.addListener((function(id, details) {
      chrome.tabs.get(details.tab_id, (function(tab) {
        switch (id) {
          case 'open':
            this.showFileEntriesInUi_({
              targetTab: tab
            }, details.entries);
            break;
        }
      }).bind(this));
    }).bind(this));
  }

  // This is a workaround for a regression in Chrome that prevents blob URIs
  // from work in content scripts. Instead, we smuggle the options data
  // synchronously via HTTP headers. Yeah, I know. FML.
  // https://code.google.com/p/chromium/issues/detail?id=295829
  chrome.webRequest.onHeadersReceived.addListener((function(details) {
    var uuid = details.url.substr(details.url.lastIndexOf('/') + 1);
    var headerValue = this.pageOptionsBlobs_[uuid];
    return {
      responseHeaders: [
        {
          name: 'X-WTF-Options',
          value: headerValue
        }
      ]
    };
  }).bind(this), {
    urls: ['http://tracing-framework.appspot.com/tab-options/*'],
    types: ['xmlhttprequest']
  }, ['blocking']);
}
1029638
function PluginDocLink({ plugin, onClick }) {
	  if (!plugin) {
	    return null;
	  }

	  const href = `https://www.npmjs.com/package/${ plugin }`;
	  return React.createElement(
	    "a",
	    { className: "snapshot__helper", target: "_blank", href: href, onClick: onClick },
	    "?"
	  );
	}
369888
private function insert()
    {
        $Eresus = Eresus_CMS::getLegacyKernel();

        $item = array();
        $item['caption'] = arg('caption', 'dbsafe');
        $item['active'] = arg('active', 'int');
        if (arg('section'))
        {
            $item['section'] = '|' . implode('|', arg('section')) . '|';
        }
        $item['block'] = arg('block', 'dbsafe');
        $item['priority'] = arg('priority', 'int');
        $item['showFrom'] = arg('showFrom', 'dbsafe');
        if (arg('showTill'))
        {
            $item['showTill'] = arg('showTill', 'dbsafe');
        }
        $item['showCount'] = arg('showCount', 'int');
        $item['html'] = arg('html', 'dbsafe');
        $item['image'] = arg('image');
        $item['width'] = arg('width', 'int');
        $item['height'] = arg('height', 'int');
        $item['url'] = arg('url', 'dbsafe');
        $item['target'] = arg('target', 'dbsafe');

        $Eresus->db->insert($this->table['name'], $item);

        $item['id'] = $Eresus->db->getInsertedID();
        if (is_uploaded_file($_FILES['image']['tmp_name']))
        {
            $filename = 'banner' . $item['id'] . substr($_FILES['image']['name'],
                    strrpos($_FILES['image']['name'], '.'));
            upload('image', $Eresus->fdata . $this->name . '/' . $filename);
            $item['image'] = $filename;
            $Eresus->db->updateItem($this->table['name'], $item, "`id`='" . $item['id'] . "'");
        }
        HTTP::redirect(arg('submitURL'));
    }
577668
function injectScriptElement(targetWindow, doc) {
  var Node = targetWindow.Node;
  var HTMLDocument = targetWindow.HTMLDocument;
  var HTMLScriptElement = targetWindow.HTMLScriptElement;
  var proto = HTMLScriptElement.prototype;

  // Listen for sets on innerText.
  // Listen for sets on src.
  // Track when added to DOM via appendChild.

  // Replace appendChild/etc so that we can watch for script adds.
  var originalAppendChild = Node.prototype.appendChild;
  Node.prototype.appendChild = function appendChild(newChild) {
    if (newChild instanceof HTMLScriptElement && !newChild['__wtfi__']) {
      // appendChild(<script>)
      log('appendChild of script', newChild);
      var baseUrl = arguments.callee.caller ?
          arguments.callee.caller['__src'] : null;
      var processedChild = processScript(newChild, false, baseUrl);
      return originalAppendChild.call(this, processedChild);
    } else {
      return originalAppendChild.apply(this, arguments);
    }
  };
  var originalInsertBefore = Node.prototype.insertBefore;
  Node.prototype.insertBefore = function insertBefore(newChild, refChild) {
    if (newChild instanceof HTMLScriptElement && !newChild['__wtfi__']) {
      // insertBefore(<script>, ...)
      log('insertBefore of script', newChild);
      var baseUrl = arguments.callee.caller ?
          arguments.callee.caller['__src'] : null;
      var processedChild = processScript(newChild, false, baseUrl);
      return originalInsertBefore.call(this, processedChild, refChild);
    } else {
      return originalInsertBefore.apply(this, arguments);
    }
  };
  var originalReplaceChild = Node.prototype.replaceChild;
  Node.prototype.replaceChild = function replaceChild(
      newChild, oldChild) {
    if (newChild instanceof HTMLScriptElement && !newChild['__wtfi__']) {
      // replaceChild(<script>, ...)
      log('insertBefore of script', newChild);
      var baseUrl = arguments.callee.caller ?
          arguments.callee.caller['__src'] : null;
      var processedChild = processScript(newChild, false, baseUrl);
      return originalReplaceChild.call(this, processedChild, oldChild);
    } else {
      return originalReplaceChild.apply(this, arguments);
    }
  };

  // Replace document.createElement so we can hook new script elements.
  // var originalCreateElement = HTMLDocument.prototype.createElement;
  // HTMLDocument.prototype.createElement = function createElement(tagName) {
  //   if (tagName.toLowerCase() == 'script') {
  //     // <script>.
  //     var result = originalCreateElement.apply(this, arguments);
  //     log('could instrument <script>', result);
  //     return result;
  //   } else {
  //     return originalCreateElement.apply(this, arguments);
  //   }
  // };
}
834639
function drawLink(editor) {
	var cm = editor.codemirror;
	var stat = getState(cm);
	var options = editor.options;
	var url = "http://";
	if(options.promptURLs) {
		url = prompt(options.promptTexts.link);
		if(!url) {
			return false;
		}
	}
	_replaceSelection(cm, stat.link, options.insertTexts.link, url);
}
1156233
function( p, dir, desired, s, best ) {
        var result, r, diff, desiredForArrow = {}, tip = {};

        // If the arrow has no wiggle room along the edge of the popup, it cannot
        // be displayed along the requested edge without it sticking out.
        if ( s.arFull[ p.dimKey ] > s.guideDims[ p.dimKey ] ) {
            return best;
        }

        desiredForArrow[ p.fst ] = desired[ p.fst ] +
            ( s.arHalf[ p.oDimKey ] + s.menuHalf[ p.oDimKey ] ) * p.offsetFactor -
            s.contentBox[ p.fst ] + ( s.clampInfo.menuSize[ p.oDimKey ] - s.contentBox[ p.oDimKey ] ) * p.arrowOffsetFactor;
        desiredForArrow[ p.snd ] = desired[ p.snd ];

        result = s.result || this._calculateFinalLocation( desiredForArrow, s.clampInfo );
        r = { x: result.left, y: result.top };

        tip[ p.fst ] = r[ p.fst ] + s.contentBox[ p.fst ] + p.tipOffset;
        tip[ p.snd ] = Math.max( result[ p.prop ] + s.guideOffset[ p.prop ] + s.arHalf[ p.dimKey ],
            Math.min( result[ p.prop ] + s.guideOffset[ p.prop ] + s.guideDims[ p.dimKey ] - s.arHalf[ p.dimKey ],
                desired[ p.snd ] ) );

        diff = Math.abs( desired.x - tip.x ) + Math.abs( desired.y - tip.y );
        if ( !best || diff < best.diff ) {
            // Convert tip offset to coordinates inside the popup
            tip[ p.snd ] -= s.arHalf[ p.dimKey ] + result[ p.prop ] + s.contentBox[ p.snd ];
            best = { dir: dir, diff: diff, result: result, posProp: p.prop, posVal: tip[ p.snd ] };
        }

        return best;
    }
283919
def click_link_with_text(link_text, opts = {})
        if opts && opts[:index]
          elements = find_elements(:link_text, link_text)
          elements[opts[:index]-1].click
        else
          find_element(:link_text, link_text).click
        end
      end
432069
function insertAnchors(content) {
    var $ = cheerio.load(content);
    $(':header').each(function(i, elem) {
        var header = $(elem);
        var id = header.attr("id");
        if (!id) {
            id = slug(header.text());
            header.attr("id", id);
        }
        header.prepend('<a name="' + id + '" class="plugin-anchor" '
                   + 'href="#' + id + '">'
                   + '<i class="fa fa-link" aria-hidden="true"></i>'
                   + '</a>');
    });
    return $.html();
}
693632
def click(self, name):
    """"""
    try:
        elem = world.browser.find_element_by_link_text(name)
    except NoSuchElementException:
        raise AssertionError(
            "Cannot find the link with text '{}'.".format(name))
    elem.click()
699343
function() {

      var id, cssClass, src, target, link, alt, title;

      // populate link values
      if (hashedit.current.node !== null) {

        // get  attributes
        id = hashedit.current.node.getAttribute('id') || '';
        cssClass = hashedit.current.node.getAttribute('class') || '';
        src = hashedit.current.node.getAttribute('src') || '';
        alt = hashedit.current.node.getAttribute('alt') || '';
        title = hashedit.current.node.getAttribute('title') || '';


        // show the link dialog
        link = document.querySelector('#hashedit-image-settings-modal');
        link.setAttribute('visible', '');

        // sets start values
        document.getElementById('hashedit-image-id').value = id;
        document.getElementById('hashedit-image-cssclass').value = cssClass;
        document.getElementById('hashedit-image-src').value = src;
        document.getElementById('hashedit-image-alt').value = alt;
        document.getElementById('hashedit-image-title').value = title;

      }

    }