UNIBASE

/usr/local/lib/inc

This directory holds a number of short scripts and snippets to help with building web pages. The reason for including them is so that central changes can be made when standards or other details change and have to be applied to all applications.

  • dtd
    • doctype declaration. Required at the start of every standard html document
      • <!DOCTYPE HTML>
  • html
    • html element. This must be the first element in every document and follows the dtd instruction
      • <html>
  • head
    • head element. The first of the two main html elements: head and body.
      • <head>
  • meta
    • meta elements to provide basic information and configuration
      • <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
        <meta name=”Description” content=”Unibase program”>
        <meta name=”Author” content=”Zenucom Pty Ltd”>
        <meta name=”Copyright” content=”&copy; 1978-2018 Zenucom Pty Ltd”>

        <meta http-equiv=”Expires” content=”0″>
        <meta http-equiv=”Cache-Control” content=”no-cache”>
        <meta http-equiv=”Pragma” content=”no-cache”>
        <meta http-equiv=”Content-Language” content=”en-US”>
  • css
    • include essential css files
    • Note that the version can be changed to force the browser to reload the css files
      • <link rel=”preconnect” href=”https://fonts.gstatic.com” crossorigin>
        <link rel=”preconnect” href=”https://fonts.googleapis.com” crossorigin>

        <link rel=”StyleSheet” type=”text/css” href=”https://fonts.googleapis.com/css?family=Raleway:400,700″>
        <link rel=”StyleSheet” type=”text/css” href=”/ub/css/reset.css?version=04″>
        <link rel=”StyleSheet” type=”text/css” href=”/ub/css/unibase.css?version=04″>
        <link rel=”StyleSheet” type=”text/css” href=”/ub/modules/ub_menus/css/menus.css?version=04″>
        <link rel=”StyleSheet” type=”text/css” href=”/css/application.css?version=04″>
  • bodyInit
    • start the body element and include basic javascript files
    • Note the two iframes. These are off the viewport and can be used as a target when you don’t want to display output.
    • Note that the version can be changed to force the browser to reload javascript files
      • <body> <script rel=”preconnect” src=”https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js” integrity=”sha384-i+dHPTzZw7YVZOx9lbH5l6lP74sLRtMtwN2XjVqjf3uAGAREAF4LMIUDTWEVs4LI” crossorigin=”anonymous”></script>
        <script rel=”preconnect” src=”https://cdn.ckeditor.com/4.19.0/full/ckeditor.js” integrity=”sha384-HY1R1S9YmARtli66PSRPfTh42GH9wvoTJXmF7sIthvr78eYKy9PgqOws3Qddk87D” crossorigin=”anonymous”></script>
        <script src=”/ub/js/bb23f83fd6.js?version=02″></script>

        <script src=”/ub/js/unibase.js?version=61″></script>
        <script src=”/ub/js/ub_widgets.js?version=237″></script>
        <script src=”https://maps.googleapis.com/maps/api/js?key=AIzaSyDyHNjS37gAiYrxyJlwZU8Wk10T92PBDS8&libraries=places&callback=ub_widgets.initMap&channel=GMPSB_addressselection_v1_cABC” defer></script>
        <script src=”/ub/js/ub_layout.js?version=155″></script>
        <script src=”/ub/js/ubprompt.js?version=120″></script>
        <script src=”/ub/js/ub_input.js?version=28″></script>
        <script src=”/ub/js/ub_keyinput.js?version=30″></script>
        <script src=”/ub/js/ubmenu.js?version=04″></script>
        <script src=”/ub/js/ubmulti.js?version=04″></script>
        <script src=”/js/application.js?version=150″></script>

        <link href=”https://fonts.googleapis.com/css2?family=Roboto:wght@300;400&display=swap” rel=”stylesheet”>

        <iframe style=”position: fixed; top: -200px; left: -200px; height: 100px; width: 100px;” id=”printReport”></iframe>
        <iframe style=”position: fixed; top: 1em; left: 0px; width: 100%; height: 100%; z-Index: 1; display: none;” id=”_ub_edit”></iframe>
  • dtdHead
    • shortcut that includes dtd, html, head, meta, and css
      • /usr/local/lib/ub/inc/dtd
      • /usr/local/lib/ub/inc/html
      • /usr/local/lib/ub/inc/head
      • /usr/local/lib/ub/inc/meta
      • /usr/local/lib/ub/inc/css
  • dialogClose
    • javascript to close a dialog window
      • puts {<script>parent.ubprompt.dialogClose();</script>}
  • reload
    • javascript to reload the current page
      • puts {<html><head><title></title></head>}
        puts {<body>}
        puts {<script>window.opener.location.reload(true);window.close();</script>}
        puts {</body>}
        puts {</html>}
  • reload_parent
    • javascript to reload the parent of the current page
      • puts {<script>parent.location = parent.location.href;</script>}
  • reload_parentParent
    • javascript to reload the grandparent of the current page
      • puts {<script>parent.parent.location=parent.parent.location.href;</script>}
  • xlsx
    • standard header for generating xlsx files
      • use Excel::Writer::XLSX;
        use Excel::Writer::XLSX::Utility;

        my $report = Excel::Writer::XLSX->new(‘-‘);

        my $format_cell = $report->add_format(border => 1);
        my $format_green = $report->add_format (bg_color => ‘green’, border => 1);
        my $format_heading = $report->add_format(bold => 1, bg_color => ‘silver’, size => 18, align => ‘center’);
        my $format_pink = $report->add_format (bg_color => ‘pink’, border => 1);
        my $format_rate = $report->add_format(num_format => ‘0.0000’);
        my $format_staff = $report->add_format(border => 1, bg_color => ‘yellow’);
        my $format_title = $report->add_format(bold => 1, border => 1, bg_color => ‘silver’, align => ‘center’, text_wrap => 1);
        my $format_total = $report->add_format(bold => 1, border => 1, bg_color => ‘silver’);
        my $format_url = $report->add_format(color => ‘blue’, underline => 1);