Set up bundling and move blog JS to JS file.

This commit is contained in:
Robert Marshall 2020-04-04 12:50:20 +01:00
parent 1b13e22bce
commit a375a4356a
6 changed files with 15 additions and 11 deletions

View file

@ -9,5 +9,3 @@
</article>
<small>Posted on @Model.Timestamp</small>
<partial name="_BlogImageJs" />

View file

@ -21,5 +21,3 @@
<a href="/blog/page/@(Model.Page + 1)" class="round-button blog-navigation__next"><img src="/images/next.svg" alt="Next"/></a>
}
</div>
<partial name="_BlogImageJs" />

View file

@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] | Robware</title>
<link href="/css/style.css" rel="stylesheet" defer/>
<script type="text/javascript" src="/js/javascript.min.js"></script>
</head>
<body>
<header class="header">

View file

@ -2,7 +2,8 @@
{
"outputFileName": "wwwroot/js/javascript.min.js",
"inputFiles": [
"wwwroot/js/javascript.js"
"wwwroot/js/javascript.js",
"wwwroot/js/blog.js"
],
"minify": {
"enabled": true,

View file

@ -1,4 +1,4 @@
<script type="text/javascript">
documentReady(() => {
function adornImage(image, append) {
var parent = image.parentNode;
parent.removeChild(image);
@ -23,7 +23,6 @@
parent.prepend(containerContainer);
}
document.querySelectorAll("p>img:only-child,p>img:first-child").forEach(image => adornImage(image, false));
document.querySelectorAll("p>img:last-child").forEach(image => adornImage(image, true));
</script>
});

View file

@ -58,3 +58,10 @@ Number.prototype.toString=function(input, shouldRound){
return round(this, input);
};
function documentReady(callback) {
if (document.readyState === "complete" || document.readyState === "interactive")
setTimeout(callback, 1);
else
document.addEventListener("DOMContentLoaded", callback);
}