Repository: syncthing/syncthing
File: gui/default/syncthing/core/syncthingController.js (JavaScript)

Code before:
            }
            return deviceID.substr(0, 6);
        };

        $scope.findDevice = function (deviceID) {
            var matches = $scope.devices.filter(function (n) {
                return n.deviceID === deviceID;
            });
            if (matches.length !== 1) {
                return undefined;
            }
            return matches[0];
        };

        $scope.deviceName = function (deviceCfg) {
            if (typeof deviceCfg === 'undefined' || typeof deviceCfg.deviceID === 'undefined') {
                return "";
            }
            if (deviceCfg.name) {
                return deviceCfg.name;
            }
            return deviceCfg.deviceID.substr(0, 6);
        };

        $scope.getSupportBundle = function (){
            $http.get(urlbase + '/system/support', {responseType: 'arraybuffer'})
             .success( function (data, status, headers) {
                var header = headers()["content-disposition"]
                var contentType = headers()['content-type']
                var filename = header.split(';')[1].trim().split('=')[1];
                // Get the blob url
                    var url = window.URL || window.webkitURL || window.mozURL || window.msURL;
                    if(url)
                    {
                        var a = document.createElement('a');
                        var blob = new Blob([data], { type: contentType });
                        var url = url.createObjectURL(blob);
                        a.setAttribute('href', url);
                        a.setAttribute("download", filename);
                        var event = document.createEvent('MouseEvents');
                        event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
                        a.dispatchEvent(event);
                    };
             });
        };

        $scope.thisDeviceName = function () {
            var device = $scope.thisDevice();
            if (typeof device === 'undefined') {
                return "(unknown device)";
            }

Review comment (suggestion):
I think this thing is not required at all. A simple `<a href="...">` pointing directly to the `/system/support` endpoint should cause the browser to save the file, as you are setting the content-disposition header server-side. No javascript required. :)

Code after:
                return $scope.deviceName(match);
            }
            return deviceID.substr(0, 6);
        };

        $scope.findDevice = function (deviceID) {
            var matches = $scope.devices.filter(function (n) {
                return n.deviceID === deviceID;
            });
            if (matches.length !== 1) {
                return undefined;
            }
            return matches[0];
        };

        $scope.deviceName = function (deviceCfg) {
            if (typeof deviceCfg === 'undefined' || typeof deviceCfg.deviceID === 'undefined') {
                return "";
            }
            if (deviceCfg.name) {
                return deviceCfg.name;
            }
            return deviceCfg.deviceID.substr(0, 6);
        };

        $scope.thisDeviceName = function () {
            var device = $scope.thisDevice();
            if (typeof device === 'undefined') {
                return "(unknown device)";
            }
            if (device.name) {
                return device.name;
            }
            return device.deviceID.substr(0, 6);
        };

        $scope.setDevicePause = function (device, pause) {
            $scope.devices.forEach(function (cfg) {
                if (cfg.deviceID == device) {
                    cfg.paused = pause;
                }
            });
            $scope.config.devices = $scope.devices;
            $scope.saveConfig();
        };

        $scope.setFolderPause = function (folder, pause) {
            var cfg = $scope.folders[folder];
            if (cfg) {
                cfg.paused = pause;
                $scope.config.folders = folderList($scope.folders);