반응형
m.logPrint() is working!
<eq> and <eqq> tags are rendered to MathJax format, being enclosed by \ ( \ ) and \ [ \ ].
docuK-1 scripts started!
If this log is not closed automatically, there must be an error somewhere in your document or scripts.
Table of Contents is filled out.
Auto numberings of sections (div.sec>h2, div.subsec>h3, div.subsubsec>h4), <eqq> tags, and <figure> tags are done.
<cite> and <refer> tags are rendered to show bubble reference.
<codeprint> tags are printed to corresponding <pre> tags, only when the tags exist in the document.
Current styles (dark/bright mode, font-family, font-size, line-height) are shown.
disqus.js with id="disqus-js" is loaded.
kakao.js with id="kakao-jssdk" is loaded.
New ShortKeys (T: Table of Contents, F: Forward Section, D: Previous Section, L: To 전체목록/[Lists]) are set.
m.delayPad=512;
m.wait=1024;
wait 1321ms.
<eq> and <eqq> tags are rendered to MathJax format, being enclosed by \ ( \ ) and \ [ \ ].
docuK-1 scripts started!
If this log is not closed automatically, there must be an error somewhere in your document or scripts.
Table of Contents is filled out.
Auto numberings of sections (div.sec>h2, div.subsec>h3, div.subsubsec>h4), <eqq> tags, and <figure> tags are done.
<cite> and <refer> tags are rendered to show bubble reference.
<codeprint> tags are printed to corresponding <pre> tags, only when the tags exist in the document.
Current styles (dark/bright mode, font-family, font-size, line-height) are shown.
disqus.js with id="disqus-js" is loaded.
kakao.js with id="kakao-jssdk" is loaded.
New ShortKeys (T: Table of Contents, F: Forward Section, D: Previous Section, L: To 전체목록/[Lists]) are set.
m.delayPad=512;
m.wait=1024;
wait 1321ms.







Mode: Bright; Font: Noto Sans KR; font-size: 18.0px (10.0); line-height: 1.6;
width: 1280, height: 720, version: 2.12.18
Canonical URI: https://kipid.tistory.com/entry/Pattern-Replace-를-이용한-http-https-링크-그림-동영상-유튜브-인스타그램-틱톡-Soundcloud-카카오TV-네이버TV-등-처리-Rendering
dg:plink (Document Global Permanent Link): https://kipid.tistory.com/322
document.referrer: Empty
width: 1280, height: 720, version: 2.12.18
Canonical URI: https://kipid.tistory.com/entry/Pattern-Replace-를-이용한-http-https-링크-그림-동영상-유튜브-인스타그램-틱톡-Soundcloud-카카오TV-네이버TV-등-처리-Rendering
dg:plink (Document Global Permanent Link): https://kipid.tistory.com/322
document.referrer: Empty







Pattern Replace 를 이용한 http, https 링크 (그림, 동영상, 유튜브, 인스타그램, 틱톡, Soundcloud, 카카오TV, 네이버TV 등) 처리 | URI (Unique Resource Identifier) Rendering
Regular Expression 을 사용해서 http, https 링크들을 적절하게 처리해 봅시다.
Table of Contents
T1.URI rendering
▼ Show/Hide
//////////////////////////////////////////////////// // URI rendering :: http link itself, videos, images, maps. //////////////////////////////////////////////////// m.ptnURI = []; m.ptnURL = /^https?:\/\/\S+/i; m.ptnTag = /^<\w+[\s\S]+>$/i; m.ptnVal = /^([0-9]+(?:\.[0-9]+)?)\/([0-9]+(?:\.[0-9]+)?)$/; m.uriToA = function (uri) { if (!uri || uri.constructor !== String) { return ""; } let exec = m.ptnURL.exec(uri); if (exec !== null) { return `<a target="_blank" href="${exec[0]}">${m.escapeOnlyTag(decodeURIComponent(uri)).replace(/[\n\s\t\r]/g, " ")}</a>`; } else { return m.escapeOnlyTag(uri); } }; m.videoZIndex = 10000; m.togglePosition = function (elem) { let $elem = $(elem); let $parent = $elem.parents(".rC"); if ($parent.hasClass("fixed")) { $parent.removeClass("fixed"); $parent.css("z-index", 0); window.scrollTo(0, $parent.offset().top); $elem.text("▲ [--stick to the left top--]"); m.fsToRs.fixed = false; } else { $parent.addClass("fixed"); $parent.css("z-index", m.videoZIndex--); window.scrollBy(0, -$parent.height()); $elem.text("▲ [--return to the original position--]"); m.fsToRs.fixed = true; } }; m.rC = function (elemStr, option, id, noPc) { return `<div class="rC${(option ? ` ${option}` : '')}"${id ? ` id="${id}"` : ""}><div class="rSC">${elemStr}</div>${noPc ? "" : `<div class="pc"><span onclick="m.togglePosition(this)">▲ [--stick to the left top--]</span></div>`}</div>`; }; m.YTiframe = function (v, inListPlay) { return m.rC(`<iframe delayed-src="https://www.youtube.com/embed/${v}?origin=https://recoeve.net" frameborder="0" allowfullscreen="" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)); }; let ptnURI; ptnURI = m.ptnURI["www.youtube.com"] = m.ptnURI["youtube.com"] = m.ptnURI["youtu.be"] = m.ptnURI["m.youtube.com"] = {}; ptnURI.regEx = /^(?:watch|embed|live|shorts)?\/?([\w\-]+)?(\?\S+)?/i; ptnURI.regEx1 = /^([\w\-]+)(\?\S+)?/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["www.youtube.com"].regEx.exec(uriRest); if (exec !== null) { let vars = null; if (exec[2]) { vars = m.getSearchVars(exec[2]); } let v = null; if (exec[1]) { v = exec[1]; } if (vars?.v?.val) { v = vars.v.val; } if (v) { let list = vars?.list?.val; return resolve({ html: (toA ? `<a target="_blank" href="https://www.youtube.com/watch?v=${v}${list ? `&list=${list}` : ""}">https://www.youtube.com/watch?v=${v}${list ? `&list=${list}` : ""}</a><br>` : "") + m.YTiframe(v, inListPlay), from: "youtube", videoId: v, list }); } } else { exec = m.ptnURI["youtu.be"].regEx1.exec(uriRest); if (exec !== null) { let v = exec[1]; let vars = null; let list = null; if (exec[2]) { vars = m.getSearchVars(exec[2]); if (vars?.list?.val) { list = vars.list.val; } if (vars?.v?.val) { v = vars.v.val; } } return resolve({ html: (toA ? `<a target="_blank" href="https://www.youtube.com/watch?v=${v}${list ? `&list=${list}` : ""}">https://www.youtube.com/watch?v=${v}${list ? `&list=${list}` : ""}</a><br>` : "") + m.YTiframe(v, inListPlay), from: "youtube", videoId: v, list }); } } return reject(false); }); }; ptnURI = m.ptnURI["docs.google.com"] = {}; ptnURI.regEx = /^spreadsheets\/d\/e\/([\w\-]+)\/pubhtml/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["docs.google.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://docs.google.com/spreadsheets/d/e/${exec[1]}/pubhtml">https://docs.google.com/spreadsheets/d/e/${exec[1]}/pubhtml</a><br>` : "") + m.rC(`<iframe delayed-src="https://docs.google.com/spreadsheets/d/e/${exec[1]}/pubhtml?widget=true&headers=false" frameborder="0" scrolling="auto"></iframe>`), from: "docs-google", docId: exec[1] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["instagram.com"] = m.ptnURI["www.instagram.com"] = {}; ptnURI.regEx = /^(?:p|tv|reel)\/([\w\-]+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["instagram.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://www.instagram.com/p/${exec[1]}/">https://www.instagram.com/p/${exec[1]}/</a><br>` : "") + m.rC(`<div class="center"><iframe delayed-src="https://www.instagram.com/p/${exec[1]}/embed" frameborder="0" scrolling="auto" allowtransparency="true"></iframe></div>`, "instagram", null, true), from: "instagram", imgId: exec[1] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["imgur.com"] = m.ptnURI["www.imgur.com"] = {}; ptnURI.regEx = /^a\/([\w\-]+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["imgur.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://imgur.com/a/${exec[1]}">https://imgur.com/a/${exec[1]}</a><br>` : "") + m.rC(`<div class="center"><iframe delayed-src="https://imgur.com/a/${exec[1]}/embed?pub=true&context=false" frameborder="0" scrolling="auto" allowtransparency="true"></iframe></div>`, "imgur", null, true), from: "imgur", imgId: exec[1] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["www.tiktok.com"] = {}; ptnURI.regEx = /^@(\S+)\/video\/([0-9]+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["www.tiktok.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://www.tiktok.com/@${exec[1]}/video/${exec[2]}">https://www.tiktok.com/@${exec[1]}/video/${exec[2]}</a><br>` : "") + m.rC(`<div class="center"><iframe sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-top-navigation allow-same-origin" delayed-src="https://www.tiktok.com/embed/v2/${exec[2]}?referrer=${encodeURIComponent(window.location.href)}" frameborder="no" scrolling="auto"></iframe></div>`, "tiktok", null, true), from: "tiktok", userId: exec[1], videoId: exec[2] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["vt.tiktok.com"] = {}; ptnURI.regEx = /^(\w+)\//i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["vt.tiktok.com"].regEx.exec(uriRest); if (exec !== null) { let shortURI = `https://vt.tiktok.com/${exec[1]}/`; $.ajax({ type: "POST", url: "https://recoeve.net/BlogStat/getFullURI", data: shortURI, dataType: "text" }).fail(function (resp) { resolve(resp); // throw new Error("Failed to expand TikTok URL"); }).done(async function (resp) { let uriRendered = await uriRendering(resp, toA, inListPlay); uriRendered.newURI = resp; resolve(uriRendered); }); } }); }; ptnURI = m.ptnURI["serviceapi.rmcnmv.naver.com"] = {}; ptnURI.regEx = /^\S+/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["serviceapi.rmcnmv.naver.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://serviceapi.rmcnmv.naver.com/${exec[0]}">https://serviceapi.rmcnmv.naver.com/${exec[0]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://serviceapi.rmcnmv.naver.com/${exec[0]}" frameborder="no" scrolling="auto" marginwidth="0" marginheight="0" allowfullscreen></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "naver", videoId: exec[0] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["tv.naver.com"] = {}; ptnURI.regEx = /^(?:v|embed)\/([0-9]+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["tv.naver.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://tv.naver.com/v/${exec[1]}">https://tv.naver.com/v/${exec[1]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://tv.naver.com/embed/${exec[1]}?autoPlay=false" frameborder="no" scrolling="auto" marginwidth="0" marginheight="0" allowfullscreen></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "naver", videoId: exec[1] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["weverse.io"] = {}; ptnURI.regEx = /^(\S+)\/artist\/([0-9\-]+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["weverse.io"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://weverse.io/${exec[1]}/artist/${exec[2]}">https://weverse.io/${exec[1]}/artist/${exec[2]}</a><br>` : "") + m.rC(`<iframe src="https://weverse.io/${exec[1]}/artist/${exec[2]}" frameborder="no" scrolling="auto" marginwidth="0" marginheight="0" allowfullscreen></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "weverse", singer: exec[1], videoId: exec[2] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["tv.kakao.com"] = m.ptnURI["entertain.daum.net"] = {}; ptnURI.regEx = /(?:v|cliplink)\/([0-9]+)/i; ptnURI.regEx1 = /video\/([0-9]+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["tv.kakao.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://tv.kakao.com/v/${exec[1]}">https://tv.kakao.com/v/${exec[1]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://play-tv.kakao.com/embed/player/cliplink/${exec[1]}" frameborder="0" scrolling="auto" allowfullscreen></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "kakao", videoId: exec[1] }); } else { exec = m.ptnURI["entertain.daum.net"].regEx1.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://tv.kakao.com/v/${exec[1]}">https://tv.kakao.com/v/${exec[1]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://play-tv.kakao.com/embed/player/cliplink/${exec[1]}" frameborder="0" scrolling="auto" allowfullscreen></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "kakao", videoId: exec[1] }); } else { return reject(false); } } }); }; ptnURI = m.ptnURI["tvpot.daum.net"] = {}; ptnURI.regEx = /^v\/([\w\-]+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["tvpot.daum.net"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://tvpot.daum.net/v/${exec[1]}">https://tvpot.daum.net/v/${exec[1]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://videofarm.daum.net/controller/video/viewer/Video.html?vid=${exec[1]}${exec[1].length < 15 ? '$' : ''}&play_loc=undefined" frameborder="0" scrolling="auto"></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "daum", videoId: exec[1] }); } return reject(false); }); }; ptnURI = m.ptnURI["vimeo.com"] = {}; ptnURI.regEx = /^([0-9]+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["vimeo.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://vimeo.com/${exec[1]}">https://vimeo.com/${exec[1]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://player.vimeo.com/video/${exec[1]}" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "vimeo", videoId: exec[1] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["www.dailymotion.com"] = {}; ptnURI.regEx = /video\/(\w+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["www.dailymotion.com"].regEx.exec(uriRest); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="https://www.dailymotion.com/video/${exec[1]}">https://www.dailymotion.com/video/${exec[1]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://www.dailymotion.com/embed/video/${exec[1]}" frameborder="0" allowfullscreen></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "dailymotion", videoId: exec[1] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["namu.wiki"] = {}; ptnURI.regEx = /w\/(.*)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["namu.wiki"].regEx.exec(uriRest); if (exec !== null) { let pathname = exec[1].replace(/\+/gi, "%20").replace(/%2B/gi, "%20"); return resolve({ html: `<a target="_blank" href="https://namu.wiki/w/${pathname}">https://namu.wiki/w/${m.escapeOnlyTag(decodeURIComponent(pathname))}</a>`, from: "namu.wiki", pathname }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["www.ted.com"] = m.ptnURI["embed.ted.com"] = {}; ptnURI.regEx = /^talks\/(\S+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["www.ted.com"].regEx.exec(uriRest); if (exec !== null) { uriRest = uriRest.substring(6); let k = uriRest.indexOf("?"); let vars = null; if (k !== -1) { vars = m.getSearchVars(uriRest.substring(k)); uriRest = uriRest.substring(0, k); } let v = uriRest; if (vars?.language) { uriRest = "lang/" + vars.language.val + "/" + uriRest; } return resolve({ html: (toA ? `<a target="_blank" href="https://www.ted.com/${exec[1]}">https://www.ted.com/${exec[1]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://embed.ted.com/talks/${uriRest}" frameborder="0" scrolling="auto" allowfullscreen></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: "ted", videoId: v }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["w.soundcloud.com"] = {}; ptnURI.regEx = /^player\/(\?\S+)/i; ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["w.soundcloud.com"].regEx.exec(uriRest); if (exec !== null) { let vars = m.getSearchVars(exec[1]); let lastPath = "player/?"; for (let i = 0; i < vars.length; i++) { if (vars[i].key === "auto_play") { lastPath += "auto_play=false&"; } else { lastPath += vars[i].key + "=" + vars[i].val + "&"; } } return resolve({ html: (toA ? `<a target="_blank" href="https://w.soundcloud.com/${exec[1]}">https://w.soundcloud.com/${exec[1]}</a><br>` : "") + m.rC(`<iframe delayed-src="https://w.soundcloud.com/${lastPath.substring(0, lastPath.length - 1)}" scrolling="auto" frameborder="no"></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed soundcloud" : "soundcloud")), from: "soundcloud", videoId: vars?.url?.val }); } else { return reject(false); } }); }; ptnURI = m.ptnURI["gall.dcinside.com"] = {}; ptnURI.regEx = /\/movie\/share_movie(\?\S+)/i; ptnURI.regEx1 = /\/poll\/vote(\?\S+)/i; https://gall.dcinside.com/board/poll/vote?no=710233 ptnURI.toIframe = function (uriRest, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI["gall.dcinside.com"].regEx.exec(uriRest); if (exec !== null) { let vars = m.getSearchVars(exec[1]); let v = vars.no?.val; if (v) { return resolve({ html: (toA ? `<a target="_blank" href="https://gall.dcinside.com/board/movie/share_movie?no=${v}">https://gall.dcinside.com/board/movie/share_movie?no=${v}</a><br>` : "") + m.rC(`<iframe delayed-src="https://gall.dcinside.com/board/movie/share_movie?no=${v}" scrolling="auto" frameborder="no"></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : "")), from: "dcinside", videoId: v }); } else { return resolve({ html: `<a target="_blank" href="https://gall.dcinside.com/${uriRest}">https://gall.dcinside.com/${m.escapeOnlyTag(decodeURIComponent(uriRest))}</a>` }); } } else { exec = m.ptnURI["gall.dcinside.com"].regEx1.exec(uriRest); if (exec !== null) { let vars = m.getSearchVars(exec[1]); let no = vars.no?.val; if (no) { return resolve({ html: (toA ? `<a target="_blank" href="https://gall.dcinside.com/board/poll/vote?no=${no}">https://gall.dcinside.com/board/poll/vote?no=${no}</a><br>` : "") + m.rC(`<iframe src="https://gall.dcinside.com/board/poll/vote?no=${no}" scrolling="auto"></iframe>`), from: "dcinside", voteId: no }) } } } return reject(false); }); }; ptnURI = m.ptnURI[0] = {}; ptnURI.regEx = /^(https?:\/\/\S+\.(?:jpg|jpeg|bmp|gif|png|webp|svg|tif))(?=$|\?|\s)/i; ptnURI.toIframe = function (uri, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI[0].regEx.exec(uri); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="${exec[1]}">${m.escapeOnlyTag(decodeURIComponent(uri))}</a><br>` : "") + `<div class="center"><img delayed-src="${exec[1]}"/></div>`, from: 'image', src: exec[1] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI[1] = {}; ptnURI.regEx = /^https?:\/\/\S+\.(?:mp4|ogg|webm|avi)(?=$|\?|\s)/i; ptnURI.toIframe = function (uri, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI[1].regEx.exec(uri); if (exec !== null) { return resolve({ html: (toA ? `<a target="_blank" href="${exec[0]}">${m.escapeOnlyTag(decodeURIComponent(uri))}</a><br>` : "") + m.rC(`<video controls preload="metadata" delayed-src="${exec[0]}"></video>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: 'video', src: exec[0] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI[2] = {}; ptnURI.regEx = /^https?:\/\/kr[\d]+\.sogirl\.so(\/\S*)?/i; ptnURI.regEx1 = /^https?:\/\/kr[\d]+\.sogirl\.co(\/\S*)?/i; ptnURI.toIframe = function (uri, inListPlay) { return new Promise(function (resolve, reject) { let exec = m.ptnURI[2].regEx.exec(uri); if (exec !== null) { return resolve({ html: `<a target="_blank" href="https://kr57.sogirl.so${exec[1] ? exec[1] : ""}">${m.escapeOnlyTag(decodeURIComponent(`https://kr57.sogirl.so${exec[1] ? exec[1] : ""}`))}</a>`, newURI: `https://kr57.sogirl.so${exec[1] ? exec[1] : ""}`, from: 'sogirl', src: exec[1] }); } else { exec = m.ptnURI[2].regEx1.exec(uri); if (exec !== null) { return resolve({ html: `<a target="_blank" href="https://kr57.sogirl.so${exec[1] ? exec[1] : ""}">${m.escapeOnlyTag(decodeURIComponent(`https://kr57.sogirl.so${exec[1] ? exec[1] : ""}`))}</a>`, newURI: `https://kr57.sogirl.so${exec[1] ? exec[1] : ""}`, from: 'sogirl', src: exec[1] }); } else { return reject(false); } } }); }; ptnURI = m.ptnURI[3] = {}; ptnURI.regEx = /^https?:\/\/kr[\d]+\.topgirl\.co(\/\S*)?/i; ptnURI.toIframe = function (uri, inListPlay) { return new Promise(function (resolve, reject) { let exec = m.ptnURI[3].regEx.exec(uri); if (exec !== null) { return resolve({ html: `<a target="_blank" href="https://kr26.topgirl.co${exec[1] ? exec[1] : ""}">${m.escapeOnlyTag(decodeURIComponent(`https://kr26.topgirl.co${exec[1] ? exec[1] : ""}`))}</a>`, newURI: `https://kr26.topgirl.co${exec[1] ? exec[1] : ""}`, from: 'topgirl', src: exec[1] }); } else { return reject(false); } }); }; ptnURI = m.ptnURI[4] = {}; ptnURI.regEx = /^file:\/\/\/(\S+\.(?:jpg|jpeg|bmp|gif|png|webp|svg|tif))(?=$|\?|\s)/i; ptnURI.regEx1 = /^file:\/\/\/(\S+\.(?:mp4|ogg|webm|avi))(?=$|\?|\s)/i; ptnURI.regEx2 = /^file:\/\/\/(\S+\.(?:pdf|html|htm))(?=$|\?|\s)/i; ptnURI.toIframe = function (uri, inListPlay, toA) { return new Promise(function (resolve, reject) { let exec = m.ptnURI[4].regEx.exec(uri); let href = null; if (exec !== null) { href = exec[1].replace(/\+/gi, "%20").replace(/%2B/gi, "%20"); uri = uri.replace(/\+/gi, "%20").replace(/%2B/gi, "%20"); return resolve({ html: `<a target="_blank" href="${href}">${m.escapeOnlyTag(decodeURIComponent(uri))}</a>` + m.rC(`<div class="center"><img delayed-src="${href}"/></div>`, (inListPlay && m.fsToRs.fixed ? "fixed eveElse" : "eveElse")), from: 'file-image', src: href }); } else { exec = m.ptnURI[4].regEx1.exec(uri); if (exec !== null) { href = exec[1].replace(/\+/gi, "%20").replace(/%2B/gi, "%20"); uri = uri.replace(/\+/gi, "%20").replace(/%2B/gi, "%20"); return resolve({ html: `<a target="_blank" href="${href}">${m.escapeOnlyTag(decodeURIComponent(uri))}</a><br>` + m.rC(`<video controls preload="metadata" delayed-src="${href}"></video>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: 'file-video', src: href }); } else { exec = m.ptnURI[4].regEx2.exec(uri); if (exec !== null) { href = exec[1].replace(/\+/gi, "%20").replace(/%2B/gi, "%20"); uri = uri.replace(/\+/gi, "%20").replace(/%2B/gi, "%20"); return resolve({ html: `<a target="_blank" href="${href}">${m.escapeOnlyTag(decodeURIComponent(uri))}</a><br>` + m.rC(`<iframe delayed-src="${href}"></iframe>`, (inListPlay && m.fsToRs.fixed ? "fixed" : null)), from: 'file-pdf', src: href }); } } return reject(false); } }); }; window.uriRendering = function (uri, toA, inListPlay) { return new Promise(async function (resolve, reject) { if (uri?.constructor === String) { if (uri.length > 6) { if (uri.substring(0, 4).toLowerCase() === "http") { let k = 4; if (uri.charAt(k).toLowerCase() === 's') { k++; } if (uri.substring(k, k + 3) === "://") { k += 3; let l = uri.indexOf('/', k); let uriHost = null; let uriRest = ''; if (l === -1) { uriHost = uri.substring(k); } else { uriHost = uri.substring(k, l); uriRest = uri.substring(l + 1); } if (m.ptnURI[uriHost]) { try { let result = await m.ptnURI[uriHost].toIframe(uriRest, inListPlay, toA); if (Boolean(result) !== false && (!result.list)) { return resolve(result); } } catch (error) { // continue. } } } } for (let i = 0; i < m.ptnURI.length; i++) { try { let result = await m.ptnURI[i].toIframe(uri, inListPlay, toA); // img or video if (Boolean(result) !== false) { return resolve(result); } } catch (error) { // continue. } } if (toA) { return resolve({ html: m.uriToA(uri) }); } } else { return resolve({ html: m.escapeOnlyTag(uri) }); } } return resolve({ html: "" }); }); };
▲ Hide
TRefs.References and Related Articles
▼ Show/Hide







반응형
'[IT/Programming] > HTML related' 카테고리의 다른 글
자바스크립트 (JavaScript) 기초 (0) | 2024.08.12 |
---|---|
jQuery 분석 (Analysis): $.find([CSS Selector]) and $.parents([CSS Selector]) (1) | 2024.08.11 |
week2 위클리 페이퍼 (브라우저가 어떻게 동작하는지 설명) (0) | 2024.08.06 |
Learning Node.js (0) | 2024.08.04 |
Helper div with display: flex; margin, padding 으로 가로 너비 설정/맞추는 법 정리 (1) | 2024.07.31 |
HTML docuK format ver. 2.3 (2023-10-25) (4) | 2024.07.27 |
Vertical center align by CSS in HTML (0) | 2024.05.05 |