#!/bin/bash
# Создать файл JavaScript с набором раскладок в формате Base64.

function gen
{
    fileName=$1
    target=$2

    echo -n "'$fileName' : '" >> $target
    base64 $fileName | tr -d \\n >> $target
    echo -e "',\n" >> $target
}

function genLayouts
{
    target=$1

    echo -e "function RR() { return {\n" > $target

    layouts=$(ls *.layout)
    for layout in $layouts;
    do
        gen $layout $target
    done

    echo "}; }" >> $target
}

genLayouts "../2019-09-19.js"
