Parsing JSON table: hiding a row, changing color of word.

Parsing JSON table: hiding a row, changing color of word.

Hi all,

I am using jquery to convert a google spreadsheet to JSON that produces a HTML table.

I would like to:
- hide one of the rows that has the phrase "E9" in it.
- change the color of the phrase "C12" to red.

I have tried many scripts, but to no avail!

Here is the code I currently have.

Thank you very much!

  1. <html>
  2. <head>
  3.   <script src="https://code.jquery.com/jquery-3.1.0.js"></script>
  4.     <script>       
  5.       //google spreadsheet
  6.   var spData=null;function doData(a){spData=a.feed.entry}function drawCell(b,c,a){var d=$(a?"<th/>":"<td/>");b.append(d);d.append(c);return d}function drawRow(a,e,d){if(e==null){return null}if(e.length==0){return null}var b=$("<tr/>");if(d){b.addClass("head")}a.append(b);for(var f=0;f<e.length;f++){drawCell(b,e[f],((f==0)||d))}return b}function drawTable(a){var b=$("<table/>");a.append(b);return b}function readData(b){var f=spData;var d=drawTable(b);var e=[];var h=0;for(var c=0;c<f.length;c++){var a=f[c]["gs$cell"];var g=a["$t"];if(a.col==1){drawRow(d,e,(h==1));e=[];h++}e.push(g)}drawRow(d,e,(h==1))}$(document).ready(function(){readData($("#data"))});
  7.   
  8.    //Hide Row based on Phrase
  9.     $("#data tr:contains('E9')").hide ();
  10.       
  11.       //change color of phrase: C12
  12.       $('table').each(function(){
  13.    $(this).html(
  14.         $(this).html()
  15.        .replace(
  16.               /(?<!-)(\bC12\b)(?!([^<]+)?>)(?!-)/ig, 
  17.              '<span style="color:green;">$1</span>'
  18.         )
  19.     );
  20. });
  21.         
  22.   </script>
  23. </head>
  24. <body>
  25.   
  26. <script src="https://spreadsheets.google.com/feeds/cells/1LM353z3Q8EeYVC2Lpxta8p4U4QBP_ih8vzERA9dh_D4/1/public/values?alt=json-in-script&callback=doData">
  27.   </script>
  28.   
  29.   <div class="box-table" id="spreadsheet" style="overflow-x:auto!important;">
  30. <table id="data"></table>
  31. </div>

  32. </body>
  33. </html>