Skip to content

Commit 95cb637

Browse files
committed
URL add top-level support
1 parent 956caee commit 95cb637

11 files changed

Lines changed: 1054 additions & 371 deletions

URL/URL.gcomp/Support/URL.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
(function () {
22
'use strict';
33

4+
const getWindowTarget = function (topLevel) {
5+
if (topLevel) {
6+
let windowTarget = window;
7+
while (windowTarget !== windowTarget.parent) {
8+
windowTarget = windowTarget.parent;
9+
}
10+
return windowTarget;
11+
} else {
12+
return window;
13+
}
14+
};
15+
416
const validateEventStreamReader = function (eventStreamReader) {
517
// NXG 5 does not include the ReadableStreamDefaultReader in the global scope so skip validation
618
if (window.ReadableStreamDefaultReader === undefined) {
@@ -15,8 +27,9 @@
1527
return typeof val === 'string' ? val : '';
1628
};
1729

18-
const urlBuildRelativePath = function (baseURL, relativeURL) {
19-
const urlInstance = baseURL === '' ? new URL(relativeURL, window.location.href) : new URL(relativeURL, baseURL);
30+
const urlBuildRelativePath = function (baseURL, relativeURL, topLevel) {
31+
const windowTarget = getWindowTarget(topLevel);
32+
const urlInstance = baseURL === '' ? new URL(relativeURL, windowTarget.location.href) : new URL(relativeURL, baseURL);
2033
return urlInstance.href;
2134
};
2235

@@ -123,34 +136,37 @@
123136
return result;
124137
};
125138

126-
const windowLocationGet = function () {
127-
const url = window.location.href;
139+
const windowLocationGet = function (topLevel) {
140+
const windowTarget = getWindowTarget(topLevel);
141+
const url = windowTarget.location.href;
128142
return url;
129143
};
130144

131-
const windowLocationSet = function (action, url) {
145+
const windowLocationSet = function (action, url, topLevel) {
146+
const windowTarget = getWindowTarget(topLevel);
132147
if (action === 'set') {
133148
// Pushes a new history item onto the history stack and updates url bar.
134149
// Causes the browser to navigate to the new URL.
135150
// Triggers a popstate event
136-
window.location.href = url;
151+
windowTarget.location.href = url;
137152
} else if (action === 'push') {
138153
// Pushes a new history item into the history stack and updates url bar.
139154
// Does not cause the browser to navigate / load a new URL.
140155
// Does not trigger a popstate event
141-
window.history.pushState({}, '', url);
156+
windowTarget.history.pushState({}, '', url);
142157
} else if (action === 'replace') {
143158
// Replaces the current history item on the history stack and updates the url bar.
144159
// Does not cause the browser to navigate / load to a new URL.
145160
// Does not trigger a popstate event
146-
window.history.replaceState({}, '', url);
161+
windowTarget.history.replaceState({}, '', url);
147162
} else {
148163
throw new Error(`Unexpected set window location action: ${action}`);
149164
}
150165
};
151166

152-
const windowLocationReload = function () {
153-
window.location.reload();
167+
const windowLocationReload = function (topLevel) {
168+
const windowTarget = getWindowTarget(topLevel);
169+
windowTarget.location.reload();
154170
};
155171

156172
const windowLocationAddEventListener = function () {

URL/URL.gcomp/Support/URL.jsli

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<SourceFile Checksum="5FF5B4644543A6E9AAC6E83D2716CE301D10EF7889AC3FDE9BB99E926CAA3FAED88D46146AE2067D26422DD27FB0C30A118380A27B960BC538C6CC8EAD413B71" Timestamp="1D7609B4137767C" xmlns="http://www.ni.com/PlatformFramework">
2+
<SourceFile Checksum="79A7B6B272D0475704912265A34195677B37503F028811C2ACF6D3ABAE73D465917DF3B146F2D63BD80156D00A67FEBF72FA6236B442EB2A816170D34A69B669" Timestamp="1DBF06006A4D844" xmlns="http://www.ni.com/PlatformFramework">
33
<SourceModelFeatureSet>
4-
<ParsableNamespace AssemblyFileVersion="8.4.0.49575" FeatureSetName="JavaScript Library" Name="http://www.ni.com/JavaScriptLibrary" OldestCompatibleVersion="6.4.0.49152" Version="6.4.0.49152" />
5-
<ParsableNamespace AssemblyFileVersion="8.4.0.49575" FeatureSetName="Editor" Name="http://www.ni.com/PlatformFramework" OldestCompatibleVersion="8.1.0.49152" Version="8.1.0.49152" />
6-
<ApplicationVersionInfo Build="8.4.0.49575" Name="LabVIEW NXG" Version="5.1.0" />
4+
<ParsableNamespace AssemblyFileVersion="9.5.3.55052" FeatureSetName="JavaScript Library" Name="http://www.ni.com/JavaScriptLibrary" OldestCompatibleVersion="6.4.0.49152" Version="6.4.0.49152" />
5+
<ParsableNamespace AssemblyFileVersion="9.5.3.55052" FeatureSetName="Editor" Name="http://www.ni.com/PlatformFramework" OldestCompatibleVersion="8.1.0.49152" Version="8.1.0.49152" />
6+
<ApplicationVersionInfo Build="9.5.3.55052" Name="G Web Development Software" Version="22.3.0" />
77
</SourceModelFeatureSet>
88
<JavaScriptLibrary Id="c21418cdea384d71b1acbceb67c84ed6" xmlns="http://www.ni.com/JavaScriptLibrary">
99
<Icon Id="1e569c2e1bef447a9f015318c91e7e8a" ListViewIconCrop="0 0 40 40" xmlns="http://www.ni.com/PlatformFramework">
@@ -29,9 +29,9 @@
2929
</IconTemplate>
3030
</IconPanel>
3131
</Icon>
32-
<ConnectorPane Height="40" Id="88a336f02a4f4f0880bf43b082b93cd6" ListViewHeight="85" ListViewWidth="150" Width="40" xmlns="http://www.ni.com/PlatformFramework">
32+
<ConnectorPane Height="40" Id="88a336f02a4f4f0880bf43b082b93cd6" ListViewHeight="100" ListViewWidth="150" Width="40" xmlns="http://www.ni.com/PlatformFramework">
3333
<ConnectorPaneTerminal />
34-
<ConnectorPaneTerminal Hotspot="0 15" />
34+
<ConnectorPaneTerminal Hotspot="0 15" ListViewHotspot="0 80" Parameter="352f54702e2743dcac8aac4a69543758" />
3535
<ConnectorPaneTerminal Hotspot="0 25" />
3636
<ConnectorPaneTerminal Hotspot="0 35" ListViewHotspot="0 35" Parameter="1ea26ea9d4a949df96348dade03035d8" />
3737
<ConnectorPaneTerminal Hotspot="15 0" />
@@ -49,6 +49,10 @@
4949
<JavaScriptType ActualDataType="@7a0d745212ea43e8a195a3e0a8f4fb9a" Id="11f3e542288241c4bbf8bc04a19cab80" />
5050
<JavaScriptLibraryDiagramParameter CallDirection="Output" Id="cbbeffdbe6774dab8444d4ec6f8f109d" Name="url" />
5151
</JavaScriptLibraryParameter>
52+
<JavaScriptLibraryParameter Id="6ba684e3a23e4707a294168c824e16c0" Name="topLevel">
53+
<JavaScriptType ActualDataType="@d2fa43a9368e42e68ed3c38f551d293a" Id="750cb8c68f55428e86e0f8657711320b" />
54+
<JavaScriptLibraryDiagramParameter CallDirection="Input" Id="352f54702e2743dcac8aac4a69543758" Name="topLevel" />
55+
</JavaScriptLibraryParameter>
5256
</JavaScriptLibraryEntryPoint>
5357
</EmbeddedDefinitionReference>
5458
<EmbeddedDefinitionReference Id="c62fc718eb5a4094954159d875a4f4aa" ModelDefinitionType="{http://www.ni.com/JavaScriptLibrary}JavaScriptLibraryEntryPoint" Name="WindowLocationSet">
@@ -64,10 +68,10 @@
6468
</IconTemplate>
6569
</IconPanel>
6670
</Icon>
67-
<ConnectorPane Height="40" Id="47cd19e69092431395a908e01d17196a" ListViewHeight="100" ListViewWidth="150" Width="40" xmlns="http://www.ni.com/PlatformFramework">
71+
<ConnectorPane Height="40" Id="47cd19e69092431395a908e01d17196a" ListViewHeight="115" ListViewWidth="150" Width="40" xmlns="http://www.ni.com/PlatformFramework">
6872
<ConnectorPaneTerminal ListViewHotspot="0 65" Parameter="7e90b309f60b43d28d79af7edd39bcce" />
6973
<ConnectorPaneTerminal Hotspot="0 15" ListViewHotspot="0 80" Parameter="3f8da4c732d541bb8df77acf2fc53c2e" />
70-
<ConnectorPaneTerminal Hotspot="0 25" />
74+
<ConnectorPaneTerminal Hotspot="0 25" ListViewHotspot="0 95" Parameter="bcaff11b73d4e109b699de887e8c171" />
7175
<ConnectorPaneTerminal Hotspot="0 35" ListViewHotspot="0 35" Parameter="3e2e8681617e46ea9c8894d4b56287a8" />
7276
<ConnectorPaneTerminal Hotspot="15 0" />
7377
<ConnectorPaneTerminal Hotspot="25 0" />
@@ -92,6 +96,10 @@
9296
<JavaScriptType ActualDataType="@7a0d745212ea43e8a195a3e0a8f4fb9a" Id="22e40ab6b174430aa07befe1e75995d5" />
9397
<JavaScriptLibraryDiagramParameter CallDirection="Input" Id="3f8da4c732d541bb8df77acf2fc53c2e" Name="url" />
9498
</JavaScriptLibraryParameter>
99+
<JavaScriptLibraryParameter Id="b0a2d5398bb84f74b127e030525e4660" Name="topLevel">
100+
<JavaScriptType ActualDataType="@d2fa43a9368e42e68ed3c38f551d293a" Id="98f5aa9356514392abc0f74de2f9544d" />
101+
<JavaScriptLibraryDiagramParameter CallDirection="Input" Id="bcaff11b73d4e109b699de887e8c171" Name="topLevel" />
102+
</JavaScriptLibraryParameter>
95103
</JavaScriptLibraryEntryPoint>
96104
</EmbeddedDefinitionReference>
97105
<EmbeddedDefinitionReference Id="2660beb50fcd4841beb98ff1ba9419f0" ModelDefinitionType="{http://www.ni.com/JavaScriptLibrary}JavaScriptLibraryEntryPoint" Name="URLDownload">
@@ -252,30 +260,32 @@
252260
</EmbeddedDefinitionReference>
253261
<EmbeddedDefinitionReference Id="446a73b35ce4463eb1dd39ebbd561a39" ModelDefinitionType="{http://www.ni.com/JavaScriptLibrary}JavaScriptLibraryEntryPoint" Name="URLBuildRelativePath">
254262
<JavaScriptLibraryEntryPoint Id="78081f5ee6d74ec391af5d85bfc60872" Symbol="WebVIURL.urlBuildRelativePath" xmlns="http://www.ni.com/JavaScriptLibrary">
255-
<Icon Id="e2537d0213524241801af4b41898b059" ListViewIconCrop="0 0 40 40" xmlns="http://www.ni.com/PlatformFramework">
256-
<IconPanel Height="[float]40" Id="7a31d4d1d59b407898fd8842a1ea93bb" Left="[float]0" PanelSizeMode="Resize" Top="[float]0" Width="[float]40">
257-
<IconTemplate ClipMargin="[SMThickness]3,3,3,3" Height="[float]40" Id="4a3efa9351474444b9f0e02ffa94ac6c" Left="[float]0" TemplateName="[string]Gray" Top="[float]0" Width="[float]40">
263+
<Icon Id="e2537d0213524241801af4b41898b059" ListViewIconCrop="0 0 40 50" xmlns="http://www.ni.com/PlatformFramework">
264+
<IconPanel Height="[float]50" Id="7a31d4d1d59b407898fd8842a1ea93bb" Left="[float]0" PanelSizeMode="Resize" Top="[float]0" Width="[float]40">
265+
<IconTemplate ClipMargin="[SMThickness]3,3,3,3" Height="[float]50" Id="4a3efa9351474444b9f0e02ffa94ac6c" Left="[float]0" TemplateName="[string]Gray" Top="[float]0" Width="[float]40">
258266
<Rectangle Fill="[SMSolidColorBrush]#ff727272" Id="3306cec5e05449fba5c336c02a639f20" IsHitTestVisible="[bool]False" Left="[float]0" RadiusX="[float]4" RadiusY="[float]4" Top="[float]0" />
259267
<Rectangle Fill="[SMSolidColorBrush]#ffe5e5e5" Id="b8b7a857756749a080dbf738c15b525c" IsHitTestVisible="[bool]False" Left="[float]0" Margin="[SMThickness]1,1,1,1" RadiusX="[float]2.5" RadiusY="[float]2.5" Stroke="[SMSolidColorBrush]#fff2f2f2" Top="[float]0" />
260-
<FileNameText Attached="[bool]True" Id="80fa98095eeb4cf2826f42dd80ed5a9b" Left="[float]0" Margin="[SMThickness]2,2,2,2" SizeMode="[TextModelSizeMode]AutoFont" Text="[string]URLBuildRelativePath" TextAlignment="[TextAlignment]Center" TextWrapping="[TextWrapping]Wrap" Top="[float]0" VerticalScrollBarVisibility="[ScrollBarVisibility]Hidden">
268+
<FileNameText Attached="[bool]True" Height="[float]46" Id="80fa98095eeb4cf2826f42dd80ed5a9b" Left="[float]0" Margin="[SMThickness]2,2,2,2" SizeMode="[TextModelSizeMode]AutoFont" Text="[string]URLBuildRelativePath" TextAlignment="[TextAlignment]Center" TextWrapping="[TextWrapping]Wrap" Top="[float]0" VerticalScrollBarVisibility="[ScrollBarVisibility]Hidden">
261269
<FontSetting FontFamily="Segoe UI" FontSize="6" Id="7ca509d77d2040a990260e52e70bf19d" />
262270
</FileNameText>
263271
</IconTemplate>
264272
</IconPanel>
265273
</Icon>
266-
<ConnectorPane Height="40" Id="4e132446867d4b4fad7e895834fa141b" ListViewHeight="115" ListViewWidth="150" Width="40" xmlns="http://www.ni.com/PlatformFramework">
274+
<ConnectorPane Height="50" Id="4e132446867d4b4fad7e895834fa141b" ListViewHeight="130" ListViewWidth="150" Width="40" xmlns="http://www.ni.com/PlatformFramework">
267275
<ConnectorPaneTerminal />
268-
<ConnectorPaneTerminal Hotspot="0 15" ListViewHotspot="0 65" Parameter="afcda2c5884f4920b363186548880e13" />
269-
<ConnectorPaneTerminal Hotspot="0 25" ListViewHotspot="0 95" Parameter="bcfa4d28a96a427db896967ded08d0fa" />
270-
<ConnectorPaneTerminal Hotspot="0 35" ListViewHotspot="0 35" Parameter="d9eb97489df94e418022a9f5ff63fb63" />
276+
<ConnectorPaneTerminal Hotspot="0 15" ListViewHotspot="0 50" Parameter="afcda2c5884f4920b363186548880e13" />
277+
<ConnectorPaneTerminal Hotspot="0 25" ListViewHotspot="0 80" Parameter="bcfa4d28a96a427db896967ded08d0fa" />
278+
<ConnectorPaneTerminal Hotspot="0 35" ListViewHotspot="0 35" Parameter="35d9722e413a422a8dfbe48a17a7a7ed" />
271279
<ConnectorPaneTerminal Hotspot="15 0" />
272280
<ConnectorPaneTerminal Hotspot="25 0" />
273-
<ConnectorPaneTerminal Hotspot="40 5" ListViewHotspot="150 80" Parameter="b14728856b484a41b1bcac46ca889573" />
281+
<ConnectorPaneTerminal Hotspot="40 5" ListViewHotspot="150 65" Parameter="b14728856b484a41b1bcac46ca889573" />
274282
<ConnectorPaneTerminal Hotspot="40 15" />
275283
<ConnectorPaneTerminal Hotspot="40 25" />
276-
<ConnectorPaneTerminal Hotspot="40 35" ListViewHotspot="150 50" Parameter="da5ee9099d1f413a9d35c9ba287880ba" />
277-
<ConnectorPaneTerminal Hotspot="15 40" />
278-
<ConnectorPaneTerminal Hotspot="25 40" />
284+
<ConnectorPaneTerminal Hotspot="40 35" />
285+
<ConnectorPaneTerminal Hotspot="15 50" />
286+
<ConnectorPaneTerminal Hotspot="25 50" />
287+
<ConnectorPaneTerminal Hotspot="0 45" ListViewHotspot="0 95" Parameter="d9eb97489df94e418022a9f5ff63fb63" />
288+
<ConnectorPaneTerminal Hotspot="40 45" ListViewHotspot="150 110" Parameter="da5ee9099d1f413a9d35c9ba287880ba" />
279289
</ConnectorPane>
280290
<JavaScriptLibraryDiagramParameter CallDirection="Input" Id="d9eb97489df94e418022a9f5ff63fb63" IsError="True" Name="error in" />
281291
<JavaScriptLibraryDiagramParameter CallDirection="Output" Id="da5ee9099d1f413a9d35c9ba287880ba" IsError="True" Name="error out" />
@@ -291,6 +301,10 @@
291301
<JavaScriptType ActualDataType="@7a0d745212ea43e8a195a3e0a8f4fb9a" Id="e19655b37d47440baff6d24e7a397557" />
292302
<JavaScriptLibraryDiagramParameter CallDirection="Input" Id="bcfa4d28a96a427db896967ded08d0fa" Name="relativeURL" />
293303
</JavaScriptLibraryParameter>
304+
<JavaScriptLibraryParameter Id="b6f34edbf3a847c29dfe20d94733f8d2" Name="topLevel">
305+
<JavaScriptType ActualDataType="@d2fa43a9368e42e68ed3c38f551d293a" Id="9f5e7ffcb6004389aff48828360e07f7" />
306+
<JavaScriptLibraryDiagramParameter CallDirection="Input" Id="35d9722e413a422a8dfbe48a17a7a7ed" Name="topLevel" />
307+
</JavaScriptLibraryParameter>
294308
</JavaScriptLibraryEntryPoint>
295309
</EmbeddedDefinitionReference>
296310
<EmbeddedDefinitionReference Id="33569941adae48029710ee1edb27a2f1" ModelDefinitionType="{http://www.ni.com/JavaScriptLibrary}JavaScriptLibraryEntryPoint" Name="URLGetParts">
@@ -580,8 +594,8 @@
580594
</IconTemplate>
581595
</IconPanel>
582596
</Icon>
583-
<ConnectorPane Height="40" Id="bc7e4c15d5e5478cbb3163b1d0f4d9c2" ListViewHeight="70" ListViewWidth="150" Width="40" xmlns="http://www.ni.com/PlatformFramework">
584-
<ConnectorPaneTerminal />
597+
<ConnectorPane Height="40" Id="bc7e4c15d5e5478cbb3163b1d0f4d9c2" ListViewHeight="85" ListViewWidth="150" Width="40" xmlns="http://www.ni.com/PlatformFramework">
598+
<ConnectorPaneTerminal ListViewHotspot="0 65" Parameter="44dc4a34284f4abcb1b05baef6d81369" />
585599
<ConnectorPaneTerminal Hotspot="0 15" />
586600
<ConnectorPaneTerminal Hotspot="0 25" />
587601
<ConnectorPaneTerminal Hotspot="0 35" ListViewHotspot="0 35" Parameter="995b4d91de2349ef85dfde36ddf28126" />
@@ -600,6 +614,10 @@
600614
<JavaScriptType ActualDataType="@761c1e6d42c140fea62c015adb1483c9" Id="d828e315ec5e4b07a0ecfd643eeb07af" />
601615
<JavaScriptLibraryDiagramParameter CallDirection="Output" Id="e893e2cfdc445558ebb926c2d5b127c" Name="return out" Visible="False" />
602616
</JavaScriptLibraryParameter>
617+
<JavaScriptLibraryParameter Id="36ed187b753448d2b9b46632ccb2d183" Name="topLevel">
618+
<JavaScriptType ActualDataType="@d2fa43a9368e42e68ed3c38f551d293a" Id="8c5242276d414096929a7c3c598e45ea" />
619+
<JavaScriptLibraryDiagramParameter CallDirection="Input" Id="44dc4a34284f4abcb1b05baef6d81369" Name="topLevel" />
620+
</JavaScriptLibraryParameter>
603621
</JavaScriptLibraryEntryPoint>
604622
</EmbeddedDefinitionReference>
605623
<EmbeddedDefinitionReference Id="215eeec980694fcdb8b6ae344d2772c8" ModelDefinitionType="{http://www.ni.com/JavaScriptLibrary}JavaScriptLibraryEntryPoint" Name="QueryStringDeleteParameter">
@@ -739,25 +757,25 @@
739757
</AttributeValues>
740758
</Attributed>
741759
</p.TypeReference>
742-
<p.TypeReference TypeId="761c1e6d42c140fea62c015adb1483c9">
743-
<Attributed AttributedType="Void">
760+
<p.TypeReference TypeId="d2fa43a9368e42e68ed3c38f551d293a">
761+
<Attributed AttributedType="Boolean">
744762
<AttributeValues>
745763
<AttributeValue Name="NationalInstruments.JavaScriptType" Value="[string]" />
746764
</AttributeValues>
747765
</Attributed>
748766
</p.TypeReference>
749-
<p.TypeReference TypeId="8e39b3e51f424325880b3db570786c0a">
750-
<Attributed AttributedType="@e954979a712f445f984cd718323f5e1e">
767+
<p.TypeReference TypeId="761c1e6d42c140fea62c015adb1483c9">
768+
<Attributed AttributedType="Void">
751769
<AttributeValues>
752770
<AttributeValue Name="NationalInstruments.JavaScriptType" Value="[string]" />
753-
<AttributeValue Name="NI_PlatformFramework_RefnumAttributes" Value="[NI_PlatformFramework_RefnumAttributes]Refnum" />
754771
</AttributeValues>
755772
</Attributed>
756773
</p.TypeReference>
757-
<p.TypeReference TypeId="d2fa43a9368e42e68ed3c38f551d293a">
758-
<Attributed AttributedType="Boolean">
774+
<p.TypeReference TypeId="8e39b3e51f424325880b3db570786c0a">
775+
<Attributed AttributedType="@e954979a712f445f984cd718323f5e1e">
759776
<AttributeValues>
760777
<AttributeValue Name="NationalInstruments.JavaScriptType" Value="[string]" />
778+
<AttributeValue Name="NI_PlatformFramework_RefnumAttributes" Value="[NI_PlatformFramework_RefnumAttributes]Refnum" />
761779
</AttributeValues>
762780
</Attributed>
763781
</p.TypeReference>

0 commit comments

Comments
 (0)