Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="all">
    <h3>Interface for glc.js</h3>
    <p><small><a href="https://github.com/monkeyraptor/gcf_lcm" target="_blank" title="New tab">https://github.com/monkeyraptor/gcf_lcm</a></small></p>
    <div class="wrapper">
        <input id="input" type="text" class="ta" placeholder="Please wait..." disabled>
    </div>
    <div class="wrapper">
        <button type="button" class="btn" id="calc" disabled>CALCULATE</button>
    </div>
    <div class="wrapper">
        <textarea class="ta" id="output" rows="10" readonly placeholder="Waiting glc.js being loaded..." disabled></textarea>
    </div>
</div>
              
            
!

CSS

              
                body {
    font-size: 14px;
    background: #eee;
}
.all,
.wrapper {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
.all {
    margin: 10px auto;
    width: 480px;
    max-width: 100%;
}
.wrapper {
    margin: 10px 0;
}
.btn {
    margin: auto;
    padding: 8px;
    display: block;
    width: 120px;
}
.btn:hover {
    cursor: pointer;
}

.ta {
    width: 100%;
    border-radius: 4px;
    padding: 8px;
    border: 1px solid #aaa;
    font-size: 16px;
}
textarea.ta {
    resize: none;
}
.ta:focus {
    outline: none;
    box-shadow: 0 0 0 1px green;
    background: rgba(152, 251, 152, 0.11);
}
.ta[readonly] {
    background: rgba(255, 255, 204, 0.41);
}
.error,
.error[readonly],
.error:focus,
.error[readonly]:focus {
    background: mistyrose;
    box-shadow: 0 0 2px 2px brown;
}
.btn[disabled]:hover,
.error[disabled]:hover,
.ta[disabled]:hover {
    cursor: not-allowed;
}
.ta[disabled] {
    background: #ddd;
}

              
            
!

JS

              
                (function (d, w) {
    "use strict";
    var g = function (a) {
        return Array.prototype.slice.call(d.querySelectorAll(a));
    };
    var input = g("#input")[0];
    var output = g("#output")[0];
    var btn = g("#calc")[0];
    var input_placeholder = "2, 4, 5, ... and so on (use comma, max 20 numbers)";
    var output_placeholder = "Output";

    var to_array = function (a) {
        var array = [];
        a.forEach(function (v) {
            if (v !== "") {
                array.push(Number(v));
            }
        });
        return array;
    };
    var print = function (a) {
        var text;
        if (a.constructor === Object) {
            text = a.input.join(", ") + "\n------------";
            text += "\nGCF = " + a.output.gcf;
            text += "\nLCM = " + a.output.lcm;
            text += "\n---------------";
            text += "\nCompletion → " + a.duration;
        } else {
            text = a;
        }
        return text;
    };
    var click = function () {
        var v = input.value;
        var tc = v.replace(/\s/g, "").split(",");
        output.value = print(glc(to_array(tc)));
    };
    var listen = function () {
        output.value = "";
        var test = input.value.replace(/\s/g, "").split(",");
        if (test.length > 1 && test[test.length - 1] !== "") {
            btn.disabled = false;
            btn.onclick = click;
        } else {
            btn.disabled = true;
            btn.onclick = "";
        }
    };
    var enter_btn = function (e) {
        var kc = e.keyCode;
        if (kc === 13 || e.key === "Enter" || e.code === "Enter") {
            if (!btn.disabled) {
                click();
            }
        }
    };
    if (w.glc) {
        input.disabled = false;
        output.disabled = false;
        input.placeholder = input_placeholder;
        output.placeholder = output_placeholder;
        input.focus();
        input.addEventListener("input", listen);
        input.addEventListener("keyup", enter_btn);
    } else {
        input.value = "Cannot load glc.js";
        output.value = "https://cdn.rawgit.com/monkeyraptor/gcf_lcm/39333a0d/the.js isn't available for now...";
        input.className = "ta error";
        output.className = "ta error";
        input.disabled = true;
        output.disabled = true;
    }
}(document, window));
              
            
!
999px

Console