mirror of
https://github.com/SoPat712/videospeed.git
synced 2026-04-27 06:32:52 -04:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
b3707c0803
|
|||
|
fb25c56230
|
|||
|
4efc3e0acc
|
|||
|
7c0a188cd3
|
|||
|
d7ce1fd000
|
|||
|
313832015b
|
@@ -10,8 +10,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
WEB_EXT_IGNORE_FILES: scripts/**
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -776,40 +776,27 @@ function setSubtitleNudgeEnabledForVideo(video, enabled) {
|
|||||||
return normalizedEnabled;
|
return normalizedEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderSubtitleNudgeIndicatorContent(target, isEnabled) {
|
function subtitleNudgeIconMarkup(isEnabled) {
|
||||||
if (!target) return;
|
|
||||||
var action = isEnabled ? "subtitleNudgeOn" : "subtitleNudgeOff";
|
var action = isEnabled ? "subtitleNudgeOn" : "subtitleNudgeOff";
|
||||||
var custom =
|
var custom =
|
||||||
tc.settings.customButtonIcons &&
|
tc.settings.customButtonIcons &&
|
||||||
tc.settings.customButtonIcons[action] &&
|
tc.settings.customButtonIcons[action] &&
|
||||||
tc.settings.customButtonIcons[action].svg;
|
tc.settings.customButtonIcons[action].svg;
|
||||||
vscClearElement(target);
|
|
||||||
if (custom) {
|
if (custom) {
|
||||||
var customWrap = vscCreateSvgWrap(
|
return (
|
||||||
target.ownerDocument || document,
|
'<span class="vsc-btn-icon" aria-hidden="true">' + custom + "</span>"
|
||||||
custom,
|
|
||||||
"vsc-btn-icon"
|
|
||||||
);
|
);
|
||||||
if (customWrap) {
|
|
||||||
target.appendChild(customWrap);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (typeof vscIconSvgString !== "function") {
|
if (typeof vscIconSvgString !== "function") {
|
||||||
target.textContent = isEnabled ? "✓" : "×";
|
return isEnabled ? "✓" : "×";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var svg = vscIconSvgString(action, 14);
|
var svg = vscIconSvgString(action, 14);
|
||||||
if (!svg) {
|
if (!svg) {
|
||||||
target.textContent = isEnabled ? "✓" : "×";
|
return isEnabled ? "✓" : "×";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var wrap = vscCreateSvgWrap(target.ownerDocument || document, svg, "vsc-btn-icon");
|
return (
|
||||||
if (wrap) {
|
'<span class="vsc-btn-icon" aria-hidden="true">' + svg + "</span>"
|
||||||
target.appendChild(wrap);
|
);
|
||||||
return;
|
|
||||||
}
|
|
||||||
target.textContent = isEnabled ? "✓" : "×";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSubtitleNudgeIndicator(video) {
|
function updateSubtitleNudgeIndicator(video) {
|
||||||
@@ -817,10 +804,11 @@ function updateSubtitleNudgeIndicator(video) {
|
|||||||
|
|
||||||
var isEnabled = isSubtitleNudgeEnabledForVideo(video);
|
var isEnabled = isSubtitleNudgeEnabledForVideo(video);
|
||||||
var title = isEnabled ? "Subtitle nudge enabled" : "Subtitle nudge disabled";
|
var title = isEnabled ? "Subtitle nudge enabled" : "Subtitle nudge disabled";
|
||||||
|
var mark = subtitleNudgeIconMarkup(isEnabled);
|
||||||
|
|
||||||
var indicator = video.vsc.subtitleNudgeIndicator;
|
var indicator = video.vsc.subtitleNudgeIndicator;
|
||||||
if (indicator) {
|
if (indicator) {
|
||||||
renderSubtitleNudgeIndicatorContent(indicator, isEnabled);
|
indicator.innerHTML = mark;
|
||||||
indicator.dataset.enabled = isEnabled ? "true" : "false";
|
indicator.dataset.enabled = isEnabled ? "true" : "false";
|
||||||
indicator.dataset.supported = "true";
|
indicator.dataset.supported = "true";
|
||||||
indicator.title = title;
|
indicator.title = title;
|
||||||
@@ -829,7 +817,7 @@ function updateSubtitleNudgeIndicator(video) {
|
|||||||
|
|
||||||
var flashEl = video.vsc.nudgeFlashIndicator;
|
var flashEl = video.vsc.nudgeFlashIndicator;
|
||||||
if (flashEl) {
|
if (flashEl) {
|
||||||
renderSubtitleNudgeIndicatorContent(flashEl, isEnabled);
|
flashEl.innerHTML = mark;
|
||||||
flashEl.dataset.enabled = isEnabled ? "true" : "false";
|
flashEl.dataset.enabled = isEnabled ? "true" : "false";
|
||||||
flashEl.dataset.supported = "true";
|
flashEl.dataset.supported = "true";
|
||||||
flashEl.setAttribute("aria-label", title);
|
flashEl.setAttribute("aria-label", title);
|
||||||
@@ -1369,15 +1357,12 @@ chrome.storage.sync.get(tc.settings, function (storage) {
|
|||||||
tc.settings.customButtonIcons &&
|
tc.settings.customButtonIcons &&
|
||||||
tc.settings.customButtonIcons[act] &&
|
tc.settings.customButtonIcons[act] &&
|
||||||
tc.settings.customButtonIcons[act].svg;
|
tc.settings.customButtonIcons[act].svg;
|
||||||
vscClearElement(btn);
|
btn.innerHTML = "";
|
||||||
if (svg) {
|
if (svg) {
|
||||||
var cw = vscCreateSvgWrap(doc, svg, "vsc-btn-icon");
|
var cw = doc.createElement("span");
|
||||||
if (cw) {
|
cw.className = "vsc-btn-icon";
|
||||||
|
cw.innerHTML = svg;
|
||||||
btn.appendChild(cw);
|
btn.appendChild(cw);
|
||||||
} else {
|
|
||||||
var cdf = controllerButtonDefs[act];
|
|
||||||
btn.textContent = (cdf && cdf.label) || "?";
|
|
||||||
}
|
|
||||||
} else if (typeof vscIconWrap === "function") {
|
} else if (typeof vscIconWrap === "function") {
|
||||||
var wrap = vscIconWrap(doc, act, 14);
|
var wrap = vscIconWrap(doc, act, 14);
|
||||||
if (wrap) {
|
if (wrap) {
|
||||||
@@ -1420,12 +1405,10 @@ function createControllerButton(doc, action, label, className) {
|
|||||||
tc.settings.customButtonIcons[action] &&
|
tc.settings.customButtonIcons[action] &&
|
||||||
tc.settings.customButtonIcons[action].svg;
|
tc.settings.customButtonIcons[action].svg;
|
||||||
if (custom) {
|
if (custom) {
|
||||||
var customWrap = vscCreateSvgWrap(doc, custom, "vsc-btn-icon");
|
var customWrap = doc.createElement("span");
|
||||||
if (customWrap) {
|
customWrap.className = "vsc-btn-icon";
|
||||||
|
customWrap.innerHTML = custom;
|
||||||
button.appendChild(customWrap);
|
button.appendChild(customWrap);
|
||||||
} else {
|
|
||||||
button.textContent = label || "?";
|
|
||||||
}
|
|
||||||
} else if (typeof vscIconWrap === "function") {
|
} else if (typeof vscIconWrap === "function") {
|
||||||
var wrap = vscIconWrap(doc, action, 14);
|
var wrap = vscIconWrap(doc, action, 14);
|
||||||
if (wrap) {
|
if (wrap) {
|
||||||
|
|||||||
+25
-2
@@ -31,9 +31,32 @@ function sanitizeLucideSvg(svgText) {
|
|||||||
var t = String(svgText).replace(/\0/g, "").trim();
|
var t = String(svgText).replace(/\0/g, "").trim();
|
||||||
if (!/<svg[\s>]/i.test(t)) return null;
|
if (!/<svg[\s>]/i.test(t)) return null;
|
||||||
var doc = new DOMParser().parseFromString(t, "image/svg+xml");
|
var doc = new DOMParser().parseFromString(t, "image/svg+xml");
|
||||||
if (doc.querySelector("parsererror")) return null;
|
var svg = doc.querySelector("svg");
|
||||||
var svg = vscSanitizeSvgTree(doc.querySelector("svg"));
|
|
||||||
if (!svg) return null;
|
if (!svg) return null;
|
||||||
|
svg.querySelectorAll("script").forEach(function (n) {
|
||||||
|
n.remove();
|
||||||
|
});
|
||||||
|
svg.querySelectorAll("style").forEach(function (n) {
|
||||||
|
n.remove();
|
||||||
|
});
|
||||||
|
svg.querySelectorAll("*").forEach(function (el) {
|
||||||
|
for (var i = el.attributes.length - 1; i >= 0; i--) {
|
||||||
|
var attr = el.attributes[i];
|
||||||
|
var name = attr.name.toLowerCase();
|
||||||
|
var val = attr.value;
|
||||||
|
if (name.indexOf("on") === 0) {
|
||||||
|
el.removeAttribute(attr.name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
(name === "href" || name === "xlink:href") &&
|
||||||
|
/^javascript:/i.test(val)
|
||||||
|
) {
|
||||||
|
el.removeAttribute(attr.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
||||||
svg.removeAttribute("width");
|
svg.removeAttribute("width");
|
||||||
svg.removeAttribute("height");
|
svg.removeAttribute("height");
|
||||||
svg.setAttribute("width", "100%");
|
svg.setAttribute("width", "100%");
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Speeder",
|
"name": "Speeder",
|
||||||
"short_name": "Speeder",
|
"short_name": "Speeder",
|
||||||
"version": "5.1.6",
|
"version": "5.1.4",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"description": "Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts (New and improved version of \"Video Speed Controller\")",
|
"description": "Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts (New and improved version of \"Video Speed Controller\")",
|
||||||
"homepage_url": "https://github.com/SoPat712/speeder",
|
"homepage_url": "https://github.com/SoPat712/speeder",
|
||||||
|
|||||||
+16
-18
@@ -172,9 +172,8 @@ var customButtonIconsLive = {};
|
|||||||
|
|
||||||
function fillControlBarIconElement(icon, buttonId) {
|
function fillControlBarIconElement(icon, buttonId) {
|
||||||
if (!icon || !buttonId) return;
|
if (!icon || !buttonId) return;
|
||||||
var doc = icon.ownerDocument || document;
|
|
||||||
if (buttonId === "nudge") {
|
if (buttonId === "nudge") {
|
||||||
vscClearElement(icon);
|
icon.innerHTML = "";
|
||||||
icon.className = "cb-icon cb-icon-nudge-pair";
|
icon.className = "cb-icon cb-icon-nudge-pair";
|
||||||
function nudgeChipMarkup(action) {
|
function nudgeChipMarkup(action) {
|
||||||
var c = customButtonIconsLive[action];
|
var c = customButtonIconsLive[action];
|
||||||
@@ -190,11 +189,11 @@ function fillControlBarIconElement(icon, buttonId) {
|
|||||||
sp.setAttribute("data-nudge-state", stateKey);
|
sp.setAttribute("data-nudge-state", stateKey);
|
||||||
var inner = nudgeChipMarkup(action);
|
var inner = nudgeChipMarkup(action);
|
||||||
if (inner) {
|
if (inner) {
|
||||||
var wrap = vscCreateSvgWrap(doc, inner, "vsc-btn-icon");
|
var wrap = document.createElement("span");
|
||||||
if (wrap) {
|
wrap.className = "vsc-btn-icon";
|
||||||
|
wrap.innerHTML = inner;
|
||||||
sp.appendChild(wrap);
|
sp.appendChild(wrap);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
icon.appendChild(sp);
|
icon.appendChild(sp);
|
||||||
}
|
}
|
||||||
appendChip("subtitleNudgeOn", "on");
|
appendChip("subtitleNudgeOn", "on");
|
||||||
@@ -208,15 +207,16 @@ function fillControlBarIconElement(icon, buttonId) {
|
|||||||
icon.className = "cb-icon";
|
icon.className = "cb-icon";
|
||||||
var custom = customButtonIconsLive[buttonId];
|
var custom = customButtonIconsLive[buttonId];
|
||||||
if (custom && custom.svg) {
|
if (custom && custom.svg) {
|
||||||
if (vscSetSvgContent(icon, custom.svg)) return;
|
icon.innerHTML = custom.svg;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (typeof vscIconSvgString === "function") {
|
if (typeof vscIconSvgString === "function") {
|
||||||
var svgHtml = vscIconSvgString(buttonId, 16);
|
var svgHtml = vscIconSvgString(buttonId, 16);
|
||||||
if (svgHtml) {
|
if (svgHtml) {
|
||||||
if (vscSetSvgContent(icon, svgHtml)) return;
|
icon.innerHTML = svgHtml;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vscClearElement(icon);
|
|
||||||
var def = controllerButtonDefs[buttonId];
|
var def = controllerButtonDefs[buttonId];
|
||||||
icon.textContent = (def && def.icon) || "?";
|
icon.textContent = (def && def.icon) || "?";
|
||||||
}
|
}
|
||||||
@@ -1200,8 +1200,8 @@ function createControlBarBlock(buttonId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function populateControlBarZones(activeZone, availableZone, activeIds, allowButtonId) {
|
function populateControlBarZones(activeZone, availableZone, activeIds, allowButtonId) {
|
||||||
vscClearElement(activeZone);
|
activeZone.innerHTML = "";
|
||||||
vscClearElement(availableZone);
|
availableZone.innerHTML = "";
|
||||||
|
|
||||||
var allowed = function (id) {
|
var allowed = function (id) {
|
||||||
if (!controllerButtonDefs[id]) return false;
|
if (!controllerButtonDefs[id]) return false;
|
||||||
@@ -1394,7 +1394,7 @@ function initLucideButtonIconsUI() {
|
|||||||
|
|
||||||
if (!actionSel.dataset.lucideInit) {
|
if (!actionSel.dataset.lucideInit) {
|
||||||
actionSel.dataset.lucideInit = "1";
|
actionSel.dataset.lucideInit = "1";
|
||||||
vscClearElement(actionSel);
|
actionSel.innerHTML = "";
|
||||||
Object.keys(controllerButtonDefs).forEach(function (aid) {
|
Object.keys(controllerButtonDefs).forEach(function (aid) {
|
||||||
if (aid === "nudge") {
|
if (aid === "nudge") {
|
||||||
Object.keys(lucideSubtitleNudgeActionLabels).forEach(function (subId) {
|
Object.keys(lucideSubtitleNudgeActionLabels).forEach(function (subId) {
|
||||||
@@ -1415,7 +1415,7 @@ function initLucideButtonIconsUI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderResults(slugs) {
|
function renderResults(slugs) {
|
||||||
vscClearElement(resultsEl);
|
resultsEl.innerHTML = "";
|
||||||
slugs.forEach(function (slug) {
|
slugs.forEach(function (slug) {
|
||||||
var b = document.createElement("button");
|
var b = document.createElement("button");
|
||||||
b.type = "button";
|
b.type = "button";
|
||||||
@@ -1450,13 +1450,11 @@ function initLucideButtonIconsUI() {
|
|||||||
.then(function (txt) {
|
.then(function (txt) {
|
||||||
var safe = sanitizeLucideSvg(txt);
|
var safe = sanitizeLucideSvg(txt);
|
||||||
if (!safe) throw new Error("Bad SVG");
|
if (!safe) throw new Error("Bad SVG");
|
||||||
if (!vscSetSvgContent(previewEl, safe)) {
|
previewEl.innerHTML = safe;
|
||||||
throw new Error("Preview render failed");
|
|
||||||
}
|
|
||||||
setLucideStatus("Preview: " + slug);
|
setLucideStatus("Preview: " + slug);
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(function (e) {
|
||||||
vscClearElement(previewEl);
|
previewEl.innerHTML = "";
|
||||||
setLucideStatus(
|
setLucideStatus(
|
||||||
"Could not load: " + slug + " — " + e.message
|
"Could not load: " + slug + " — " + e.message
|
||||||
);
|
);
|
||||||
@@ -1475,7 +1473,7 @@ function initLucideButtonIconsUI() {
|
|||||||
.then(function (map) {
|
.then(function (map) {
|
||||||
var q = searchInput.value;
|
var q = searchInput.value;
|
||||||
if (!q.trim()) {
|
if (!q.trim()) {
|
||||||
vscClearElement(resultsEl);
|
resultsEl.innerHTML = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
renderResults(searchLucideSlugs(map, q, 48));
|
renderResults(searchLucideSlugs(map, q, 48));
|
||||||
@@ -1640,7 +1638,7 @@ function restore_options() {
|
|||||||
? storage.siteRules
|
? storage.siteRules
|
||||||
: tcDefaults.siteRules || [];
|
: tcDefaults.siteRules || [];
|
||||||
|
|
||||||
vscClearElement(document.getElementById("siteRulesContainer"));
|
document.getElementById("siteRulesContainer").innerHTML = "";
|
||||||
if (siteRules.length > 0) {
|
if (siteRules.length > 0) {
|
||||||
siteRules.forEach((rule) => {
|
siteRules.forEach((rule) => {
|
||||||
if (rule && rule.pattern) {
|
if (rule && rule.pattern) {
|
||||||
|
|||||||
@@ -230,17 +230,16 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
btn.dataset.action = btnId;
|
btn.dataset.action = btnId;
|
||||||
var customEntry = customMap[btnId];
|
var customEntry = customMap[btnId];
|
||||||
if (customEntry && customEntry.svg) {
|
if (customEntry && customEntry.svg) {
|
||||||
var customSpan = vscCreateSvgWrap(document, customEntry.svg, "vsc-btn-icon");
|
var customSpan = document.createElement("span");
|
||||||
if (customSpan) {
|
customSpan.className = "vsc-btn-icon";
|
||||||
|
customSpan.innerHTML = customEntry.svg;
|
||||||
btn.appendChild(customSpan);
|
btn.appendChild(customSpan);
|
||||||
} else {
|
|
||||||
btn.textContent = def.label || "?";
|
|
||||||
}
|
|
||||||
} else if (typeof vscIconSvgString === "function") {
|
} else if (typeof vscIconSvgString === "function") {
|
||||||
var svgStr = vscIconSvgString(btnId, 16);
|
var svgStr = vscIconSvgString(btnId, 16);
|
||||||
if (svgStr) {
|
if (svgStr) {
|
||||||
var iconSpan = vscCreateSvgWrap(document, svgStr, "vsc-btn-icon");
|
var iconSpan = document.createElement("span");
|
||||||
if (iconSpan) {
|
iconSpan.className = "vsc-btn-icon";
|
||||||
|
iconSpan.innerHTML = svgStr;
|
||||||
btn.appendChild(iconSpan);
|
btn.appendChild(iconSpan);
|
||||||
} else {
|
} else {
|
||||||
btn.textContent = def.label || "?";
|
btn.textContent = def.label || "?";
|
||||||
@@ -248,9 +247,6 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
} else {
|
} else {
|
||||||
btn.textContent = def.label || "?";
|
btn.textContent = def.label || "?";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
btn.textContent = def.label || "?";
|
|
||||||
}
|
|
||||||
if (def.className) btn.className = def.className;
|
if (def.className) btn.className = def.className;
|
||||||
btn.title = btnId.charAt(0).toUpperCase() + btnId.slice(1);
|
btn.title = btnId.charAt(0).toUpperCase() + btnId.slice(1);
|
||||||
|
|
||||||
|
|||||||
+4
-75
@@ -3,7 +3,6 @@
|
|||||||
* Use stroke="currentColor" so buttons inherit foreground for monochrome UI.
|
* Use stroke="currentColor" so buttons inherit foreground for monochrome UI.
|
||||||
*/
|
*/
|
||||||
var VSC_ICON_SIZE_DEFAULT = 18;
|
var VSC_ICON_SIZE_DEFAULT = 18;
|
||||||
var VSC_SVG_NS = "http://www.w3.org/2000/svg";
|
|
||||||
|
|
||||||
/** Inner SVG markup only (paths / shapes inside <svg>). */
|
/** Inner SVG markup only (paths / shapes inside <svg>). */
|
||||||
var vscUiIconPaths = {
|
var vscUiIconPaths = {
|
||||||
@@ -55,79 +54,6 @@ function vscIconSvgString(action, size) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function vscClearElement(el) {
|
|
||||||
if (!el) return;
|
|
||||||
while (el.firstChild) {
|
|
||||||
el.removeChild(el.firstChild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function vscSanitizeSvgTree(svg) {
|
|
||||||
if (!svg || String(svg.tagName).toLowerCase() !== "svg") return null;
|
|
||||||
|
|
||||||
svg.querySelectorAll("script, style, foreignObject").forEach(function (n) {
|
|
||||||
n.remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
svg.querySelectorAll("*").forEach(function (el) {
|
|
||||||
for (var i = el.attributes.length - 1; i >= 0; i--) {
|
|
||||||
var attr = el.attributes[i];
|
|
||||||
var name = attr.name.toLowerCase();
|
|
||||||
var val = attr.value;
|
|
||||||
if (name.indexOf("on") === 0) {
|
|
||||||
el.removeAttribute(attr.name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
(name === "href" || name === "xlink:href") &&
|
|
||||||
/^\s*javascript:/i.test(val)
|
|
||||||
) {
|
|
||||||
el.removeAttribute(attr.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
svg.setAttribute("xmlns", VSC_SVG_NS);
|
|
||||||
svg.setAttribute("aria-hidden", "true");
|
|
||||||
return svg;
|
|
||||||
}
|
|
||||||
|
|
||||||
function vscCreateSvgNode(doc, svgText) {
|
|
||||||
if (!doc || !svgText || typeof svgText !== "string") return null;
|
|
||||||
var clean = String(svgText).replace(/\0/g, "").trim();
|
|
||||||
if (!clean || !/<svg[\s>]/i.test(clean)) return null;
|
|
||||||
|
|
||||||
var parsed = new DOMParser().parseFromString(clean, "image/svg+xml");
|
|
||||||
if (parsed.querySelector("parsererror")) return null;
|
|
||||||
|
|
||||||
var svg = vscSanitizeSvgTree(parsed.querySelector("svg"));
|
|
||||||
if (!svg) return null;
|
|
||||||
|
|
||||||
return doc.importNode(svg, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function vscSetSvgContent(el, svgText) {
|
|
||||||
if (!el) return false;
|
|
||||||
vscClearElement(el);
|
|
||||||
|
|
||||||
var doc = el.ownerDocument || document;
|
|
||||||
var svg = vscCreateSvgNode(doc, svgText);
|
|
||||||
if (!svg) return false;
|
|
||||||
|
|
||||||
el.appendChild(svg);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function vscCreateSvgWrap(doc, svgText, className) {
|
|
||||||
if (!doc) return null;
|
|
||||||
var span = doc.createElement("span");
|
|
||||||
span.className = className || "vsc-btn-icon";
|
|
||||||
if (!vscSetSvgContent(span, svgText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return span;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Document} doc
|
* @param {Document} doc
|
||||||
* @param {string} action
|
* @param {string} action
|
||||||
@@ -136,5 +62,8 @@ function vscCreateSvgWrap(doc, svgText, className) {
|
|||||||
function vscIconWrap(doc, action, size) {
|
function vscIconWrap(doc, action, size) {
|
||||||
var html = vscIconSvgString(action, size);
|
var html = vscIconSvgString(action, size);
|
||||||
if (!html) return null;
|
if (!html) return null;
|
||||||
return vscCreateSvgWrap(doc, html, "vsc-btn-icon");
|
var span = doc.createElement("span");
|
||||||
|
span.className = "vsc-btn-icon";
|
||||||
|
span.innerHTML = html;
|
||||||
|
return span;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user