function newCircuit(name, id, isVerilog = false, isVerilogMain = false) {
    if (layoutModeGet()) { toggleLayoutMode(); }
    if (verilogModeGet()) { verilogModeSet(false); }
    name = name || prompt('Enter circuit name:', 'Untitled-Circuit');
    name = escapeHtml(stripTags(name));
    if (!name) return;
    const scope = new Scope(name);
    if (id) scope.id = id;
    scopeList[scope.id] = scope;
    if (isVerilog) {
        scope.verilogMetadata.isVerilogCircuit = true;
        scope.verilogMetadata.isMainCircuit = isVerilogMain;
    }
    globalScope = scope;
    $('.circuits').removeClass('current');
    if (!isVerilog || isVerilogMain) {
        if (embed) {
            var html = `<div style='' class='circuits toolbarButton current' draggable='true' id='${scope.id}'><span class='circuitName noSelect'>${truncateString(name, 18)}</span></div>`;
            $('#tabsBar').append(html);
            $("#tabsBar").addClass('embed-tabs');
        } else {
            var html = `<div style='' class='circuits toolbarButton current' draggable='true' id='${scope.id}'><span class='circuitName noSelect'>${truncateString(name, 18)}</span><span class ='tabsCloseButton' id='${scope.id}'  >x</span></div>`;
            $('#tabsBar').children().last().before(html);
        }

        // Remove listeners
        $('.circuits').off('click');
        $('.circuitName').off('click');
        $('.tabsCloseButton').off('click');

        // Add listeners
        $('.circuits').on('click',function () {
            switchCircuit(this.id);
        });

        $('.circuitName').on('click',(e) => {
            simulationArea.lastSelected = globalScope.root;
            setTimeout(() => {
                document.getElementById('circname').select();
            }, 100);
        });

        $('.tabsCloseButton').on('click',function (e) {
            e.stopPropagation();
            deleteCurrentCircuit(this.id);
        });
        if (!embed) {
            showProperties(scope.root);
        }
        dots(false);
    }

    return scope;
}
Function to create new circuit
Function creates button in tab, creates scope and switches to this circuit
@param {string} name - name of the new circuit
@param {string} id - identifier for circuit
@category circuit