Okay To start off this is my first post so I apologize initially for any "Newbie" mistakes I may Make. I will try to be Detailed as possible and lay it out as best I can.
What I Am doing:
Creating a Chrome App for Internal Company Use.
Issue:
Parsing Through an Ajax Call that contains full HTML Data from a loaded ajax call:
What I don't Have access to:
Server based PHP or MYSQL.
What I do have access to:
Full html data of all pages that contain the data that I need to loop through, as well as posting new data to server via put and get.
App Is already setup for permissions to access cross domain data so I will not run into issues with ajax and it cross domain policy. All data pulls successfully for pages I need to pull.
What I am Using: Jquery Javascript for things that may or not be supported or my lack of understanding of J Query as it is pretty robust and still trying to grasp the different api's available.
Problem:
I am able to load the ajax data with the html data I need. I have listed how the html looks after i have used Jquery "find" to locate the tbody within the html of the call I orginally made with ajax and what I filtered out so far. I also have it printing to consol.log(variablename) in the console of chrome. I have listed my goal for this data below the code. I am not worried about cross browser compatibility as this will be a chrome only app and other browsers will not be using the code.
<tbody>
<tr>
<td><strong>Header 1</strong></td>
<td><strong>Header 2</strong></td>
<td><strong>Header 3</strong></td>
<td><strong>Header 4</strong></td>
<td><strong>Header 5</strong></td>
<td><strong>Header 6</strong></td>
<td><strong>Header 7</strong></td>
</tr>
<tr >
<td>image location link</td>
<td>another link</td>
<td>Product</td>
<td>New</td>
<td></td>
<td>date</td>
<td></td>
<td>another link to an account</td>
</tr>
<tr>
<td>image location link</td>
<td>another link</td>
<td>Product2</td>
<td>New</td>
<td></td>
<td>date</td>
<td></td>
<td>another link to an account</td>
</tr>
<tr>
<td>image location link</td>
<td>another link</td>
<td>Product</td>
<td>old</td>
<td></td>
<td>date</td>
<td></td>
<td>another link to an account</td>
</tr>
</tbody>
Goal: The Tbody above will have more tr's then listed but is a sample of what is available. I would need to parse through the data each time and find each tr with td's that contain the Same product type and the td that has "New" Listed.
I really appreciate your guys help on this and look forward to hearing your responses.
What I have attempted using Jquery:
Trying to use contains and each loop to create a new data object. Instead of providing some horribly written code haha, I would like if someone can provide some great framework code that will help me get to the next level if possible.
Thanks In Advance!
So you can find for New or find or old and get rid of the old. It's up to you.
Here is another update that provides a second table. This should get you started. Basically it skips the first "tr" since that is the header and finds the rest that have New at the 4 position. Closest traverses up the dom to the first parent.
var data = $("#holder").html();
$("#newTable").append($(data).find("tr:eq(0)"));
$(data).find("tr:gt(0) :nth-child(4):contains('New')").closest('tr').each(function(index){
var row = "<tr>"+$(this).html()+"</tr>";
$("#newTable").append(row);
});
Something else you can do is set the html to that entire table and simple hide anything with old.