Skip to content

Instantly share code, notes, and snippets.

@omeome762
Last active July 10, 2017 02:45
Show Gist options
  • Save omeome762/bd4fe03229272a0d08292f49e974ea74 to your computer and use it in GitHub Desktop.
Save omeome762/bd4fe03229272a0d08292f49e974ea74 to your computer and use it in GitHub Desktop.
POP UP Notification like Notify apps
<script>
$(function() {
$('#someone-purchased').show();
var mytimeAgo = ['20 seconds', '34 seconds','35 seconds', '43 seconds','1 minute', '5 minutes', '10 minutes', '12 minutes', '14 minutes', '16 minutes', '18 minutes', '20 minutes', '25 minutes', '30 minutes', '35 minutes', '40 minutes','42 minutes','45 minutes', '50 minutes', '1 hours'];
var randomlytimeAgo = Math.floor(Math.random() * mytimeAgo.length);
var currentmytimeAgo = mytimeAgo[randomlytimeAgo];
$(".timeAgo").text(currentmytimeAgo+" ago");
$("#someone-purchased > div:gt(0)").hide();
setInterval(function() {
$('#someone-purchased > div:first')
.fadeOut(0)
.next()
.fadeIn(0)
.end()
.appendTo('#someone-purchased');
var mytimeAgo = ['0 minute', '1 minute', '5 minutes', '10 minutes', '12 minutes', '14 minutes', '16 minutes', '18 minutes', '20 minutes', '25 minutes', '30 minutes', '35 minutes', '40 minutes','42 minutes','45 minutes', '50 minutes', '1 hours'];
var randomlytimeAgo = Math.floor(Math.random() * mytimeAgo.length);
var currentmytimeAgo = mytimeAgo[randomlytimeAgo];
$(".timeAgo").text(currentmytimeAgo+" ago");
}, 20000);
setInterval(function() {
$('#someone-purchased').fadeIn(function() { $(this).removeClass("fade-out"); }).delay(5000).fadeIn( function() { $(this).addClass("fade-out"); }).delay(15000);
}, 5000);
});
</script>
{{ 'notify_popup.scss.css' | asset_url | stylesheet_tag }}
{% assign randomly_collection = collections[settings.popup_randomly_collection] %}
{% if settings.popup_enable %}
<div id="someone-purchased" class="customized fade-in" style="display:none;">
{% capture index %}{{ 'now' | date: '%S' | times: randomly_collection.products.size | divided_by: 60 }}{% endcapture %}
{% for product in randomly_collection.products offset:index limit:1000 %}
<div>
<img src="{{ product | img_url: '120x85' }}">
<p>
{{ settings.buttom_message }}
<a href="{{ product.url }}">
{{ product.title }}</a>
{% if settings.popup_ago_custom_time %}
<small class="timeAgo"></small>
{% endif %}
</p>
</div>
{% endfor %}
</div>
{% endif %}
@Marketingguru
Copy link

Can you add in an option for how many seconds in between notifications? Or limit the number of notifications per page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment