2018-01-07 15:30:12 +00:00
|
|
|
(function() {
|
|
|
|
|
2018-01-22 20:01:39 +00:00
|
|
|
var repeat = function(string, count) {
|
|
|
|
var repeatedString = '';
|
|
|
|
|
|
|
|
for (var i = 0; i < count; i++) {
|
|
|
|
repeatedString += string;
|
|
|
|
}
|
|
|
|
|
|
|
|
return repeatedString;
|
|
|
|
};
|
|
|
|
|
2018-01-07 15:30:12 +00:00
|
|
|
angular
|
2018-01-09 08:01:00 +00:00
|
|
|
.module('NginxConfigIoApp', ['ngclipboard', '720kb.tooltips'])
|
2018-01-07 22:34:59 +00:00
|
|
|
.controller('NginxConfigIoController', function NginxConfigIoController($scope, $location, $timeout) {
|
|
|
|
///////////////////////
|
|
|
|
// PRIVATE VARIABLES //
|
|
|
|
///////////////////////
|
|
|
|
var data = {
|
2018-01-07 15:30:12 +00:00
|
|
|
domain: 'example.com',
|
|
|
|
path: '/var/www/example.com',
|
|
|
|
document_root: '/public',
|
|
|
|
https: false,
|
|
|
|
http2: true,
|
|
|
|
email: 'hello@example.com',
|
2018-01-07 21:53:27 +00:00
|
|
|
cdn: false,
|
2018-01-07 15:30:12 +00:00
|
|
|
non_www: true,
|
|
|
|
php: '7.2',
|
2018-01-07 23:02:48 +00:00
|
|
|
index_php: true,
|
2018-01-07 15:30:12 +00:00
|
|
|
index_html: false,
|
|
|
|
wordpress: false,
|
|
|
|
|
|
|
|
file_structure: 'unified',
|
|
|
|
|
|
|
|
worker_processes: 'auto',
|
|
|
|
user: 'www-data',
|
|
|
|
pid: '/run/nginx.pid',
|
|
|
|
access_log: '/var/log/nginx/access.log',
|
|
|
|
error_log: '/var/log/nginx/error.log',
|
|
|
|
gzip: true,
|
|
|
|
server_tokens: false,
|
|
|
|
log_not_found: false,
|
|
|
|
limit_req: false,
|
|
|
|
|
2018-01-09 07:27:12 +00:00
|
|
|
expires_assets: '7d',
|
|
|
|
expires_media: '7d',
|
|
|
|
expires_svg: '7d',
|
|
|
|
expires_fonts: '7d',
|
2018-01-07 15:30:12 +00:00
|
|
|
};
|
|
|
|
|
2018-01-07 22:34:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
// SCOPE VARIABLES //
|
|
|
|
/////////////////////
|
2018-01-08 07:53:08 +00:00
|
|
|
$scope.location = $location;
|
2018-01-07 22:34:59 +00:00
|
|
|
$scope.data = angular.copy(data);
|
|
|
|
$scope.dataInit = false;
|
2018-01-21 17:49:04 +00:00
|
|
|
$scope.isDirty = false;
|
2018-01-07 22:34:59 +00:00
|
|
|
|
2018-01-07 21:42:27 +00:00
|
|
|
$scope.extensions = {
|
|
|
|
assets: 'css(\\.map)?|js(\\.map)?',
|
|
|
|
fonts: 'ttf|ttc|otf|eot|woff|woff2',
|
|
|
|
svg: 'svgz?',
|
|
|
|
images: 'jpe?g|png|gif|ico|cur|heic|webp|tiff?',
|
|
|
|
audio: 'mp3|m4a|aac|ogg|midi?|wav',
|
|
|
|
video: 'mp4|mov|webm|mpe?g|avi|ogv|flv|wmv',
|
|
|
|
docs: 'pdf|docx?|xlsx?|pptx?'
|
|
|
|
};
|
|
|
|
|
2018-01-07 21:53:27 +00:00
|
|
|
$scope.gzipTypes = 'text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml';
|
|
|
|
|
2018-01-20 21:01:08 +00:00
|
|
|
$scope.clipboardCopy = undefined;
|
2018-01-07 21:42:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
// SCOPE FUNCTIONS //
|
|
|
|
/////////////////////
|
2018-01-07 15:30:12 +00:00
|
|
|
$scope.refreshHighlighting = function() {
|
2018-01-22 20:01:39 +00:00
|
|
|
var sourceCodes = document.querySelectorAll('main .file .code.source');
|
|
|
|
|
|
|
|
for (var i = 0; i < sourceCodes.length; i++) {
|
|
|
|
var sourceCode = sourceCodes[i];
|
|
|
|
|
|
|
|
$timeout(function(_sourceCode) {
|
|
|
|
_sourceCode.nextSibling.innerHTML = _sourceCode.innerHTML;
|
|
|
|
if (_sourceCode.nextSibling.children.length && _sourceCode.nextSibling.children[0].children.length) {
|
|
|
|
hljs.highlightBlock(_sourceCode.nextSibling.children[0].children[0]);
|
2018-01-07 15:30:12 +00:00
|
|
|
}
|
2018-01-22 20:01:39 +00:00
|
|
|
}, 0, true, sourceCode);
|
|
|
|
}
|
2018-01-07 15:30:12 +00:00
|
|
|
};
|
|
|
|
|
2018-01-07 22:34:59 +00:00
|
|
|
$scope.setDataFromHash = function() {
|
|
|
|
var hashData = $location.search();
|
|
|
|
|
|
|
|
for (var key in hashData) {
|
|
|
|
if ($scope.data[key] !== undefined && typeof $scope.data[key] === typeof hashData[key]) {
|
2018-01-21 17:49:04 +00:00
|
|
|
$scope.isDirty = true;
|
2018-01-07 22:34:59 +00:00
|
|
|
$scope.data[key] = hashData[key];
|
2018-01-12 07:29:50 +00:00
|
|
|
gtag('event', key, {
|
|
|
|
event_category: 'data_from_hash',
|
|
|
|
event_label: hashData[key],
|
2018-01-09 07:27:26 +00:00
|
|
|
});
|
2018-01-07 22:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.updateHash = function() {
|
|
|
|
if (!$scope.dataInit) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var changedData = {};
|
|
|
|
for (var key in $scope.data) {
|
|
|
|
if (!angular.equals($scope.data[key], data[key])) {
|
|
|
|
changedData[key] = $scope.data[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Object.keys(changedData).length) {
|
2018-01-21 17:49:04 +00:00
|
|
|
$scope.isDirty = true;
|
2018-01-07 22:34:59 +00:00
|
|
|
$location.search(changedData).replace();
|
|
|
|
} else {
|
2018-01-21 17:49:04 +00:00
|
|
|
$scope.isDirty = false;
|
2018-01-07 22:34:59 +00:00
|
|
|
$location.search({});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-08 07:53:08 +00:00
|
|
|
$scope.reset = function() {
|
|
|
|
$scope.data = angular.copy(data);
|
2018-01-09 07:27:26 +00:00
|
|
|
gtag('event', 'reset');
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.clipboardSuccess = function(key) {
|
2018-01-20 21:01:08 +00:00
|
|
|
$scope.clipboardCopy = key;
|
|
|
|
|
|
|
|
$timeout(function(_key) {
|
|
|
|
if ($scope.clipboardCopy === _key) {
|
|
|
|
$scope.clipboardCopy = undefined;
|
|
|
|
}
|
|
|
|
}, 1500, true, key);
|
|
|
|
|
2018-01-12 07:29:50 +00:00
|
|
|
gtag('event', key, {
|
|
|
|
event_category: 'clipboard',
|
2018-01-09 07:27:26 +00:00
|
|
|
});
|
2018-01-08 07:53:08 +00:00
|
|
|
};
|
|
|
|
|
2018-01-07 21:42:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////
|
|
|
|
// SCOPE EVENTS //
|
|
|
|
//////////////////
|
2018-01-09 07:27:26 +00:00
|
|
|
$scope.$watch('data', function(newValue, oldValue) {
|
2018-01-07 22:34:59 +00:00
|
|
|
$scope.refreshHighlighting();
|
|
|
|
$scope.updateHash();
|
|
|
|
|
2018-01-09 07:27:26 +00:00
|
|
|
for (var key in $scope.data) {
|
|
|
|
if (!angular.equals(newValue[key], oldValue[key])) {
|
2018-01-12 07:29:50 +00:00
|
|
|
gtag('event', key, {
|
|
|
|
event_category: 'data_changed',
|
|
|
|
event_label: $scope.data[key],
|
2018-01-09 07:27:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-07 22:34:59 +00:00
|
|
|
if (!$scope.dataInit) {
|
|
|
|
$scope.dataInit = true;
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////
|
|
|
|
// INIT //
|
|
|
|
//////////
|
|
|
|
$scope.setDataFromHash();
|
2018-01-08 01:49:44 +00:00
|
|
|
})
|
2018-01-09 08:01:00 +00:00
|
|
|
.config(['tooltipsConfProvider', function (tooltipsConfProvider) {
|
|
|
|
tooltipsConfProvider.configure({
|
|
|
|
side: 'right',
|
|
|
|
size: 'small',
|
|
|
|
});
|
|
|
|
}])
|
2018-01-08 01:49:44 +00:00
|
|
|
.directive('ngIncludeTabs', function () {
|
|
|
|
return {
|
|
|
|
require: 'ngInclude',
|
|
|
|
restrict: 'A',
|
|
|
|
link: {
|
|
|
|
pre: function preLink(scope, iElement, iAttrs, controller) {
|
|
|
|
var tabs = parseInt(iAttrs.ngIncludeTabs || 0);
|
2018-01-08 07:28:51 +00:00
|
|
|
|
2018-01-22 20:01:39 +00:00
|
|
|
var startRegex = new RegExp(repeat('\t', tabs - 1));
|
2018-01-08 07:28:51 +00:00
|
|
|
|
|
|
|
controller.template = controller.template
|
2018-01-22 20:01:39 +00:00
|
|
|
.replace(/^(.*)$/mg, repeat('\t', tabs) + '$1')
|
2018-01-08 07:28:51 +00:00
|
|
|
.replace(startRegex, '')
|
|
|
|
.replace(/\s*$/, '');
|
2018-01-08 01:49:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2018-01-07 15:30:12 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
})();
|