Advertisement
Guest User

specked

a guest
Oct 20th, 2010
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     $(function() {
  2.            
  3.         function formatResults(item){
  4.             if(item.currentRotation == "1st"){
  5.                 currLocation = item.firstRotationLocation;
  6.                 offset = item.firstRotationAL.substring(item.firstRotationAL.indexOf("PERSON_ID")+14,item.firstRotationAL.indexOf("',FIRST_NAME"));
  7.                 offset = offset.length+3;
  8.                 currAL = item.firstRotationAL
  9.                     .substring(item.firstRotationAL.indexOf("PERSON_ID"),item.firstRotationAL.indexOf("size"));
  10.                 currAL = currAL.split("'");
  11.                 currAL[0] = item.firstRotationAL.substring(item.firstRotationAL.indexOf("id=")+offset,item.firstRotationAL.indexOf("id=")+offset+9);
  12.                 currAL = currAL[5] + ", " + currAL[3] + " (" + currAL[0] + ")";
  13.                 latlong = item.firstlatlong;
  14.             }
  15.             else if(item.currentRotation == "2nd"){
  16.                 currLocation = item.secondRotationLocation
  17.                 offset = item.secondRotationAL.substring(item.secondRotationAL.indexOf("PERSON_ID")+14,item.secondRotationAL.indexOf("',FIRST_NAME"));
  18.                 offset = offset.length+3;              
  19.                 currAL = item.secondRotationAL
  20.                     .substring(item.secondRotationAL.indexOf("PERSON_ID"),item.secondRotationAL.indexOf("size"));
  21.                 currAL = currAL.split("'");
  22.                 currAL[0] = item.secondRotationAL.substring(item.secondRotationAL.indexOf("id=")+offset,item.secondRotationAL.indexOf("id=")+offset+9);
  23.                 currAL = currAL[5] + ", " + currAL[3] + " (" + currAL[0] + ")";
  24.                 latlong = item.secondlatlong;
  25.                 }
  26.             else if(item.currentRotation == "3rd"){
  27.                 currLocation = item.thirdRotationLocation
  28.                 offset = item.thirdRotationAL.substring(item.thirdRotationAL.indexOf("PERSON_ID")+14,item.thirdRotationAL.indexOf("',FIRST_NAME"));
  29.                 offset = offset.length+3;              
  30.                 currAL = item.thirdRotationAL
  31.                     .substring(item.thirdRotationAL.indexOf("PERSON_ID"),item.thirdRotationAL.indexOf("size"));                
  32.                 currAL = currAL.split("'");
  33.                 currAL[0] = item.thirdRotationAL.substring(item.thirdRotationAL.indexOf("id=")+offset,item.thirdRotationAL.indexOf("id=")+offset+9);
  34.                 currAL = currAL[5] + ", " + currAL[3] + " (" + currAL[0] + ")";
  35.                 latlong = item.thirdlatlong;
  36.                 }
  37.             else if(item.currentRotation == "4th"){
  38.                 currLocation = item.fourthRotationLocation
  39.                 offset = item.fourthRotationAL.substring(item.fourthRotationAL.indexOf("PERSON_ID")+14,item.fourthRotationAL.indexOf("',FIRST_NAME"));
  40.                 offset = offset.length+3;              
  41.                 currAL = item.fourthRotationAL
  42.                     .substring(item.fourthRotationAL.indexOf("PERSON_ID"),item.fourthRotationAL.indexOf("size"));
  43.                 currAL = currAL.split("'");
  44.                 currAL[0] = item.fourthRotationAL.substring(item.fourthRotationAL.indexOf("id=")+offset,item.fourthRotationAL.indexOf("id=")+offset+9);
  45.                 currAL = currAL[5] + ", " + currAL[3] + " (" + currAL[0] + ")";
  46.                 latlong = item.fourthlatlong;
  47.                 }
  48.             else{ currLocation = "Location information not available"
  49.             alert(item.toString());
  50.                 };     
  51. };
  52.             $("#_results").focus(function() {
  53.                 if(!($(this).val()=="Loading....Please wait")){
  54.                     $(this).val("");
  55.                 }
  56.             });
  57.             $("#_results").blur(function() {
  58.                 if($(this).val()=="") {
  59.                     $(this).val("Search by Name, Location, Project or Keyword");
  60.                 }
  61.         });
  62.         var currLocation = "";
  63.         var currAL = "";
  64.         var imlpName = "";
  65.         var offset = "";
  66.         var latlong = "";
  67.             function log(message) {
  68.                 $("<div/>").text(message).appendTo("#log");
  69.                 $("#log").attr("scrollTop", 0);
  70.         }
  71.     $("#_results").addClass( "ui-autocomplete-loading" );
  72.     $("#_results").val( "Loading....Please wait" );
  73.         $.ajax({
  74.             url: "sup_dataform_viewall.asp.xml",
  75.             dataType: "xml",
  76.             success: function(xmlResponse) {
  77.                 var data = $("ROW", xmlResponse).map(function() {
  78.                     return {
  79.                          value: $("SC_DF_FIELD_35", this).text().replace(/&nbsp;/g,"").substring($("SC_DF_FIELD_35", this).text().indexOf("FIRST_NAME")+15,$("SC_DF_FIELD_35", this).text().indexOf("LAST_NAME")-2) + " " + $("SC_DF_FIELD_35", this).text().replace(/&nbsp;/g,"").substring($("SC_DF_FIELD_35", this).text().indexOf("LAST_NAME")+11,$("SC_DF_FIELD_35", this).text().indexOf(" size")-4) + " " + $("SC_DF_FIELD_1", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_2", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_3", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_4", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_5", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_6", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_7", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_8", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_9", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_10", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_11", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_12", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_13", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_14", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_15", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_16", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_17", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_18", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_19", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_20", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_21", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_22", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_24", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_26", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_28", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_26", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_27", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_28", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_29", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_30", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_31", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_32", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_33", this).text().replace(/&nbsp;/g,"") + " " + $("SC_DF_FIELD_34", this).text().replace(/&nbsp;/g,"") + $("SC_DF_SSO", this).text().replace(/&nbsp;/g,"").substring(0,9),
  80.                          college: $("SC_DF_FIELD_1", this).text().replace(/&nbsp;/g,""),
  81.                          fourthRotationTeam: $("SC_DF_FIELD_2", this).text().replace(/&nbsp;/g,""),
  82.                          thirdRotationTeam: $("SC_DF_FIELD_3", this).text().replace(/&nbsp;/g,""),
  83.                          secondRotationTeam: $("SC_DF_FIELD_4", this).text().replace(/&nbsp;/g,""),
  84.                          firstRotationTeam: $("SC_DF_FIELD_5", this).text().replace(/&nbsp;/g,""),
  85.                          fourthRotationBus: $("SC_DF_FIELD_6", this).text().replace(/&nbsp;/g,""),
  86.                          thirdRotationBus: $("SC_DF_FIELD_7", this).text().replace(/&nbsp;/g,""),
  87.                          secondRotationBus: $("SC_DF_FIELD_8", this).text().replace(/&nbsp;/g,""),
  88.                          firstRotationBus: $("SC_DF_FIELD_9", this).text().replace(/&nbsp;/g,""),
  89.                          fourthRotationType: $("SC_DF_FIELD_10", this).text().replace(/&nbsp;/g,""),
  90.                          thirdRotationType: $("SC_DF_FIELD_11", this).text().replace(/&nbsp;/g,""),
  91.                          secondRotationType: $("SC_DF_FIELD_12", this).text().replace(/&nbsp;/g,""),
  92.                          firstRotationType: $("SC_DF_FIELD_13", this).text().replace(/&nbsp;/g,""),
  93.                          fourthRotationDR: $("SC_DF_FIELD_14", this).text().replace(/&nbsp;/g,""),
  94.                          thirdRotationDR: $("SC_DF_FIELD_15", this).text().replace(/&nbsp;/g,""),
  95.                          secondRotationDR: $("SC_DF_FIELD_16", this).text().replace(/&nbsp;/g,""),
  96.                          firstRotationDR: $("SC_DF_FIELD_17", this).text().replace(/&nbsp;/g,""),
  97.                          fourthRotationAL: $("SC_DF_FIELD_18", this).text().replace(/&nbsp;/g,""),
  98.                          thirdRotationAL: $("SC_DF_FIELD_19", this).text().replace(/&nbsp;/g,""),
  99.                          secondRotationAL: $("SC_DF_FIELD_20", this).text().replace(/&nbsp;/g,""),
  100.                          firstRotationAL: $("SC_DF_FIELD_21", this).text().replace(/&nbsp;/g,""),
  101.                          firstRotationLocation: $("SC_DF_FIELD_22", this).text().replace(/&nbsp;/g,""),
  102.                          firstlatlong:$("SC_DF_FIELD_23", this).text().replace(/&nbsp;/g,""),
  103.                          secondRotationLocation: $("SC_DF_FIELD_24", this).text().replace(/&nbsp;/g,""),
  104.                          secondlatlong:$("SC_DF_FIELD_25", this).text().replace(/&nbsp;/g,""),
  105.                          thirdRotationLocation: $("SC_DF_FIELD_36", this).text().replace(/&nbsp;/g,""),
  106.                          thirdlatlong:$("SC_DF_FIELD_37", this).text().replace(/&nbsp;/g,""),
  107.                          fourthRotationLocation: $("SC_DF_FIELD_38", this).text().replace(/&nbsp;/g,""),
  108.                          fourthlatlong:$("SC_DF_FIELD_39", this).text().replace(/&nbsp;/g,""),
  109.                          firstMajProj: $("SC_DF_FIELD_26", this).text().replace(/&nbsp;/g,""),
  110.                          secondMajProj: $("SC_DF_FIELD_27", this).text().replace(/&nbsp;/g,""),
  111.                          thirdMajProj: $("SC_DF_FIELD_28", this).text().replace(/&nbsp;/g,""),
  112.                          fourthMajProj: $("SC_DF_FIELD_29", this).text().replace(/&nbsp;/g,""),
  113.                          firstRotationCommittees: $("SC_DF_FIELD_30", this).text().replace(/&nbsp;/g,""),
  114.                          secondRotationCommittees: $("SC_DF_FIELD_31", this).text().replace(/&nbsp;/g,""),
  115.                          thirdRotationCommittees: $("SC_DF_FIELD_32", this).text().replace(/&nbsp;/g,""),
  116.                          fourthRotationCommittees: $("SC_DF_FIELD_33", this).text().replace(/&nbsp;/g,""),
  117.                          currentRotation: $("SC_DF_FIELD_34", this).text().replace(/&nbsp;/g,""),
  118.                          imlpName: $("SC_DF_FIELD_35", this).text().replace(/&nbsp;/g,""),
  119.                          sso: $("SC_DF_SSO", this).text().replace(/&nbsp;/g,"").substring(0,9),
  120.                          dataformEntry: $("ENTRY_VIEW_URL", this).text()
  121.                     };
  122.                 }).get(data);
  123.         $("#_results").removeClass( "ui-autocomplete-loading" );
  124.         $("#_results").val( "Search by Name, Location, Project or Keyword" );
  125.                 $("#_results").autocomplete({
  126.                     source: data,
  127.                     minLength: 0,
  128.                     select: function(event, ui) {
  129.                         $("#log").empty();
  130.                         $("#log").unbind("click");
  131.                         formatResults(ui.item);
  132.                         imlpName = ui.item.imlpName.split("'");
  133.                         imlpName = imlpName[5] + ", " + imlpName[3];
  134.                         log(imlpName + " " + ui.item.sso);
  135.                         log("Currently in " + ui.item.currentRotation + " rotation" + " located in " + currLocation);
  136.                         log("Graduated from: " + ui.item.college);
  137.                         log("Current AL is: " + currAL);
  138.                         log("--------------------------------------------------------");
  139.                         log("More details can be viewed by clicking here");
  140.                         $("#log").bind("click", function() {
  141.                             window.open(ui.item.dataformEntry, "_blank");
  142.                         });
  143.  
  144.                     }              
  145.                 }).data( "autocomplete" )._renderItem = function( ul, item ) {
  146.  
  147.                         imlpName = item.imlpName.split("'");
  148.                         imlpName = imlpName[5] + ", " + imlpName[3];
  149.                     formatResults(item);
  150.                     return $( "<li></li>" )
  151.                     .data( "item.autocomplete", item )
  152.                     .append( "<a> <span class='apptitle'>" + imlpName + "</span> <br />" + "<span class='descrip'> SSO: " + item.sso + "<br />" + "Current location: " + currLocation + "<br />" + "AL: " + currAL + "</span></a> <br /> <hr width='80%' align='center'>")
  153.                     .appendTo( ul )
  154.                
  155.                 };
  156.             }
  157.         });
  158.         };
  159.  
  160.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement