javascript - 如何创建一个部分以显示博客上特定标签的最新帖子?
问题描述
问题是下面我有所有的代码和功能,有一段labbel最近在博客中发布的帖子,可以在Android专区看到。但是由于我没有太多的javascript经验并且代码都是javascript,所以我请求你帮助解决这个问题。
因此,如果有人可以帮助我,我希望将所有帖子并排放置(例如,当我自动到达第 2 个帖子时,最右边的 3 个已经在左侧,4 个在右侧,按照这个顺序总是如此),第一个帖子的样式位于红色正方形内,您可以在下图中看到。
JavaScript 代码是这样的。我希望你能帮助我,在此先感谢。
//<![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"><a href="' + n + '"><span class="rollover"></span><img width="' + thumb_width + '" height="' + thumb_height + '" alt="' + m + '" src="' + u + '"/></a></div></div>'), document.write('<span class="newsmartpik_title"><a href="' + n + '" target ="_top">' + m + "</a></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"><a href="' + o + '">' + l + "</a></span>", v += showcomment), 1 == displaymore && (v = v + '<span class="newsmartpik_meta_more"><a href="' + n + '" class="url" target ="_top">Read More...</a></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"><a href="' + n + '"><img width="' + thumb_width2 + '" height="' + thumb_height2 + '" alt="' + m + '" src="' + x + '"/></a></div></div>'), document.write("<li>"), document.write('<span class="newsmartpik_title newsmartpik_title2"><a href="' + n + '" target ="_top">' + m + "</a></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"><a href="' + o + '">' + l + "</a></span>", v += showcomment), 1 == displaymore2 && (v = v + '<span class="newsmartpik_meta_more newsmartpik_meta_more2"><a href="' + n + '" class="url" target ="_top">Ler Mais</a></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";
解决方案
推荐阅读
- identityserver4 - 撤销的令牌和身份验证 cookie
- java - 在java中的组中生成每个请求log4j
- r - 在大型数据表上执行时,如何防止 {data.table}foverlaps 将 NA 输入到它的 any(...) 调用中?
- javascript - 为什么光滑的滑块在循环的第二次迭代中刷新滑块项的 css
- angular - Angular - 总是在请求中出现“[Object object]”错误(即使请求有效)
- yii2 - 如何获取每个类别的订单数量?
- c++ - 我的 Qt5 程序如何从控制台获取参数?
- r - R bar_geom 千位分隔符
- css - 为什么我的高程阴影在本机反应中位于错误的一侧?
- c# - 使用 Moq 模拟接口时,方法会发生什么?