在我之前的问题中,当我发布新帖子时,我正在寻找一种在我的WordPress网站上创建通知消息的方法.经过一个很好的回答,这是非常好的.我可以更改在发布帖子之后该消息应显示多长时间的设置.当时间到期时,消息将消失.
所以它工作绝对精细,特别感谢Pieter Goosen,但如果用户已经看过一次消息,我想能够关闭通知栏并确保用户不再看到它以刷新页面没有telksens返回消息,当然提供了一个新帖子再次发布.
我怎样才能做到这一点?我在想javascript.对于该功能,当然应该有一个控制关闭按钮的功能,我认为应该还有一个cookie功能,检查用户是否已关闭该消息,并在时间内检查定时器,以便两者都相互同步.
我之前可以在这里找到通知的问题:
[更新]我只是坐下来尝试清除通知栏的结构,所以我简单地说,看看它是否会起作用,所以PieterGoosen的代码检查了WordPress中是否有新的帖子和显示通知栏.然后应在时间到期或用户单击关闭按钮后关闭该栏.所以代码也应该检查一下.如果用户单击关闭按钮== YES,则必须设置cookie(cookie应与PHP中设置的时间同步),因此只要有新帖子可用,它就会删除cookie.如果用户没有点击关闭按钮,那么请注意,如果时间已过期>删除cookie.
我创建了一个函数,它将在JSON文件中搜索不同的标签,像[image]和[gallery]这样的标签.如果匹配,它将返回并用新输出替换它.像图像对象或幻灯片.
JSON对象可以包含多个相同类型的标记,或者同时包含不同的标记.因此,对象可以包含两个[image]标签,例如
JSON
问题是,如果找到多个[image]标签,则将其替换为相同的内容.我正在寻找一个搜索标签的脚本,直到不再有匹配为止.非常感谢@debatanu的解决方案.
不幸的是,我对脚本有一些额外的愿望,因为现在像图像这样的标签将替换为JSON内媒体数组的最后一个图像对象,它只会抓取并替换第一个标签.
我想知道是否可以检查每个标签并用新输出替换每个标签.
搜索标签
filterText: function(data) {
// Loop through JSON data
// Check if [tag] in data.text exists
var dataText = data.text;
var tags = {
"gallery": /\[gallery\]/ig,
"image": /\[image\]/ig
};
if (dataText != undefined) {
var raw_data = dataText;
for (var key in tags) {
if (tags.hasOwnProperty(key)) {
var tag = tags[key];
var tagArr = [];
// Check if [tag] in data.text exists
while ( (tagArr = tag.exec(dataText)) !== null ) {
// Call …Run Code Online (Sandbox Code Playgroud) 我创建了一个iOS应用程序,利用Vimeo播放视频.我想知道在iOS Swift中显示Vimeo视频的最佳方法是什么.
我已经修复了,当点击图像时,占位符图像将被隐藏,但视频将无法直接播放.除此之外,所有Vimeo界面元素都是可见的.我知道你应该给Vimeo提供信用,所以不用说我在视频的底部显示了一个Vimeo标志.是否有可能隐藏网络播放器的所有Vimeo元素?
我可以找到更多信息的来源会很好.如果还有任何问题,请告诉我!提前致谢.
我在Xcode的Interface Builder中发现了一个非常奇怪的错误,我希望其他人可以告诉我如何修复它,或者至少告诉我我不是唯一的错误.
当我尝试使用Interface Builder 添加一个UILabel和UITextview内部时stackView,堆栈视图将以无限宽度拉伸.因为我UITextView禁用了滚动和编辑功能.
这是在我将两个元素组合在一个StackView:
当我使用两个UILabel并将其添加到其中时,StackView它正常工作.
I want to create a filter function in jQuery. So when someone clicks on a category, it will show only the items of that category. I have code some functions, but I can't get it work.
What I want is to check if the data-filter from the category list is equal to the `data-cat. If so I want to show the post that match the formule.
What do I wrong?
HTML:
<div class="grid_12" id="category-nav">
<ul id="category" class="list-of-links centered">
<li><a href="#" …Run Code Online (Sandbox Code Playgroud) 我已经忙于一页导航了。您将在下面找到有关问题和我的愿望的更多信息。
单击导航项后,滚动到其特定部分并更新菜单的活动类。如果页面滚动到其特定部分,它也应该更新活动状态 - 因此将类更改为其特定锚点。
对于网站,我还使用了固定标题,因此不应覆盖特定部分。因此,当标题底部到达该部分的顶部时,菜单应停止滚动。
一页设计上的所有部分都有不同的高度。
我已经尝试了很多代码,以使其工作。大部分代码都可以工作,但并非在所有浏览器中都相同。此外,我在更新特定部分的活动状态时遇到了一些麻烦 - 与活动锚点匹配。
我使用 jQuery 创建了一个平滑的滚动到锚点。你可以在 JSfiddle 看到我的工作代码。
以下是所有资源:
这里我控制导航的点击功能。因此,当用户单击 的列表项时#primary-navwrapper,然后更改活动状态类并滚动到与单击的锚点匹配的特定部分。
$('#primary-navwrapper li').find('a[href^="#"]').click(function(event) {
// Prevent from default action to intitiate
event.preventDefault();
$('#primary-navwrapper li a').removeClass("current");
$(this).addClass("current");
// The id of the section we want to go to.
var anchorId = $(this).attr("href");
// Our scroll target : the top position of the
// section that has the id referenced by our href.
var target = …Run Code Online (Sandbox Code Playgroud) 如何创建一个搜索表单来搜索 JSON 文件中输入的术语?
因此,如果搜索词等于位置对象内的标题,它应该返回该对象信息。如果没有匹配,则向用户反馈没有找到项目
我创建了一个搜索输入:
<form action="" method="get">
<input id="search" type="text" placeholder="Search term">
<input type="submit" class="button">
</form>
Run Code Online (Sandbox Code Playgroud)
我的 JSON 看起来像这样:
{
"title": "Locations",
"locations": [
{
"title": "New York",
"url": "api/newyork.js"
},{
"title": "Dubai",
"url": "api/dubai.js"
},{
"title": "Netherlands",
"url": "api/netherlands.js"
},{
"title": "Lanzarote",
"url": "api/lanzarote.js"
},{
"title": "Italy",
"url": "api/italy.js"
}
]
}
Run Code Online (Sandbox Code Playgroud)
更新:
我使用 jQuery 想出了以下内容:
$("#search").change(function() {
var arrival = $(this).val();
$.getJSON( "api/videoData.js")
.done(function(data) {
// update your ui here
console.dir(data.pages);
var dataArr = data.pages;
// Iterate …Run Code Online (Sandbox Code Playgroud) 我使用了一个集合视图来显示一组图像.它正在工作,但是当我使用该功能时didDeselectItemAt,如果我点击某些图像,它将崩溃.
发生错误:
fatal error: unexpectedly found nil while unwrapping an Optional value
numberOfItemsInSection:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return images.count
}
Run Code Online (Sandbox Code Playgroud)
cellForItemAt:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cellIdentifier = "ImageCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! ImageCollectionViewCell
let imageUrls = collection?.imageUrls
// Configure the cell
// Reset alpha of first item in collection
if indexPath.row == 0 {
cell.imageView.alpha = 1.0
if videoUrl != …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用jQuery创建一个无限滑块.活动幻灯片将是屏幕的2/3,即将到来的幻灯片将是1/3.所以你已经看到了下一张幻灯片的预览.
我构建的滑块正在工作.单击next滑块时将向左侧动画.
诀窍
在初始化时,我在最后一张幻灯片后复制了前两张幻灯片.当slideIndex关注当前索引时,当幻灯片的数量减去1时,它会将滑块重置为零.所以你有一个无限滑块.
问题
当我在第一张幻灯片上并且之前单击时我也想要应用效果时出现问题.它基本上应该这样做,但不能将滑块重置为零,而是重置幻灯片的末尾.
var slider = $('.slider');
var slides = slider.find('.slides').children();
var slidesW = slides.width();
root.offset = -Math.abs((root.slideIndex * slides.eq(index).width()));
console.log(root.offset);
// Update active class
slides.removeClass('active');
// slides.eq(index).addClass('active');
// Add class active
TweenMax.to(slides.eq(index), 1, {
className: 'active',
onComplete: function() {
if (root.slideIndex >= (root.numOfSlides - 2)) {
slider.find('.slides').addClass('no-transition');
slides.removeClass('active');
slides.filter(':first').addClass('active');
root.offset = 0;
TweenMax.set(slider.find('.slides'), {
x: root.offset,
onComplete: function() {
root.slideIndex = 0;
$('#footer .paging #indicator').find('span').html('01');
return false;
}
});
}
}
}); …Run Code Online (Sandbox Code Playgroud) 我想知道如何通过在Sass中使用for循环来计算两个动画延迟(淡入和淡出)。
提出了以下建议,但不知道如何计算第二个动画延迟。
@for $i from 1 through 2 {
.text:nth-child(#{$i}) {
animation-delay: ($i * 0.5s), 4s;
}
}
Run Code Online (Sandbox Code Playgroud)
我想对淡入淡出做同样的事情,所以每个文本元素都会有些许交错。
已经尝试过类似的方法,但是没有结果。
@for $i from 1 through 2 {
.text:nth-child(#{$i, $a}) {
animation-delay: ($i * 0.5s), ($a * 0.5s);
}
}
Run Code Online (Sandbox Code Playgroud)
以及如何使用上一个延迟来开始另一个动画的另一个延迟?