Knex transactions having queries on multiple table?

I have two tables and I want to write a query that does the following.

Get some data from table1.
based on the value received in the above query, insert in table2.
I have written the query as following:

await Table1Model.transaction(async trx => {
                // First check if the meeting exists?
                const room = await this.**table1**.query()
                    .select('*')
                    .where({ id: this.m_id, is_deleted: false });

                if (typeof room !== "undefined") {
                    await this.**table2**.query().insert(newUser);
                }
                else {
                    // do something else
                }
            });

Please suggest any better way to do something like this.

I want to know the correct way of writing this kind of transactions using knex or objection js.

Step to write a script auto comment new post instagram

Like all the app and software I need to use. I in the past did automation on chrome with selenium and python. Now I want to try with app. Thanks a lot if you can help me.

Also, there is some function of IG app support but on webpage theres not (like Reels). Can I write a script to interact with those function on web?

My aim is to write one like people with their bots always comment on the new post appear on the hashtag of IG.

Woocommerce: Hide All Shipping Method & Rate When Choose Payment Gateway COD

anyone can help me, im try hide all shipping method when choose cod payment gateway but it’s not working.

this my site pyorsihate.com

this PHP code:

// Enqueue the script on the checkout page
add_action('wp_enqueue_scripts', 'enqueue_hide_all_shipping_script');

function enqueue_hide_all_shipping_script() {
    // Ensure it's the checkout page
    if (is_checkout() && !is_wc_endpoint_url()) {
        wp_enqueue_script('hide-all-shipping-script', get_stylesheet_directory_uri() . '/hide-all-shipping.js', array('jquery'), '1.0', true);
    }
}

This JS Code:

jQuery(function($) {
    // On page load
    checkPaymentMethod();

    // On payment method change
    $('form.checkout').on('change', 'input[name="payment_method"]', function() {
        checkPaymentMethod();
    });

    function checkPaymentMethod() {
        // Check if COD is chosen
        if ($('#payment_method_cod:checked').length > 0) {
            // Hide all shipping methods
            $('ul.shipping_methods').hide();
        } else {
            // Show all shipping methods
            $('ul.shipping_methods').show();
        }
    }
});

If someone can help me, im try to many option, choose ID and hide all shipping it’s still not working.

Hide All Shipping Method & Not Include Rate In total when choose payment method Cash On delivery (COD)

After conversion from jQuery to JavaScript

I converted a jQuery plugin to Vanilla JS. It works pretty well but at least I have two quick questions.

1- Is it safe to use?

2- Why does it run slowly than jQuery?

I tried to clear my doubts regarding but not able to clarify it well. That is why I asked.

Here’s the code (Pure JS) I’m using:

document.addEventListener('DOMContentLoaded', function()
{
  var elements = document.querySelectorAll('.reactions-icon');
  elements.forEach(function(element)
  {
    element.addEventListener('click', function(event)
    {
      event.preventDefault();
      var main = this.parentElement.parentElement;
      var vote_type = main.dataset.type;
      var voted = main.dataset.vote;
      var type = this.dataset.action;
      var style = main.dataset.style;

      var data = new FormData();
      data.append('action', 'reaction_save_action');
      data.append('nonce', main.dataset.nonce);
      data.append('type', type);
      data.append('post', main.dataset.post);
      data.append('voted', voted);
      data.append('style', style);
      data.append('vote_type', type);

      var xhr = new XMLHttpRequest();
      xhr.open('POST', '/ajax.php');
      xhr.onload = function()
      {
        if (xhr.status === 200) {
          var responseData = JSON.parse(xhr.responseText);
          if (responseData.success) {
            var postElement = document.querySelector('.reactions-post-' + main.dataset.post);
            postElement.innerHTML = responseData.data.html;
            main.setAttribute('data-vote', 'yes');
            main.setAttribute('data-type', 'unvote');
            document.querySelectorAll('.reactions-box-2').forEach(function(box) {
              box.classList.add('unvote');
              box.removeEventListener('click', boxClickHandler);
            });
          }
        }
      };

      xhr.send(data);

      function boxClickHandler() {
        main.setAttribute('data-vote', 'no');
        main.setAttribute('data-type', vote_type);
        document.querySelectorAll('.reactions-box-2').forEach(function(box) {
          box.classList.remove('unvote');
          box.addEventListener('click', boxClickHandler);
        });
      }
      document.querySelectorAll('.reactions-box-2').forEach(function(box) {
        box.addEventListener('click', boxClickHandler);
      });
    });
  });
});

It works pretty well as I said, and here’s the jQuery code:

jQuery(document).ready(function($)
{
    $(document).on("click", ".reactions-icon", function (event)
    {
        event.preventDefault();
        var t = $(this),
            main = t.parent().parent(),
            vote_type = main.data("type"),
            voted = main.data("vote"),
            type = $(this).data("action"),
            style = main.data("style");
        $.ajax({
            url: "/ajax.php",
            dataType: "json",
            type: "POST",
            data: { action: "reaction_save_action", nonce: main.data("nonce"), type: type, post: main.data("post"), voted: voted, style: style, vote_type: type },
            success: function (data) {
                if (data.success) {
                    $(".reactions-post-" + main.data("post")).html(data.data.html);
                    main.attr("data-vote", "yes").attr("data-type", "unvote");
                    $(".reactions-box-2").addClass("unvote").off("click");
                }
            },
        });
    });
});

I think a little help would be nice…

DataTable is not displaying data received by AJAX

I’m currently learning how to display AJAX-received data to DataTables using .NETCore 6 Razor Pages. Here’s the front-end code:

<table id="dataTable" class="table table-striped" style="width:100%">
    <thead>
        <tr>
            <th hidden>Id</th> //I want the id column to be hidden; all SQL tables have the same 4 columns
            <th>Region</th>
            <th>Daily Range Minimum</th>
            <th>Daily Range Maximum</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var row in Model.Client)
        {
            <tr>
                <td hidden>@row.Id</td>
                <td>@row.Region</td>
                <td>@row.range1</td>
                <td>@row.range2</td>
            </tr>
        }
    </tbody>
</table>

<script>

    var dataTable, headers;

    $(document).ready(function () {

        dataTable = $('#dataTable').DataTable();

        $('.button-container button').on('click', function (event) {
            event.preventDefault();
            var buttonId = $(this).attr('id');
            fetchDataForButton(buttonId);
        });
    });

        // Function to handle data retrieval based on the button id
    function fetchDataForButton(buttonId) {
        $.ajax({
            type: 'POST',
            headers: { RequestVerificationToken: $('input:hidden[name="__RequestVerificationToken"]').val() },
            url: '/wagetable?handler=CollectData',
            dataSrc: '',
            data: { buttonId: buttonId },

            success: function (response) {
                
                console.log("Success callback reached");
                console.log("Data received:", response);

                //Destroy previous DataTable if exists
                if ($.fn.DataTable.isDataTable('#dataTable')) {
                    $('#dataTable').DataTable().destroy();
                }

                // Clear the existing headers
                $('#dataTable thead').empty();

                // Add the new headers
                var headers = getHeadersForButton(buttonId);
                var headerRow = $('<tr>');
                headers.forEach(function (header) {
                    headerRow.append($('<th>').text(header));
                });

                $('#dataTable thead').append(headerRow);

                // Add the new data to the DataTable
                dataTable.clear().rows.add(response).draw();

            },
            error: function (error) {
                console.error("Error fetching data: ", error);
                // Handle error as needed
            }
        });
    }

    // Function to get headers based on the buttonId
    function getHeadersForButton(buttonId) {
        // Implement logic to retrieve headers based on the buttonId
        // Example:
        switch (buttonId) {
            case 'btnSSS':
                return ['Monthly Range Minimum', 'Monthly Range Maximum', 'Monthly Credit'];
            case 'btnIndustry':
                return ['Industry', 'Monthly Range Minimum', 'Monthly Range Maximum'];
            case 'btnRegion':
                return ['Region', 'Range1', 'Range2'];
            // Add cases for other buttonIds
            default:
                return [];
        }
    }


</script>

When a button is clicked, AJAX sends the button id to a function in the Model page that handles data retrieval. Here’s the back-end code:

public IActionResult OnPostCollectData(string buttonId)
{
    IEnumerable<object> data = null;

    // Call the appropriate SQL function based on the buttonId
    switch (buttonId)
    {
        case "btnSSS":
            data = employeeRepository.GetAllRanges(); // All are SQL functions that retrieve data from SQL tables
            break;
        case "btnIndustry":
            data = employeeRepository.GetAllIndustries();
            break;
        case "btnRegion":
            data = employeeRepository.GetAllRegions();
            break;
        // Add cases for other buttonIds
        default:
            break;
    }

    try
    {
        Console.WriteLine($"OnPostCollectData called for buttonId: {buttonId}");
        return new JsonResult(new { Data = data });
    
    }

    catch (Exception ex)
    {
        Logger.LogError(ex, "An error occurred while processing the OnPostGetData request.");
        return BadRequest(new { ErrorMessage = "An error occurred. Please check the logs for more details." });
    }
}

Problem and Solutions tried

The problem is that the data is not displaying; table headers are successfully displayed but not the table cell values. I’ve noticed that:

  • there are no Javascript errors in console
  • the ‘response’ variable is not null or empty; in the console log, the data received is being displayed correctly as an array of table row values
  • calling dataTable = $('#dataTable').DataTable(); again after dataTable.clear().rows.add(response).draw(); causes Incorrect column count error. I assume that’s because it’s redundant?

Any help is appreciated.

Users created using Supabase Dashboard “Add User’ button can sign in, but users created using JS API cannot sign in

When I create a user using signUp callback, the response returned contains a session and a user object, and the user is added to the auth table in Supabase. But, when I try to log in using the same credentials, it returns a 400 Error (“no API key was found”).

However, when I add a user using “Add User” from the Supabase Authentication Dashboard
the same user can log in!

Things I have tried:

  • Rechecked Site URL
  • ReAdded URL and ANON_KEY
  • switched from @supabase/ssr to @supabase/supabase-js and vice versa

SignUp function

async function signUpWithEmail() {

    if (signUpPassword !== signUpPasswordConfirm) {
      setSignUpError("Passwords do not match!")
      return
    }

    if (signUpPassword.length < 8) {
      setSignUpError("Password must be at least 8 characters long!")
      return
    }

    if (date === undefined) {
      setSignUpError("Please enter your birthday!")
      return
    }

    //check if age is atleast 16 
    const today = new Date()
    const birthDate = new Date(date)
    let age = today.getFullYear() - birthDate.getFullYear()
    const m = today.getMonth() - birthDate.getMonth()
    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
      age--
    }
    if (age < 16) {
      setSignUpError("You must be atleast 16 years old to use Wessenger!")
      return
    }



    const { data, error } = await supabase.auth.signUp(
      {
        email: signUpEmail,
        password: 'example-password',
        options: {
          data: {
            name: signUpName,
            dateOfBirth: date,
          }
        }
      }
    )

    if (error) {
      setSignUpError(error.message)
      return
    }
    console.log(data)
    if (data) {
      //check
      
      //send data to user table
      const firstName = signUpName.split(" ")[0]
      const lastName = signUpName.split(" ").slice(1).join(" ")
      console.log(lastName)

      const { data, error } = await supabase.from('users').insert([
        { email: signUpEmail, username: signUpUsername, first_name: firstName, last_name: lastName, date_of_birth: date }
      ])

      if (error) {
        setSignUpError(error.message)
        return
      }
    }
    setSignUpError("")
    setSignUpSuccess(true)
  }

Sign In Function

async function signInWithEmail() {

    const { data, error } = await supabase.auth.signInWithPassword({
      email: signInEmail,
      password: signInPassword
    })

    if (error) {
      setSignInError(true)
    }

    if (data) {
      setSignInError(false)
      setSignInSuccess(true)
      console.log(data)
    }
  }

How do I show a list of notes in my Obsidian vault that do not include a tag name?

In my MOC pages, I would like to display a list of notes with tag1 & tag2, but not notes that contain tag3.

I use YAML frontmatter in my notes in Obsidian and include a property for tags i.e. tags: [tag1, tag2, tag3]. I also have MOC pages which are just a menu of links to related notes where I write inline DataviewJS scripts to display the links.

I am currently able to display notes with multiple tags such as tag1 and tag2 with the following inline script, but now I want to exclude notes with a specific tag such as tag3.

`$=dv.list(dv.pages('"Notes"').where(p => p.file.tags.includes("#tag1") && p.file.tags.includes("#tag2")).file.link)`

How would I go about modifying the above script to include notes with tag1 and tag2, but not include notes with tag3?

I guess what I really need to find out is what properties are available under p.file.tags. Does anyone know a good way to examine what properties that are available?

Is there something like p.file.tags.notincludes(“#tag3”) or something?

Uncaught TypeError: Cannot read properties of undefined (reading ‘header’)

[enter image description here](https://i.stack.imgur.com/DIyLN.png)

app.js:213 Uncaught TypeError: Cannot read properties of undefined (reading 'header')
    at getSlot (vuedraggable.js:59:1)
    at computeChildrenAndOffsets (vuedraggable.js:65:1)
    at Proxy.render (vuedraggable.js:163:1)
    at renderComponentRoot (runtime-core.esm-bundler.js:820:1)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5749:1)
    at ReactiveEffect.run (reactivity.esm-bundler.js:178:1)
    at instance.update (runtime-core.esm-bundler.js:5862:1)
    at setupRenderEffect (runtime-core.esm-bundler.js:5870:1)
    at mountComponent (runtime-core.esm-bundler.js:5660:1)
    at processComponent (runtime-core.esm-bundler.js:5613:1)

Once i start to run the program this will be appearing

Uncaught TypeError: Spread syntax requires ...iterable[Symbol.iterator] to be a function
    at ./src/store.js (store.js:11:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./src/index.js (actions.js:13:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at startup:7:1
    at startup:7:1

[Uncaught TypeError: Spread syntax requires ...iterable[Symbol.iterator] to be a function
    at ./src/store.js (store.js:11:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./src/index.js (actions.js:13:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at startup:7:1
    at startup:7:1]
import { legacy_createStore as createStore,applyMiddleware } from "redux";

import { composeWithDevTools } from "redux-devtools-extension";

import reducer from "./reducer";

import thunk from "redux-thunk";

const middleware = {thunk};

const store =  
createStore(
    reducer,
    composeWithDevTools(applyMiddleware(...middleware))

);

export default store;

React virtualized, Infinite Scroll – start at the bottom of List

I am using react-virtualized to create an infinite scroll. The code for this is shown below (full link to the codesandbox where this code is taken from- https://codesandbox.io/p/sandbox/react-virtualized-infinite-scroll-demo-ngexu?file=%2Fsrc%2FApp.js%3A120%2C34 )

  <div className="repositoriesWrapper">
    <AutoSizer disableHeight={true}>
      {({ width }) => (
        <WindowScroller>
          {({ height, isScrolling, onChildScroll, scrollTop }) => (
            <InfiniteLoader
              isRowLoaded={isRowLoaded}
              loadMoreRows={loadMoreRows}
              rowCount={1000}
            >
              {({ onRowsRendered, registerChild }) => (
                <List
                  autoHeight
                  onRowsRendered={onRowsRendered}
                  ref={registerChild}
                  scrollToIndex={repositories.length}
                  scrollToAlignment="end
                  height={height}
                  isScrolling={isScrolling}
                  onScroll={onChildScroll}
                  rowCount={repositories.length}
                  rowHeight={42}
                  rowRenderer={rowRenderer}
                  scrollTop={scrollTop}
                  width={width}
                />
              )}
            </InfiniteLoader>
          )}
        </WindowScroller>
      )}
    </AutoSizer>
    {isNextPageLoading && <span>loading more repositories..</span>}
  </div>

When the page renders, I want the list to automatically start at the bottom/end of the list, and as the user scrolls up, load more items. After researching, I discovered the props scrollToIndex={data.length} and scrollToAlignment="end" should be added to accomplish this. I have added these two props to the List component, however the list still starts from the top.

Is there an issue with this code, or is there any other methods/functionality needed in order to accomplish this? Thanks.

MutationObserver too slow to redefine navigator property in a dynamic iframe?

I’m making some updates to a Chrome extension that re-defines navigator.userAgent,
and I came across this behavior when replacing DOMNodeInserted with MutationObserver ..

This question is generic and doesn’t require testing from a Chrome extension.

The best way to explain this behavior is to navigate to:
https://webbrowsertools.com/useragent/

Then … using the console run the following javacript code, and check the response from iframe> navigator.userAgent:

DOMNodeInserted works fine, the iframe > navigator.userAgent is switched:

document.addEventListener('DOMNodeInserted', function(event)
{
    if (event.target.tagName == 'IFRAME')
        for (var i=0; i<window.frames.length; i++)
            try { Object.defineProperty(window.frames[i].navigator, 'userAgent', {value:'TEST'}); } catch(e) {}
});

MutationObserver doesn’t work, the iframe > navigator.userAgent is NOT switched:

var observer = new MutationObserver(function(mutations)
{
    for (var mutation of mutations)
        for (var item of mutation.addedNodes)
            if (item.tagName == 'IFRAME')
                for (var i=0; i<window.frames.length; i++)
                    try { Object.defineProperty(window.frames[i].navigator, 'userAgent', {value:'TEST'}); } catch(e) {}
});
observer.observe(document, { childList:true, subtree:true });

Excuse the crude iteration through window.frames and not the actual event.target

I believe it has to do with MutationObserver being too slow, but I don’t know how to fix this ?!

How to share a React context between two different files

So I am using the context api from React, and have one component called CreateComposition that uses the createContext() and exports it. I then import it into a component called Compositions, and use useContext() to display it as a list. However when I go between the two, they do not save.

This is the current code I have for both components.

import React, { useState, createContext } from 'react';
import {Link} from 'react-router-dom';

const CompositionsContext = createContext([' No Compositions Currently']);

const CreateComposition = () =>{
    const [taal, setTaal] = useState('');
    const [bpm, setBpm] = useState('');
    const [name, setName] = useState('');
  
    const [compositions, setCompositions] = useState([]); 
  
    const sayKayeda = () => {
      alert(taal + " " + bpm + " " + name);
    }
  
    const changeTaal = (event) => {
      setTaal(event.target.value);
    }
  
    const changeBPM = (event) => {
      setBpm(event.target.value);
    }
  
    const changeName = (event) => {
      setName(event.target.value);
    }
  
    const addNewComposition = () => {
      const newComposition = `${taal} ${bpm} ${name}`;
      setCompositions([...compositions, newComposition]);
      setTaal('');
      setBpm('');
      setName('');
      
    }

    return (
    <CompositionsContext.Provider value={compositions}>
        <h2>Input Kayeda Details Below</h2>
        <br></br>
        <br></br>
        <label> <b>Taal</b>&nbsp; 
            <input onChange={changeTaal} value={taal}></input>
        </label>
        <br></br>
        <label> <b>BPM</b>&nbsp; 
            <input onChange={changeBPM} value={bpm}></input>
        </label>
        <br></br>
        <label> <b>Name</b>&nbsp; 
            <input onChange={changeName} value={name}></input>
        </label>
        <p></p>
        <button onClick={sayKayeda}>Current Kayeda</button>
        &nbsp; 
        <button onClick={addNewComposition}>Add Composition</button>
        <br></br>
        <Link to = '/compositions' className = 'btn'><h2>Compositions</h2></Link>
    </CompositionsContext.Provider>
    );
}

export {CompositionsContext};
export default CreateComposition;


```


```
// Compositions.js
import React, {useContext} from 'react';
import {Link} from 'react-router-dom';
import { CompositionsContext } from './CreateComposition'

//Fix the display
const Compositions = () => {
  const compositions = useContext(CompositionsContext);
  return (
    <CompositionsContext.Provider value = {compositions}>
       <Link to = '/createcomposition' className = 'btn'><h1>Create Compositions</h1></Link>
       <p></p>
      <h2>List of Compositions</h2>
      <ul>
        {compositions.map((composition, index) => (
          <li key={index}>{composition}</li>
        ))}
      </ul>
    </CompositionsContext.Provider>
  );
};

export default Compositions;

`
```

pdfjs_dist_1.default.getDocument is not a function

I am building an Outlook add-in and want to render a small version of a pdf inside it.

For this i have choosen pdf.js, because in the add-in i only have the browser context.

But i get the following error:

Uncaught TypeError TypeError: pdfjs_dist_1.default.getDocument is not
a function
at (a:erpolsrctaskpanetaskpane.ts:284:24)
at step (localhost꞉3000/taskpane.js:332:17)
at (localhost꞉3000/taskpane.js:281:14)
at (localhost꞉3000/taskpane.js:255:67)
at webpack_modules../src/taskpane/taskpane.ts.__awaiter (localhost꞉3000/taskpane.js:237:10)
at displayPDFThumbnail (localhost꞉3000/taskpane.js:605:10)
at (a:erpolsrctaskpanetaskpane.ts:355:13)
at (appsforoffice.microsoft.com/lib/1.1/hosted/outlook-win32-16.02.js:20:204418)
at a (appsforoffice.microsoft.com/lib/1.1/hosted/outlook-win32-16.02.js:20:205014)
at (appsforoffice.microsoft.com/lib/1.1/hosted/outlook-win32-16.02.js:20:205402)
at agaveResponseCallback (/VM46947590:1:8812)
at window.agaveHostCallback (/VM46947590:1:11244)
at (/VM46947597:1:8)

This is basically my code:

import pdfjslib from 'pdfjs-dist';
...
const pdf = pdfjslib.getDocument({data: pdfDataAsB64});

I also tried these imports, which did not work:

// import * as pdfjs from 'pdfjs-dist';
// import { getDocument } from 'pdfjs-dist/webpack';
// import * as pdfjslib from "pdfjs-dist/build/pdf.mjs";
// var pdfjslib = require('pdfjs-dist');

I have installed pdfjs with npm i pdfjs-dist. Intelli sense also works an i can ctrl+click on get Document and can see the api.d.ts file:

export function getDocument(src: string | URL | TypedArray | ArrayBuffer | DocumentInitParameters): PDFDocumentLoadingTask;
export class LoopbackPort {
    postMessage(obj: any, transfer: any): void;
    addEventListener(name: any, listener: any): void;
    removeEventListener(name: any, listener: any): void;
    terminate(): void;
    #private;
}

One last thing to note is that Outlook add-ins use webpack.

Rubik’s Cube scrambler giving all of the same move

I am new to JavaScript loops, and I am making a Rubik’s Cube scrambler. It generates random moves and displays them fine, but all of them are the same move.

I think there is a way of fixing it by having 20 scramble variables but it would be inefficient and too long. Is there any compact way of fixing this? This is my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Speedcubing Timer</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <style>
        * {
            padding:20px;
        }
    </style>
</head>
<body>
<h1>CubeTimer v1.0</h1>
    <div class="row">
        <div class="col-xs-5">
            <h1>Scramble</h1>
            <h3 id="scramble"></h1>
        </div>
    </div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script>
let scramble = Math.floor(Math.random() * 12);
function scramble_translator() {
    if (scramble <= 1) {
        scramble = 'R '
    } else if (scramble > 1 && scramble <= 2) {
        scramble = 'R' '
    } else if (scramble > 2 && scramble <= 3) {
        scramble = 'U '
    } else if (scramble > 3 && scramble <= 4) {
        scramble = 'U' '
    } else if (scramble > 4 && scramble <= 5) {
        scramble = 'L '
    } else if (scramble > 5 && scramble <= 6) {
        scramble = 'L' '
    } else if (scramble > 6 && scramble <= 7) {
        scramble = 'F '
    } else if (scramble > 7 && scramble <= 8) {
        scramble = 'F' '
    } else if (scramble > 8 && scramble <= 9) {
        scramble = 'D '
    } else if (scramble > 9 && scramble <= 10) {
        scramble = 'D' '
    } else if (scramble > 10 && scramble <= 11) {
        scramble = 'B '
    } else if (scramble > 11 && scramble <= 12) {
        scramble = 'B' '
    }

    document.getElementById('scramble').innerHTML += scramble;
}
for (let i = 0; i < 20; i++) {
    scramble_translator();
}
</script>
</body>
</html>