<commit_before><%@page contentType="text/javascript" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
function createAllArmControls() {
    $$('#epochs li.arm').each(function(li) {
        createArmControls(li)
    })
    $$('#epochs ul').each(function(ul) {
        _updateAllArmsControlVisibility(ul.id)
    })
}

function createArmControls(armItem) {
    var armA = armItem.getElementsByTagName("A")[0];
    var armId = armA.id.substring(4)
    var controlBox = Builder.node("div", {className: 'arm-controls controls'});
    armItem.appendChild(controlBox)

    var renameControl = createRenameControl('arm', armId)
    SC.inPlaceEdit(armA, renameControl.href, {
        externalControl: renameControl,
        externalControlOnly: true,
        highlight: false,
        clickToEditText: armA.title
    })

    var deleteControl = createDeleteControl('arm', armId)
    Event.observe(deleteControl, "click", deleteHandler(function() {
            return "Are you sure you want to delete the arm '" + armA.innerHTML +
                "'?  This will permanently remove it, all its periods, and its events.  " +
                "\n\nThis action cannot be undone."
        }, deleteControl.href
    ))

    var moveUpControl   = createMoveControl(-1, '&#9650;', 'arm', armId)
    SC.asyncLink(moveUpControl, {}, "epochs-indicator")
    var moveDownControl = createMoveControl( 1, '&#9660;', 'arm', armId)
    SC.asyncLink(moveDownControl, {}, "epochs-indicator")

    controlBox.appendChild(moveUpControl)
    controlBox.appendChild(renameControl)
    controlBox.appendChild(deleteControl)
    controlBox.appendChild(moveDownControl)

    updateArmControlVisibility('arm-' + armId + '-item')
}

function updateArmControlVisibility(armItem) {
    var thisArm = $(armItem)
    var siblings = $A(thisArm.parentNode.getElementsByTagName("LI"))

    updateMoveControlVisibility('arm', thisArm.id.split('-')[1], thisArm, siblings)
}

function updateAllArmsControlVisibility(epochId) {
    _updateAllArmsControlVisibility('epoch-' + epochId + '-arms')
}

function _updateAllArmsControlVisibility(eltId) {
    var armItems = $$('#' + eltId + ' li');
    armItems.each(updateArmControlVisibility)
    updateDeleteControlVisibility('arm', armItems, eltId);
}

function createStudyControls() {
    var h1 = $$("h1")[0];
    var studyId = ${param.study}
    var controlBox = Builder.node("span", {className: 'study-controls controls'})
    h1.appendChild(controlBox)

    var renameControl = createRenameControl('study', studyId)
    SC.inPlaceEdit("study-name", renameControl.href, {
        externalControl: renameControl,
        clickToEditText: "Click to rename"
    })

    var addEpochControl = createAddControl("Add epoch", 'study', studyId)
    SC.asyncLink(addEpochControl, {}, "epochs-indicator")

    controlBox.appendChild(renameControl)<commit_msg>Hide arm rename control for zero arm epochs<commit_after><%@page contentType="text/javascript" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
function createAllArmControls() {
    $$('#epochs li.arm').each(function(li) {
        createArmControls(li)
    })
    $$('#epochs ul').each(function(ul) {
        _updateAllArmsControlVisibility(ul.id)
    })
}

function createArmControls(armItem) {
    var armA = armItem.getElementsByTagName("A")[0];
    var armId = armA.id.substring(4)
    var controlBox = Builder.node("div", {className: 'arm-controls controls'});
    armItem.appendChild(controlBox)

    var renameControl = createRenameControl('arm', armId)
    SC.inPlaceEdit(armA, renameControl.href, {
        externalControl: renameControl,
        externalControlOnly: true,
        highlight: false,
        clickToEditText: armA.title
    })

    var deleteControl = createDeleteControl('arm', armId)
    Event.observe(deleteControl, "click", deleteHandler(function() {
            return "Are you sure you want to delete the arm '" + armA.innerHTML +
                "'?  This will permanently remove it, all its periods, and its events.  " +
                "\n\nThis action cannot be undone."
        }, deleteControl.href
    ))

    var moveUpControl   = createMoveControl(-1, '&#9650;', 'arm', armId)
    SC.asyncLink(moveUpControl, {}, "epochs-indicator")
    var moveDownControl = createMoveControl( 1, '&#9660;', 'arm', armId)
    SC.asyncLink(moveDownControl, {}, "epochs-indicator")

    controlBox.appendChild(moveUpControl)
    controlBox.appendChild(renameControl)
    controlBox.appendChild(deleteControl)
    controlBox.appendChild(moveDownControl)

    updateArmControlVisibility('arm-' + armId + '-item')
}

function updateArmControlVisibility(armItem) {
    var thisArm = $(armItem)
    var siblings = $A(thisArm.parentNode.getElementsByTagName("LI"))

    updateMoveControlVisibility('arm', thisArm.id.split('-')[1], thisArm, siblings)
}

function updateAllArmsControlVisibility(epochId) {
    _updateAllArmsControlVisibility('epoch-' + epochId + '-arms')
}

function _updateAllArmsControlVisibility(eltId) {
    var armItems = $$('#' + eltId + ' li');
    armItems.each(updateArmControlVisibility)
    updateDeleteControlVisibility('arm', armItems, eltId);
    if (armItems.length <= 1) {
        $$('#' + eltId + ' li .arm-rename-control').each(function(e) { e.hide() })
    } else {
        $$('#' + eltId + ' li .arm-rename-control').each(function(e) { e.show() })
    }
}

function createStudyControls() {
    var h1 = $$("h1")[0];
    var studyId = ${param.study}
    var controlBox = Builder.node("span", {className: 'study-controls controls'})
    h1.appendChild(controlBox)

    var renameControl = createRenameControl('study', studyId)
    SC.inPlaceEdit("study-name", renameControl.href, {
        externalControl: renameControl,
        clickToEditText: "Click to rename"
    })

    var addEpochControl = createAddControl("Add epoch", 'study', studyId)
    SC.asyncLink(addEpochControl, {}, "epochs-indicator")

    controlBox.appendChild(renameControl)
{'fraction_non_alphanumeric': 0.13932095668171934, 'fraction_numerical': 0.005853821709315939, 'mean_word_length': 3.925864909390445, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6256537', 'n_tokens_mistral': 1865, 'n_tokens_neox': 1818, 'n_words': 348}