Righty-Lefty App Development Log

A dialog between You and GitHub Copilot during the creation of the Righty-Lefty app.

We started this app with a template designed for TNT that gives 'credit' to Copilot for development. Based on that template, we started 'shoehorning' code into the framework Here are the sequential development 'prompts' we used along the way:

Development Dialog

You: In div#r1c1Div create a Bootstrap5 responsive table with an overall heading: 'Keyboard Letter Assignments' and two columns: 'Left Hand' and 'Right Hand'

Copilot: Did it

Commentary: Copilot made these comments afterwards: Explanation:
The table is created using Bootstrap 5 classes for styling and responsiveness.
The table header includes the overall heading and two columns for left and right hand letters.
The table body contains the left-handed and right-handed letters as specified. I had not requested that!

You: In r2c1Div, create a textarea to collect a typing sample from a user. Once submitted, collect the sample and analyze each word's symbol as to whether it was typed with the right or the left hand. Style right-hand letters with yellow and left-hand letters with lavender. Put the words in a Bootstrap5 responsive table in r1c2Div, alphabetized.

Copilot: Did it
It's commentary:
Explanation Textarea and Button: The textarea allows users to input their typing sample, and the button triggers the analysis. JavaScript Analysis: Splits the input into words and sorts them alphabetically. Iterates through each word and checks each letter to determine if it belongs to the left or right hand. Styles left-hand letters in lavender and right-hand letters in yellow. Results Table: Dynamically updates the table in r1c2Div with the analyzed words and their styled letters. Result When the user types a sample and clicks "Analyze," the words are displayed in the table, with letters styled based on whether they were typed with the left or right hand.

Commentary: It not only provided the table, but it suggested 'analyzeTypingSample' which worked out of the gate. At first, I thought the words were not alphabetized, but later discovered that it was including 'casing' in the sorting. In that case (pardon the pun), capital letters come first!

You: Create CSS style rules to style the left hand letters as bolded orange and right hand letters as bolded purple in the table#kbRefTable. Use a monospaced font as well and make the letters 25% bigger than they are now

Copilot: Did it. Created appropriate rules that targeted the table
It's commentary:
Explanation: Monospaced Font: The font-family property ensures that the letters are displayed in a monospaced font like Courier New. Font Size: The font-size property increases the size of the letters by 25%. Left-Hand Letters: The .left-hand class styles left-hand letters in bold orange. Right-Hand Letters: The .right-hand class styles right-hand letters in bold purple. Updated HTML for table#kbRefTable To apply these styles, wrap the left-hand and right-hand letters in span elements with the appropriate classes:

Commentary: Suggested updates to the HTML worked as requested. Colors were later changed to green and purple

You: Apply these same styles to the Analysis column

Copilot: To apply the same styles (bolded orange for right-hand letters and bolded purple for left-hand letters) to the Analysis column in the #resultsTable, you can modify the analyzeTypingSample function to use the existing CSS classes (left-hand and right-hand) instead of inline styles.

Commentary: (Used the new function; it was wrong about using existing styles; I had to make classes for left and right hand letters, but then it worked)

You: Create a sentence in English where alternating letters come from the left side of the QUERTY keyboard and the right side of the QUERTY keyboard

Copilot: "A big cat dug a huge pit."

You: Create a 'Default' button in the textarea region that loads the sentence: "A big cat dug a huge pit"

Copilot: Did it properly

Commentary: (Wrote code that worked) Explanation HTML Changes: Added a Default button styled with Bootstrap classes (btn btn-info). Placed the Default button alongside the Analyze and Clear buttons using a d-flex container with gap-2 for spacing. JavaScript Function: The loadDefaultSample function sets the value of the #typingSample textarea to the default sentence: "A big cat dug a huge pit". Result Clicking the Default button will populate the textarea with the sentence "A big cat dug a huge pit". The Analyze and Clear buttons will continue to function as before.

You: In the textarea region include an option to either alphabetize the words or leave them in the original order. Set the default to original order. Use Bootstrap5 styling

Copilot: Worked
(Code worked) Explanation HTML Changes: Added a radio button group with two options: "Original Order" and "Alphabetical Order." Used Bootstrap 5 classes (form-check, form-check-input, form-check-label) for styling. Set the default option to "Original Order" using the checked attribute. JavaScript Changes: The analyzeTypingSample function now checks the selected radio button using document.querySelector('input[name="wordOrder"]:checked').value. If "Alphabetical Order" is selected, the words are sorted alphabetically using words.sort(). Result Users can choose between "Original Order" or "Alphabetical Order" for the word analysis. The default option is "Original Order." The radio buttons are styled with Bootstrap 5 for a clean and consistent look.

You: Create a 'Default' button in the textarea region that loads the sentence: "A big cat dug a huge pit"

Copilot: Did it properly

Commentary: (Wrote code that worked) Explanation HTML Changes: Added a Default button styled with Bootstrap classes (btn btn-info). Placed the Default button alongside the Analyze and Clear buttons using a d-flex container with gap-2 for spacing. JavaScript Function: The loadDefaultSample function sets the value of the #typingSample textarea to the default sentence: "A big cat dug a huge pit". Result Clicking the Default button will populate the textarea with the sentence "A big cat dug a huge pit". The Analyze and Clear buttons will continue to function as before.

You: When the radio buttons are clicked, automatically adjust the table to reflect the request.

Copilot: Added onclick attributes to the radio buttons to call the analyzeTypingSample function whenever a radio button is selected. This ensures the table dynamically updates based on the selected word order.

You: In the results table, include a column to show the total number of left-handed letters and the total of right-handed letters in each word. At the bottom of the table, show the totals and include a percentage for each.

Copilot: Did it. Explanation: Added two new columns in the table for "Left-Handed" and "Right-Handed" counts. Added a <tfoot> section to display totals and percentages...

You: Hide the total and percentages information until the analysis is performed.

Copilot: To hide the totals and percentages information until the analysis is performed, you can use CSS to initially hide the <tfoot> section of the table and then make it visible when the analysis is completed...

You: Write a function that determines whether or not a word has alternating left-handed/right-handed typed characters; for example, the words 'fox' and 'of' would fit this pattern.

Copilot: Created the isAlternatingHanded function, which checks if a word alternates between left-handed and right-handed letters. It uses two sets of characters (leftHandLetters and rightHandLetters) to determine which hand types each character.

You: Use the function you just wrote to highlight any word in the Analysis column with yellow if it has alternating handedness.

Copilot: Updated the analyzeTypingSample function to check each word using isAlternatingHanded. Words with alternating handedness are highlighted with a pale yellow background in the "Analysis" column.

You: Change the "About Righty-Lefty" button color to #69A3C0.

Copilot: Added a custom CSS class .btn-about to style the button with the requested color.

You: Change the mastheadIcon color to #5182A2.

Copilot: Updated the filter property in the CSS to approximate the requested color for the image.

You:The 'Word' column is superfluous and makes the results table too wide. Please remove it so that the results table has only 3 columns

Copilot: To remove the "Word" column from the results table, you need to update both the table header and the JavaScript code that generates the table rows. Here's how you can do it:

Commentary: Copilot's code worked, except it forgot to update the footer stuff. Once the colspan was changed to '1' from '2' it worked

You:I need a background image for a web app that analyzes word characters as to whether they are typed with the left or right hand on a 'querty; keyboard. The center of the image needs to be light in color

Copilot: Done

Commentary:The image it gave, we used and sampled colors for the site from it

You: Compose a short summary of introduction/instruction for a new user of this app

Copilot: The original statement:
Welcome to Righty-Lefty, a fun and educational app designed to analyze your typing patterns! Simply type or paste a sample text into the "Typing Sample" box and click Analyze to see how your words are typed using left-handed and right-handed keys. The app highlights each letter based on which hand types it and calculates totals and percentages for left- and right-handed usage. You can also sort words alphabetically or keep them in their original order. Explore your typing style and discover if your words alternate hands!

Commentary: I made a few minor changes and additions. I like the first paragraph so much I used it as default input in the text area

You: Place the 'introDiv' in a Bootstrap5 dropdown area, activated by a button labeled: 'About Righty-Lefty'

Copilot: Did it;

Commentary: Copilot made these comments afterwards: Explanation:
Button: A button with data-bs-toggle="collapse" and data-bs-target="#aboutRightyLefty" is used to toggle the visibility of the collapsible area.
Collapsible Area: The introDiv content is placed inside a div with the collapse class and an ID of aboutRightyLefty.
Styling: The mt-3 class adds spacing between the button and the collapsible content.
Result: When the "About Righty-Lefty" button is clicked, the introDiv content will expand or collapse, providing a clean and interactive way to display the introduction and instructions.

You: Looking at 'ourLeftyRightyLog.html' , add our interactions today into that file so I can document how the app was made

Copilot: Here’s how you can document today’s interactions in ourLeftyRightyLog.html. I’ve added entries for each of the key interactions we had today:

Commentary: Copilot made these comments afterwards: Explanation: Each interaction is added as an accordion item with a unique id for the header and collapse sections. The strong tags document the request and response for each interaction. The data-bs-parent="#dialogAccordion" ensures only one accordion item is expanded at a time. Result: This will document today's interactions in a structured and readable format within the development log.

You: Create a Java application that takes a user's word like 'quick' and returns a String like 'lrrlr' denoting which hand typed it on a 'QWERTY' keyboard. If a character has no designation, use a 'n' for not-found

Copilot:

import java.util.Scanner;

public class HandTypingAnalyzer {

    public static void main(String[] args) {
        // Define the QWERTY keyboard hand mappings
        String leftHandLetters = "asdfgqwertzxcvb";
        String rightHandLetters = "hjkl;yuio.pnm,/";
        
        // Create a Scanner to take user input
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter a word to analyze:");
        String word = scanner.nextLine().toLowerCase(); // Convert input to lowercase for consistency
        
        // Analyze the word and determine which hand typed each character
        String result = analyzeWord(word, leftHandLetters, rightHandLetters);
        
        // Output the result
        System.out.println("Hand typing pattern: " + result);
        
        scanner.close();
    }

    public static String analyzeWord(String word, String leftHandLetters, String rightHandLetters) {
        StringBuilder handPattern = new StringBuilder();
        
        for (char c : word.toCharArray()) {
            if (leftHandLetters.indexOf(c) != -1) {
                handPattern.append("l"); // Left hand
            } else if (rightHandLetters.indexOf(c) != -1) {
                handPattern.append("r"); // Right hand
            } else {
                handPattern.append("n"); // Not found
            }
        }
        
        return handPattern.toString();
    }
}
                            

Commentary: Copilot made these comments afterwards:

How It Works:
Keyboard Hand Mappings:
    leftHandLetters contains all the letters typed by the left hand on a QWERTY keyboard.
    rightHandLetters contains all the letters typed by the right hand.
User Input:
    The program prompts the user to enter a word.
    The input is converted to lowercase to ensure case-insensitive matching.
Analysis:
    Each character in the word is checked against the leftHandLetters 
        and rightHandLetters strings.
    If the character is found in leftHandLetters, an l is appended to the result.
    If the character is found in rightHandLetters, an r is appended.
    If the character is not found in either, an n is appended.
Output:
    The program outputs the resulting string, where each character 
    corresponds to the hand that typed it 
    (l for left, r for right, n for not found).

Explanation of Result:
q → Left hand (l)
u → Right hand (r)
i → Right hand (r)
c → Left hand (l)
k → Right hand (r)   
                            

You: One of my requests here

Copilot: Copilot's response here

Commentary:The image it gave, we used and sampled colors for the site from it