// version: 2017-11-25 /** * o--------------------------------------------------------------------------------o * | This file is part of the RGraph package - you can learn more at: | * | | * | http://www.rgraph.net | * | | * | RGraph is licensed under the Open Source MIT license. That means that it's | * | totally free to use and there are no restrictions on what you can do with it! | * o--------------------------------------------------------------------------------o */ /** * Initialise the various objects */ RGraph = window.RGraph || {isRGraph: true}; RGraph.CSV = function (url, func) { var RG = RGraph, ua = navigator.userAgent, ma = Math; /** * Some default values */ this.url = url; this.ready = func; this.data = null; this.numrows = null; this.numcols = null; this.seperator = arguments[2] || ','; this.endofline = arguments[3] || /\r?\n/; this.uid = RGraph.createUID(); /** * A Custom split function * * @param string str The CSV string to split * @param mixed char The character to split on - or it can also be an object like this: * { * preserve: false, // Whether to preserve whitespace * char: ',' // The character to split on * } */ this.splitCSV = function (str, split) { // Defaults var arr = []; var field = ''; var inDoubleQuotes = false; var inSingleQuotes = false; var preserve = (typeof split === 'object' && split.preserve) ? true : false; // The character to split the CSV string on if (typeof split === 'object') { if (typeof split.char === 'string') { split = split.char; } else { split = ','; } } // If not an object just leave the char as it's supplied for (var i=0,len=str.length; i