Bot-Factory 602 Posted March 19, 2014 Report Share Posted March 19, 2014 Hi. I'm looking for a way to format the content of a table into good looking HTML code.So that I can show it in the ubot browser via load HTML. The html table code could be like:<table border="2" bordercolor="F91E1E" style="background-color:EFEFEF" width="450" cellpadding="5" cellspacing="5"><tr><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td></tr><tr><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td></tr><tr><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td></tr></table> I'm looking for a define that is able to generate that HTML code dynamically depending on the amount of rows / columns in a table. Maybe someone has done something like that already? if not, I will start working on it. CheersDan Quote Link to post Share on other sites
blumi40 222 Posted March 19, 2014 Report Share Posted March 19, 2014 schau mal ob dir das was taugt schon lange nicht mehr benutzt... plugin command("Open.Framework_new.dll", "Structure Container", "JSON LIST") { clear list(%jsonlist) add list to list(%jsonlist, $list from text(#TABLE or LIST, $new line), "Don\'t Delete", "Local") clear list(%json_columnnames) add list to list(%json_columnnames, $list from text(#COLUMNNAMES, ","), "Don\'t Delete", "Global") clear list(%JSONLISTclean) set(#JSON recid name, "recid:", "Global") set(#JSON recid counter, 1, "Global") comment("HIER WERDEN DIE DATENSÄTZE ZUSAMMEN GEBAUT") loop($list total(%jsonlist)) { set(#list_record, $next list item(%jsonlist), "Global") clear list(%list_record) add list to list(%list_record, $list from text(#list_record, #SEPARATOR), "Don\'t Delete", "Local") set(#list_record_total, $list total(%list_record), "Global") set(#list_record_total_counter, 0, "Global") set(#jsonval, "\{{#JSON recid name} {#JSON recid counter},", "Global") set(#jsonval counter, 0, "Global") loop($list total(%list_record)) { set(#item, $list item(%list_record, #jsonval counter), "Global") if($comparison(#list_record_total, "=", #list_record_total_counter)) { then { } else { set(#jsonval, "{#jsonval}f{$change text casing($list item(%json_columnnames, #jsonval counter), "Lower Case")}: \"{#item}\", ", "Global") } } increment(#jsonval counter) increment(#list_record_total_counter) } set(#jsonval, "{#jsonval}\},", "Global") set(#jsonval, $replace(#jsonval, ", \}", "\}"), "Global") set(#jsonval, $replace(#jsonval, ",\}", "\}"), "Global") add item to list(%JSONLISTclean, #jsonval, "Don\'t Delete", "Global") set list position(%list_record, 0) increment(#JSON recid counter) } clear list(%jsonlist) clear list(%list_record) clear list(%json_tmp) set list position(%json_columnnames, 0) set(#jsonsize, $divide(100, $list total(%json_columnnames)), "Global") set(#jsonsize, "{#jsonsize}%", "Global") comment("HIER WERDEN DIE COLUMNS GEBAUT") set(#jsonval, "\{ field: 'recid', caption: 'ID', size: '50px', sortable: true \},", "Global") add item to list(%json_tmp, #jsonval, "Don\'t Delete", "Global") loop($list total(%json_columnnames)) { set(#json_col, $next list item(%json_columnnames), "Global") set(#jsonval, "\{field: 'f{$change text casing(#json_col, "Lower Case")}', caption: '{#json_col}', size:'{#jsonsize}',sortable: true, resizable: true, editable: \{ type: 'text' \}\},", "Global") add item to list(%json_tmp, #jsonval, "Don\'t Delete", "Global") set(#jsearch, "\{field: \'f{$change text casing(#json_col, "Lower Case")}\', caption: \'{#json_col}\', type:\'text\'\},", "Global") add item to list(%jsearch, #jsearch, "Delete", "Global") } set(#jsonval, %json_tmp, "Global") set(#jsearch, %jsearch, "Global") set(#jsonrec, %JSONLISTclean, "Global") set(#jsonval, "name: \'grid\', show: \{ toolbar: true, footer: true, toolbarAdd: true, toolbarDelete: true, toolbarSave: true, fixedBody: false, \}, toolbar: \{ onClick: function (target, data) \{console.log(target)\} \}, searches: [ {#jsearch} ], sortData: [\{ field: \'recid\', direction: \'ASC\' \}], columns: [ {#jsonval} ], records:[ {#jsonrec} ]", "Global") set(#JSONTEMPLATE, "<!DOCTYPE HTML> <html> <head> <meta charset=\"utf-8\"> <script src=\"http://skapps.webhop.net/incl/w2ui/jquery.min.js\"></script> <script src=\"http://code.jquery.com/ui/1.10.3/jquery-ui.js\"></script> <script src=\"http://skapps.webhop.net/incl/w2ui/w2ui-1.2.js\"></script> <link rel=\"stylesheet\" href=\"http://skapps.webhop.net/incl/w2ui/w2ui-1.2.css\" /> </head> <body> <div id=\"MyList\"></div> <script> $(function ()\{ $(\'#MyList\').w2grid(\{ {#jsonval} \}); var winheight = $(window).height(); $(\'#MyList\').css(\'height\', winheight-20); document.title = \'My List\'; \}); </script> </body> </html> ", "Global") set(#jsonrec, $nothing, "Global") set(#jsonval, $nothing, "Global") clear list(%JSONLISTclean) } Quote Link to post Share on other sites
Aymen 385 Posted March 19, 2014 Report Share Posted March 19, 2014 if you have my sqlite plugin you can use table to html function Quote Link to post Share on other sites
Bot-Factory 602 Posted March 19, 2014 Author Report Share Posted March 19, 2014 if you have my sqlite plugin you can use table to html functionI have that one. It's realy nice. The problem I have with that is, that it doesn't add any borders around the table cells. So it's a little bit hard for users to see what belongs to what. would that be something you could add Aymen? Dan Quote Link to post Share on other sites
jamesfar 15 Posted March 20, 2014 Report Share Posted March 20, 2014 @Blumi : how can i get this plugin : Open.Framework_new.dll ? Quote Link to post Share on other sites
blumi40 222 Posted March 20, 2014 Report Share Posted March 20, 2014 http://www.sendspace.com/file/39syyt 1 Quote Link to post Share on other sites
jamesfar 15 Posted March 20, 2014 Report Share Posted March 20, 2014 Thanks Blumi Quote Link to post Share on other sites
Bot-Factory 602 Posted March 21, 2014 Author Report Share Posted March 21, 2014 (edited) Ok, I wrote a short function to convert a table into a HTML table.You can change the look and feel of the table by just changing the html table options in the last "load html" command: define CreateTable { set(#tableHtml, $nothing, "Global") set(#RowPosition, 0, "Global") loop($table total rows(&reportingdata)) { set(#tableHtml, "{#tableHtml}<tr>", "Global") set(#Cellposition, 0, "Global") loop($table total columns(&reportingdata)) { set(#tableHtml, "{#tableHtml}<td>{$table cell(&reportingdata, #RowPosition, #Cellposition)}</td>", "Global") increment(#Cellposition) } set(#tableHtml, "{#tableHtml}</tr>", "Global") increment(#RowPosition) } load html("<table border=\"2\" bordercolor=\"F91E1E\" style=\"background-color:EFEFEF\" width=\"450\" cellpadding=\"5\" cellspacing=\"5\">{#tableHtml}</table> ")} CheersDan Edited March 21, 2014 by dan 3 Quote Link to post Share on other sites
the_way 52 Posted March 31, 2014 Report Share Posted March 31, 2014 Dan, everytime i look up something, you always have a post there with a handy solution! cheers Quote Link to post Share on other sites
Bot-Factory 602 Posted March 31, 2014 Author Report Share Posted March 31, 2014 Dan, everytime i look up something, you always have a post there with a handy solution! cheersI'm happy if some of my stuff helps. Have a nice dayDan Quote Link to post Share on other sites
Brutal 164 Posted November 20, 2014 Report Share Posted November 20, 2014 Ok, I wrote a short function to convert a table into a HTML table.You can change the look and feel of the table by just changing the html table options in the last "load html" command: define CreateTable { set(#tableHtml, $nothing, "Global") set(#RowPosition, 0, "Global") loop($table total rows(&reportingdata)) { set(#tableHtml, "{#tableHtml}<tr>", "Global") set(#Cellposition, 0, "Global") loop($table total columns(&reportingdata)) { set(#tableHtml, "{#tableHtml}<td>{$table cell(&reportingdata, #RowPosition, #Cellposition)}</td>", "Global") increment(#Cellposition) } set(#tableHtml, "{#tableHtml}</tr>", "Global") increment(#RowPosition) } load html("<table border=\"2\" bordercolor=\"F91E1E\" style=\"background-color:EFEFEF\" width=\"450\" cellpadding=\"5\" cellspacing=\"5\">{#tableHtml}</table> ")} CheersDanVery handy Dan - Thanks for that. Quote Link to post Share on other sites
Frank 177 Posted December 2, 2015 Report Share Posted December 2, 2015 schau mal ob dir das was taugt schon lange nicht mehr benutzt... plugin command("Open.Framework_new.dll", "Structure Container", "JSON LIST") { clear list(%jsonlist) add list to list(%jsonlist, $list from text(#TABLE or LIST, $new line), "Don\'t Delete", "Local") clear list(%json_columnnames) add list to list(%json_columnnames, $list from text(#COLUMNNAMES, ","), "Don\'t Delete", "Global") clear list(%JSONLISTclean) set(#JSON recid name, "recid:", "Global") set(#JSON recid counter, 1, "Global") comment("HIER WERDEN DIE DATENSÄTZE ZUSAMMEN GEBAUT") loop($list total(%jsonlist)) { set(#list_record, $next list item(%jsonlist), "Global") clear list(%list_record) add list to list(%list_record, $list from text(#list_record, #SEPARATOR), "Don\'t Delete", "Local") set(#list_record_total, $list total(%list_record), "Global") set(#list_record_total_counter, 0, "Global") set(#jsonval, "\{{#JSON recid name} {#JSON recid counter},", "Global") set(#jsonval counter, 0, "Global") loop($list total(%list_record)) { set(#item, $list item(%list_record, #jsonval counter), "Global") if($comparison(#list_record_total, "=", #list_record_total_counter)) { then { } else { set(#jsonval, "{#jsonval}f{$change text casing($list item(%json_columnnames, #jsonval counter), "Lower Case")}: \"{#item}\", ", "Global") } } increment(#jsonval counter) increment(#list_record_total_counter) } set(#jsonval, "{#jsonval}\},", "Global") set(#jsonval, $replace(#jsonval, ", \}", "\}"), "Global") set(#jsonval, $replace(#jsonval, ",\}", "\}"), "Global") add item to list(%JSONLISTclean, #jsonval, "Don\'t Delete", "Global") set list position(%list_record, 0) increment(#JSON recid counter) } clear list(%jsonlist) clear list(%list_record) clear list(%json_tmp) set list position(%json_columnnames, 0) set(#jsonsize, $divide(100, $list total(%json_columnnames)), "Global") set(#jsonsize, "{#jsonsize}%", "Global") comment("HIER WERDEN DIE COLUMNS GEBAUT") set(#jsonval, "\{ field: 'recid', caption: 'ID', size: '50px', sortable: true \},", "Global") add item to list(%json_tmp, #jsonval, "Don\'t Delete", "Global") loop($list total(%json_columnnames)) { set(#json_col, $next list item(%json_columnnames), "Global") set(#jsonval, "\{field: 'f{$change text casing(#json_col, "Lower Case")}', caption: '{#json_col}', size:'{#jsonsize}',sortable: true, resizable: true, editable: \{ type: 'text' \}\},", "Global") add item to list(%json_tmp, #jsonval, "Don\'t Delete", "Global") set(#jsearch, "\{field: \'f{$change text casing(#json_col, "Lower Case")}\', caption: \'{#json_col}\', type:\'text\'\},", "Global") add item to list(%jsearch, #jsearch, "Delete", "Global") } set(#jsonval, %json_tmp, "Global") set(#jsearch, %jsearch, "Global") set(#jsonrec, %JSONLISTclean, "Global") set(#jsonval, "name: \'grid\', show: \{ toolbar: true, footer: true, toolbarAdd: true, toolbarDelete: true, toolbarSave: true, fixedBody: false, \}, toolbar: \{ onClick: function (target, data) \{console.log(target)\} \}, searches: [ {#jsearch} ], sortData: [\{ field: \'recid\', direction: \'ASC\' \}], columns: [ {#jsonval} ], records:[ {#jsonrec} ]", "Global") set(#JSONTEMPLATE, "<!DOCTYPE HTML> <html> <head> <meta charset=\"utf-8\"> <script src=\"http://skapps.webhop.net/incl/w2ui/jquery.min.js\"></script> <script src=\"http://code.jquery.com/ui/1.10.3/jquery-ui.js\"></script> <script src=\"http://skapps.webhop.net/incl/w2ui/w2ui-1.2.js\"></script> <link rel=\"stylesheet\" href=\"http://skapps.webhop.net/incl/w2ui/w2ui-1.2.css\" /> </head> <body> <div id=\"MyList\"></div> <script> $(function ()\{ $(\'#MyList\').w2grid(\{ {#jsonval} \}); var winheight = $(window).height(); $(\'#MyList\').css(\'height\', winheight-20); document.title = \'My List\'; \}); </script> </body> </html> ", "Global") set(#jsonrec, $nothing, "Global") set(#jsonval, $nothing, "Global") clear list(%JSONLISTclean) } I know that this is a bit old, but what is it about? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.