1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
|
/*
*
* This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
* project.
*
* Copyright (C) 1998-2006 OpenLink Software
*
* This project is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; only version 2 of the License, dated June 1991.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
function Show(objid){
var obj = document.getElementById(objid);
obj.style.display="";
obj.visible = true;
}
function Hide(objid){
var obj = document.getElementById(objid);
obj.style.display="none";
obj.visible = false;
}
var InitialCheck = 0;
var HaveInitialState = 1;
function toggle_tab(div_id,no_init_load){
var obj = document.getElementById('tab_'+div_id);
var ul_obj = document.getElementById('ex_navlist');
var nodeList = returnListOfNodes(ul_obj.childNodes);
for(var i=0;i<nodeList.length;i++){
returnListOfNodes(nodeList[i].childNodes)[0].className = "";
};
obj.className = "current";
var ContentDivs = Array(document.getElementById('info'),
document.getElementById('initial_state'),
document.getElementById('view_source'),
document.getElementById('run'));
for(var i=0;i<ContentDivs.length;i++){
if (ContentDivs[i].id == div_id && ContentDivs[i].style.display == 'none')
Show(ContentDivs[i].id);
else if (ContentDivs[i].id != div_id && ContentDivs[i].style.display != 'none')
Hide(ContentDivs[i].id);
};
if (div_id == 'initial_state' && InitialCheck == 0) {
if (HaveInitialState)
CheckStatus();
else
document.getElementById('initial_state').innerHTML = '<p>This example doesn\'t have initial state.</p>';
InitialCheck = 1;
};
if (div_id == 'view_source' || div_id == 'initial_state') {
//Patch for f..g IE not properly shows and resizes the div, it also hides the texts.
if (navigator.userAgent.toLowerCase().indexOf('msie') > 0 && navigator.userAgent.indexOf('Opera') == -1 && window.onresize == null) {
window.onresize = function(){
var filesource = document.getElementById('filesource');
if (filesource.offsetWidth > 0) {
var filecontent = filesource.innerHTML;
filesource.innerHTML = '';
filesource.style.width = '78%';
var div_width = filesource.offsetWidth;
filesource.style.width = div_width - 2 + 'px';
filesource.innerHTML = filecontent;
};
var content = document.getElementById('initial_state_content');
if (content.offsetWidth > 0) {
var res_content = content.innerHTML;
content.innerHTML = '';
content.style.width = '100%';
var div_width = content.offsetWidth;
content.style.width = div_width - 2 + 'px';
content.innerHTML = res_content;
};
};
};
if (div_id == 'initial_state' && window.onresize != null)
window.onresize();
}
if (div_id == 'view_source' && !no_init_load && Files.length) {
var checked_vs = 0;
var filelist_ul = document.getElementById('filelist_nav');
for(i in Files){
if (filelist_ul.childNodes[i].firstChild.className == 'current') {
checked_vs = 1;
}
}
if (!checked_vs) {
LoadFile(Files[0]);
}
}
if (div_id == 'run' && !no_init_load && RunFiles.length) {
var checked_vs = 0;
var runfilelist_ul = document.getElementById('runfilelist_nav');
for(i in RunFiles){
if (runfilelist_ul.childNodes[i].firstChild.className == 'current') {
checked_vs = 1;
}
}
if (!checked_vs) {
RunFile(RunFiles[0][0]);
document.getElementById('run_frame').src = RunFiles[0][0];
}
}
}
function InitialStateLink() {
var content = document.getElementById('initial_state_content');
content.innerHTML = '<p>Initializing, please wait...</p>';
InitialCheck = 1;
toggle_tab('initial_state');
SetInitialState();
}
function returnListOfNodes(nodeList){
list = new Object();
var x = 0;
for(var i=0;i<nodeList.length;i++){
if(nodeList[i].nodeType == 1){
list[x++] = nodeList[i];
}
}
list.length = x--;
return list;
}
var timer = null;
function ResetState(){
var xmlhttp = null;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) { }
if (xmlhttp == null) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) { }
} // if
// Gecko / Mozilla / Firefox
if (xmlhttp == null)
xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", URL + '?load_scr_reset=1',false);
xmlhttp.setRequestHeader("Pragma", "no-cache");
xmlhttp.send("");
}
var req_handle = null;
function SetInitialState(){
document.getElementById("bt_SetInitialState").disabled=true;
ResetState();
var content = document.getElementById('initial_state_content');
var xmlhttp = null;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) { }
if (xmlhttp == null) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) { }
} // if
// Gecko / Mozilla / Firefox
if (xmlhttp == null)
xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", URL + '?load_scr=1',true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
//content.innerHTML += '<hr/>Finished';
}
};
xmlhttp.setRequestHeader("Pragma", "no-cache");
xmlhttp.send("");
if (timer == null)
timer = setTimeout("CheckStatus()",500);
req_handle = xmlhttp;
}
function CancelInitialState(){
req_handle.abort();
}
function debug(str){
var debug = document.getElementById('debug');
debug.innerHTML = str + '<br/>' + debug.innerHTML;
}
function CheckStatus(){
var content = document.getElementById('initial_state_content');
var xmlhttp = null;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) { }
if (xmlhttp == null) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) { }
} // if
// Gecko / Mozilla / Firefox
if (xmlhttp == null)
xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", URL + '?load_scr_status=1',true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
var inx = xmlhttp.responseText.indexOf(':');
var completed_val = xmlhttp.responseText.substring(0,inx);
var content_val = xmlhttp.responseText.substring(inx + 1,xmlhttp.responseText.length)
if (completed_val != 'noinit') {
document.getElementById("PBcompleted").style.width = completed_val + '%';
document.getElementById("PBcontent").innerHTML = completed_val + '%';
}
content.innerHTML = '<pre>' + content_val + '</pre>';
content.scrollTop = content.scrollHeight;
content.scrollTop = content.scrollHeight; // the second time is for IE.
if (completed_val < 100 && completed_val != null && completed_val != 'noinit') {
document.getElementById("bt_SetInitialState").disabled=true;
timer = setTimeout("CheckStatus()",500);
} else {
document.getElementById("bt_SetInitialState").disabled=false;
timer = null;
}
}
};
xmlhttp.setRequestHeader("Pragma", "no-cache");
xmlhttp.send("");
}
var Files = Array();
function FileListInit(){
var filelist_ul = document.getElementById('filelist_nav');
filelist_ul.innerHTML = '';
for(i in Files){
filelist_ul.innerHTML += '<li><a href="#" onclick="LoadFile(\''+Files[i]+'\')"> ' + Files[i] + '</a></li>';
};
if (Files.length == 0)
filelist_ul.innerHTML = '<li>~no files~</li>';
}
function LoadFile(in_File) {
var filelist_ul = document.getElementById('filelist_nav');
var hilite_btn = document.getElementById('hilite');
hilite_btn.value = 'Show Syntax Highlight';
hilite_btn.disabled = true;
for(i in Files){
filelist_ul.childNodes[i].firstChild.className='';
if (in_File == Files[i]) {
filelist_ul.childNodes[i].firstChild.className='current';
};
};
var filesource = document.getElementById('filesource');
filesource.innerHTML = 'Loading, please wait...';
var xmlhttp = null;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) { }
if (xmlhttp == null) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) { }
} // if
// Gecko / Mozilla / Firefox
if (xmlhttp == null)
xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", URL + '?src=' + in_File,true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
var filecontent = xmlhttp.responseText.substring(xmlhttp.responseText.indexOf('<pre>\r\n')+7,xmlhttp.responseText.lastIndexOf('\r\n</pre>'));
filesource.innerHTML = '<pre>' + filecontent + '</pre>';
var hilite_btn = document.getElementById('hilite');
hilite_btn.disabled = false;
}
};
xmlhttp.setRequestHeader("Pragma", "no-cache");
xmlhttp.send("");
}
function ViewSourceLink(in_File) {
toggle_tab('view_source',1);
LoadFile(in_File);
}
function doSyntax (btn) {
var filesource = document.getElementById('filesource');
if (btn.value == 'Show Syntax Highlight') {
var lng = getFileLanguage();
var filecontent = filesource.innerHTML.substring(filesource.innerHTML.toLowerCase().indexOf('<pre>')+5,filesource.innerHTML.toLowerCase().lastIndexOf('</pre>'));
filesource.innerHTML = '<textarea id="filesource_highlight" name="filesource_highlight" class="' + lng + ':nogutter:nocontrols">' + filecontent + '</textarea>';
dp.SyntaxHighlighter.HighlightAll('filesource_highlight', true, false);
btn.value = 'Hide Syntax Highlight';
} else {
var filecontent = document.getElementById('filesource_highlight').value.replace(/</g, '<');;
filesource.innerHTML = '<pre>' + filecontent + '</pre>';
btn.value = 'Show Syntax Highlight';
}
}
function getFileLanguage() {
var filelist_ul = document.getElementById('filelist_nav');
var FileExt = null;
var ret = 'sql';
for(i in Files){
if(filelist_ul.childNodes[i].firstChild.className == 'current')
break;
};
FileExt = Files[i].substring(Files[i].lastIndexOf('.')+1);
//('java','pl','pm','bpel', 'xq', 'cpp', 'h')
if (inArray(FileExt,Array('vsp','sql')))
ret = 'sql';
else if (inArray(FileExt,Array('xsl','xml','html','vspx','wsdl','xslt','aspx')))
ret = 'xml';
else if (inArray(FileExt,Array('cs')))
ret = 'c#';
else if (inArray(FileExt,Array('php')))
ret = 'php';
else if (inArray(FileExt,Array('py')))
ret = 'py';
else if (inArray(FileExt,Array('rb')))
ret = 'rb';
return ret;
}
function inArray(str,arr){
for(i in arr){
if (arr[i] == str)
return 1;
}
return 0;
}
var RunFiles = Array();
function RunFileListInit(){
var runfilelist_ul = document.getElementById('runfilelist_nav');
runfilelist_ul.innerHTML = '';
for(i in RunFiles){
runfilelist_ul.innerHTML += '<li><a target="run_frame" href="'+RunFiles[i][0]+'" onclick="RunFile(\''+RunFiles[i][0].replace(/'/g, "\\\'")+'\')"> ' + RunFiles[i][1] + '</a></li>';
};
if (RunFiles.length == 0)
runfilelist_ul.innerHTML = '<li>~no files~</li>';
}
function RunLink(in_File) {
toggle_tab('run',1);
RunFile(in_File);
}
function RunFile(in_Link) {
var runfilelist_ul = document.getElementById('runfilelist_nav');
for(i in RunFiles){
runfilelist_ul.childNodes[i].firstChild.className='';
if (in_Link == RunFiles[i][0].replace(/&/g,'&').replace(/'/g,'\'')) {
runfilelist_ul.childNodes[i].firstChild.className='current';
};
};
}
|