// o---------------------------------------------------------------------------------o // | This file is part of the RGraph package - you can learn more at: | // | | // | https://www.rgraph.net/license.html | // | | // | RGraph is dual-licensed under the Open Source GPL license. That means that it's | // | free to use and there are no restrictions on what you can use RGraph for! | // | If the GPL license does not suit you however, then there's an inexpensive | // | commercial license option available. See the URL above for more details. | // o---------------------------------------------------------------------------------o // // Initialise the various objects // window.RGraph = window.RGraph || {isrgraph:true,isRGraph: true,rgraph:true}; window.RGraph.HTMLTable = {}; // Module pattern (function (win, doc, undefined) { // // This function has been taken out of the RGraph.common.core.js file to // enable the table reader to work standalone. // RGraph.HTMLTable.AJAX = function () { var args = RGraph.HTMLTable.getArgs(arguments, 'url,callback'); // Mozilla, Safari, ... if (win.XMLHttpRequest) { var httpRequest = new XMLHttpRequest(); // MSIE } else if (win.ActiveXObject) { var httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } httpRequest.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { this.__user_callback__ = args.callback; this.__user_callback__(this.responseText); } } httpRequest.open('GET', args.url, true); httpRequest.send(); }; // // Use the AJAX function above to fetch a string // RGraph.HTMLTable.AJAX.getString = function () { var args = RGraph.HTMLTable.getArgs(arguments, 'url,callback'); RGraph.HTMLTable.AJAX(args.url, function () { var str = String(this.responseText); args.callback(str); }); }; RGraph.HTMLTable = function () { // // The fetch function that starts everythjing going // this.fetch = function () { // // Parse the HTML table for the data // this.parseTable(); // // Call the callback // this.callback(this); }; // // Parse the HTML table to get the data from it. If the tag // this.parseTable = function () { // Allow for string: ...
if (this.id.substr(0, 7) === 'string:') { this.id = this.id.substr(7); var template = doc.createElement('template'); html = this.id.trim(); // Never return a text node of whitespace as the result template.innerHTML = html; var table = template.content.firstChild; } else { var table = doc.getElementById(this.id.replace(/^#/,'')); } var rows = table.getElementsByTagName('tr'); // Loop thru the rows for (var i=0; i 0) { row = row.slice(0, length) // Negative length } else if (typeof length === 'number' && length < 0) { for (var i=0; i= 0) { for (var i=start; i 0) { col = col.slice(0, length) // Negative length } else if (typeof length === 'number' && length < 0) { for (var i=0; i