1function preg_print_pre(obj,reg) 2{if(!reg)reg=/.*/;var p='' 3for(var prop in obj){if(prop.match(reg)){p+=prop+': '+obj[prop]+'\n'}} 4alert(p)} 5function Request(){} 6Request.timeout=60000;Request.method='GET';Request.headers={};Request.params=null;Request.progressText='Loading ...';Request.makeRequest=function(p_url,p_busyReq,p_progId,p_successCallBack,p_errorCallBack,p_pass,p_object){if(p_busyReq)return;var req=Request.getRequest();if(req!=null){p_busyReq=true;Request.showProgress(p_progId);req.onreadystatechange=function(){if(req.readyState==4){p_busyReq=false;window.clearTimeout(toId);try{if(req.status==200){p_successCallBack(req,p_pass,p_object);}else{p_errorCallBack(req,p_pass,p_object);} 7Request.hideProgress(p_progId);} 8catch(e){}}} 9var $ajax_mark=(p_url.indexOf('?')?'&':'?')+'ajax=yes';req.open(Request.method,p_url+$ajax_mark,true);if(Request.method=='POST'){Request.headers['Content-type']='application/x-www-form-urlencoded';Request.headers['referer']=p_url;} 10else{Request.headers['If-Modified-Since']='Sat, 1 Jan 2000 00:00:00 GMT';} 11Request.sendHeaders(req);if(Request.method=='POST'){req.send(Request.params);Request.method='GET';} 12else{req.send(null);} 13var toId=window.setTimeout(function(){if(p_busyReq)req.abort();},Request.timeout);}} 14Request.processRedirect=function($request){var $match_redirect=new RegExp('^#redirect#(.*?)($|\\s.*)').exec($request.responseText);if($match_redirect!=null){window.location.href=$match_redirect[1];return true;} 15return false;} 16Request.sendHeaders=function($request){for(var $header_name in Request.headers){if(typeof Request.headers[$header_name]=='function'){continue;} 17$request.setRequestHeader($header_name,Request.headers[$header_name]);} 18Request.headers={};} 19Request.getRequest=function(){var xmlHttp;try{xmlHttp=new ActiveXObject('MSXML2.XMLHTTP');return xmlHttp;}catch(e){} 20try{xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');return xmlHttp;}catch(e){} 21try{xmlHttp=new XMLHttpRequest();return xmlHttp;}catch(e){} 22return null;} 23Request.showProgress=function(p_id){if(p_id!=''){var $content_div=$(jq('#'+p_id));var $content_offset=$content_div.offset();var $content_width=$content_div.width();var $content_height=$content_div.height();var $parent_div=$content_div.parents(':first');$content_width=Math.min($content_width,$parent_div.width());$content_height=Math.min($content_height,$parent_div.height());var $progress_overlay=$(jq('#'+p_id+'_progress'));if($progress_overlay.length==0){$progress_overlay=$('<div id="'+p_id+'_progress"></div>');var $maximal_height=$(window).height()-$content_offset.top;$progress_overlay.css({width:$content_div.width(),height:$content_height>0?$content_height:$maximal_height,left:$content_offset.left,top:$content_offset.top+$parent_div.scrollTop(),position:'absolute',zIndex:30,opacity:0.8,backgroundColor:'#2D79D6',display:$content_offset.top>0?'block':'none'});$('body').append($progress_overlay);$progress_overlay.html(Request.getProgressHtml());} 24else{if($content_height>0){$progress_overlay.css({width:$content_width,height:$content_height,top:$content_offset.top+$parent_div.scrollTop()});} 25$progress_overlay.show();}}} 26Request.hideProgress=function(p_id){if(p_id!=''){$(jq('#'+p_id+'_progress')).hide();}} 27Request.setOpacity=function(opacity,id){var $element=$(typeof(id)=='string'?jq('#'+id):id);$element.css('opacity',opacity/100);} 28Request.getProgressHtml=function(){return"<div class='progress' style='position: relative; top: 50%; text-align: center; color: white;'>"+Request.progressText+"<br /><img src='img/ajax_progress.gif' align='absmiddle' width='100' height='7' alt='"+Request.progressText+"' title='"+Request.progressText+"'/></div>";} 29Request.getErrorHtml=function(p_req){return'[status: '+p_req.status+'; status_text: '+p_req.statusText+'; responce_text: '+p_req.responseText+']';} 30Request.serializeForm=function(theform){if(typeof(theform)=='string'){theform=document.getElementById(theform);} 31var els=theform.elements;var len=els.length;var queryString='';Request.addField=function(name,value){if(queryString.length>0)queryString+='&';queryString+=encodeURIComponent(name)+'='+encodeURIComponent(value);};for(var i=0;i<len;i++){var el=els[i];if(el.disabled)continue;switch(el.type){case'text':case'password':case'hidden':case'textarea':Request.addField(el.name,el.value);break;case'select-one':if(el.selectedIndex>=0){Request.addField(el.name,el.options[el.selectedIndex].value);} 32break;case'select-multiple':for(var j=0;j<el.options.length;j++){if(!el.options[j].selected)continue;Request.addField(el.name,el.options[j].value);} 33break;case'checkbox':case'radio':if(!el.checked)continue;Request.addField(el.name,el.value);break;}} 34return queryString;};function AjaxProgressBar($url){this.WindowTitle=this.GetWindow().document.title;this.URL=$url;this.BusyRequest=false;this.LastResponceTime=this.GetMicroTime();this.ProgressPercent=0;this.ProgressTime=new Array();this.Query();} 35AjaxProgressBar.prototype.GetWindow=function(){return window.parent?window.parent:window;} 36AjaxProgressBar.prototype.GetMicroTime=function(){var $now=new Date();return Math.round($now.getTime()/1000);}
37AjaxProgressBar.prototype.Query=function(){Request.makeRequest(this.URL,this.BusyRequest,'',this.successCallback,this.errorCallback,'',this);} 38AjaxProgressBar.prototype.GetEstimatedTime=function(){return Math.ceil((100-this.ProgressPercent)*Math.sum(this.ProgressTime)/this.ProgressPercent);} 39AjaxProgressBar.prototype.successCallback=function($request,$params,$object){var $responce=$request.responseText;var $match_redirect=new RegExp('^#redirect#(.*?)($|\\s.*)').exec($responce);if($match_redirect!=null){$object.showProgress(100);window.location.href=$match_redirect[1];return false;} 40if(isNaN(parseFloat($responce))){alert($responce);return;} 41if($object.showProgress($responce)){$object.Query();}} 42AjaxProgressBar.prototype.errorCallback=function($request,$params,$object){alert('AJAX Error; class: AjaxProgressBar; '+Request.getErrorHtml($request));} 43AjaxProgressBar.prototype.FormatTime=function($seconds){$seconds=parseInt($seconds);var $minutes=Math.floor($seconds/60);if($minutes<10)$minutes='0'+$minutes;$seconds=$seconds%60;if($seconds<10)$seconds='0'+$seconds;return $minutes+':'+$seconds;} 44AjaxProgressBar.prototype.showProgress=function($percent){this.ProgressPercent=$percent;var $now=this.GetMicroTime();this.ProgressTime[this.ProgressTime.length]=$now-this.LastResponceTime;this.LastResponceTime=$now;var $display_progress=parseInt(this.ProgressPercent);this.GetWindow().document.title=$display_progress+'% - '+this.WindowTitle;document.getElementById('progress_display[percents_completed]').innerHTML=$display_progress+'%';document.getElementById('progress_display[elapsed_time]').innerHTML=this.FormatTime(Math.sum(this.ProgressTime));document.getElementById('progress_display[Estimated_time]').innerHTML=this.FormatTime(this.GetEstimatedTime());document.getElementById('progress_bar[done]').style.width=$display_progress+'%';document.getElementById('progress_bar[left]').style.width=(100-$display_progress)+'%';return $percent<100?true:false;} 45function AjaxPopupManager($url){this.URL=$url;this.ResponceFunction=null;this.PopupSizes=new Array();} 46AjaxPopupManager.prototype.GetSize=function($template){if(this.ResponceFunction==null){alert('Please define responce function first (type: '+typeof(this.ResponceFunction)+')');} 47if(!isset(this.PopupSizes[$template])){var $url=this.URL+'&type=GetPopupSize&template_name='+$template;Request.makeRequest($url,this.BusyRequest,'',this.successCallback,this.errorCallback,['GetSize',$template],this);} 48else{this.ResponceFunction(this.PopupSizes[$template]);}} 49AjaxPopupManager.prototype.successCallback=function($request,$params,$object){var $responce=$request.responseText;switch($params[0]){case'GetSize':$object.PopupSizes[$params[1]]=$responce;break;} 50$object.ResponceFunction($responce);$object.ResponceFunction=null;} 51AjaxPopupManager.prototype.errorCallback=function($request,$params,$object){alert('AJAX Error; class: AjaxPopupManager; '+Request.getErrorHtml($request));} 52function AjaxDropdownPreloader($url,$input_mask,$filter_field,$dependend_field,value){this.URL=$url;this.InputMask=$input_mask;this.FilterField=$filter_field;this.DependendField=$dependend_field;this.Titles=this.prepareTitles();this.Value=value;this.BusyRequest=false;} 53AjaxDropdownPreloader.prototype.prepareURL=function() 54{return this.URL.replace('#DEPENDEND#',this.Dependend).replace('#FILTER_VALUE#',this.getValue(this.FilterField));} 55AjaxDropdownPreloader.prototype.prepareTitles=function(){var $control=this.getControl(this.DependendField);var $i=0;var $ret=new Array();while($i<$control.options.length){$ret[$control.options[$i].value]=$control.options[$i].innerHTML;$i++;} 56return $ret;} 57AjaxDropdownPreloader.prototype.getValue=function($field_name){var $control=this.getControl($field_name);if($control.tagName=='INPUT')return $control.value;return $control.selectedIndex>0?$control.options[$control.selectedIndex].value:'';} 58AjaxDropdownPreloader.prototype.Query=function(){var $url=this.prepareURL();var $selected_value=this.Value||this.getValue(this.DependendField);this.removeOptions();Request.makeRequest($url,this.BusyRequest,'',this.successCallback,this.errorCallback,$selected_value,this);} 59AjaxDropdownPreloader.prototype.getControl=function($field){var $id=this.InputMask.replace('#FIELD#',$field);return document.getElementById($id);} 60AjaxDropdownPreloader.prototype.successCallback=function($request,$params,$object){if(Request.processRedirect($request)===true){return;} 61var control=$object.getControl($object.DependendField) 62$object.ProcessXMLNode($request.responseXML,control,$params);runOnChange(control);$object.AfterProcess();} 63AjaxDropdownPreloader.prototype.ProcessXMLNode=function($node,$dst_field,$selected_value){for(var i=0;i<$node.childNodes.length;i++){var $child=$node.childNodes.item(i);switch($child.tagName){case'option':var opt_value=$child.getAttribute('value');var title;if(opt_value){title=$child.firstChild.nodeValue} 64else{opt_value=$child.firstChild.nodeValue;title=this.Titles[$child.firstChild.nodeValue];} 65this.addOption($dst_field,opt_value,title,$child.attributes);if(!$dst_field.multiple&&(opt_value==$selected_value)){$dst_field.options[$dst_field.options.length-1].selected=true;} 66break;case'field_options':if(!$dst_field.multiple){this.addOption($dst_field,'','');} 67this.ProcessXMLNode($child,$dst_field,$selected_value);if($dst_field.options.length==0||$dst_field.options.length==2){$dst_field.value=$dst_field.options[$dst_field.options.length-1].value;} 68break;}}} 69AjaxDropdownPreloader.prototype.AfterProcess=function(){} 70AjaxDropdownPreloader.prototype.removeOptions=function($object){if(!$object)$object=this.getControl(this.DependendField);if($object.options.length>0){while($object.options.length>0){$object.remove(0);}}} 71AjaxDropdownPreloader.prototype.addOption=function($object,$value,$title,attributes){var $option=document.createElement('OPTION');$object.options.add($option,$object.options.length);$option.innerText=$title;$option.innerHTML=$title;$option.value=$value;if(attributes){for(var i=0;i<attributes.length;i++){if(attributes[i].nodeName=='value')continue;$option.setAttribute(attributes[i].nodeName,attributes[i].nodeValue);}}} 72AjaxDropdownPreloader.prototype.errorCallback=function($request,$params,$object){alert('AJAX Error; class: AjaxDropdownPreloader; '+Request.getErrorHtml($request));} 73function StoryManager($url){this.Url=$url;this.BusyRequest=false;} 74StoryManager.prototype.LoadPage=function($object_id){var $url=this.Url.replace('#STORY_PAGE#',$object_id)
75Request.makeRequest($url,this.BusyRequest,'',this.successCallback,this.errorCallback,[$object_id],this);} 76StoryManager.prototype.successCallback=function($request,$params,$object){var response=$request.responseText;if(response.substring(0,5)=='@err:'){alert(response.substring(5));return;} 77document.getElementById('story').innerHTML=response;fade('story');} 78StoryManager.prototype.errorCallback=function($request,$params,$object){alert('AJAX Error; class: PollManager; '+Request.getErrorHtml($request));} 79function ActualsManager($url){this.Url=$url;this.BusyRequest=false;} 80ActualsManager.prototype.LoadPage=function($object_id){var $url=this.Url.replace('#STORY_PAGE#',$object_id) 81Request.makeRequest($url,this.BusyRequest,'',this.successCallback,this.errorCallback,[$object_id],this);} 82ActualsManager.prototype.successCallback=function($request,$params,$object){var response=$request.responseText;if(response.substring(0,5)=='@err:'){alert(response.substring(5));return;} 83document.getElementById('actuals-news').innerHTML=response;fade('actuals-news');} 84ActualsManager.prototype.errorCallback=function($request,$params,$object){alert('AJAX Error; class: PollManager; '+Request.getErrorHtml($request));} 85function LoginManager($url){this.Url=$url;this.BusyRequest=false;} 86LoginManager.prototype.LoadPage=function($object_id){var $url=this.Url.replace('#LOGIN#',$object_id) 87Request.makeRequest($url,this.BusyRequest,'',this.successCallback,this.errorCallback,[$object_id],this);} 88LoginManager.prototype.successCallback=function($request,$params,$object){var response=$request.responseText;if(response.substring(0,5)=='@err:'){alert(response.substring(5));return;} 89document.getElementById('test-login').innerHTML=response;} 90LoginManager.prototype.errorCallback=function($request,$params,$object){alert('AJAX Error; class: LoginManager; '+Request.getErrorHtml($request));} 91function CommentsManager($url) 92{this.Url=$url;this.BusyRequest=false;} 93CommentsManager.prototype.LoadPage=function($object_id){var $url=this.Url.replace('#COMMENT_ID#',$object_id) 94Request.makeRequest($url,this.BusyRequest,'',this.successCallback,this.errorCallback,[$object_id],this);} 95CommentsManager.prototype.successCallback=function($request,$params,$object){var response=$request.responseText;if(response.substring(0,5)=='@err:'){alert(response.substring(5));return;}} 96CommentsManager.prototype.errorCallback=function($request,$params,$object){}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.