mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-09 23:18:37 +02:00
fix: fix minimization of the client js
This commit is contained in:
+84
-73
@@ -196,32 +196,35 @@ angular
|
|||||||
return capitalized.join(" ");
|
return capitalized.join(" ");
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter("diff", function ($sce) {
|
.filter("diff", [
|
||||||
return function (str) {
|
"$sce",
|
||||||
if (!str) return str;
|
function ($sce) {
|
||||||
const lines = str.split("\n");
|
return function (str) {
|
||||||
const o = [];
|
if (!str) return str;
|
||||||
for (let i = 1; i < lines.length; i++) {
|
const lines = str.split("\n");
|
||||||
lines[i] = lines[i].replace(/</g, "<").replace(/>/g, ">");
|
const o = [];
|
||||||
if (lines[i].startsWith("+++")) {
|
for (let i = 1; i < lines.length; i++) {
|
||||||
o.push(`<span class="diff-file">${lines[i]}</span>`);
|
lines[i] = lines[i].replace(/</g, "<").replace(/>/g, ">");
|
||||||
} else if (lines[i].startsWith("---")) {
|
if (lines[i].startsWith("+++")) {
|
||||||
o.push(`<span class="diff-file">${lines[i]}</span>`);
|
o.push(`<span class="diff-file">${lines[i]}</span>`);
|
||||||
} else if (lines[i].startsWith("@@")) {
|
} else if (lines[i].startsWith("---")) {
|
||||||
o.push(`<span class="diff-lines">${lines[i]}</span>`);
|
o.push(`<span class="diff-file">${lines[i]}</span>`);
|
||||||
} else if (lines[i].startsWith("index")) {
|
} else if (lines[i].startsWith("@@")) {
|
||||||
o.push(`<span class="diff-index">${lines[i]}</span>`);
|
o.push(`<span class="diff-lines">${lines[i]}</span>`);
|
||||||
} else if (lines[i].startsWith("+")) {
|
} else if (lines[i].startsWith("index")) {
|
||||||
o.push(`<span class="diff-add">${lines[i]}</span>`);
|
o.push(`<span class="diff-index">${lines[i]}</span>`);
|
||||||
} else if (lines[i].startsWith("-")) {
|
} else if (lines[i].startsWith("+")) {
|
||||||
o.push(`<span class="diff-remove">${lines[i]}</span>`);
|
o.push(`<span class="diff-add">${lines[i]}</span>`);
|
||||||
} else {
|
} else if (lines[i].startsWith("-")) {
|
||||||
o.push(`<span class="diff-line">${lines[i]}</span>`);
|
o.push(`<span class="diff-remove">${lines[i]}</span>`);
|
||||||
|
} else {
|
||||||
|
o.push(`<span class="diff-line">${lines[i]}</span>`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return $sce.trustAsHtml(o.join("\n"));
|
||||||
return $sce.trustAsHtml(o.join("\n"));
|
};
|
||||||
};
|
},
|
||||||
})
|
])
|
||||||
.directive("markdown", [
|
.directive("markdown", [
|
||||||
"$location",
|
"$location",
|
||||||
function ($location) {
|
function ($location) {
|
||||||
@@ -394,37 +397,42 @@ angular
|
|||||||
return {
|
return {
|
||||||
restrict: "E",
|
restrict: "E",
|
||||||
scope: { file: "=" },
|
scope: { file: "=" },
|
||||||
controller: function ($element, $scope, $http) {
|
controller: [
|
||||||
function renderNotebookJSON(json) {
|
"$element",
|
||||||
const notebook = nb.parse(json);
|
"$scope",
|
||||||
try {
|
"$http",
|
||||||
$element.html("");
|
function ($element, $scope, $http) {
|
||||||
$element.append(notebook.render());
|
function renderNotebookJSON(json) {
|
||||||
Prism.highlightAll();
|
const notebook = nb.parse(json);
|
||||||
} catch (error) {
|
|
||||||
$element.html("Unable to render the notebook.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function render() {
|
|
||||||
if ($scope.$parent.content) {
|
|
||||||
try {
|
try {
|
||||||
renderNotebookJSON(JSON.parse($scope.$parent.content));
|
$element.html("");
|
||||||
|
$element.append(notebook.render());
|
||||||
|
Prism.highlightAll();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
$element.html(
|
$element.html("Unable to render the notebook.");
|
||||||
"Unable to render the notebook invalid notebook format."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else if ($scope.file) {
|
|
||||||
$http
|
|
||||||
.get($scope.file.download_url)
|
|
||||||
.then((res) => renderNotebookJSON(res.data));
|
|
||||||
}
|
}
|
||||||
}
|
function render() {
|
||||||
$scope.$watch("file", (v) => {
|
if ($scope.$parent.content) {
|
||||||
|
try {
|
||||||
|
renderNotebookJSON(JSON.parse($scope.$parent.content));
|
||||||
|
} catch (error) {
|
||||||
|
$element.html(
|
||||||
|
"Unable to render the notebook invalid notebook format."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if ($scope.file) {
|
||||||
|
$http
|
||||||
|
.get($scope.file.download_url)
|
||||||
|
.then((res) => renderNotebookJSON(res.data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$scope.$watch("file", (v) => {
|
||||||
|
render();
|
||||||
|
});
|
||||||
render();
|
render();
|
||||||
});
|
},
|
||||||
render();
|
],
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
@@ -435,32 +443,35 @@ angular
|
|||||||
scope: { stats: "=" },
|
scope: { stats: "=" },
|
||||||
template:
|
template:
|
||||||
"<div class='lang' ng-repeat='lang in elements' title='{{lang.lang|title}}: {{lang.loc | number}} lines' data-toggle='tooltip' data-placement='bottom' style='width:{{lang.loc*100/total}}%;background:{{lang.color}};'></div>",
|
"<div class='lang' ng-repeat='lang in elements' title='{{lang.lang|title}}: {{lang.loc | number}} lines' data-toggle='tooltip' data-placement='bottom' style='width:{{lang.loc*100/total}}%;background:{{lang.color}};'></div>",
|
||||||
controller: function ($scope) {
|
controller: [
|
||||||
function render() {
|
"$scope",
|
||||||
$scope.elements = [];
|
function ($scope) {
|
||||||
$scope.total = 0;
|
function render() {
|
||||||
for (let lang in $scope.stats) {
|
$scope.elements = [];
|
||||||
const loc = $scope.stats[lang].code;
|
$scope.total = 0;
|
||||||
if (!loc) {
|
for (let lang in $scope.stats) {
|
||||||
continue;
|
const loc = $scope.stats[lang].code;
|
||||||
|
if (!loc) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$scope.total += loc;
|
||||||
|
$scope.elements.push({
|
||||||
|
lang,
|
||||||
|
loc,
|
||||||
|
color: langColors[lang],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
$scope.total += loc;
|
setTimeout(() => {
|
||||||
$scope.elements.push({
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
lang,
|
}, 100);
|
||||||
loc,
|
|
||||||
color: langColors[lang],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.$watch("stats", (v) => {
|
$scope.$watch("stats", (v) => {
|
||||||
|
render();
|
||||||
|
});
|
||||||
render();
|
render();
|
||||||
});
|
},
|
||||||
render();
|
],
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user