function generateSaveData(name, setName = true) {
    data = {};

    // Prompts for name, defaults to Untitled
    name = getProjectName() || name || prompt('Enter Project Name:') || 'Untitled';
    data.name = stripTags(name);
    if (setName) setProjectName(data.name);

    // Save project details
    data.timePeriod = simulationArea.timePeriod;
    data.clockEnabled = simulationArea.clockEnabled;
    data.projectId = projectId;
    data.focussedCircuit = globalScope.id;
    data.orderedTabs = getTabsOrder();

    // Project Circuits, each scope is one circuit
    data.scopes = [];
    const dependencyList = {};
    const completed = {};
    // Getting list of dependencies for each circuit
    for (id in scopeList) { dependencyList[id] = scopeList[id].getDependencies(); }

    // Helper function to save Scope
    // Recursively saves inner subcircuits first, before saving parent circuits
    function saveScope(id) {
        if (completed[id]) return;

        for (let i = 0; i < dependencyList[id].length; i++) {
            // Save inner subcircuits
            saveScope(dependencyList[id][i]);
        }

        completed[id] = true;


        // This update is very important.
        // if a scope's input/output changes and the user saves without going
        // to circuits where this circuit is used as a subcircuit. It will
        // break the code since the Subcircuit will have different number of
        // in/out nodes compared to the localscope input/output objects.
        update(scopeList[id], true); // For any pending integrity checks on subcircuits
        data.scopes.push(backUp(scopeList[id]));
    }

    // Save all circuits
    for (let id in scopeList) { saveScope(id); }

    // convert to text
    data = JSON.stringify(data);
    return data;
}
Generates JSON of the entire project
@param {string} name - the name of project
@return {JSON}
@category data