/*
从本地个性化存储中取出数据列顺序
975226
function getGridCompColumnArrFromLocal() {
    if (!this.options.needLocalStorage) return null;
    var defData = this.getLocalData();
    if (defData == null) return null;
    if (defData["gridCompColumnArr"] == null) return null;
    return defData["gridCompColumnArr"];
}
251272
function execute(&$content, $from_url, $min_file_size = 0)
    {
        preg_match_all('~<img[^>]*(?<!_mce_)\s+src\s?=\s?([\'"])((?:(?!\1).)*?)\1[^>]*>~i', $content, $match);
        if (empty($match[2]))
        {
            return 0;
        }

        $image_n = 0;
        $replaced = array();
        $this->referrer_url = $from_url;

        foreach ($match[2] as $uri)
        {
            //已经替换过的
            if (isset($replaced[$uri]))
            {
                continue;
            }
            if(!(strpos($uri,"data:image") === false))
            {
                return false;
            }
            if ($this->beforeUrlGet)
            {
                $replaced_uri = call_user_func($this->beforeUrlGet, $this, $uri);
            }
            else
            {
                $replaced_uri = $uri;
            }
            $_abs_uri = str_replace("%","",HTML::parseRelativePath($from_url, $replaced_uri));
            $info = parse_url($_abs_uri);
            $path = $info['host'].'/'.ltrim($info['path'], '/');
            $file =  $this->base_dir.'/'.$path;

            $update = true;
            if (!is_file($file))
            {
                $dir = dirname($file);
                if (!is_dir($dir))
                {
                    mkdir($dir, 0777, true);
                }
                $update = $this->downloadFile($_abs_uri, $file, $min_file_size);
                if ($this->afterUrlGet)
                {
                    call_user_func($this->afterUrlGet, $this, $_abs_uri);
                }
            }
            if ($update)
            {
                $new_uri = $this->base_url .'/'. ltrim($path, '/');
                $content = str_replace($uri, $new_uri, $content);
                $replaced[$uri] = true;
                $image_n ++;
            }
            else
            {
                return false;
            }
        }
        return $image_n;
    }
897726
private static void fillReqAndRes(ServletRequest req, ServletResponse res){
		//-- 填充请求和响应对象到ActionContext本地线程
		Request.init((HttpServletRequest)req);
		Response.init((HttpServletResponse)res);
	}
174023
function (uri, fromUri, source) {
        if (!/^\./.test(uri) || EXTNAME_RE.test(uri)) {

            var line;

            // 如果只出现一次这个字符串，很容易确认模板错误行
            if (source.split(uri).length === 2) {
                source.split(/\n/).forEach(function (code, index) {
                    if (code.indexOf(uri) !== -1) {
                        line = index + 1;
                        source = code.trim();
                    }
                });
            }

            var error = {
                name: 'Syntax Error',
                line: line,
                source: source,
                message: 'Template must be a relative path, and can not have a suffix.'
            };

            if (fromUri) {
                error.filename = fromUri;
            }

            throw error;
        }
    }
1095786
function getHome(): \Closure {
    return function($value, \Mustache_LambdaHelper $helper) {
      return UrlHelper::home($helper->render($value) ?: false);
    };
  }
827265
@Override
    public String fetch(String url) {
        try{
            LOGGER.debug("url:"+url);
            HtmlPage htmlPage = WEB_CLIENT.getPage(url);
            String html = htmlPage.getBody().asXml();
            LOGGER.debug("html:"+html);
            return html;
        }catch (Exception e) {
            LOGGER.error("获取URL："+url+"页面出错", e);
        }
        return "";
    }
109693
function _doMain(jsonObj,isDir2TreeStr){
    if(false!==jsonObj){
        isDir2TreeStr = !!isDir2TreeStr;
        let treeStr;
        try{
            // console.time(colorful.green("\nConvert takes"));
            treeStr = jsonToy.treeString(jsonObj,{
                rootName: jsonName,
                space: s,
                vSpace: v,
                needValueOut: outputVal,
                msReturnChar: needMsEol
            });
            // console.timeEnd(colorful.green("\nConvert takes"));
        }catch(e2){
            errorOut(e2.toString());
        }
        if(!!treeStr){
            if(!isDir2TreeStr){
                console.log(treeStr);
            }else{
                // 当显示的是文件目录，将"文件夹"字段变成蓝色显示，这里仅仅是对显示进行转换，而不对源内容转换，因为远内容还要用做复制到剪切板
                let newTreeStr = "" + treeStr;
                let resArr = [];
                let filterOutStr = " (ignored) /";
                newTreeStr.split("\n").forEach(k=>{
                    k = k.replace(/\r/g,"");
                    let mt = k.match(/[└├─]\s([\S]+[\s\S]*\s\/$)/);
                    if(mt && mt[1]){
                        let ov = mt[1],nv;
                        if(ov.substr(-filterOutStr.length) === filterOutStr){
                          let foArr = ov.split(filterOutStr);
                          nv = colorful.cyan(foArr[0]) + colorful.gray(filterOutStr);
                        }else{
                            nv = colorful.cyan(ov);
                        }
                        k = k.replace(ov,nv);
                    }
                    resArr.push(k);
                });
                console.log(resArr.join("\n"));
            }
            if(!Type.isObject.isEmptyOwn(jsonObj) && needCopy){
                clipboardy.write(treeStr)
                    .then(()=>console.log(colorful.success("Copy tree-string success!")));
            }
        }
    }
}
935840
public function getScriptUrl()
    {
        if (!$this->scriptUrl) {
            $scriptName = 'index.php';
            if(false != $scriptUrl = $this->getServer('PHP_SELF')) {
                $scriptName = $this->getServer('SCRIPT_FILENAME');
                // 去掉 index.php之后的字符
                if (false !== ($pos = stripos($scriptUrl, basename($scriptName)))) {
                    $scriptUrl = substr($scriptUrl, 0, $pos + strlen(basename($scriptName)));
                }
                
                if($scriptName && $scriptName == $scriptUrl) {
                    $docRoot = $this->getServer('DOCUMENT_ROOT');
                    if($docRoot && strpos($scriptName, $docRoot) === 0) {
                        $scriptUrl = str_replace('\\','/', str_replace($docRoot, '', $scriptName));
                    } else {
                        $scriptUrl = '/'.basename($scriptName);
                    }
                } elseif ($scriptName && strlen($scriptName) < strlen($scriptUrl)) {
                    $scriptUrl = '/'.basename($scriptName);
                } else {
                    //$scriptUrl = $scriptUrl;
                }
            } else {
                $scriptUrl = '/'.basename($scriptName);
            }
            
            $this->scriptUrl = htmlentities($scriptUrl);
        }
        
        return $this->scriptUrl;
    }
1298506
function getAddDirectionsJS(){
		$_output = ""; 
		 
		foreach($this->_directions as $directions){
			$dom_id = $directions["dom_id"];			
			$travelModeParams = array();
			$directionsParams = "";         
			if($this->walking_directions==TRUE)
				$directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.WALKING";
			else if($this->biking_directions==TRUE)
				$directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.BICYCLING";
			else
				$directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.DRIVING";
		   
			if($this->avoid_highways==TRUE)
			   $directionsParams .= ", \n avoidHighways: true";
			if($this->avoid_tollways==TRUE)
			   $directionsParams .= ", \n avoidTolls: true";

			if($this->directions_unit_system!=''){
			    if($this->directions_unit_system == 'METRIC'){
			        $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.METRIC";
			    }else{
			        $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL";
			    }
			}
			
			$_output .= "
			    directions".$this->map_id."['$dom_id'] = {
					displayRenderer:new google.maps.DirectionsRenderer(),
					directionService:new google.maps.DirectionsService(),
					request:{
            					waypoints: [{$this->_waypoints_string}],
						origin: '".$directions["start"]."',
						destination: '".$directions["dest"]."'
						$directionsParams
					}
					".(($this->elevation_directions)?",		
					   selector: '".$directions["elevation_dom_id"]."',
					   chart: new google.visualization.ColumnChart(document.getElementById('".$directions["elevation_dom_id"]."')),
					   service: new google.maps.ElevationService(),
					   width:".$directions["width"].",
					   height:".$directions["height"].",
					   focusColor:'#00FF00',
					   marker:null
				   ":"")."
				};
				directions".$this->map_id."['$dom_id'].displayRenderer.setMap(map".$this->map_id.");
				directions".$this->map_id."['$dom_id'].displayRenderer.setPanel(document.getElementById('$dom_id'));
				directions".$this->map_id."['$dom_id'].directionService.route(directions".$this->map_id."['$dom_id'].request, function(response, status) {
					if (status == google.maps.DirectionsStatus.OK) {
					   directions".$this->map_id."['$dom_id'].displayRenderer.setDirections(response);
					   ".(($this->elevation_directions)?"
						   directions".$this->map_id."['$dom_id'].service.getElevationAlongPath({
							   path: response.routes[0].overview_path,
							   samples: ".$directions["elevation_samples"]."
						   }, function(results,status){plotElevation(results,status, directions".$this->map_id."['$dom_id'], map".$this->map_id.", elevationCharts".$this->map_id.");});
					   ":"")."
					}
				});
			 ";
		 }
		 
		 return $_output;
	 }
1215576
function LinkCapturePromise() {
  const self = this;
  return new Promise((resolve) => {
    console.time("捕获a标签用时:");
    /***
     * 初始化 link-capture events
     */
    window.document.addEventListener("click", function (e) {
      e.preventDefault();
      let target = e.target;
      if (!target) return;
      // 不是a元素
      if (
        target.tagName.toLocaleLowerCase() !== "a" &&
        !(target = CtMobileFactory.getParentElementByTag(target, "a"))
      ) {
        return;
      }

      const ctDataAjax = target.getAttribute("ct-data-ajax");
      // 如果用户不想让框架控制a元素
      if (
        ctDataAjax &&
        ctDataAjax === "false"
      ) return;

      const ctPageId = target.getAttribute("ct-pageId");
      const ctParameter = target.getAttribute("ct-parameter") || "";
      if (!ctPageId) {
        return;
      }

      const pageRouterConfig = self.config.router[ctPageId];
      const href = `${(pageRouterConfig && pageRouterConfig.url) ? pageRouterConfig.url : "#" + ctPageId}?pageId=${ctPageId}${ctParameter}`;
      self.startPage(href, {
        reload: target.getAttribute("ct-reload") === "true" ? true : self.config.linkCaptureReload
      });

      return false;
    });
    console.timeEnd("捕获a标签用时:");
    resolve();
  });
}
806725
@RequestMapping(value = "/site/**")
	public Object site(HttpServletRequest req, HttpServletResponse resp, AuthorizationEngine ap,
			PsnRuleEngine psnEngine, @RequestHeader(value = "X-Url-Prefix", required = false) String urlPrefix) {
		String path = req.getServletPath().substring(5);

		try {
			Branch branch = getBranch(ap, getContextRoot(req));
			if (branch == null) {
				return pageNotFound;
			}

			if (branch.isStatic()) { // 静态分支，直接返回要访问的资源
				if (path.equals("/cfg.cfg")) // 不允许访问cfg.cfg
					path = "";

				return returnFile(branch, path);
			} else {
				Page page = branch.findPage(path, ap);
				if (page == null)
					return pageNotFound;

				if (page.getLink() != null)
					return "redirect:" + page.getLink();

				if (page.isStatic()) {
					if (path.equals(page.getFullPath() + "cfg.cfg")) // 不允许访问cfg.cfg
						return pageNotFound;

					return returnFile(branch, path.replace(page.getFullPath(), page.getFullDir()));
				} else {
					SiteContext sc = new SiteContext(req, page, urlPrefix);
					req.setAttribute(SiteContext.SITE_CONTEXT_KEY, sc);
					req.setAttribute(PAGE_PATH, sc.getPageUrl(page.getFullPath()));
					req.setAttribute(PAGE_DATA, page.getDataMap());
					if (page.isExpand() && !page.getFullPath().equals(path) && path.startsWith(page.getFullPath()))
						req.setAttribute(PATH_EXPAND, path.substring(page.getFullPath().length()));

					return isSpringBoot ? "/WEB-INF/templates/" + page.getPsnTemplate(psnEngine) + ".jsp"
							: "/WEB-INF/site/template/" + page.getPsnTemplate(psnEngine) + ".jsp";
				}
			}
		} catch (Exception e) {
			return pageNotFound;
		}
	}
181844
function pGetUrl(url, headers){
    //console.log(`\r\n发起远程请求(${Date()})：${url}\r\n`);
    if(!headers){
        headers = {};
    }
    headers['User-Agent'] = 'Request-Promise';
    return rp({
        uri: url,
        headers: headers,
        json: true // Automatically parses the JSON string in the response
    });
}
796820
static function position($name, $value=null, $settings=[])
    {
        if (!isset($settings['description'])) {
            $settings['description'] = '位置可设为：1到9的数字表示九宫格的位置, 或100|30, 或 center|center, 或100|left';
        }
        
        return static::input('text', $name, $value, $settings);
    }
1133829
function(url, filepath, fn){
        // 提交请求
        try{
            fs.createReadStream(filepath).pipe(request.post(url, fn))
        }
        catch(e){ fn(e) }
    }
1070994
function ensureImageLoaded(url) {
            var img = new Image();
            var destroy = function () {
                if (img) {
                    img.src = ""; // 読み込み停止
                    img = null;
                }
            };
            return new Promise(function (resolve, reject) {
                img.onload = function (event) {
                    destroy();
                    resolve(url);
                };
                img.onerror = function (event) {
                    destroy();
                    reject(CDP.makeErrorInfo(CDP.RESULT_CODE.ERROR_CDP_TOOLS_IMAGE_LOAD_FAILED, TAG, "image load failed. [url: " + url + "]"));
                };
                img.src = url;
            }, destroy);
        }
1055446
function(domain, ip, groupName, target_groupName) {
		this._batchHost(function(hostsobject) {
			var group = hostsobject[groupName];
			var t_group = hostsobject[target_groupName] = hostsobject[target_groupName] || [];
			if (group) {
				var host, move, i;
				//目标分组里是否存在该条host，若存在则不作处理。
				for (i = 0; i < t_group.length; i++) {
					host = t_group[i];
					if (host.domain === domain && host.ip === ip) {
						return false;
					}
				}
				for (i = 0; i < group.length; i++) {
					host = group[i];
					if (host.domain === domain && host.ip === ip) {
						t_group.push(host);
						group.splice(i, 1);
						break;
					}
				}
				return hostsobject;
			}
		});
	}
393475
function(){
		// this.bodyが空の場合はEncode.jsの仕様により対象外
		// カンペンには以下のパズルは存在しないのでURL_KANPENPも対象外
		if(!this.body || (this.type!==URL_PZPRV3 && this.type!==URL_PZPRAPP)){ return;}
		
		switch(this.pid){
		case 'ichimaga':
			if     (this.pflag.indexOf('m')>=0){ this.pid = 'ichimagam';}
			else if(this.pflag.indexOf('x')>=0){ this.pid = 'ichimagax';}
			else                               { this.pid = 'ichimaga'; }
			break;
		case 'icelom':
			if(this.pflag.indexOf('a')<0){ this.pid = 'icelom2';}
			break;
		case 'pipelink':
			if(this.body.match(/[0-9]/)){ this.pid = 'pipelinkr';}
			break;
		case 'bonsan':
			if(this.pflag.indexOf('c')<0){
				var col = this.cols, row = this.rows;
				if(this.body.substr(0,((((col-1)*row+4)/5)|0)+(((col*(row-1)+4)/5)|0)||0).match(/[^0]/)){
					this.pid = 'heyabon';
				}
			}
			break;
		case 'kramma':
			if(this.pflag.indexOf('c')<0){
				var len=(this.cols-1)*(this.rows-1), cc=0;
				for(var i=0;i<this.body.length;i++){
					var ca = this.body.charAt(i);
					if(ca.match(/\w/)){
						cc += parseInt(ca,36);
						if(cc<len){ this.pid = 'kramman'; break;}
					}
					else if(ca === '.'){ cc+=36;}
					if(cc>=len){ break;}
				}
			}
			break;
		}
	}