I have a code that fetches the categorized posts, but the code when adding 150 posts or above is slow to fetch posts. This is the code
if(-1 < e.indexOf("://")) return (-1 < e.indexOf("://www.") ? e.split("://www.") : e.split("://"))[1].split(".")[0]
}
$(document).ready(function() {
$.each($(".emped-tv .views"), function(e, t) {
var a = $(this),
i = new Firebase("https://episode-viewer.firebaseIO.com/pages/id/" + a.attr("data-id"));
i.once("value", function(e) {
var t = e.val(),
e = !1;
null == t && ((t = {
value: 0
}).url = window.location.href, t.id = a.attr("data-id"), e = !0), a.html('<i class="fa fa-eye" aria-hidden="true"></i> ' + t.value), t.value++, "/" != window.location.pathname && (e ? i.set(t) : i.child("value").set(t.value))
})
}), $(".episodes-get").each(function() {
for(var e = $(this).find(".server-get i"), t = "", a = "", i = 0; i < e.length; i++) {
var s, n, o = e[i].textContent,
r = o.split("*");
r[1] ? (s = r[1], n = r[0], 0) : (s = i + 1, n = o);
o = smart_domain(n);
null == o && (o = "سيرفر مشاهدة"), 0 == i ? (t += '<a class="server-link active waves-effect waves-light" href="' + n + '" target="abdoutech">' + o + '<span class="server-num">' + s + '<i class="fa fa-play"></i></span></a>', a += '<iframe allowfullscreen="" class="embed-item" frameborder="0" height="1080" marginheight="0" marginwidth="0" name="abdoutech" scrolling="no" src="about:blank" width="1920"></iframe>') : t += '<a class="server-link waves-effect waves-light" href="' + n + '" target="abdoutech">' + o + '<span class="server-num">' + s + '<i class="fa fa-play"></i></span></a>'
}
$(".embed-responsive").append(a), $("#servers-content").html(t), $(".embed-responsive .play").click(function() {
$(".embed-item").attr("src", $(".server-link.active").attr("href")), $(this).remove()
}), $(".server-link").click(function() {
$(".server-link").removeClass("active"), $(this).addClass("active")
}), $(".tabs-content button").click(function(e) {
e.preventDefault();
var t = $(this),
e = $(this).data("content");
$(".tabs-content button,.content-div").removeClass("active"), t.toggleClass("active"), $("#" + e).toggleClass("active")
});
for(var l = $(this).find(".download-get i"), c = "", i = 0; i < l.length; i++) {
var d, f, v = l[i].textContent,
p = v.split("*"),
h = "";
p[1] ? (f = d = p[1], h = smart_domain(m = p[0])) : (d = "", h = smart_domain(m = v), f = "fa fa-download");
var m = encode_be64(m, $(".home-anime").text(), $(this).attr("number-episode"));
c += l ? '<a class="waves-effect waves-light" href="' + m + '" target="_blank"><span class="icon-M ' + f + '">' + d + "</span> " + h + "</a>" : "لايوجد روابط تحميل"
}
$("#download-content").html('<div class="outer-download">' + c + "</div>");
var u = $(".home-anime").text(),
g = document.location.origin + u;
$.get(g, function(e) {
var t = $(e).find(".info-post .rating").text();
$(".emped-tv .details .info h3.rat").html(t + "/10");
t = $(e).find(".info-post .date").text();
$(".emped-tv .details .info h3.release").html(t);
t = $(e).find(".main-posts .post-outer .thumb img").attr("src"), e = $(e).find(".titlepost").text();
$(".emped-tv .info-container a.cover").attr("href", g).html('<img alt="' + e + '" class="cover" src="' + t + '">'), $(".emped-tv .details .info h1").html('<a title="' + e + '" href="' + g + '">' + e + "</a>")
}, "html"), $(".info-container").removeClass("hide")
}), $("[name-anime]").each(function() {
var m = $("#episodes-content"),
e = $(this).attr("name-anime");
$.ajax({
type: "GET",
url: "https://www.blogger.com/feeds/" + idblogger + "/posts/default/-/" + e + "?alt=json-in-script&max-results=" + numposts,
dataType: "jsonp",
success: function(e) {
var t = "",
a = "";
if(e.feed.entry) {
for(var i = 0; i < e.feed.entry.length; i++) {
for(var s = 0; s < e.feed.entry[i].link.length; s++)
if("alternate" == e.feed.entry[i].link[s].rel) {
var n = e.feed.entry[i].link[s].href;
break
} var o, r, l = e.feed.entry[i].title.$t,
c = e.feed.entry[i].content.$t,
d = $(c).find(".episodes-get").attr("number-episode"),
f = "";
d && (o = d.split("."), c = d.split("-"), o[1] || (c[1] ? (d = c[0], f = " - " + c[1]) : d = (d = d.match(/\d/g)).join(""))), r = d ? " الحلقة : " + d + f : (r = l, ""), t += n == $($("html").html()).filter('meta[property="og:url"]').attr("content") ? '<a data-position="' + d + '" class="active waves-effect" href="' + n + '" ><i class="fa fa-pause"></i> ' + r + "</a>" : '<a data-position="' + d + '" class="waves-effect" href="' + n + '" ><i class="fa fa-play-circle"></i> ' + r + "</a>", a += '<option data-position="' + d + '" value="' + n + '">' + r + "</option>"
}
m.html('<div class="episodes-list">' + t + "</div>"), m.append('<select class="ep-select" onchange="if (this.value) window.location.href=this.value">' + a + "</select>"), $(".episodes-list a").sort(function(e, t) {
return $(t).data("position") > $(e).data("position") ? 1 : -1
}).appendTo(".episodes-list"), $(".ep-select option").sort(function(e, t) {
return $(t).data("position") > $(e).data("position") ? 1 : -1
}).appendTo(".ep-select");
var v = $(".episodes-get").attr("number-episode");
$('option[data-position="' + v + '"]').attr("selected", "selected");
var p = $("option[value*='" + location.pathname + "']"),
h = (p.text(), p.next().attr("value")),
v = p.prev().attr("value"),
p = $(".episodesfastReach"),
v = (h ? '<li ><a class="waves-effect" href="' + h + '">الحلقة السابقة</a></li>' : "") + (v ? '<li ><a class="waves-effect" href="' + v + '">الحلقة التالية</a></li>' : "");
$(p).html(v)
} else m.html('<div class="box-error"><i class="fa fa-exclamation" aria-hidden="true"></i><div class="info-error"></div></div>')
}
})
})
});
But I saw a blogger site that brings the classified posts in another way, as it brings 150 posts, and when you go down to the last post, it downloads 150 others.
This is the code for that site that you saw
$.ajax({
url: url,
type: get,
dataType: jsonp,
success: function(responce) {
fn(responce, type);
}
});
}
function lazy(fn, done, err, modules) {
var document;
var _0xE6BD = err[2][3];
if(done.scrollTop() + done.innerHeight() >= done[0].scrollHeight && !modules && $(".ep").length < _0xE6BD) {
document = true; <
div class = 'lds-ring' > < div > < /div><div></div > < div > < /div><div></div > < /div>;
load($(".ae-title .loader"), document, < div class = 'lds-ring' > < div > < /div><div></div > < div > < /div><div></div > < /div>);
fn(err); modules = true; document = false;
}
}
function load(ast, document, name) {
if(document) {
ast.append(name);
} else {
ast.html("");
}
}
function np(session, lib, end) {
var THREAD_STARTED = [];
var cb = 0;
for(; cb < parseInt(end / 150) + 1; cb++) {
var id = si(cb);
ajax(/feeds/posts /
default / -/ + lib + ?alt=json-in-script&max-results=150&start-index= + id, json_to_np, [THREAD_STARTED]);
}
links_ready(THREAD_STARTED, end, append_np, [THREAD_STARTED, window.location.href, session]);
}
function links_ready(type, done, error, callback) {
if(type.length < done) {
setTimeout(links_ready, 1e3, type, done, error, callback);
} else {
error(callback);
}
}
function append_np(right) {
var [typeR, cardR, nameR] = right;
var s3 = typeR.indexOf(cardR);
var managementcommandsdns = 0 == s3 ? : < div class = 'next' > < span > الحلقة التالية < /span><a href=' + typeR[s3 - 1] + '><i class='fa fa-chevron-right'></i > < /a></div > ;
var siteName = s3 + 1 == typeR.length ? : < div class = 'previous' > < span > الحلقة السابقة < /span><a href=' + typeR[s3 + 1] + '><i class='fa fa-chevron-left'></i > < /a></div > ;
nameR.append(managementcommandsdns + siteName);
}
function json_to_np(globalComponentsContext, componentStack) {
var data;
var PL$13 = globalComponentsContext.feed.entry;
var command_codes = componentStack[0];
if(void 0 !== PL$13) {
var PL$17 = 0;
for(; PL$17 < PL$13.length; PL$17++) {
var signedTransactionsCounter = PL$13[PL$17].link.length - 1;
for(; 0 <= signedTransactionsCounter; signedTransactionsCounter--) {
if(alternate == PL$13[PL$17].link[signedTransactionsCounter].rel) {
data = PL$13[PL$17].link[signedTransactionsCounter].href;
break;
}
}
command_codes.push(data);
}
}
}
function json_to_episodes(enumValueDeclaration, parameters) {
var i;
var sprite;
var _0xE6A1;
var PL$13 = enumValueDeclaration.feed.entry;
var GET_AUTH_URL_TIMEOUT = ;
var [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths, pkg] = parameters;
var document = true;
if(void 0 !== PL$13) {
var PL$17 = 0;
for(; PL$17 < PL$13.length; PL$17++) {
var signedTransactionsCounter = 0;
for(; signedTransactionsCounter < PL$13[PL$17].link.length; signedTransactionsCounter++) {
if(alternate == PL$13[PL$17].link[signedTransactionsCounter].rel) {
_0xE6A1 = PL$13[PL$17].link[signedTransactionsCounter].href;
break;
}
}
i = PL$13[PL$17].content.$t;
PL$13[PL$17].title.$t.match(/\u0627\u0644\u062d\u0644\u0642\u0629\s\d+(\.\d+)?/g);
GET_AUTH_URL_TIMEOUT = GET_AUTH_URL_TIMEOUT + ( < div class = 'ep' > < a href = ' + _0xE6A1 + ' > +( != (sprite = get_element(i, type)) ? sprite : الحلقة + (inhibitorObjectPaths - (PL$17 + totalSecondsToStayOpen) + 1)) + < /a></div > );
}
$(timestamp).find(".eps").append(GET_AUTH_URL_TIMEOUT);
document = false;
load(timestamp.find(".ae-title .loader"), document, pkg);
}
}
function get_element(i, name) {
var flags;
var regex = ;
i = < div > +i + < /div>;
var template = 0;
for(; template < name.length; template++) {
regex = regex + (flags = null != (flags = $(i).find(name[template]).html()) ? flags : );
}
return regex;
}
function get_episodes(layoutItems) {
var [inputElement, floatLabelOffsetLeft, success] = layoutItems;
ajax(/feeds/posts /
default / -/ + floatLabelOffsetLeft + ?alt=json-in-script&max-results=150&start-index= + inputElement, json_to_episodes, success);
}
function si(name) {
return start_ind = 150 * name + 1, start_ind;
}
function forward(name, res) {
var DLF = name.feed.openSearch$totalResults.$t;
var args = si(0);
var pkg = < div class = 'lds-ring' > < div > < /div><div></div > < div > < /div><div></div > < /div>;
var [chain_from, label, chain_memo_sender, chain_propose_account] = res;
if(load(container.find(".ae-title .loader"), true, pkg), get_episodes([args, chain_from, [chain_propose_account, label, args, DLF, pkg]]), np($("#select-chapter .np"), chain_from, DLF), DLF > 150) {
var cb = 1;
for(; cb < parseInt(DLF / 150) + 1; cb++) {
args = si(cb);
$(label).find(".eps").on(scroll, function() {
lazy(get_episodes, $(label).find(".eps"), [args, chain_from, [chain_propose_account, label, args, DLF, pkg]], executed = false);
});
executed = true;
}
}
}
var anime = $(".anname").attr("data-anime");
var episode = $(".post-title").text();
var container = $("#select-chapter");
var url = /feeds/posts /
default / -/ + anime + ?alt=json-in-script&max-results=0;
var go = ajax(url, forward, [anime, container, episode, [.nofe, .noff]]);
I want to convert my code to make it like its code
I wanted to comment this solution, but unfortunately could not.
Add a read more (jump link) in every post, then it will load as its supposed to.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I use blogger costum domain. Related post image thumbnail not show on the detail post (example this post). Image was upload (cache) on my subdomain.
this script on related post
<script>
//<![CDATA[
var related_blogUrl = "https://www.perantiguru.com";
var related_total = 6;
var related_thumbnail = 1;
var related_imgWidth = 210;
var related_imgHeight = 130;
(function(){
var relatedNum = 0; var relatedUrl = new Array(); var relatedImage = new Array(); var relatedTitle = new Array(); var relatedTotal = related_total; var callback = "relatedposts"; var containerID = document.getElementById("relatedposts"); var noImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAA3NCSVQICAjb4U/gAAAADElEQVQImWOor68HAAL+AX7vOF2TAAAAAElFTkSuQmCC"; var imgSize = [related_imgWidth, related_imgHeight]; window[callback] = function(data){ for (var i = 0; i < data.feed.entry.length; i++){ var entry = data.feed.entry[i]; relatedTitle[relatedNum] = entry.title.$t; for (var j = 0; j < entry.link.length; j++){ if ("alternate" == entry.link[j].rel){ relatedUrl[relatedNum] = entry.link[j].href; break; } } relatedImage[relatedNum] = noImg.replace("/s72-c/", "/w" + imgSize[0] + "-h" + imgSize[1] + "-p-k-no-nu/"); if ("media$thumbnail" in entry) { relatedImage[relatedNum] = entry.media$thumbnail.url.replace("/s72-c/", "/w"+imgSize[0]+"-h"+imgSize[1]+"-p-k-no-nu/"); } relatedNum++; } }; function filterTags(g, h) { var e = g.split("<"); for (var f = 0; f < e.length; f++) { if (e[f].indexOf(">") != -1) { e[f] = e[f].substring(e[f].indexOf(">") + 1, e[f].length) } } e = e.join(""); e = e.substring(0, h - 1); return e; }; function contains(a, e) { for (var f = 0; f < a.length; f++) { if (a[f] == e) return true; } return false; }; function removeDuplicates() { var v = new Array(0); var A = new Array(0); var w = new Array(0); for (var u = 0; u < relatedUrl.length; u++) { if (!contains(v, relatedUrl[u])) { v.length += 1; v[v.length - 1] = relatedUrl[u]; A.length += 1; A[A.length - 1] = relatedImage[u]; w.length += 1; w[w.length - 1] = relatedTitle[u]; } } relatedUrl = v; relatedImage = A; relatedTitle = w; }; function createRelated() { removeDuplicates(); for (var u = 0; u < relatedTitle.length; u++) { var B = Math.floor((relatedTitle.length - 1) * Math.random()); var s = relatedUrl[u]; var C = relatedImage[u]; var i = relatedTitle[u]; relatedUrl[u] = relatedUrl[B]; relatedImage[u] = relatedImage[B]; relatedTitle[u] = relatedTitle[B]; relatedUrl[B] = s; relatedImage[B] = C; relatedTitle[B] = i; } var r = 0; var D = Math.floor((relatedTitle.length - 1) * Math.random()); var z = D; var t = document.URL; var e = ""; while (r < relatedTotal) { if (relatedUrl[D] != t) { e += "<li>"; if (related_thumbnail >= 1) { e += "<div class='thumbnail'>"; e += "<a href='" + relatedUrl[D] + "' title='" + relatedTitle[D] + "'>"; e += "<img src='" + relatedImage[D] + "' alt='" + relatedTitle[D] + "' width='" + imgSize[0] +"' height='" + imgSize[1] + "'/>"; e += "</a>"; e += "</div>"; } e += "<div class='title'>"; e += "<a href='" + relatedUrl[D] + "' title='" + relatedTitle[D] + "'>" + relatedTitle[D] + "</a>"; e += "</div>"; e += "</li>"; r++; if (r == relatedTotal) { break; } } if (D < relatedTitle.length - 1) { D++; } else { D = 0; } if (D == z) { break; } } containerID.innerHTML = e; }; var labels = ""; var ralatedlist = document.querySelectorAll("span.list-item"); ralatedlist.forEach(function(list) { labels += 'label:"' + list.dataset.label + '"|'; }); var js = document.createElement("script"); var blogUrl = related_blogUrl.replace(/\/$/, ""); js.src = blogUrl + "/feeds/posts/summary?v=2&q=" + labels + "&alt=json&callback=" + callback + "&max-results=20"; js.onload = createRelated; document.getElementsByTagName("head")[0].appendChild(js);
})();
//]]>
</script>
help me to fix it
fixed, Thumbnail not show on related post blogger from external source
Before:
<b:if cond='data:blog.pageType == "item"'>
<div class='relatedposts'>
<h4>Post Lainnya</h4>
<ul id='relatedposts'>
<b:loop values='data:post.labels' var='label'>
<span class='list-item' expr:data-label='data:label.name'/>
</b:loop>
</ul>
</div>
</b:if>
<script>
//<![CDATA[
var related_blogUrl = "https://www.perantiguru.com";
var related_total = 6;
var related_thumbnail = 1;
var related_imgWidth = 210;
var related_imgHeight = 130;
(function(){
var relatedNum = 0; var relatedUrl = new Array(); var relatedImage = new Array(); var relatedTitle = new Array(); var relatedTotal = related_total; var callback = "relatedposts"; var containerID = document.getElementById("relatedposts"); var noImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAA3NCSVQICAjb4U/gAAAADElEQVQImWOor68HAAL+AX7vOF2TAAAAAElFTkSuQmCC"; var imgSize = [related_imgWidth, related_imgHeight]; window[callback] = function(data){ for (var i = 0; i < data.feed.entry.length; i++){ var entry = data.feed.entry[i]; relatedTitle[relatedNum] = entry.title.$t; for (var j = 0; j < entry.link.length; j++){ if ("alternate" == entry.link[j].rel){ relatedUrl[relatedNum] = entry.link[j].href; break; } } relatedImage[relatedNum] = noImg.replace("/s72-c/", "/w" + imgSize[0] + "-h" + imgSize[1] + "-p-k-no-nu/"); if ("media$thumbnail" in entry) { relatedImage[relatedNum] = entry.media$thumbnail.url.replace("/s72-c/", "/w"+imgSize[0]+"-h"+imgSize[1]+"-p-k-no-nu/"); } relatedNum++; } }; function filterTags(g, h) { var e = g.split("<"); for (var f = 0; f < e.length; f++) { if (e[f].indexOf(">") != -1) { e[f] = e[f].substring(e[f].indexOf(">") + 1, e[f].length) } } e = e.join(""); e = e.substring(0, h - 1); return e; }; function contains(a, e) { for (var f = 0; f < a.length; f++) { if (a[f] == e) return true; } return false; }; function removeDuplicates() { var v = new Array(0); var A = new Array(0); var w = new Array(0); for (var u = 0; u < relatedUrl.length; u++) { if (!contains(v, relatedUrl[u])) { v.length += 1; v[v.length - 1] = relatedUrl[u]; A.length += 1; A[A.length - 1] = relatedImage[u]; w.length += 1; w[w.length - 1] = relatedTitle[u]; } } relatedUrl = v; relatedImage = A; relatedTitle = w; }; function createRelated() { removeDuplicates(); for (var u = 0; u < relatedTitle.length; u++) { var B = Math.floor((relatedTitle.length - 1) * Math.random()); var s = relatedUrl[u]; var C = relatedImage[u]; var i = relatedTitle[u]; relatedUrl[u] = relatedUrl[B]; relatedImage[u] = relatedImage[B]; relatedTitle[u] = relatedTitle[B]; relatedUrl[B] = s; relatedImage[B] = C; relatedTitle[B] = i; } var r = 0; var D = Math.floor((relatedTitle.length - 1) * Math.random()); var z = D; var t = document.URL; var e = ""; while (r < relatedTotal) { if (relatedUrl[D] != t) { e += "<li>"; if (related_thumbnail >= 1) { e += "<div class='thumbnail'>"; e += "<a href='" + relatedUrl[D] + "' title='" + relatedTitle[D] + "'>"; e += "<img src='" + relatedImage[D] + "' alt='" + relatedTitle[D] + "' width='" + imgSize[0] +"' height='" + imgSize[1] + "'/>"; e += "</a>"; e += "</div>"; } e += "<div class='title'>"; e += "<a href='" + relatedUrl[D] + "' title='" + relatedTitle[D] + "'>" + relatedTitle[D] + "</a>"; e += "</div>"; e += "</li>"; r++; if (r == relatedTotal) { break; } } if (D < relatedTitle.length - 1) { D++; } else { D = 0; } if (D == z) { break; } } containerID.innerHTML = e; }; var labels = ""; var ralatedlist = document.querySelectorAll("span.list-item"); ralatedlist.forEach(function(list) { labels += 'label:"' + list.dataset.label + '"|'; }); var js = document.createElement("script"); var blogUrl = related_blogUrl.replace(/\/$/, ""); js.src = blogUrl + "/feeds/posts/summary?v=2&q=" + labels + "&alt=json&callback=" + callback + "&max-results=20"; js.onload = createRelated; document.getElementsByTagName("head")[0].appendChild(js);
})();
//]]>
</script>
After:
<b:if cond='data:blog.pageType == "item"'>
<div id='related-posts'>
<b:loop index='labelcount' values='data:post.labels' var='label'>
<script>
var currentURL = '<data:blog.url/>';
</script>
<b:if cond='data:labelcount < 1'>
<script async='async' expr:src='"/feeds/posts/default/-/" + data:label.name + "?alt=json-in-script&callback=display_related_posts"' type='text/javascript'/></b:if></b:loop>
</div><div style='clear:both'/>
</b:if>
<script type='text/javascript'>
/*<![CDATA[*/
var post_thumbnail_width = 180;
var post_thumbnail_height = 120;
var max_related_entries = 6;
function escapeRegExp(string){return string.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function replaceAll(str,term,replacement){return str.replace(new RegExp(escapeRegExp(term),"g"),replacement)}function display_related_posts(json_feed){for(var defaultnoimage="https://i.ibb.co/yS6JvBh/no-image.jpg",post_titles=new Array,title_num=0,post_urls=new Array,post_thumbnail_url=new Array,relatedpoststitle=(window.location.href,"Post Lainnya"),border_color="#DDDDDD",i=0;i<json_feed.feed.entry.length;i++){var feed_entry=json_feed.feed.entry[i];post_titles[title_num]=feed_entry.title.$t;try{post_thumbnail_url[title_num]=feed_entry.media$thumbnail.url}catch(error){s=feed_entry.content.$t,a=s.indexOf("<img"),b=s.indexOf('src="',a),c=s.indexOf('"',b+5),d=s.substr(b+5,c-b-5),-1!=a&&-1!=b&&-1!=c&&""!=d?post_thumbnail_url[title_num]=d:"undefined"!=typeof defaultnoimage?post_thumbnail_url[title_num]=defaultnoimage:post_thumbnail_url[title_num]="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAA3NCSVQICAjb4U/gAAAADElEQVQImWOor68HAAL+AX7vOF2TAAAAAElFTkSuQmCC"}for(var k=0;k<feed_entry.link.length;k++)"alternate"==feed_entry.link[k].rel&&(post_urls[title_num]=feed_entry.link[k].href,title_num++)}var random_entry=Math.floor((post_titles.length-1)*Math.random()),iteration=0;if(post_titles.length>0){var rp_heading=document.createElement("h2"),textnode=document.createTextNode(relatedpoststitle);rp_heading.appendChild(textnode),document.getElementById("related-posts").appendChild(rp_heading);var rp_container=document.createElement("div");rp_container.setAttribute("style","clear: both;"),rp_container.setAttribute("id","rp-container"),document.getElementById("related-posts").appendChild(rp_container)}for(;iteration<post_titles.length&&20>iteration&&max_related_entries>iteration;)if(post_urls[random_entry]!=currentURL){var rp_anchor=document.createElement("a");0!=iteration?rp_anchor.setAttribute("style","text-decoration:none;padding:10px;float:left;border-left: none "+border_color+";"):rp_anchor.setAttribute("style","text-decoration:none;padding:10px;float:left;"),rp_anchor.setAttribute("id","rp-anchor-"+iteration),rp_anchor.setAttribute("href",post_urls[random_entry]),document.getElementById("rp-container").appendChild(rp_anchor);var rp_img=document.createElement("img");rp_img.setAttribute("style","width:"+post_thumbnail_width+"px;height:"+post_thumbnail_height+"px; border:1px solid #CCCCCC;"),rp_img.setAttribute("id","rp-img-"+iteration);var pin=String(post_thumbnail_url[random_entry].match(/\/s72-c\//));post_thumbnail_url[random_entry]=replaceAll(post_thumbnail_url[random_entry],pin,"/w"+post_thumbnail_width+"-h"+post_thumbnail_height+"-p/"),rp_img.setAttribute("src",post_thumbnail_url[random_entry]),rp_img.setAttribute("alt","Matched post excerpt thumbnail in the post footer."),document.getElementById("rp-anchor-"+iteration).appendChild(rp_img);var rp_para=document.createElement("div");rp_para.setAttribute("style","width:"+post_thumbnail_width+"px; height:"+post_thumbnail_height+"px;border: 0pt none ; margin: auto; padding-top: 18px; line-height:1.6;"),rp_para.setAttribute("id","rp-para-"+iteration);var textnode=document.createTextNode(post_titles[random_entry]);rp_para.appendChild(textnode),document.getElementById("rp-anchor-"+iteration).appendChild(rp_para),iteration++,random_entry<post_titles.length-1?random_entry++:random_entry=0}else iteration++,random_entry<post_titles.length-1?random_entry++:random_entry=0;post_urls.splice(0,post_urls.length),post_thumbnail_url.splice(0,post_thumbnail_url.length),post_titles.splice(0,post_titles.length)}
/*]]>*/
</script>
I'm trying to use lazy loading for thumbnails, but the problem is I don't know how to change src attribute to data-src in JavaScript.
Because when I added a lazy class like this:
class="ty-thumb-bonos lazy"
It doesn't work, so I need to change the src attribute as well.
else if (c.indexOf("<img") > -1) {
var q = $c.find('img:first').attr('src').replace('s72-c','s1600');
var k=q}else{var k=no_image}
h += '<ul><li><div class="ty-wow"><a class="ty-thumb-bonos" href="'+u+'"><img alt="'+g+'" src="'+k+'"/><span class="tyimg-lay"/></a>
$('.ty-slide-show .HTML .widget-content div.latestposts').each(function() {
var b = $(this).attr("data-no");
$.ajax({
url: "/feeds/posts/default?alt=json-in-script&max-results=" + b,
type: 'get',
dataType: "jsonp",
success: function(e) {
var u = "";
var h = '<div class="ty-slide flexslider"><div class="slides owl-carousel">';
for (var i = 0; i < e.feed.entry.length; i++) {
for (var j = 0; j < e.feed.entry[i].link.length; j++) {
if (e.feed.entry[i].link[j].rel == "alternate") {
u = e.feed.entry[i].link[j].href;
break
}
}
var g = e.feed.entry[i].title.$t;
var s = e.feed.entry[i].category[0].term;
var y = e.feed.entry[i].author[0].name.$t;
var d = e.feed.entry[i].published.$t,
t = d.substring(0, 4),
w = d.substring(5, 7),
f = d.substring(8, 10),
r = month_format[parseInt(w, 10)] + ' ' + f + ', ' + t;
var c = e.feed.entry[i].content.$t;
var $c = $('<div>').html(c);
if (c.indexOf("https://www.youtube.com/embed/") > -1) {
var p = e.feed.entry[i].media$thumbnail.url.replace('/default.jpg', '/mqdefault.jpg');
var k = p
} else if (c.indexOf("<img") > -1) {
var q = document.querySelectorAll('img');
q.forEach(c=> c.setAttribute('src',c.getAttribute('data-src')));
var k = q
} else {
var k = no_image
}
h += '<ul><li><div class="ty-wow"><a class="ty-thumb-bonos" href="' + u + '"><img alt="' + g + '" data-src="' + k + '"/><span class="tyimg-lay"/></a><div class="ty-slide-con"><div class="ty-slide-con"><div class="ty-slide-con-tab"><h3 class="ty-bonos-entry">' + g + '</h3><a class="recent-shop" href="' + u + '"><i class="fa fa-shopping-basket"></i>SHOP NOW</a></div></div></div></div></li></ul>'
}
h += '</div></div>';
$('.ty-slide-show .HTML .widget-content div.latestposts').each(function() {
var text = $(this).attr("data-no");
if (text == b) {
$(this).parent().html(h)
}
})
}
})
});
You can use setAttribute method
var imageElements = document.querySelectorAll('img');
imageElements.forEach(c=> c.setAttribute('src',c.getAttribute('data-src')));
var imageElements = document.querySelectorAll('img');
imageElements.forEach(c=> c.setAttribute('src',c.getAttribute('data-src')));
<img id='test' data-src='https://cdn4.iconfinder.com/data/icons/nature-20/512/79-512.png' />
the problem is the following I have all the code and functional, to have a section of recent posts by labbel in blogger, which can be seen here on the Android area. But since I do not have much experience in javascript and the code is all javascript, I ask you to help solve this.
So, if someone could help me I would like to have all the posts side by side (automatically, for example, when I reached post number 2 that would be the most right 3 would already be on the left, 4 on the right side , and always so by this sequence), with the style of the first post that is inside a red square, which you can see in the image below.
The JavaScript code is this. I hope you can help me, thanks in advance.
//<![CDATA[
function labelthumbs(t) {
for (var e = 0; e < numposts; e++) {
var n, r = t.feed.entry[e],
m = r.title.$t;
if (e == t.feed.entry.length) break;
for (var i = 0; i < r.link.length; i++) {
if ("replies" == r.link[i].rel && "text/html" == r.link[i].type) var l = r.link[i].title,
o = r.link[i].href;
if ("alternate" == r.link[i].rel) {
n = r.link[i].href;
break
}
}
var u;
try {
u = r.media$thumbnail.url, u = u.replace("/s72-c/", "/w" + thumb_width + "-h" + thumb_height + "-c/")
} catch (h) {
s = r.content.$t, a = s.indexOf("<img"), b = s.indexOf('src="', a), c = s.indexOf('"', b + 5), d = s.substr(b + 5, c - b - 5), u = -1 != a && -1 != b && -1 != c && "" != d ? d : no_thumb
}
var p = r.published.$t,
w = p.substring(0, 4),
_ = p.substring(5, 7),
f = p.substring(8, 10),
g = new Array;
g[1] = "Janeiro", g[2] = "Feveiro", g[3] = "Março", g[4] = "Abril", g[5] = "Maio", g[6] = "Junnho", g[7] = "Julho", g[8] = "Agosto", g[9] = "Setember", g[10] = "October", g[11] = "Novembro", g[12] = "Dezembro", document.write('<span class="newsmartpik_left">'), document.write('<ul class="newsmartpik_thumbs">'), document.write("<li>"), 1 == showpostthumbnails && document.write('<div class="block-image2"><div class="thumb2"><span class="rollover"></span><img width="' + thumb_width + '" height="' + thumb_height + '" alt="' + m + '" src="' + u + '"/></div></div>'), document.write('<span class="newsmartpik_title">' + m + "</span>");
var v = "";
if (document.write('<span class="newsmartpik_meta">'), 1 == showpostdate && (v = v + '<span class="newsmartpik_meta_date">' + g[parseInt(_)] + " " + f + ", " + w + "</span>"), 1 == showcommentnum && ("1 Comments" == l && (l = "1 Comments"), "0 Comments" == l && (l = "0 Comments"), showcomment = '<span class="newsmartpik_meta_comment">' + l + "</span>", v += showcomment), 1 == displaymore && (v = v + '<span class="newsmartpik_meta_more">Read More...</span>'), document.write(v), document.write("</span>"), document.write('<span class="newsmartpik_summary">'), "content" in r) var y = r.content.$t;
else if ("summary" in r) var y = r.summary.$t;
else var y = "";
var k = /<\S[^>]*>/g;
if (y = y.replace(k, ""), 1 == showpostsummary)
if (y.length < numchars) document.write(""), document.write(y), document.write("");
else {
document.write(""), y = y.substring(0, numchars);
var $ = y.lastIndexOf(" ");
y = y.substring(0, $), document.write(y + "..."), document.write("")
}
document.write("</span>"), document.write("</li>"), document.write("</ul>"), document.write("</span>")
}
document.write('<span class="newsmartpik_right">'), document.write('<ul class="newsmartpik_thumbs">');
for (var e = 1; e < numposts2; e++) {
var n, r = t.feed.entry[e],
m = r.title.$t;
if (e == t.feed.entry.length) break;
for (var i = 1; i < r.link.length; i++) {
if ("replies" == r.link[i].rel && "text/html" == r.link[i].type) var l = r.link[i].title,
o = r.link[i].href;
if ("alternate" == r.link[i].rel) {
n = r.link[i].href;
break
}
}
var x;
try {newsmartpik_left
x = r.media$thumbnail.url.replace("/s72-c/", "/w" + thumb_width2 + "-h" + thumb_height2 + "-c/")
} catch (h) {
s = r.content.$t, a = s.indexOf("<img"), b = s.indexOf('src="', a), c = s.indexOf('"', b + 5), d = s.substr(b + 5, c - b - 5), x = -1 != a && -1 != b && -1 != c && "" != d ? d : no_thumb2
}
var p = r.published.$t,
w = p.substring(0, 4),
_ = p.substring(5, 7),
f = p.substring(8, 10);
1 == showpostthumbnails2 && document.write('<div class="block-image2"><div class="thumb2"><img width="' + thumb_width2 + '" height="' + thumb_height2 + '" alt="' + m + '" src="' + x + '"/></div></div>'), document.write("<li>"), document.write('<span class="newsmartpik_title newsmartpik_title2">' + m + "</span>");
var v = "";
document.write('<span class="newsmartpik_meta newsmartpik_meta2">'), 1 == showpostdate2 && (v = v + '<span class="newsmartpik_meta_date">' + g[parseInt(_)] + " " + f + ", " + w + "</span>"), 1 == showcommentnum2 && ("1 Comment" == l && (l = "1 Comments"), "0 Comment" == l && (l = "0 Comments"), showcomment = '<span class="newsmartpik_meta_comment newsmartpik_meta_comment2">' + l + "</span>", v += showcomment), 1 == displaymore2 && (v = v + '<span class="newsmartpik_meta_more newsmartpik_meta_more2">Ler Mais</span>'), document.write(v), document.write("</span>"), document.write("</li>")
}
document.write("</ul>"), document.write("</span>")
}
//]]>
var numposts = 1,
numposts2 = 4,
showpostthumbnails = !0,
showpostthumbnails2 = !0,
displaymore = !1,
displaymore2 = !1,
showcommentnum = !0,
showcommentnum2 = !1,
showpostdate = !0,
showpostdate2 = !0,
showpostsummary = !0,
numchars = 75,
thumb_width = 370,
thumb_height = 250,
thumb_width2 = 370,
thumb_height2 = 250,
no_thumb = & quot;
https: //lh3.googleusercontent.com/-htHpxFoFKFU/VtfvuTf4DwI/AAAAAAAAEVM/nJicgrZGWlk/s340-Ic42/newsmartpik_thumb.png",no_thumb2=" https://lh3.googleusercontent.com/-v1FrVSrWAI4/VtfvuOMgx0I/AAAAAAAAEVI/dF8p7IUnk1k/s100-Ic42/newsmartpikthumb_small.png";
I made a javascript code to create some html element in parent iframe based on user selection from an iframe in a popup.
My code is given below.
The each loop may contain 50 to 150 iteration. Sometimes when I call function AddProcedures the Mozilla crashes during iteration, Is there any way to fix this issue or to reduce the browser load. I tried to put setTimeout after some code blocks but it didn't help.
I have also changed the for loop to jquery each, just to try if that helps.
var tot_codes = 0;
function doAddProcedure(thisVal,resolve){
var enc_id = $("#cpt_encounter").val();
var rowId = window.parent.$("[data-encounterBilled='"+ enc_id +"']").closest('tr').attr('id'); // table row ID
var recalc = parseInt(rowId.substring(rowId.indexOf('id-')+3));
var countval = $("#last_id").val();
//Load issue Fix
//Old code
//for (i = 0; i < document.cpt.elements.length; i++) {
//if (document.cpt.elements[i].type == "checkbox") {
//if (document.cpt.elements[i].checked == true) {
$('#cpt input:checkbox:checked').each(function(){
setTimeout(function() { }, 100);
var currentCodeMod = $(this).attr("data-codemod");
var currentCodeTypid = $(this).attr("data-codeTypeid");
if (currentCodeMod == null)
return;
tot_codes++;
var nextcntval = parseInt(countval) + 1;
var code_no = $(this).attr("id").replace("cpt_chkbx", "");
var Code = $("#codeVal" + code_no).val();
var just = $("#codeType" + code_no).val();
var categoryId = $("#codeType" + code_no).data("categoryid"); //Added to get category //Bug Fix
var Name = $("#cpttext" + code_no).val();
var codedisp = Code + ':' + Name;
var Modifier = '';
//if($("#modifier_setngs").val() == 1){
var Modifier1 = $("#modcpt1"+code_no).val() != '' ? $("#modcpt1"+code_no).val() + ":" : '';
var Modifier2 = $("#modcpt2"+code_no).val() != '' ? $("#modcpt2"+code_no).val() + ":" : '';
var Modifier3 = $("#modcpt3"+code_no).val() != '' ? $("#modcpt3"+code_no).val() + ":" : '';
var Modifier4 = $("#modcpt4"+code_no).val() != '' ? $("#modcpt4"+code_no).val() + ":" : '';
Modifier = Modifier1 + Modifier2 + Modifier3 + Modifier4;
//}
var codetableid = $("#code_tab_id" + code_no).val();
var j = countval; /* lineitem wise uniqid */
//var encounter = window.parent.$('#codetype-' + j).closest('tr.charge-entry-row').find('.expand-actions').attr('data-encounterid');
var encounter = enc_id;
var codeforarr = encounter + ':' + just + ':' + Code + '::' + Modifier;
window.parent.pushToArray(codeforarr);
var f = 0;
$(window.parent.$("#codetype-" + countval).parents().find('.inner-table .charge-entry-row')).each(function() {
//console.log($(this).find('.inputStringHidden').val() + '/' + codeforarr);
if ($(this).find('.inputStringHidden').val() == codeforarr) {
var exis_row_id = $(this).find('.inputStringHidden').attr('id').split('inputStringHidden-');
j = exis_row_id[1].toString();
f = 1;
$(this).find('.front_pay_codes_display').trigger('click');
}
});
if (f == 0) {
if (window.parent.document.getElementById('inputStringHidden-' + countval).value != '') {
window.parent.$("#codetype-" + countval).children().parent().parent().parent().siblings().find('.addnew-row').attr('data-rowadd', 'fromdb').trigger("click");
countval = parseInt(countval) + 1;
j = countval.toString();
}
window.parent.$("#add-" + countval).trigger("click");
window.parent.$("#codetype-" + (countval)).val(currentCodeTypid);
window.parent.$("#codetype-" + countval).trigger("change");
}
window.parent.document.getElementById('inputString' + j).value = codedisp;
window.parent.document.getElementById('category-' + j).value = categoryId; //Added to set category //Bug Fix
window.parent.document.getElementById('string_id' + j).value = Code;
window.parent.document.getElementById('string_value' + j).value = Name;
window.parent.document.getElementById('inputStringHidden-' + j).value = codeforarr;
window.parent.document.getElementById('codetableid-' + j).value = codetableid;
window.parent.$("#inputString" + j).closest('tr.charge-entry-row').find('.val-change-bit').val(1);
setTimeout(function() {}, 100);
window.parent.$("#suggestions" + j).hide();
window.parent.$("#inputString" + j).focus();
var uniqidHidden = window.parent.$("#inputString" + j).closest('tr.charge-entry-row').find('.uniqid-hidden').val();
window.parent.$('#add-modifier' + j).parent().find('.displaymode-elem').text(Modifier);
//if($("#modifier_setngs").val() == 1){
if (f == 0) {
window.parent.$('#add-modifier' + j).parent().find('.displaymode-elem').addClass('area-hide');
}else{
window.parent.$('#add-modifier' + j).parent().find('.displaymode-elem').removeClass('area-hide');
}
window.parent.$('#modifiers' + uniqidHidden).val(Modifier);
arr = Modifier.split(':');
window.parent.$('#modifier-' + uniqidHidden + '-1').val(arr[0]);
window.parent.$('#modifier-' + uniqidHidden + '-2').val(arr[1]);
window.parent.$('#modifier-' + uniqidHidden + '-3').val(arr[2]);
window.parent.$('#modifier-' + uniqidHidden + '-4').val(arr[3]);
//}
var eclaimPlanActive = window.parent.$('#eclaimPlanActive').val();
var price = $("#cpt_price" + code_no).val();
var price_level = $("#pricelevelhidden" + code_no).val();
if (price == 0 || price == null)
price = 0;
window.parent.$('#price-' + j).val(price);
window.parent.$('#bill-pricelevel-' + j).val(price_level);
/** Charge Total **/
var chargeTotal = window.parent.$('#charge-total').text().replace(/[\s\,]/g, '').trim();
if (chargeTotal == '')
chargeTotal = parseFloat(0);
var tempChargeTotal = parseFloat(chargeTotal) + parseFloat(price);
window.parent.$('#charge-total span').html(tempChargeTotal);
/** End **/
var units = $("#cpt_units" + code_no).val(); //data[0]['units']
if (units == 0 || units == null)
units = 1;
window.parent.$('#qty-' + j).val(units);
var tax = 0;
var disc = 0;
setTimeout(function() { }, 100);
if (window.parent.$('#tax-' + j).length > 0)
tax = window.parent.$('#tax-' + j).val().replace(/[\s\,]/g, '');
if (window.parent.$('#discount-' + j).length > 0)
disc = window.parent.$('#discount-' + j).val().replace(/[\s\,]/g, '');
var amount = price * units;
amount = amount + ((amount * tax) / 100);
if (disc > 0) {
var p = price * units;
var dc = ((p * disc) / 100);
amount = amount - dc;
}
/** Discount Total **/
var disTotal = window.parent.$('#discount-total').text().replace(/[\s\,]/g, '').trim();
if (disTotal == '')
disTotal = parseFloat(0);
var tempDisTotal = parseFloat(disTotal) + parseFloat(dc);
if (isNaN(tempDisTotal) == true) {
tempDisTotal = '0.00';
}
window.parent.$('#discount-total').html(tempDisTotal);
/** End **/
if (!parseFloat(window.parent.$('#lineitempaid-' + j).val()))
window.parent.$('#lineitempaid-' + j).val('0.00');
window.parent.$('#total-' + j).val(amount);
window.parent.$('#remainder-' + j).val(amount);
window.parent.$('#hidremainder-' + j).val(amount);
//insurance and patient_share
if (eclaimPlanActive == '1') {
var codetableid = window.parent.$('#codetableid-' + j).val();
var parentRowVal = parseInt(window.parent.$('#codetableid-' + j).closest('tr').find('.row_value').attr('data-rowvalue')) - 1;
var insData1 = window.parent.$('tr#row-id-' + parentRowVal + ' .encounter').attr('data-insdata1');
window.parent.getBenefitCategoryOfCode(j, codetableid, insData1);
if (window.parent.$('#have-benefit').val() == '0') {
var insData2 = window.parent.$('tr#row-id-' + parentRowVal + ' .encounter').attr('data-insdata2');
window.parent.getBenefitCategoryOfCode(j, codetableid, insData2);
}
}
var passParams = '';
window.parent.calculate('qty-' + j, passParams);
//Updating the title
window.parent.$("#inputString" + j).closest('tr.charge-entry-row').find('.fi-searchitems').attr('data-original-title', codedisp);
if (f == 0) {
//Display DIv :: Relace with new values
var cloneLabel = window.parent.$("#inputString" + j).closest('tr.charge-entry-row').find('.show_label').clone();
//In Edit Mode
if (cloneLabel.find('.displaymode-elem').length > 0) {
var $max_length = 16;
var trucncateCode = Name;
if (trucncateCode.length > $max_length)
trucncateCode = trucncateCode.substring(0, $max_length) + '...';
cloneLabel.find('.front_pay_codetype').text(just + ":");
cloneLabel.find('.front_pay_code').text(trucncateCode);
cloneLabel.find('.displaymode-elem').removeClass('area-hide');
cloneLabel.removeClass('area-hide');
cloneLabel.find("input[name='code_type']").val(just).attr('id', 'code_type-' + j);
cloneLabel.find("input[name='string_id']").val(Code).attr('id', 'string_id-' + j);
cloneLabel.find("input[name='string_value']").val(Name);
var dataType = $("#inputString" + j).closest('tr.charge-entry-row').find('.data_type').val();
if (dataType == "lab") {
var lab = $("select[name='lab_type']").find('option:selected').val();
if (cloneLabel.find("input[name='lab_type']").length > 0) {
cloneLabel.find("input[name='lab_type']").val(lab);
} else {
cloneLabel.append('<input type="hidden" name="lab_type" class="lab_type" value="' + lab + '">');
}
} else {
cloneLabel.find("input[name='lab_type']").remove();
}
setTimeout(function() { }, 100);
//Making the view
cloneLabel.removeClass('area-hide');
window.parent.$("#inputString" + j).closest('tr.charge-entry-row').find('.front_pay_codes_editelem').removeClass('area-show').addClass('area-hide');
window.parent.$("#inputString" + j).closest('tr.charge-entry-row').find('.show_label').replaceWith(cloneLabel);
window.parent.$("#inputString" + j).closest('tr.charge-entry-row').find('.show_autosuggest').html('');
}
window.parent.$("#codetype-" + countval).children().parent().parent().parent().siblings().find('.addnew-row').attr('data-rowadd', 'fromdb').trigger("click");
countval = nextcntval.toString();
}
else {
window.parent.$("#suggestions" + j).hide();
countval = countval.toString();
}
setTimeout(function() { }, 150);
});
window.parent.reCalculatePlanEncounterWise(recalc);
resolve("Success!");
}
function doAddPromise(thisVal){
return new Promise(function(resolve){
doAddProcedure(thisVal,resolve);
});
}
function AddProcedures(thisval)
{
$('#procedureSaveButton').text('Processing....');
// $('.fa-spinner').removeClass('hide');
top.ShowAjaxLoader('Loading..');
setTimeout(function(){
}, 2000);
//top.ShowAjaxLoader('Loading..');
setTimeout(function(){
$.when(doAddPromise(thisval)).done(function(){
if (tot_codes > 0) {
window.parent.phFrntpayClosePopup();
top.notification('Successfully added the procedures.');
//top.HideAjaxLoader('Loading..');
top.HideAjaxLoader();
$('body').removeClass('modal-open');
} else {
top.notification('Please select atleast one procedure.');
$('#procedureSaveButton').text('Add Procedures');
//$('.fa-spinner').addClass('hide');
top.HideAjaxLoader();
}
});
}, 10);
}
so im trying to make a script for youtube in my psp and when i try to play it crashes.
var YouTube = new Object();
YouTube.rev = 4;
YouTube.SearchDesc = "YouTube by NT and JCRV";
YouTube.Name = "YouTube";
YouTube.Search = function(keyword, page) {
var result = new Object();
result.bypage = 20;
result.start = (page - 1) * result.bypage + 1;
var sortBy = "relevance";
var catSpecified = false;
if (keyword.charAt(0) == '$')
{
var keywordBu = keyword;
var kpos = keyword.indexOf(" ");
var category = keyword.substring(1, kpos);
keyword = keyword.substring(kpos + 1);
catSpecified = true;
}
if (keyword.charAt(0) == '#')
{
sortBy = "published";
}
if (catSpecified == false)
{
c = GetContents('https://www.googleapis.com/youtube/v3/search?q=' + escape(keyword) + '&maxResults=' + result.bypage + '&order=' + sortBy + '&part=snippet&key=AIzaSyD6Bdt4uJP0ewhNtgagGbSszfrYqcx6ydU');
}
else
{
c = GetContents('https://www.googleapis.com/youtube/v3/search?q=' + escape(keyword) + '&maxResults=' + result.bypage + '&order=' + sortBy + '&part=snippet&key=AIzaSyD6Bdt4uJP0ewhNtgagGbSszfrYqcx6ydU');
}
result.total = ext("<openSearch:totalResults>");
result.VideoInfo = new Array();
v = {attr: 2};
v.id = 0;
v.Title = "YouTube Search Help";
v.Description = "#query = search by upload date\n$category query = search in a category";
v.URL = '';
p = 0;
result.VideoInfo.push(v);
while (p = c.indexOf("<entry", p) + 1) {
v = {attr: 2};//neither IDA|npp find this string ...0=RD 1= 2=SRD 3=S
v.id = ext("https://www.googleapis.com/youtube/v3/videos?id=", "&key=AIzaSyD6Bdt4uJP0ewhNtgagGbSszfrYqcx6ydU&part=snippet,contentDetails,statistics,status&forMine=true&type=video");
v.Title = ext("<title type='text'>");
v.Description = ext("content type='text'>") + '\nUploader:' + ext("<name>");
v.CommentCount = ext("statistics.commentCount='") * 1;
v.Tags = ext("keywords>").replace(/,/g, "");
v.LengthSeconds = ext("contentDetails.duration='") * 1;
v.RatingAvg = ext("contentDetails.contentRating='") * 1;
v.RatingCount = ext("statistics.likeCount='") * 1;
v.MylistCount = ext("statistics.favoriteCount='") * 1;
v.ViewCount = ext("statistics.viewCount='") * 1;
v.ThumbnailURL = 'http://i.ytimg.com/vi/' + v.id + '/default.jpg';
v.SaveFilename = v.id + ".flv";
v.URL = 'YouTube.play("' + v.id + '")';
result.VideoInfo.push(v);
}
result.end = result.start - 1 + result.VideoInfo.length;
return result;
}
YouTube.play = function(id) {
var pos;
c = GetContents("http://www.youtube.com/get_video_info?html5=1&video_id=" + id);
//PSPTube.log("\n" + c + "\n");
pos = c.indexOf("url_encoded_fmt_stream_map");
if (pos == -1) {
alert("Can not be played");
return "";
}
c = ext('url_encoded_fmt_stream_map', "&");
p = 0;
c = unescape(c);
var url = c.match(/url=(.+?itag%3D5.*?)[&,]/);
//PSPTube.log("\n" + url + "\n");
url = url[1];
//PSPTube.log("\n" + url + "\n");
pos = url.lastIndexOf("http");
url = url.substr(pos);
url = unescape(url);
//PSPTube.log("\n" + url + "\n");
return url;
}
SiteList.push(YouTube);