Skip to content

Commit e656c2b

Browse files
committed
Infrastructure Preparation 23
1 parent 200524e commit e656c2b

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/Taiizor.Essentials.Blazor/Extension/Add.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,15 @@ public static async Task BodyScript(string Node)
2121
{
2222
await Interop.Call("Taiizor.Add.Script.Body", Node);
2323
}
24+
25+
public static async Task Element(string Identify, string Tag)
26+
{
27+
await Interop.Call("Taiizor.Add.Element", Identify, Tag);
28+
}
29+
30+
public static async Task ElementScript(string Identify, string Node)
31+
{
32+
await Interop.Call("Taiizor.Add.Script.Element", Identify, Node);
33+
}
2434
}
2535
}

src/Taiizor.Essentials.Blazor/Extension/Include.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ public static async Task ScriptProtected(string Path, string Pathname)
3838
}
3939
}
4040

41+
public static async Task ScriptElement(string Identify, string Path)
42+
{
43+
await Interop.Call("Taiizor.Include.Js.Element", Identify, Path);
44+
}
45+
46+
public static async Task ScriptElementProtected(string Identify, string Path, string Pathname)
47+
{
48+
if (await Location.GetPathname() == Pathname)
49+
{
50+
await ScriptElement(Identify, Path);
51+
}
52+
}
53+
4154
public static async Task Stylesheet(string Path)
4255
{
4356
await Stylesheet(Path, "stylesheet");

src/Taiizor.Essentials.Blazor/Resources/Raw/Taiizor.Blazor.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,10 @@ Taiizor.Add.Body = function (tagHtml) {
744744
document.body.appendChild(document.createRange().createContextualFragment(tagHtml));
745745
}
746746

747+
Taiizor.Add.Element = function (elementId, tagHtml) {
748+
document.getElementById(elementId).appendChild(document.createRange().createContextualFragment(tagHtml));
749+
}
750+
747751
Taiizor.Add.Script.Head = function (textNode) {
748752
var element = document.createElement('script');
749753
element.setAttribute('type', 'text/javascript');
@@ -760,6 +764,14 @@ Taiizor.Add.Script.Body = function (textNode) {
760764
document.body.appendChild(element);
761765
}
762766

767+
Taiizor.Add.Script.Element = function (elementId, textNode) {
768+
var element = document.createElement('script');
769+
element.setAttribute('type', 'text/javascript');
770+
771+
element.appendChild(document.createTextNode(textNode));
772+
document.getElementById(elementId).appendChild(element);
773+
}
774+
763775

764776

765777
Taiizor.Attribute.Set = function (elementId, propertyName, propertyValue) {
@@ -877,6 +889,12 @@ Taiizor.Include.Js = function (path) {
877889
document.body.appendChild(customScript);
878890
}
879891

892+
Taiizor.Include.Js.Element = function (elementId, path) {
893+
var customScript = document.createElement('script');
894+
customScript.setAttribute('src', path);
895+
document.getElementById(elementId).appendChild(customScript);
896+
}
897+
880898
Taiizor.Include.Css = function (path, rel, type) {
881899
var customStylesheet = document.createElement('link');
882900
customStylesheet.setAttribute('href', path);

0 commit comments

Comments
 (0)