replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
This is a revised and expanded version of Transforming complex strings into simple arrays Transforming complex strings into simple arrays
This is a revised and expanded version of Transforming complex strings into simple arrays
This is a revised and expanded version of Transforming complex strings into simple arrays
function selfToArray(input, inputArray, splitter) {
var splitby = splitter || ';'
if (input.indexOf( splitby ) >==== 0-1 ) {
}
else {
var input_split_array = input.split( splitby )
if (input_split_array.length < 1 ) {
}
else if ( input_split_array[1].charAt(0) == '#') {
for (var i = 0; i < input_split_array.length ; i++) {
if (i % 2 !== 0) { //check if odd (even is the ID, no need for this now.)
inputArray.push( input_split_array[i].replace('#', '') )
}
}
}
}
} }
}
function getAuthor(input, inputArray ) {
var author = {};
if (input.indexOf( ',,' ) >= 0) input = input.replace(/,,/g, 'dummyvalue'); //used for identifying the name later on
var arr = input.split(',#')
for(var i=0; i < arr.length; i++) {
if (arr[i].indexOf("dummyvalue") >= 0) { //find section containing the name
arr[i] = arr[i].replace('dummyvalue',',')
if (arr[i].indexOf(" (") >= 0) { //if author name contains location, such as: Fring,, Gustavo (US - New Mexico)
author.name = arr[i].split(' (')[0]
author.location = arr[i].split(' (')[1]
}
else {
author.name = arr[i][0]
}
}
else if (arr[i].indexOf("@") >= 0) { //find section with email
author.email = arr[i]
author.sip = arr[i]
author.username = arr[i].split('@')[0].toLowerCase()
}
else if (arr[i].indexOf("adfs") >= 0) {
author.login = arr[i]
}
}
inputArray.push( author );
}
function grabPerson( author_raw ) {
var result_container = ''
var filterArray = []; //for storing the data after the ID separation
var userinfoArray = []; //for collecting the results of processing this data
selfToArray( author_raw, filterArray ) //separate ID, keep the rest in the new array
if (filterArray.length) {
for (var i = 0; i < (filterArray.length); i++) {
getAuthor( filterArray[i], userinfoArray ) //transform userinfo into array
}
}
if (userinfoArray.length) {
result_container += '<ul class="persons_container">'
for (var i = 0; i < (userinfoArray.length); i++) {
var profilesizing = 0 //could utilize 'i' for gradual size increase/decrease
var author_location = userinfoArray[i].location || ""
if (author_location) author_location = " (" + author_location
var author_name = userinfoArray[i].name + author_location
if (author_name) {
var result_person = userTile( userinfoArray[i].email, author_name, "inline", profilesizing, author_location)
result_container += result_person
}
}
result_container += '<div style="display: block; clear: both;"></div>'
result_container += '</ul>'
return result_container //the results are collected and only later added to the DOM, in a single operation.
}
}
function selfToArray(input, inputArray, splitter) {
var splitby = splitter || ';'
if (input.indexOf( splitby ) >= 0) {
var input_split_array = input.split( splitby )
if (input_split_array.length) {
if ( input_split_array[1].charAt(0) == '#') {
for (var i = 0; i < input_split_array.length ; i++) {
if (i % 2 !== 0) { //check if odd (even is the ID, no need for this now.)
inputArray.push( input_split_array[i].replace('#', '') )
}
}
}
}
}
}
function getAuthor(input, inputArray ) {
var author = {};
if (input.indexOf( ',,' ) >= 0) input = input.replace(/,,/g, 'dummyvalue'); //used for identifying the name later on
var arr = input.split(',#')
for(var i=0; i < arr.length; i++) {
if (arr[i].indexOf("dummyvalue") >= 0) { //find section containing the name
arr[i] = arr[i].replace('dummyvalue',',')
if (arr[i].indexOf(" (") >= 0) { //if author name contains location, such as: Fring,, Gustavo (US - New Mexico)
author.name = arr[i].split(' (')[0]
author.location = arr[i].split(' (')[1]
}
else {
author.name = arr[i][0]
}
}
else if (arr[i].indexOf("@") >= 0) { //find section with email
author.email = arr[i]
author.sip = arr[i]
author.username = arr[i].split('@')[0].toLowerCase()
}
else if (arr[i].indexOf("adfs") >= 0) {
author.login = arr[i]
}
}
inputArray.push( author );
}
function grabPerson( author_raw ) {
var result_container = ''
var filterArray = []; //for storing the data after the ID separation
var userinfoArray = []; //for collecting the results of processing this data
selfToArray( author_raw, filterArray ) //separate ID, keep the rest in the new array
if (filterArray.length) {
for (var i = 0; i < (filterArray.length); i++) {
getAuthor( filterArray[i], userinfoArray ) //transform userinfo into array
}
}
if (userinfoArray.length) {
result_container += '<ul class="persons_container">'
for (var i = 0; i < (userinfoArray.length); i++) {
var profilesizing = 0 //could utilize 'i' for gradual size increase/decrease
var author_location = userinfoArray[i].location || ""
if (author_location) author_location = " (" + author_location
var author_name = userinfoArray[i].name + author_location
if (author_name) {
var result_person = userTile( userinfoArray[i].email, author_name, "inline", profilesizing, author_location)
result_container += result_person
}
}
result_container += '<div style="display: block; clear: both;"></div>'
result_container += '</ul>'
return result_container //the results are collected and only later added to the DOM, in a single operation.
}
}
function selfToArray(input, inputArray, splitter) {
var splitby = splitter || ';'
if (input.indexOf( splitby ) === -1 ) {
}
else {
var input_split_array = input.split( splitby )
if (input_split_array.length < 1 ) {
}
else if ( input_split_array[1].charAt(0) == '#') {
for (var i = 0; i < input_split_array.length ; i++) {
if (i % 2 !== 0) { //check if odd (even is the ID, no need for this now.)
inputArray.push( input_split_array[i].replace('#', '') )
}
}
}
}
}
function getAuthor(input, inputArray ) {
var author = {};
if (input.indexOf( ',,' ) >= 0) input = input.replace(/,,/g, 'dummyvalue'); //used for identifying the name later on
var arr = input.split(',#')
for(var i=0; i < arr.length; i++) {
if (arr[i].indexOf("dummyvalue") >= 0) { //find section containing the name
arr[i] = arr[i].replace('dummyvalue',',')
if (arr[i].indexOf(" (") >= 0) { //if author name contains location, such as: Fring,, Gustavo (US - New Mexico)
author.name = arr[i].split(' (')[0]
author.location = arr[i].split(' (')[1]
}
else {
author.name = arr[i][0]
}
}
else if (arr[i].indexOf("@") >= 0) { //find section with email
author.email = arr[i]
author.sip = arr[i]
author.username = arr[i].split('@')[0].toLowerCase()
}
else if (arr[i].indexOf("adfs") >= 0) {
author.login = arr[i]
}
}
inputArray.push( author );
}
function grabPerson( author_raw ) {
var result_container = ''
var filterArray = []; //for storing the data after the ID separation
var userinfoArray = []; //for collecting the results of processing this data
selfToArray( author_raw, filterArray ) //separate ID, keep the rest in the new array
if (filterArray.length) {
for (var i = 0; i < (filterArray.length); i++) {
getAuthor( filterArray[i], userinfoArray ) //transform userinfo into array
}
}
if (userinfoArray.length) {
result_container += '<ul class="persons_container">'
for (var i = 0; i < (userinfoArray.length); i++) {
var profilesizing = 0 //could utilize 'i' for gradual size increase/decrease
var author_location = userinfoArray[i].location || ""
if (author_location) author_location = " (" + author_location
var author_name = userinfoArray[i].name + author_location
if (author_name) {
var result_person = userTile( userinfoArray[i].email, author_name, "inline", profilesizing, author_location)
result_container += result_person
}
}
result_container += '<div style="display: block; clear: both;"></div>'
result_container += '</ul>'
return result_container //the results are collected and only later added to the DOM, in a single operation.
}
}
function selfToArray(input, inputArray, splitter) {
var values = {}
var splitby = splitter || ';'
if (input.indexOf( splitby ) >= 0) {
var input_split_array = input.split( splitby )
if (input_split_array.length) {
if ( input_split_array[1].charAt(0) == '#') {
for (var i = 0; i < input_split_array.length ; i++) {
if (i % 2 !== 0) { //check if odd (even is the ID, no need values.datafor =this input_split_array[i]now.replace('#', '')
inputArray.push( values );
}
else { //if even
//values.id = input_split_array[i].replace('#', '') //currently not used)
}
}
}
}
}
}
function getAuthor(input, inputArray ) {
var author = {};
if (input.indexOf( ',,' ) >= 0) input = input.replace(/,,/g, 'dummyvalue'); //used for identifying the name later on
var arr = input.split(',#')
for(var i=0; i < arr.length; i++) {
if (arr[i].indexOf("dummyvalue") >= 0) { //find section containing the name
arr[i] = arr[i].replace('dummyvalue',',')
if (arr[i].indexOf(" (") >= 0) { //if author name contains location, such as: Fring,, Gustavo (US - New Mexico)
author.name = arr[i].split(' (')[0]
author.location = arr[i].split(' (')[1]
}
else {
author.name = arr[i][0]
}
}
else if (arr[i].indexOf("@") >= 0) { //find section with email
author.email = arr[i]
author.sip = arr[i]
author.username = arr[i].split('@')[0].toLowerCase()
}
else if (arr[i].indexOf("adfs") >= 0) {
author.login = arr[i]
}
}
inputArray.push( author );
}
function grabPerson( author_raw ) {
var result_container = ''
var filterArray = []; //for storing the data after the ID separation
var userinfoArray = []; //for collecting the results of processing this data
selfToArray( author_raw, filterArray ) //separate ID, keep the rest in the new array
if (filterArray.length) {
for (var i = 0; i < (filterArray.length); i++) {
getAuthor( filterArray[i].data, userinfoArray ) //transform userinfo into array
}
}
if (userinfoArray.length) {
result_container += '<ul class="persons_container">'
for (var i = 0; i < (userinfoArray.length); i++) {
var profilesizing = 0 //could utilize 'i' for gradual size increase/decrease
var author_location = userinfoArray[i].location || ""
if (author_location) author_location = " (" + author_location
var author_name = userinfoArray[i].name + author_location
if (author_name) {
var result_person = userTile( userinfoArray[i].email, author_name, "inline", profilesizing, author_location)
result_container += result_person
}
}
result_container += '<div style="display: block; clear: both;"></div>'
result_container += '</ul>'
return result_container //the results are collected and only later added to the DOM, in a single operation.
}
}
function selfToArray(input, inputArray, splitter) {
var values = {}
var splitby = splitter || ';'
if (input.indexOf( splitby ) >= 0) {
var input_split_array = input.split( splitby )
if (input_split_array.length) {
if ( input_split_array[1].charAt(0) == '#') {
for (var i = 0; i < input_split_array.length ; i++) {
if (i % 2 !== 0) { //check if odd values.data = input_split_array[i].replace('#', '')
inputArray.push( values );
}
else { //if even
//values.id = input_split_array[i].replace('#', '') //currently not used
}
}
}
}
}
}
function getAuthor(input, inputArray ) {
var author = {};
if (input.indexOf( ',,' ) >= 0) input = input.replace(/,,/g, 'dummyvalue'); //used for identifying the name later on
var arr = input.split(',#')
for(var i=0; i < arr.length; i++) {
if (arr[i].indexOf("dummyvalue") >= 0) { //find section containing the name
arr[i] = arr[i].replace('dummyvalue',',')
if (arr[i].indexOf(" (") >= 0) { //if author name contains location, such as: Fring,, Gustavo (US - New Mexico)
author.name = arr[i].split(' (')[0]
author.location = arr[i].split(' (')[1]
}
else {
author.name = arr[i][0]
}
}
else if (arr[i].indexOf("@") >= 0) { //find section with email
author.email = arr[i]
author.sip = arr[i]
author.username = arr[i].split('@')[0].toLowerCase()
}
else if (arr[i].indexOf("adfs") >= 0) {
author.login = arr[i]
}
}
inputArray.push( author );
}
function grabPerson( author_raw ) {
var result_container = ''
var filterArray = []; //for storing the data after the ID separation
var userinfoArray = []; //for collecting the results of processing this data
selfToArray( author_raw, filterArray ) //separate ID, keep the rest in the new array
if (filterArray.length) {
for (var i = 0; i < (filterArray.length); i++) {
getAuthor( filterArray[i].data, userinfoArray ) //transform userinfo into array
}
}
if (userinfoArray.length) {
result_container += '<ul class="persons_container">'
for (var i = 0; i < (userinfoArray.length); i++) {
var profilesizing = 0 //could utilize 'i' for gradual size increase/decrease
var author_location = userinfoArray[i].location || ""
if (author_location) author_location = " (" + author_location
var author_name = userinfoArray[i].name + author_location
if (author_name) {
var result_person = userTile( userinfoArray[i].email, author_name, "inline", profilesizing, author_location)
result_container += result_person
}
}
result_container += '<div style="display: block; clear: both;"></div>'
result_container += '</ul>'
return result_container //the results are collected and only later added to the DOM, in a single operation.
}
}
function selfToArray(input, inputArray, splitter) {
var splitby = splitter || ';'
if (input.indexOf( splitby ) >= 0) {
var input_split_array = input.split( splitby )
if (input_split_array.length) {
if ( input_split_array[1].charAt(0) == '#') {
for (var i = 0; i < input_split_array.length ; i++) {
if (i % 2 !== 0) { //check if odd (even is the ID, no need for this now.)
inputArray.push( input_split_array[i].replace('#', '') )
}
}
}
}
}
}
function getAuthor(input, inputArray ) {
var author = {};
if (input.indexOf( ',,' ) >= 0) input = input.replace(/,,/g, 'dummyvalue'); //used for identifying the name later on
var arr = input.split(',#')
for(var i=0; i < arr.length; i++) {
if (arr[i].indexOf("dummyvalue") >= 0) { //find section containing the name
arr[i] = arr[i].replace('dummyvalue',',')
if (arr[i].indexOf(" (") >= 0) { //if author name contains location, such as: Fring,, Gustavo (US - New Mexico)
author.name = arr[i].split(' (')[0]
author.location = arr[i].split(' (')[1]
}
else {
author.name = arr[i][0]
}
}
else if (arr[i].indexOf("@") >= 0) { //find section with email
author.email = arr[i]
author.sip = arr[i]
author.username = arr[i].split('@')[0].toLowerCase()
}
else if (arr[i].indexOf("adfs") >= 0) {
author.login = arr[i]
}
}
inputArray.push( author );
}
function grabPerson( author_raw ) {
var result_container = ''
var filterArray = []; //for storing the data after the ID separation
var userinfoArray = []; //for collecting the results of processing this data
selfToArray( author_raw, filterArray ) //separate ID, keep the rest in the new array
if (filterArray.length) {
for (var i = 0; i < (filterArray.length); i++) {
getAuthor( filterArray[i], userinfoArray ) //transform userinfo into array
}
}
if (userinfoArray.length) {
result_container += '<ul class="persons_container">'
for (var i = 0; i < (userinfoArray.length); i++) {
var profilesizing = 0 //could utilize 'i' for gradual size increase/decrease
var author_location = userinfoArray[i].location || ""
if (author_location) author_location = " (" + author_location
var author_name = userinfoArray[i].name + author_location
if (author_name) {
var result_person = userTile( userinfoArray[i].email, author_name, "inline", profilesizing, author_location)
result_container += result_person
}
}
result_container += '<div style="display: block; clear: both;"></div>'
result_container += '</ul>'
return result_container //the results are collected and only later added to the DOM, in a single operation.
}
}
default