Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. 1074;#Fring,, Gustavo (US - New Mexico),#i:0ǵ.t|adfs|gfring,#gfring@LPH.com,#gfring@lph.com,#Fring,, Gustavo (US - New Mexico);#11903;#Rodarte-Quaylet,, Lydia (US - Houston),#i:0#.w|atremalrquaylet,#lrquaylet@madrigal.com,#,#,, Rodarte-Quaylet,, Lydia (US - Houston)
  2.  
  3. function selfToArray(input, inputArray, splitter) {
  4. var values = {}
  5. var splitby = splitter || ';'
  6. if (input.indexOf( splitby ) >= 0) {
  7. var input_split_array = input.split( splitby )
  8. if (input_split_array.length) {
  9. if ( input_split_array[1].charAt(0) == '#') {
  10. for (var i = 0; i < input_split_array.length ; i++) {
  11. if (i % 2 !== 0) { //check if odd
  12. values.data = input_split_array[i].replace('#', '')
  13. inputArray.push( values );
  14. }
  15. else { //if even
  16. //values.id = input_split_array[i].replace('#', '') //currently not used
  17. }
  18. }
  19. }
  20. }
  21. }
  22. }
  23.  
  24. function getAuthor(input, inputArray ) {
  25. var author = {};
  26. if (input.indexOf( ',,' ) >= 0) input = input.replace(/,,/g, 'dummyvalue'); //used for identifying the name later on
  27. var arr = input.split(',#')
  28. for(var i=0; i < arr.length; i++) {
  29. if (arr[i].indexOf("dummyvalue") >= 0) { //find section containing the name
  30. arr[i] = arr[i].replace('dummyvalue',',')
  31. if (arr[i].indexOf(" (") >= 0) { //if author name contains location, such as: Fring,, Gustavo (US - New Mexico)
  32. author.name = arr[i].split(' (')[0]
  33. author.location = arr[i].split(' (')[1]
  34. }
  35. else {
  36. author.name = arr[i][0]
  37. }
  38. }
  39. else if (arr[i].indexOf("@") >= 0) { //find section with email
  40. author.email = arr[i]
  41. author.sip = arr[i]
  42. author.username = arr[i].split('@')[0].toLowerCase()
  43. }
  44. else if (arr[i].indexOf("adfs") >= 0) {
  45. author.login = arr[i]
  46. }
  47. }
  48. inputArray.push( author );
  49. }
  50.  
  51. function grabPerson( author_raw ) {
  52. var result_container = ''
  53. var filterArray = []; //for storing the data after the ID separation
  54. var userinfoArray = []; //for collecting the results of processing this data
  55. selfToArray( author_raw, filterArray ) //separate ID, keep the rest in the new array
  56. if (filterArray.length) {
  57. for (var i = 0; i < (filterArray.length); i++) {
  58. getAuthor( filterArray[i].data, userinfoArray ) //transform userinfo into array
  59. }
  60. }
  61. if (userinfoArray.length) {
  62. result_container += '<ul class="persons_container">'
  63. for (var i = 0; i < (userinfoArray.length); i++) {
  64. var profilesizing = 0 //could utilize 'i' for gradual size increase/decrease
  65. var author_location = userinfoArray[i].location || ""
  66. if (author_location) author_location = " (" + author_location
  67. var author_name = userinfoArray[i].name + author_location
  68. if (author_name) {
  69. var result_person = userTile( userinfoArray[i].email, author_name, "inline", profilesizing, author_location)
  70. result_container += result_person
  71. }
  72. }
  73. result_container += '<div style="display: block; clear: both;"></div>'
  74. result_container += '</ul>'
  75. return result_container //the results are collected and only later added to the DOM, in a single operation.
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement