Translate the given work to the current locale of to a one specified in the arguments.
@param {object} ctx The current context in wich the helper is executing.
@param {String} url The url to genereate the link.
@return {String} The helper content.
160633
function makeLink (ctx, url, render) {
	let route = KoatonRouter.AllRoutes(ctx.subdomain).map(exp => {
		let variables = (exp[1].match(/\$/g) || []).length;
		let matches = (url.match(exp[0]) || []).length - 1;
		if (matches === variables && url.replace(...exp).indexOf('.') === -1) {
			return url.replace(...exp);
		}
	}).filter(r => !!r);
	route = url === 'home' ? '/' : route[0];
	let content;
	let active = ctx.route === url || ctx.path === route;
	if (ctx.path === route) {
		content = `<a class="active">${render(this)}</a>`;
	} else {
		content = `<a href="${route}" class="${active ? 'active' : ''}">${render()}</a>`;
	}
	return content;
}
1345545
function getTranslation(keyPath, locale) {
    var translation = eval('_locales.' + locale + '.' + keyPath);
    if(!translation || (translation === undefined)) {
      return null;
    }
    return translation;
  }
1106949
function LocationUrl(url, pathPrefix, appBaseUrl) {
  pathPrefix = pathPrefix || '';

  /**
   * Parse given html5 (regular) url string into properties
   * @param {string} newAbsoluteUrl HTML5 url
   * @private
   */
  this.$$parse = function(newAbsoluteUrl) {
    var match = matchUrl(newAbsoluteUrl, this);

    if (match.path.indexOf(pathPrefix) !== 0) {
      throw Error('Invalid url "' + newAbsoluteUrl + '", missing path prefix "' + pathPrefix + '" !');
    }

    this.$$path = decodeURIComponent(match.path.substr(pathPrefix.length));
    this.$$search = parseKeyValue(match.search);
    this.$$hash = match.hash && decodeURIComponent(match.hash) || '';

    this.$$compose();
  };

  /**
   * Compose url and update `absUrl` property
   * @private
   */
  this.$$compose = function() {
    var search = toKeyValue(this.$$search),
        hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';

    this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
    this.$$absUrl = composeProtocolHostPort(this.$$protocol, this.$$host, this.$$port) +
                    pathPrefix + this.$$url;
  };


  this.$$rewriteAppUrl = function(absoluteLinkUrl) {
    if(absoluteLinkUrl.indexOf(appBaseUrl) == 0) {
      return absoluteLinkUrl;
    }
  }


  this.$$parse(url);
}
566821
static function getLangByUrl($url = null)
    {
        if ($url === null) {
            return null;
        } else {
            $language = Lang::find()->where('url = :url', [':url' => $url])->one();
            if ( $language === null ) {
                return null;
            }else{
                return $language;
            }
        }
    }
64738
function() {

      // create a canvas element
      var canvas = document.createElement('canvas');

      // define a context var that will be used for browsers with canvas support
      var ctx;

      // try/catch for older browsers that don't support the canvas element
      try {

        // attempt to give ctx a 2d canvas context value
        ctx = canvas.getContext('2d');

      } catch (e) {

        // return empty string if canvas element not supported
        return "";
      }

      // https://www.browserleaks.com/canvas#how-does-it-work
      // Text with lowercase/uppercase/punctuation symbols
      var txt = 'ClientJS,org <canvas> 1.0';
      ctx.textBaseline = "top";
      // The most common type
      ctx.font = "14px 'Arial'";
      ctx.textBaseline = "alphabetic";
      ctx.fillStyle = "#f60";
      ctx.fillRect(125, 1, 62, 20);
      // Some tricks for color mixing to increase the difference in rendering
      ctx.fillStyle = "#069";
      ctx.fillText(txt, 2, 15);
      ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
      ctx.fillText(txt, 4, 17);
      return canvas.toDataURL();
    }
792676
function toUrl(mId) {
  const parsed = parse(mId);
  let url = parsed.bareId;
  if (url[0] !== '/' && !url.match(/^https?:\/\//)) url = _baseUrl + url;
  if (!parsed.ext) {
    // no known ext, add .js
    url += '.js';
  }
  return url;
}
1183539
function () {

      // helper method to assert if a given url is local
      function isLocal(url) {
        var loc = document.location,
            reg = new RegExp("^\\.|^\/(?!\/)|^[\\w]((?!://).)*$|" + loc.protocol + "//" + loc.host);
        return url.match(reg);
      }

      // gather all resources
      var scripts = document.getElementsByTagName("script"),
          links = document.getElementsByTagName("link"),
          uris = [];

      // track local js urls
      for (var i = 0; i < scripts.length; i++) {
        var script = scripts[i], src = script.getAttribute("src");
        if (src && isLocal(src))
          uris.push(src);
        if (src && src.match(/\blive.js#/)) {
          for (var type in active)
            active[type] = src.match("[#,|]" + type) != null
          if (src.match("notify")) 
            alert("Live.js is loaded.");
        }
      }
      if (!active.js) uris = [];
      if (active.html) uris.push(document.location.href);

      // track local css urls
      for (var i = 0; i < links.length && active.css; i++) {
        var link = links[i], rel = link.getAttribute("rel"), href = link.getAttribute("href", 2);
        if (href && rel && rel.match(new RegExp("stylesheet", "i")) && isLocal(href)) {
          uris.push(href);
          currentLinkElements[href] = link;
        }
      }

      // initialize the resources info
      for (var i = 0; i < uris.length; i++) {
        var url = uris[i];
        Live.getHead(url, function (url, info) {
          resources[url] = info;
        });
      }

      // add rule for morphing between old and new css files
      var head = document.getElementsByTagName("head")[0],
          style = document.createElement("style"),
          rule = "transition: all .3s ease-out;"
      css = [".livejs-loading * { ", rule, " -webkit-", rule, "-moz-", rule, "-o-", rule, "}"].join('');
      style.setAttribute("type", "text/css");
      head.appendChild(style);
      style.styleSheet ? style.styleSheet.cssText = css : style.appendChild(document.createTextNode(css));

      // yep
      loaded = true;
    }
228053
function (url) {
            var parsed = document.createElement('a'),
                pathname;

            parsed.href = url;

            // @NOTE: IE does not automatically parse relative urls,
            // but requesting href back from the <a> element will return
            // an absolute URL, which can then be fed back in to get the
            // expected result. WTF? Yep!
            if (browser.ie && url !== parsed.href) {
                url = parsed.href;
                parsed.href = url;
            }

            // @NOTE: IE does not include the preceding '/' in pathname
            pathname = parsed.pathname;
            if (!/^\//.test(pathname)) {
                pathname = '/' + pathname;
            }

            return {
                href: parsed.href,
                protocol: parsed.protocol, // includes :
                host: parsed.host, // includes port
                hostname: parsed.hostname, // does not include port
                port: parsed.port,
                pathname: pathname,
                hash: parsed.hash,  // inclues #
                search: parsed.search // incudes ?
            };
        }
1219956
public static URL getDocumentation(Class<?> comp, Locale loc) {
        Documentation doc = (Documentation) comp.getAnnotation(Documentation.class);
        if (doc != null) {
            String v = doc.value();
            try {
                // try full URL first (external reference)
                URL url = new URL(v);
                return url;
            } catch (MalformedURLException E) {
                // local resource bundled with the class
                String name = v.substring(0, v.lastIndexOf('.'));
                String ext = v.substring(v.lastIndexOf('.'));
                String lang = loc.getLanguage();

                URL f = comp.getResource(name + "_" + lang + ext);
                if (f != null) {
                    return f;
                }

                f = comp.getResource(v);
                if (f != null) {
                    return f;
                }
            }
        }
        return null;
    }
1171160
function (url) {
    var req = new XMLHttpRequest();

    // Response handler. Check the console for errors.
    var respond = function () {
        if (req.status !== 200) {
          console.warn(req.responseText);
          return;
        }
        // Show the raw response text on page
        xmlOutput.textContent = req.responseText;
        // convert XML to javascript objects
        var json = sdmxmllib.mapSDMXMLResponse(req.responseText);
        // Convert to json and show on page
        jsonOutput.textContent = JSON.stringify(json, null, 2);
    };

    req.open('GET', url);
    // This will return latest version (SDMX-ML 2.1)
    req.setRequestHeader('Accept', 'application/xml');

    req.onreadystatechange = function () {
      if (req.readyState > 3) respond();
    };

    req.onerror = function (err) {
      console.warn(err);
    };

    req.send(null);
  }
274117
def get_help(self, ctx):
        
        formatter = ctx.make_formatter()
        self.format_help(ctx, formatter)
        return formatter.getvalue().rstrip('\n')
1073632
function(url, callback, errorcallback){
		if (!this.initialized) {
			this.initialize();
		}
		var xmlloader = JSDAS.XMLLoader; //get a reference to myself
  
  
		var usingCORS = true;
		var xhr = this.xhrCORS('GET', url);
		if(!xhr) { //if the browser is not CORS capable, fallback to proxy if available
			if(this.proxyURL) {
			    var xhr = this.xhr();
			    xhr.open('GET', this.proxyURL+'?url='+url, true);
			    usingCORS = false;
			} else {
			    errorcallback && errorcallback({id: 'no_proxy', msg: "Cross-Origin requests are not supported but no proxy has been defined"});
			}
		}

		//At this point, we've got a valid XHR
		//xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
		//xhr.setRequestHeader("Accept", "application/xml, text/xml");


		var xmlloader = this; //necessary so the closures get the variable
		var change = function(xhr){
			if (xhr && (xhr.readyState == 4)) {
				if (xmlloader.httpSuccess(xhr)) {
					processResponse(xhr);
				}
				else { //if it failed, it mighht be that the source has no CORS enabled. In such case, fallback to proxy before erroring
					if(usingCORS && xmlloader.proxyURL) { //if it failed when using CORS and we've got a proxy, try to get the data via the proxy
					  xhr=undefined;
					  usingCORS = false;
					  var new_xhr = xmlloader.xhr();
					  new_xhr.open('GET', xmlloader.proxyURL+'?url='+url, true);
					  new_xhr.onreadystatechange = function() {change(new_xhr);}
					  new_xhr.send(null);
					} else {
					  errorcallback && errorcallback({id: "xmlhttprequest_error", msg: xhr.status});
					}
				}
				//to prevent IE memory leaks
				xhr = undefined;
			} 
		};
		var processResponse = function(xhr) {
			//WARNING: Since Uniprot (and maybe others) do not respond with a correct content-type, we cannot check it here. Should be reactivated as soon as the servers are updated.
			//var ct = xhr.getResponseHeader("content-type");
			//var xml = ct && ct.indexOf("xml") >= 0;
			//if (xml) {
				var data = xhr.responseXML;
				if(!data) { //This block is here since we cannot rely on content type headers
				     errorcallback && errorcallback({id: 'not_xml', msg: "The response was not XML"});
				}
				if(data.documentElement.nodeName != 'parsererror') {
					callback(data);
					return;
				} 
			//} //if anything went wrong, the document was not XML
			//errorcallback && errorcallback({id: 'not_xml', msg: "The response was not XML"});
		};
	
		xhr.onreadystatechange = function() {change(xhr);};

		// Send the data
		try {
			xhr.send(null);

		} catch(e) {
			//This code will rarely be called. Only when there's a problem on sernding the request.
			if(usingCORS && this.proxyURL) { //if it failed when using CORS and we've got a proxy, try to get the data via the proxy
			      var xhr = this.xhr();
			      xhr.open('GET', this.proxyURL+'?url='+url, true);
			      xhr.onreadystatechange = function() {change(xhr);}
			      try {
				  xhr.send(null);
			      } catch(e) {
				  errorcallback && errorcallback({id: 'sending_error', msg: "There was an error when sending the request"});
			      }
			} else {
			      errorcallback && errorcallback({id: 'sending_error', msg: "There was an error when sending the request"});
			}
		}	
	}
1248267
function(url){
			var rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
				urlLower = url.toLowerCase(),
				parts = rurl.exec( urlLower ),
				ajaxLocation,
				ajaxLocParts;

			try {
				ajaxLocation = location.href;
			} catch( e ) {
				// Use the href attribute of an A element
				// since IE will modify it given document.location
				ajaxLocation = document.createElement('a');
				ajaxLocation.href = '';
				ajaxLocation = ajaxLocation.href;
			}

			ajaxLocation = ajaxLocation.toLowerCase();

			// uh oh, the url must be relative
			// make it fully qualified and re-regex url
			if (!parts){
				urlLower = _absolutizeURI(ajaxLocation,urlLower).toLowerCase();
				parts = rurl.exec( urlLower );
			}

			// Segment location into parts
			ajaxLocParts = rurl.exec( ajaxLocation ) || [];

			// do hostname and protocol and port of manifest URL match location.href? (a "local" request on the same domain)
			var matched = !(parts &&
					(parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
						(parts[ 3 ] || (parts[ 1 ] === 'http:' ? '80' : '443')) !==
							(ajaxLocParts[ 3 ] || (ajaxLocParts[ 1 ] === 'http:' ? '80' : '443'))));
		
			return matched;
		}
933904
function _resolveUrl(base, url) {
    var /** @type {?} */ parts = _split(encodeURI(url));
    var /** @type {?} */ baseParts = _split(base);
    if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(parts[_ComponentIndex.Scheme])) {
        return _joinAndCanonicalizePath(parts);
    }
    else {
        parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
    }
    for (var /** @type {?} */ i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
        if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["d" /* isBlank */])(parts[i])) {
            parts[i] = baseParts[i];
        }
    }
    if (parts[_ComponentIndex.Path][0] == '/') {
        return _joinAndCanonicalizePath(parts);
    }
    var /** @type {?} */ path = baseParts[_ComponentIndex.Path];
    if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["d" /* isBlank */])(path))
        path = '/';
    var /** @type {?} */ index = path.lastIndexOf('/');
    path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
    parts[_ComponentIndex.Path] = path;
    return _joinAndCanonicalizePath(parts);
}
615990
public function url($url = null, $full = false) {
		if (CakePlugin::loaded('I18n')) {
			$url = Common::url($url);
			if (is_array($url) && !array_key_exists('lang', $url)) {
				$url['lang'] = Configure::read('Config.language');
			}
		}

		return parent::url($url, $full);
	}
361343
function init(ctx) {
        var server = ctx.server;
        server.ext('onRequest', checkIfSSL);
        return new Q(ctx);
    }
1042481
function (content) {

            content = helpers.replaceCustom(content, /<script.+src=['"](.+)["'][\/>]?><[\\]?\/script>/gm);

            content = helpers.replaceCustom(content, /<link[^\>]+href=['"]([^"']+)["']/gm);

            return content;
        }