{"size": 1562, "ext": "js", "max_stars_repo_path": "Src/window.js", "max_stars_repo_name": "termijn/webgl-volumerendering", "max_stars_repo_stars_event_min_datetime": "2021-10-13T05:56:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T21:55:16.000Z", "max_issues_repo_path": "Src/window.js", "max_issues_repo_name": "termijn/webgl-volumerendering", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Src/window.js", "max_forks_repo_name": "termijn/webgl-volumerendering", "max_forks_repo_forks_event_min_datetime": "2021-06-17T08:55:16.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-09T11:17:31.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 4, "avg_line_length": 31.24, "max_line_length": 122, "alphanum_fraction": 0.5896286812}
function draggableWindow(element) {

    this.dragElement = function(elmnt) {
        var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
        if (document.getElementById(elmnt.id + "Header")) {
          document.getElementById(elmnt.id + "Header").onmousedown = dragMouseDown;
        } else {
          elmnt.onmousedown = dragMouseDown;
        }

    function dragMouseDown(e) {
        e = e || window.event;
        e.preventDefault();
        pos3 = e.clientX;
        pos4 = e.clientY;
        document.onmouseup = closeDragElement;
        document.onmousemove = elementDrag;
    }

    function elementDrag(e) {
          e = e || window.event;
          e.preventDefault();

          pos1 = pos3 - e.clientX;
          pos2 = pos4 - e.clientY;
          pos3 = e.clientX;
          pos4 = e.clientY;

          elmnt.style.top = clamp(elmnt.offsetTop - pos2, 0, window.innerHeight - elmnt.offsetHeight)  + "px";
          elmnt.style.left = Math.max(0, Math.min(elmnt.offsetLeft - pos1, window.innerWidth - elmnt.offsetWidth)) + "px";
        }

        function closeDragElement() {
          document.onmouseup = null;
          document.onmousemove = null;
        }
    }

    dragElement(element);

    element.style.left = window.innerWidth - element.offsetWidth;
    element.style.top = window.innerHeight - element.offsetHeight;

    var button = element.querySelector('#windowOpacityMapHeader > button');
    if (button) {
        button.addEventListener('click', function() {
            element.style.visibility = 'hidden';
        });
    }
}