Growing stuff and doing things

dstroy0

Zeroes and Ones
Yeah, it's a little over the top for what you need. I just deal with PHP that looks like what you have all day long, and it makes the hair on my neck raise up.

No judgement towards you at all -- for context, the codebase I work with was written by "PHP professionals" and more so resembles what a freshman in CS would write. How's that saying go? Make it work, make it fast, make it pretty or something like that... If it's doing what you need, then it's not a big deal.

On that note, Python has a library called BeautifulSoup4 that is fantastic for generating HTML, and has the added benefit of not catching the hate that PHP does. Not sure if you've worked with python at all, but I could throw you some code samples to get an idea of how easy it'd be to switch over (wrote a small app specifically to separate PHP, HTML, CSS, and JS into separate files, and reconstruct the HTML accordingly).

Did you look at the table generator? The php table code should be very readable after I implement that. What would I be scraping with beautifulsoup? Side note, I've already started separating everything into its own file.
 

coste

In Bloom
Did you look at the table generator? The php table code should be very readable after I implement that. What would I be scraping with beautifulsoup? Side note, I've already started separating everything into its own file.

You don't necessarily have to scrape with BS, you can generate HTML with it too. It's just an overall DOM library. That being said, I've only explored minimal functionality of it, it's really robust. Also, I haven't looked at the PHP table generator yet, but certainly will!
 

dstroy0

Zeroes and Ones
Figuring out how to recolor cells on the fly
1596993650095.png

JavaScript:
function cell_color(id, red_low, yellow_low, yellow_high, red_high){
    var cell_value = document.getElementById(id).textContent;
    cell_value = parseFloat(cell_value * 1);
    console.warn(cell_value);
    if (cell_value < yellow_high && cell_value > yellow_low) {
        //return;
        console.warn("nom");
    }
    if (cell_value < red_low || cell_value > red_high) {
        document.getElementById("RES_pH").setAttribute('style', 'color: white !important; background: red; opacity: 0.75;');
        //return;
        console.warn("red");
    }
    if ((cell_value < yellow_low && cell_value > red_low) || (cell_value > yellow_high  && cell_value < red_high)) {
        document.getElementById(id).setAttribute('style', 'color: black !important; background: yellow; opacity: 0.75;');
        console.warn(id, " yellow");
    }
    
    return document.getElementById(id).value;
}

function recolor_cells() {
document.getElementById("RES_pH").onchange= cell_color("RES_pH", 5.6, 5.85, 5.95, 6.1);
}
 

dstroy0

Zeroes and Ones
I think it's probably time to switch to a relational schema, but I think I need to figure out how to write CTEs in SQL to join tables before I try that. My database is at 168 columns now, probably half of those are config columns that only get populated once, so they're just there doing nothing. I think that I figured out a good way to attach/detach columns from my log daemon script:

Python:
#open file for reading 'r'
column_file = open('columns.csv', 'r')
#read contents of file
content = column_file.read()
#remove all newline
content = content.replace('\n', '')
#remove all spaces
content = content.replace(' ', '')
#split list item on comma
content_list = content.split(',')
#close file after done using
column_file.close()
#print(content_list, len(content_list))
#use sql query to get existing columns, compare against list create if not exists
#reject all other columns, log to error_columns.csv
#allow user to create columns for tables on the fly by adding columns to the tables' columns.csv
 
Top Bottom