Skip to content

Commit 16cd53f

Browse files
committed
new op over engineered hyperlink
1 parent 999754d commit 16cd53f

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const
2+
exec = op.inTriggerButton("Open"),
3+
inMeth = op.inSwitch("Method", ["anchor", "document.location", "window.open"], "anchor"),
4+
inUrl = op.inString("URL", "https://cables.gl"),
5+
inTarget = op.inSwitch("Target", ["_blank", "_self", "_parent", "_top", "frame name"]),
6+
inTargetString = op.inString("Frame Name", ""),
7+
inSpecs = op.inString("Win Specs", ""),
8+
inRel = op.inString("rel Attribute", "");
9+
10+
let targetStr = "";
11+
12+
inMeth.onChange =
13+
inTarget.onChange = updateUi;
14+
15+
updateUi();
16+
17+
function updateUi()
18+
{
19+
inTargetString.setUiAttribs({ "greyout": inTarget.get() != "frame name" });
20+
inTarget.setUiAttribs({ "greyout": inMeth.get() == "document.location" });
21+
inSpecs.setUiAttribs({ "greyout": inMeth.get() != "window.open" });
22+
inRel.setUiAttribs({ "greyout": inMeth.get() != "anchor" });
23+
24+
targetStr = inTarget.get();
25+
if (targetStr == "frame name")targetStr = inTargetString.get();
26+
}
27+
28+
exec.onTriggered = function ()
29+
{
30+
if (inMeth.get() == "anchor")
31+
{
32+
const link = document.createElement("a");
33+
link.href = inUrl.get();
34+
link.target = inTarget.get();
35+
link.rel = inRel.get();
36+
37+
link.click();
38+
}
39+
if (inMeth.get() == "document.location")
40+
{
41+
document.location.href = inUrl.get();
42+
}
43+
else
44+
{
45+
window.open(inUrl.get(), inTarget.get(), inSpecs.get());
46+
}
47+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"id": "b328a1d1-1cfd-4192-b0f2-91f26d284a1a",
3+
"changelog": [
4+
{
5+
"message": "created op",
6+
"author": "pandur",
7+
"date": 1556293017309,
8+
"type": "new"
9+
},
10+
{
11+
"message": "Choose between different methods to go to a URL, window.open, document.location or a anchor link",
12+
"type": "feature",
13+
"author": "pandur",
14+
"date": 1741792089689
15+
},
16+
{
17+
"message": "Added option to choose the target frame",
18+
"type": "feature",
19+
"author": "pandur",
20+
"date": 1741792108999
21+
},
22+
{
23+
"message": "Add input for rel attribute",
24+
"type": "feature",
25+
"author": "pandur",
26+
"date": 1741792124088
27+
}
28+
],
29+
"authorName": "pandur",
30+
"created": 1741791263322,
31+
"layout": {
32+
"portsIn": [
33+
{
34+
"type": 1,
35+
"name": "Open"
36+
},
37+
{
38+
"type": 0,
39+
"name": "Method index",
40+
"values": [
41+
"anchor",
42+
"document.location",
43+
"window.open"
44+
],
45+
"subType": "integer"
46+
},
47+
{
48+
"type": 5,
49+
"name": "URL"
50+
},
51+
{
52+
"type": 0,
53+
"name": "Target index",
54+
"values": [
55+
"_blank",
56+
"_self",
57+
"_parent",
58+
"_top",
59+
"frame name"
60+
],
61+
"subType": "integer"
62+
},
63+
{
64+
"type": 5,
65+
"name": "Frame Name"
66+
},
67+
{
68+
"type": 5,
69+
"name": "Win Specs"
70+
},
71+
{
72+
"type": 5,
73+
"name": "rel Attribute"
74+
}
75+
],
76+
"portsOut": []
77+
},
78+
"summary": "Open another website",
79+
"docs": {
80+
"ports": []
81+
},
82+
"exampleProjectId": "ilts7O",
83+
"license": "MIT"
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
For target name and spec options see: https://www.w3schools.com/jsref/met_win_open.asp
2+
3+
This operator opens a window/tab using an URL. This can be blocked by popup blockers/browser security measures.
4+
Try using a html anchor element like <a href="url">link</a>

0 commit comments

Comments
 (0)