Environment: Ubuntu 25.04 with SSH access
Starting Point: Logged in as Root User on a new installation
| /** | |
| * Converts a string to a CSS-ready color representation. | |
| * | |
| * Consistent per string: Each unique string always returns the same color. | |
| * Distinct colors: Different strings usually yield noticeably different hues. | |
| * Readable range: By fixing lightness and saturation ranges, it avoids too-light (like #F3F3F3) or too-dark values. | |
| * Easily adjustable: You can tweak saturation/lightness ranges for your theme—e.g., use slightly darker tones for dark backgrounds. | |
| * | |
| * @param str String input to be converted to a color | |
| * @param as optional string to specify output format: 'hsl' (default), 'rgb' or 'hex' |
| class htmlSelect2BulmaDropownWithFilter { | |
| constructor(HTMLSelectElement_or_ElementId) { | |
| this.selectElement = (typeof (HTMLSelectElement_or_ElementId) == "string") ? document.getElementById(HTMLSelectElement_or_ElementId) : HTMLSelectElement_or_ElementId; | |
| if (this.originalOptions == null) { | |
| this.originalOptions = Array.from(this.selectElement.options).map(option => ({ value: option.value, text: option.text })); | |
| } | |
| this.options = Array.from(this.selectElement.options).map(option => ({ value: option.value, text: option.text })); //selectElement.options; | |
| this.filter = ""; | |
| this.filteredOptions = []; | |
| this.selectElement.parentElement.querySelectorAll('.dropdown').forEach(dropdownElement => { |
| /** | |
| * Validate and clean a DEA Registration ID | |
| * @param string $enteredValue user supplied DEA ID | |
| * @param string $lastname OPTIONAL extended validation requires first letter of users last name to match corresponding character in ID | |
| * | |
| * @return string|bool returns sanitized alphanumeric DEA Registration ID or FALSE | |
| */ | |
| function cleanDEA(string $enteredValue, string $lastname = '') { | |
| //if a " Supervisee Identifier" was supplied, just ignore it |
| <?php | |
| /** | |
| * Read a CSV File an convert to JSON object | |
| * Assumes first row is header data with column titles | |
| * For Google Sheets, publish the sheet in csv format and use the provided URL | |
| */ | |
| function csv2json($url) { | |
| $csv = file_get_contents($url); | |
| $rows = array_map("str_getcsv", explode("\n", $csv)); | |
| $result = array(); |
| /** | |
| * display a quick notification box that slides up from the bottom for a few seconds | |
| */ | |
| function quickNotice(message,cssClass,timeOnScreen) | |
| { | |
| cssClass = (cssClass) ? cssClass : 'is-success'; | |
| timeOnScreen = (timeOnScreen) ? timeOnScreen : 3000; | |
| var html = '<div id="quickNotice" style="position: absolute; z-index: 100; width: 100%" class="notification has-text-centered has-text-weight-semibold '+cssClass+'">'; | |
| html+= message; |
| var escEvents = new Array(); | |
| // If something needs to listen for the "ESC" key to be pressed, pass that functionality here | |
| // eventName STRING a name for this event, like "myPopupDialog" | |
| // eventFunction FUNCTION what to do when the user hits the escape key | |
| function setEscEvent(eventName, eventFunction){ | |
| escEvents.push({ eventName: eventName, eventFunction: eventFunction }); | |
| } | |
| // When an item doesn't need to listen for the "ESC" key anymore, remove it |
| <?php | |
| /** | |
| * set the server directory that this application is stored in. | |
| * if applicaiton is in the root directory, set to "/" | |
| */ | |
| $_app_server_path = rtrim(str_replace('\\', '/', dirname(__FILE__)),"/")."/"; // eg: "/home/ubuntu/workspace/my-website/" | |
| $web_app_path = str_replace(rtrim($_SERVER['DOCUMENT_ROOT'],"/"),'',$_app_server_path); // eg: "/my-website/" or just "/" if in root |
| // make all user uploaded images responsive | |
| $(".user_uploaded_content_wrapper img").each(function(){ | |
| var oldWidth = ($(this).width() > 0) ? $(this).width()+"px" : '100%'; | |
| $(this).css({width:'100%', height:'auto', maxWidth:oldWidth}); | |
| }); |