-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSLURLtoLegacyConverter.html
More file actions
155 lines (145 loc) · 3.92 KB
/
SLURLtoLegacyConverter.html
File metadata and controls
155 lines (145 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SLURL / secondlife:// → Legacy URI Converter</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #181a1b;
color: #e0e0e0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
.converter {
background: #252728;
padding: 2em;
border-radius: 12px;
box-shadow: 0 0 12px rgba(0,0,0,0.5);
width: 90%;
max-width: 520px;
text-align: center;
}
input {
width: 100%;
padding: 0.8em;
margin-top: 0.5em;
border: none;
border-radius: 6px;
background: #333;
color: #fff;
font-size: 1em;
}
.result {
margin-top: 1em;
background: #333;
padding: 1em;
border-radius: 6px;
word-wrap: break-word;
user-select: all;
transition: all 0.3s ease;
}
.faded {
opacity: 0.5;
}
.copy-btn {
margin-top: 0.8em;
padding: 0.5em 1em;
background-color: #5a2d82;
border: none;
border-radius: 6px;
color: #fff;
font-size: 0.9em;
cursor: pointer;
transition: background-color 0.2s;
}
.copy-btn:hover {
background-color: #7b41a8;
}
.example {
font-size: 0.9em;
color: #aaa;
margin-bottom: 0.8em;
}
.footer {
margin-top: 1em;
font-size: 0.85em;
color: #aaa;
}
.footer a {
color: #a86bff;
text-decoration: none;
}
.footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="converter">
<h2>SLURL / secondlife:// → Legacy URI Converter</h2>
<p class="example">
Example: <code>http://maps.secondlife.com/secondlife/Morgantown Heights/128/128/25</code><br>
or <code>secondlife://Morgantown Heights/128/128/25</code>
</p>
<label for="slurlInput">Enter a SLURL or URI:</label>
<input
type="text"
id="slurlInput"
placeholder="Paste your link here..."
oninput="convertSLURL()"
autocomplete="off"
>
<div id="result" class="result faded">Waiting for input...</div>
<button id="copyButton" class="copy-btn" style="display:none;" onclick="copyToClipboard()">Copy to Clipboard</button>
<div class="footer">
Made by <strong>Red Robot</strong> —
<a href="https://redrobotgroup.com" target="_blank">Website</a> •
<a href="https://github.com/redrobotsl" target="_blank">GitHub</a>
</div>
</div>
<script>
function convertSLURL() {
const input = document.getElementById('slurlInput').value.trim();
const resultDiv = document.getElementById('result');
const copyBtn = document.getElementById('copyButton');
// Regular expressions for both forms
const slurlRegex = /secondlife\/([^/]+)\/(\d+)\/(\d+)\/(\d+)/i;
const uriRegex = /secondlife:\/\/([^/]+)\/(\d+)\/(\d+)\/(\d+)/i;
let match = input.match(slurlRegex) || input.match(uriRegex);
if (match) {
const region = encodeURIComponent(match[1]); // Properly encode spaces and symbols
const x = match[2];
const y = match[3];
const z = match[4];
const legacyUri = `uri:${region}&${x}&${y}&${z}`;
resultDiv.textContent = legacyUri;
resultDiv.classList.remove("faded");
copyBtn.style.display = "inline-block";
} else if (input === "") {
resultDiv.textContent = "Waiting for input...";
resultDiv.classList.add("faded");
copyBtn.style.display = "none";
} else {
resultDiv.textContent = "Invalid input. Must be a SLURL or secondlife:// link.";
resultDiv.classList.add("faded");
copyBtn.style.display = "none";
}
}
function copyToClipboard() {
const resultDiv = document.getElementById('result');
const text = resultDiv.textContent;
navigator.clipboard.writeText(text).then(() => {
const btn = document.getElementById('copyButton');
btn.textContent = "Copied!";
setTimeout(() => btn.textContent = "Copy to Clipboard", 1500);
});
}
</script>
</body>
</html>