User talk:Badmadevil: Difference between revisions

m (→‎Not Implemented Tasks by Language: regexp version, remove unsed http.js)
 
(8 intermediate revisions by 2 users not shown)
Line 1:
Welcome to Rosetta Code! I founded RC around a year ago, and still do most of the administrative work. Thanks for your code contributions. I'm curious, though, how did you hear about RC? --[[User:Short Circuit|Short Circuit]] 10:44, 23 February 2008 (MST)
:Hi, thanks. I heard from a forward message posted at Digital Mars D newsgroup about a month ago. -[[User:Badmadevil|badmadevil]] 03:03, 24 February 2008 (MST)
 
== Theme problems ==
Hi there, I'm really not seeing the issues you're reporting about the new skin. <del>If you could, post the browser version as well, as I see neither of the problems you've listed in the ones I'm testing with (FF3, Opera 9.5, IE7)</del> I'm really not seeing the issues you're talking about. Perhaps your font size is larger than normal? Ctrl + 0 or View > Zoom > Reset.
--[[User:Qrush|qrush]] 19:54, 22 June 2008 (UTC)
:oops... then my browser setting problem is the most possible explanation, sorry for the extra work. (btw, in my FF3, by changing zoom, it only affect the size of top-left logo's ''Rosetta Code'' text if ''zoom text only'', else everything is proportional) -- [[User:Badmadevil|badmadevil]] 04:08, 23 June 2008 (UTC)
:: This should be fixed. Give the skim another try. --[[User:Short Circuit|Short Circuit]] 00:14, 14 February 2009 (UTC)
 
== Mylang ==
Line 9 ⟶ 15:
== Not Implemented Tasks by Language ==
 
Hello. IIRC, it has been mentioned an idea to display a page of tasks not implemented by a specific language (It is from [[User:IanOsgood|Ian Osgood]]'s [[Rosetta_Code:Wiki_Wishlist|wishlist]]), it seems no such page at Rosetta Code yet. I've coded a dirty hack of such page using client-side javascriptPHP. It<br use/><br xmlhttprequest/>This toversion getshould thepreserve contentsRosetta ofCode's Solutions_by_Programming_Taskpages &look theand language specified page that contains tasks such language has been completedfeel, thenand bymay usingbe RegExp, extracting links under some specify id/tag, the links of set different of these 2 page arebetter tasksintegrated thatinto notRC implementedsite.<br /><br />''Sources'':
''Bugs fix notes :''
*When PHP flag <i>allow_url_fopen</i> is enabled, it is possible to read contents from RC Site via local server. Then, by directly testing with RC Site, many bugs were found;
*''fixed'', it seems that articles in tasks or languages' pages have at least 3 version of url. In most cases, they refer to the same file, but it seems some are not (may be re-direction?). Previously, some url can be accessed while other cannot, if only using one version of url; now all 3 version is tried. The version of '/w/index.php?title=' has highest priority, so that page like C++ will not mistaken by C page;
::''changed'', it seems I'm wrong again. All pages can be accesses by '/wiki/Category:' version's url, only that to not mistaken C++ page with C page, url extracted from RC page have to be encoded 2 times. In most case, this '/wiki/Category:(encoded-url)' can reach the page correctly, only pages like ''PL/I'', ''PL/SQL'' need 1 decode. No more other version of url is needed. -- [[User:Badmadevil|badmadevil]] 09:14, 17 June 2008 (MDT)
*''fixed'', previously, required link nodes to be got by xpath are assumed to be inside a table, but it is found that language page having 7 or less task completed didn't use a table; the later case is dealing with another proper xpath;
*some pages have not any task completed, eg. assembler, pike, JoCaml. They are treated as error loading page, rather than display all tasks from Task-list page;
*''unsolved'', there are unknown errors on parsing pages of ''JScript.NET'' & ''Visual Basic.NET'' as DOM. They can be load as DOMDocument (so that it is not a problem of url, eg.wrong encoding of url string), but can't get the required Node by getElementById inside the DOMDoc;
::''fixed'', it is really a problem of wrong encoding, the 'dot' is not properly encoded, and the page loaded I said previously is the create new articles page. It has been fixed. All bugs should has been fixed. -- [[User:Badmadevil|badmadevil]] 12:22, 16 June 2008 (MDT)
*''Usage'', this version need not config, as long as allow_url_fopen is enabled. Place this script in a server (local server or RC Site) some where can be access from www, and that is it.
*Tested with PHP 5.2.1
<br /><br />''Sources'':
{||-
| style="height:36em;float:left;clear:both;overflow:auto;" |
<php><?php
&lt;html&gt;
// may be need to enable allow_url_fopen, or change it to local file path
&lt;title&gt;Not Implemented Task by Langauge&lt;/title&gt;
define('RCHost' , 'www.rosettacode.org') ;
&lt;!--script src="/http.js"&gt;&lt;/script--&gt;
define('ROSETTA', 'http://' . RCHost) ;
&lt;!--script src="http.js"&gt;&lt;/script--&gt;
define('Prefix', ROSETTA . '/wiki/Category:') ;
&lt;script&gt;
define('TaskURL', 'Solutions_by_Programming_Task') ;
<javascript>/**
define('ListURL', 'Solutions_by_Programming_Language') ;
** C o n f i g
**/
// javascript's XMLHTTPRequest doesn't allow cross site request,
// so this script's location's host has to be same as the Category pages.
// the prefix change to 'http://rosettacode.org/wiki/Category:' should be ok
//var mySitePrefix = 'http://www.lynx.ran/wiki/' ;
var mySitePrefix = 'http://rosettacode.org/wiki/Category:' ;
 
define('LANGID', 'LANGID') ; // if use as a query string key-value pair
// set to true if mySitePrefix is inside rosetta site, should allow reach C++,
define('NA', 'NotAvaliable') ;
// C# etc. pages.
//var usesafeurl = false ;
var usesafeurl = true ;
 
$subfix = "" ;
// this is maximum length of '<a .. /a>' plus <li></li>, Capital Heading's HTML
$langID = LangId() ;
// sources in next link capture string in o.getlink function. Currently, it is
$IDLang = myDecode($langID) ;
// about 340 (found by trail and error).
// Modify this value if longer name of new task is added.
var preFetchLen = 400 ;
 
// this control how to access this scrtpt
// To test in a loacl web server (eg. http://localhost):
$scriptURL = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['URL'] ;
// 1.mkdir wiki in root dir of localhost,
// save http://rosettacode.org/wiki/Category:<CATEGORYNAME> to
// localhost/wiki/<CATEGORYNAME>/index.htm,
// 2.<CATEGORYNAME> should at leat include Solutions_by_Programming_Task &
// Solutions_by_Programming_Language, then include some other languages
// categories, eg. C, Java, Python, etc. to start testing.
// 3.place http.js where this html can located,
// 4.no query string should be in url of this html,
 
function ScriptURL($langId){
var working = "<none>" ;
global $scriptURL, $subfix;
if($langId == NA)
$tail = strlen($subfix) == 0 ? '' : '?' . $subfix ;
else {
$tail = strlen($subfix) == 0 ? '' : '&' . $subfix ;
$tail = '?' . LANGID . '=' . myEncode($langId) . $tail ;
}
return $scriptURL . $tail ;
}
function pageUrl($page) {
global $subfix;
$tail = strlen($subfix) == 0 ? '' : '?' . $subfix ;
return Prefix . $page . $tail ;
}
function myEncode($s) { return str_replace('.', '%252E', rawurlencode($s)) ; }
function myDecode($s) { return str_replace('_', ' ' , rawurldecode($s)) ; }
 
function LangId(){
var NA = "N/A" ;
global $subfix ;
function Page(url, ID) {
var o$langId = new ObjectNA ;
if(count($_SERVER['QUERY_STRING']) > 0) {
o.url = url ;
parse_str($_SERVER['QUERY_STRING'], $query) ;
o.ID = ID ;
if(array_key_exists(LANGID, $query) && strlen($query[LANGID]) > 0)
o.cnt = 0 ;
o.htm $langId = NA$query[LANGID] ;
else
o.lnk = new Array() ;
foreach($query as $key => $value)
o.request = function() { HTTP.getText(o.url, o.setHtm)}
if(strlen($value) == 0) {
$query[LANGID] = $key ;
$langId = $key ;
unset($query[$key]) ;
break ;
}
if(array_key_exists(LANGID, $query))
unset($query[LANGID]) ;
$subfix = http_build_query($query) ;
}
return $langId ;
}
 
class Page extends DOMDocument {
// NOTE:
public $lnk , $hdr, $msg , $tds, $url, $context ;
// GLOBAL RegExp is not use, for I can't handle it right, or the performance is bad.
public $dict = array() , $ok = TRUE ;
o.setHtm = function(txt) {
public $cnt = 0 , $notCnt = 0 ; // $notCnt = count of not implemented tasks
var head = 0 ;
 
var tail = 0 ;
function __construct($url, $id) {
working = o.url + '<br />';
global $langID ;
head = txt.search(o.ID + '">') ;
if(head$url >== 0$langID) {
if(!@$this->loadHTMLFile($this->url = pageURL($langID)))
tail = txt.search('printfooter') ;
if(!@$this->loadHTMLFile($this->url = pageURL(myDecode($langID))))
if(tail >= 0) {
o.htm = txt.slice(head$this->ok + o.ID.length + 2,tail -= 12)FALSE ;
if($this->ok) $this->context = $this->getElementById($id) ;
o.getlink() ;
} else }{
if(@$this->loadHTMLFile($url))
$this->context = $this->getElementById($id) ;
}
if($this->context) {
$xpath = new DOMXPath($this) ;
$this->hdr = $xpath->query('h2', $this->context)->item(0) ;
$this->msg = $xpath->query('p', $this->context)->item(0) ;
if($xpath->query('table', $this->context)->length)
$this->lnk = $xpath->query('table/tr/td/ul/li', $this->context) ;
else // not inside a table
$this->lnk = $xpath->query('ul/li', $this->context) ;
$this->cnt = $this->lnk->length ;
} else
$this->ok = FALSE ;
}
o.getlinkfunction = functiontoHTML() {
// not need if this script is inside RC site
if(o.htm != NA) {
if(stristr($_SERVER['HTTP_HOST'], RCHost) === FALSE) {
var re = /href="(.*)"\s*title="(.*)"\s*>.+</ ;
$head = $this->getElementsByTagName("head")->item(0) ;
var start = 0 ;
var head$base = 0$this->createElement("base") ;
$base->setAttribute("href", ROSETTA) ;
var tail = 0. ;
$head->insertBefore($base, $head->firstChild) ;
var htmlen = o.htm.length ;
while(start >= 0 && start < htmlen) {
var part = o.htm.slice(start, Math.min(start + preFetchLen, htmlen)) ;
head = part.search('<a') ;
if(head >= 0) {
tail = part.search('a>') ;
if(tail >= 0) {
var mh = part.slice(head, tail).match(re) ;
if(mh) {
o.lnk[mh[1]] = mh[2] ;
o.cnt++ ;
}
}
}
if(head < 0 || tail < 0) start = -1 ; else start += (tail + 1) ;
}
}
return $this->saveHTML() ;
}
function prepare(&$taskList) {
$temp = array() ;
// collect lang's task list
for($i = 0 ; $i < $this->lnk->length ; $i++) {
$alink = $this->lnk->item($i)->getElementsByTagName("a")->item(0) ;
$temp[$alink->getAttribute("href")] = TRUE ;
}
// set diff : total tasks - lang's tasks => not completed tasks
for($i = 0 ; $i < $taskList->length ; $i++) {
$alink = $taskList->item($i)->getElementsByTagName("a")->item(0) ;
if(array_key_exists($alink->getAttribute("href"), $temp) === FALSE)
$this->dict[$this->notCnt++] = // import from Tasks into Lang
$this->importNode($taskList->item($i),true) ;
}
$lang->lnk = null ; // release node ref. to be remove
// clear All nodes under $this->context(id)'s node
while($this->context->lastChild)
$this->context->removeChild($this->context->lastChild) ;
// create new hdr, msg
$this->hdr = $this->context->appendChild($this->createElement("h2")) ;
$this->msg = $this->context->appendChild($this->createElement("p")) ;
// make table
$table = $this->createElement("table") ;
$tr = $this->createElement("tr") ;
for($i = 0 ; $i < 3 ; $i++)
$tr->appendChild($this->createElement("td")) ;
$table->appendChild($tr) ;
$this->context->appendChild($table) ;
// get tds later work with
$xpath = new DOMXPath($this) ;
$this->tds = $xpath->query('table/tr/td', $this->context) ;
}
return o ;
}
var scriptUrl ;
with(window.location)
scriptUrl = protocol + '//' + host + pathname ;
var rosettaUrl = 'http://rosettacode.org'
var langID = getLangID() ;
var langurl = langID != NA && usesafeurl ? safeurl() : mySitePrefix + langID ;
var task = Page(mySitePrefix + 'Solutions_by_Programming_Task', "mw-pages") ;
var lang = Page(langurl, "mw-pages") ;
var list = Page(mySitePrefix + 'Solutions_by_Programming_Language', "mw-subcategories") ;
var tasklist ;
var langlist ;
var timeoutCnt = 5 ;
var count = 0 ;
 
function getLangIDprocess_task() {
global $task, $lang ;
var langid = window.location.search.slice(1) ;
if(langid.length == 0) return NA ;
 
if($lang->notCnt == 0) {
return langid ;
$lang->msg->nodeValue =
}
"All {$task->cnt} simpler tasks are completed ( {$lang->cnt} " .
"total completed tasks, some implementations and puzzles may be " .
"not yet completed )." ;
// no more tasks below, add a height to the table to look like a void.
$lang->tds->item(0)->setAttribute("height", "100px") ;
} else {
$lang->msg->nodeValue =
"There are {$lang->notCnt} not completed tasks " .
"out of {$task->cnt} total tasks ( {$lang->cnt} " .
"completed tasks, implementations and puzzles etc.)." ;
 
$curr = 0 ;
function safeurl(langname) {
$splitMax = $lang->tds->length ;
if(!langname) langname = langID ;
$splitMax = intval(($lang->notCnt + $splitMax - 1) / $splitMax) ;
return rosettaUrl + '/w/index.php?title=' + langname ;
if($splitMax < 5) $splitMax = 5 ;
}
 
$capital = '' ;
function process() {
for($i = 0 ; $i < $lang->tds->length ; $i++) {
tasklist = document.getElementById("tasklist") ;
$td = $lang->tds->item($i) ;
langlist = document.getElementById("langlist") ;
$td->setAttribute("width", intval(100/$lang->tds->length) . "%") ;
tasklist.innerHTML = "...loading..." ;
$td->setAttribute("valign", "top") ;
langlist.innerHTML = "...loading..." ;
task.request() $ul = NULL ;
$splitCnt = 0 ;
list.request() ;
while($curr < $lang->notCnt && $splitCnt < $splitMax) {
if(langID != NA) {
$li = $lang.request()->dict[$curr] ;
$heading = $capital ;
document.title = 'Not Implemented Tasks by Langauge ' + langID ;
$title = $li->getElementsByTagName("a")->item(0)->getAttribute("title") ;
$capital = strtoupper(substr($title, 0, 1)) ;
if($splitCnt == 0) {
if($capital == $heading)
$h3 = $lang->createElement("h3", $capital . " cont.") ;
else
$h3 = $lang->createElement("h3", $capital) ;
$td->appendChild($h3) ;
$ul = $lang->createElement("ul") ;
} else if($capital != $heading) {
$td->appendChild($ul) ;
$h3 = $lang->createElement("h3", $capital) ;
$td->appendChild($h3) ;
$ul = $lang->createElement("ul") ;
}
$ul->appendChild($li) ;
$curr++ ;
$splitCnt++ ;
}
if($ul) $td->appendChild($ul) ;
}
}
waitLoad() ;
}
function process_list(){ // replace languages link with corresponding scriptURL
function waitLoad() {
timeoutCnt--global $list ;
for($i = 0 ; $i < $list->lnk->length ; $i++) {
// tasklist.innerHTML = makeStatus() + '<br />...loading ' + working + 'timeout in '
$alink = $list->lnk->item($i)->getElementsByTagName("a")->item(0) ;
// + timeoutCnt + ' sec...' ;
$href = $alink->getAttribute("href") ;
tasklist.innerHTML = '...loading ' + working + 'timeout in ' + timeoutCnt + ' sec...' ;
$idLang = substr($href, 1 + strrpos($href,":")) ;
if(timeoutCnt > 0 &&
$alink->setAttribute("href", ScriptURL($idLang)) ;
((langID != NA && lang.htm == NA) || task.htm == NA || list.htm == NA))
return setTimeout(waitLoad,1000) ;
if(langID == NA)
return failLoad() ;
if(timeoutCnt <= 0)
return failLoad() ;
if(task.cnt == 0 || list.cnt == 0 || lang.cnt == 0) return failLoad() ;
doParse() ;
}
function failLoad() { // this part may be simplified to display just a short err message
var errmsg = "" ;
if(lang.htm == NA) { // may be not known language
if(langID == NA)
errmsg += 'Language ID not known.' ;
else
errmsg += 'Error Page - url : ' +
alink(scriptUrl + '?' + langID,langID,langID, true) ;
}
errmsg += '<br />' ;
with(lang) if(htm == NA)
errmsg += 'fail to load this url : ' + alink(url, url, url) + '<br />' ;
with(list) if(htm == NA)
errmsg += 'fail to load this url : ' + alink(url, url, url) + '<br />' ;
with(task) if(htm == NA)
errmsg += 'fail to load this url : ' + alink(url, url, url) + '<br />' ;
tasklist.innerHTML = errmsg + makeStatus() ;
 
var taskdom = ""
if(task.cnt > 0 && lang.cnt > 0) taskdom = makeTask() ;
try {
if(taskdom == "") taskdom = task.htm ;
} catch(e) {
taskdom = "" ;
}
if(taskdom != "")
taskdom = makeMenu() + '<br />' + taskdom ;
else
taskdom = makeMenu() + '<br />Tasks Page not found/load.' ;
var listdom = "" ;
if(list.cnt >0) listdom = makeList();
try {
if(listdom == "") listdom = list.htm ;
} catch(e) {
listdom = "" ;
}
if(listdom != "")
listdom = '<hr />' + makeReturn() + '<hr />' + listdom ;
else
listdom = '<hr />' + makeReturn() + '<hr />Languages List Page not found/load.' ;
langlist.innerHTML = taskdom + listdom ;
}
function doParselinkText(&$node, $pre, $href, $text, $post) {
$doc = $node->ownerDocument ;
var taskdom = makeTask() ;
if($pre ) $node->appendChild($doc->createElement("span", $pre)) ;
tasklist.innerHTML = makeMenu() + '<h2>Tasks not implemented by ' + alink(rosettaUrl +
if($href) {
'/wiki/' + langID, langID,langID, true) + '</h2><hr /><br />There are <strong>' +
if(!$text) $text = 'null' ;
count + '</strong> not implemented tasks out of <strong>' + task.cnt +
$alink = $doc->createElement("a", $text) ;
'</strong> total tasks. ' + '(' + lang.cnt +
$alink->setAttribute("href", $href) ;
' completed tasks, implementations & puzzles etc.)<br />' + taskdom ;
$alink->setAttribute("title", $text) ;
langlist.innerHTML = makeReturn() + '<hr />' + makeList() ;
$node->appendChild($alink) ;
}
function alink(url, tip, txt, normalsize, nameanchor) {
var extra = normalsize ? "" : ' style="font-size:smaller;"';
extra += nameanchor ? ' name="' + nameanchor + '"' : "" ;
return '<a href="' + url + '" title="' + tip + '"' + extra + '>' +
unescape(txt) + '</a>' ;
}
function makeMenu() {
var backLink ;
if(langID == NA) {
backLink = alink(list.url, "Solution by Languages",
'Return to Category : Solution by Languages') ;
} else {
backLink = alink(safeurl(), safeurl(), 'Return to Category : ' + langID)
}
if($post) $node->appendChild($doc->createElement("span", $post)) ;
var tx = 'otherlanguages' ;
return alink('#' + tx, tx, 'Select other languages', true, 'returntop') +
'&nbsp;&nbsp;|&nbsp;&nbsp;' + backLink + '<hr />' ;
}
 
function makeReturn() {
/*
var tx = 'returntop' ;
* Main Body
// return alink('#' + tx, tx, 'TOP', true, 'otherlanguages') +
*/
// '&nbsp;&nbsp;|&nbsp;&nbsp;' + makeStatus() ;
 
return alink('#' + tx, tx, 'TOP', true, 'otherlanguages') ;
if($langID != NA) {
}
$lang = new Page($langID, 'mw-pages') ;
function makeStatus() {
if($lang->ok) {
return '(total&nbsp;/&nbsp;langs&nbsp;/&nbsp;taskss) - pages length : ' +
$task = new Page(pageURL(TaskURL), 'mw-pages') ;
task.htm.length + '&nbsp;/&nbsp;' + list.htm.length + '&nbsp;/&nbsp;' +
if($task->ok)
lang.htm.length + '&nbsp;&nbsp;|&nbsp;&nbsp;link count : ' + task.cnt +
$lang->prepare($task->lnk) ;
'&nbsp;/&nbsp;' + list.cnt + '&nbsp;/&nbsp;' + lang.cnt ;
}
function makeList() {
var backLink ;
if(langID == NA) {
backLink = alink(list.url, "Solution by Languages",
'&#8251') ;
} else {
backLink = alink(safeurl(), langID, '&#8251')
}
if(list.cnt == 0) return "" ;
var html = '<h3>Not Implemented Tasks by Other Languages (<span style=' +
'"font-size:78%;">click ' + backLink + ' to visit Normal Category' +
'</span>) :</h3><table width="100%"><tr>' ;
splitCnt = 0 ;
var cols = 6 ;
var wd = 'width="' + Math.floor(100/cols) + '%"' ;
for(i in list.lnk)
if(list.lnk[i]){
var txt = list.lnk[i] ;
var uri = i ;
var langTag = txt.split(':') ;
var langUri = uri.split(':') ;
if(langTag.length == 2) {
if(splitCnt >= cols) {
splitCnt = 1 ;
html += '</tr><tr>' ;
} else
splitCnt++ ;
var langId = langTag[1] ;
var langUr = langUri[1] ;
html += '<td ' + wd + '>' + alink(safeurl(langUr), txt,"&#8251") + '&nbsp;' +
alink(scriptUrl + '?' + langUr, langId,langId) + '</td>' ;
}
}
html += '</tr></table>' ;
return html ;
}
function makeTask() {
var html = '<table width="100%"><tr><td valign="top" width="33%">' ;
var capital = "?" ;
var heading ;
for(i in task.lnk)
if(!lang.lnk[i]) count++ ;
if(count > 0) {
var splitCnt = 0 ;
for(i in task.lnk)
if(!lang.lnk[i]) {
splitCnt++ ;
var lnk = rosettaUrl + i ;
var txt = task.lnk[i] ;
heading = capital ;
capital = txt.charAt(0) ;
if(splitCnt*3 > count + 2) {
splitCnt = 0 ;
html += '</ul></td><td valign="top" width="33%">'
if(capital == heading)
html += '<h3>' + heading + ' cont.<h3><ul>' ;
}
if(heading.charAt(0) != capital.charAt(0)) {
if(heading != "?")
html += '</ul>'
html += '<h3>' + capital + '<h3><ul>'
}
html += '<li>' + alink(lnk, txt, txt) + '</li>' ;
}
html += '</ul>' ;
} else
return "" ;
html += '</td></tr></table><br />' ;
return html ;
}</javascript>
&lt;/script&gt;
&lt;!-- from http://examples.oreilly.com/jscript5/ , unused parts removed--&gt;
&lt;script&gt;
<javascript>/**
* http.js: utilities for scripted HTTP requests
*
* From the book JavaScript: The Definitive Guide, 5th Edition,
* by David Flanagan. Copyright 2006 O'Reilly Media, Inc. (ISBN: 0596101996)
*/
 
if($langID != NA && $lang->ok && $task->ok) {
// Make sure we haven't already been loaded
linkText($lang->hdr, 'Not Completed Tasks by ', $lang->url, $IDLang, NULL) ;
var HTTP;
linkText($lang->hdr, ' ( ', ScriptURL(NA), 'Other Languages', ' ) ') ;
if (HTTP && (typeof HTTP != "object" || HTTP.NAME))
throw new Error("Namespace 'HTTP' already exists");
 
process_task() ;
// Create our namespace, and specify some meta-information
echo $lang->toHTML() ;
HTTP = {};
} else {
HTTP.NAME = "HTTP"; // The name of this namespace
$list = new Page(pageURL(ListURL), 'mw-subcategories') ;
HTTP.VERSION = 1.0; // The version of this namespace
if($list->ok) {
 
if($langID == NA)
// This is a list of XMLHttpRequest creation factory functions to try
$list->hdr->nodeValue = 'Not Completed Tasks by Languages' ;
HTTP._factories = [
else {
function() { return new XMLHttpRequest(); },
$list->hdr->removeChild($list->hdr->lastChild) ;
function() { return new ActiveXObject("Msxml2.XMLHTTP"); },
linkText($list->hdr, 'Not Completed Tasks by Languages ( "',
function() { return new ActiveXObject("Microsoft.XMLHTTP"); }
$lang->url, $IDLang, '" hasn\'t any task completed yet ) ') ;
];
 
// When we find a factory that works, store it here
HTTP._factory = null;
 
/**
* Create and return a new XMLHttpRequest object.
*
* The first time we're called, try the list of factory functions until
* we find one that returns a nonnull value and does not throw an
* exception. Once we find a working factory, remember it for later use.
*/
HTTP.newRequest = function() {
if (HTTP._factory != null)
return HTTP._factory();
 
for(var i = 0; i < HTTP._factories.length; i++) {
try {
var factory = HTTP._factories[i];
var request = factory();
if (request != null) {
HTTP._factory = factory;
return request;
}
}
catch(e) {
continue;
}
process_list() ;
echo $list->toHTML() ;
}
else
 
echo '<html><body><br/><br/>
// If we get here, none of the factory candidates succeeded,
<h3 align=center>Unknown Error,
// so throw an exception now and for all future calls.
<a href="' . ROSETTA . '">Return Rosetta Code Main Page</a> or
HTTP._factory = function() {
<a href="javascript:history.go(-1) ;">Go Back</a>.
throw new Error("XMLHttpRequest not supported");
</h3>
}
</body></html>' ;
HTTP._factory(); // Throw an error
}
?></php>
 
/**
* Use XMLHttpRequest to fetch the contents of the specified URL using
* an HTTP GET request. When the response arrives, pass it (as plain
* text) to the specified callback function.
*
* This function does not block and has no return value.
*/
HTTP.getText = function(url, callback) {
var request = HTTP.newRequest();
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200)
callback(request.responseText);
}
request.open("GET", url);
request.send(null);
};</javascript>
&lt;/script&gt;
&lt;body onLoad="process();" &gt;
&lt;table width="100%"&gt;
&lt;tr&gt;&lt;td valign=top&gt;&lt;div id="tasklist"&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;hr /&gt;&lt;td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign=top&gt;&lt;div id="langlist"&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
|}
Hope it can be a temporary solution. -- [[User:Badmadevil|badmadevil]] 0212:5233, 1422 June 2008 (MDTUTC)