Commit 4be2d297 authored by yPhil's avatar yPhil
Browse files

Random nags OK

parent bca1244a
......@@ -721,9 +721,9 @@ th {
border: none !important;
}
.ui-widget-content {
color: var(--color-ui-pri) !important;
}
/* .ui-widget-content { */
/* color: var(--color-ui-pri) !important; */
/* } */
button.ui-state-success {
background-color: var(--color-ui-success) !important;
......
......@@ -7,62 +7,81 @@ PTL.dialog = {
},
nagUser:function() {
if ($('#dialogs').length <= 1) {
PTL.util.console(PTL.tr('Prevented the nag window to pop open because there is already a window opened'), 'success');
} else {
$('#dialogs').load('/static/templates/dialogs.html #nagDialog', function() {
var $dialog = $(this),
$icon = $dialog.find('div.icon > i');
$icon.addClass('icon-petrolette danger');
$dialog.dialog({
title: PTL.tr('Support Pétrolette'),
buttons: [
{
text: PTL.tr('Cancel'),
title: PTL.tr('Cancel'),
class: 'ui-state-default translate',
click: function() {
PTL.dialog.kill($dialog);
}
},
{
text: PTL.tr('Donate'),
title: PTL.tr('Send your love to Pétrolette'),
class: 'ui-state-active translate',
click: function() {
window.location.href = 'https://liberapay.com/yPhil/donate';
}
}
],
open: function () {
$('#dialogs').load('/static/templates/dialogs.html #nagDialog', function() {
$('.ui-widget-overlay').on('click', function() {
PTL.dialog.kill($dialog);
});
var $dialog = $(this);
var firstParagraph = 'Pétrolette is free software. However the development requires a lot of time and a lot of work.',
secondParagraph = 'In order to keep developing Pétrolette with new features I need your help.',
thirdParagraph = 'Please consider to support the Pétrolette project by sending a donation. Even the smallest amount will help a lot.';
var $nag1 = $('<div>').attr('class', 'dialogContent')
.append($('<div>').attr('class', 'dialogImage')
.append($('<span>')
.attr('class', 'huge dialogImage')
.text('🍏')))
.append($('<div>').attr('class', 'dialogText')
.append($('<h1>').text(PTL.tr('Pétrolette needs you')))
.append($('<p>').text(PTL.tr('Pétrolette is free software. However the development requires a lot of time and a lot of work.')))
.append($('<p>').text(PTL.tr('In order to keep developing Pétrolette with new features I need your help.')))
.append($('<p>').text(PTL.tr('Please consider to support the Pétrolette project by sending a donation. Even the smallest amount will help a lot.'))));
var $nag2 = $('<div>').attr('class', 'dialogContent')
.append($('<div>').attr('class', 'dialogImage')
.append($('<span>')
.attr('class', 'huge dialogImage')
.text('🌴')))
.append($('<div>').attr('class', 'dialogText')
.append($('<h1>').text(PTL.tr('Pétrolette is cool')))
.append($('<p>').text(PTL.tr('Pétrolette is free software. However the development requires a lot of time and a lot of work.')))
.append($('<p>').text(PTL.tr('In order to keep developing Pétrolette with new features I need your help.')))
.append($('<p>').text(PTL.tr('Please consider to support the Pétrolette project by sending a donation. Even the smallest amount will help a lot.'))));
var $nag3 = $('<div>').attr('class', 'dialogContent')
.append($('<div>').attr('class', 'dialogImage')
.append($('<span>')
.attr('class', 'huge dialogImage')
.text('🌱')))
.append($('<div>').attr('class', 'dialogText')
.append($('<h1>').text(PTL.tr('Pétrolette is growing')))
.append($('<p>').text(PTL.tr('Pétrolette is free software. However the development requires a lot of time and a lot of work.')))
.append($('<p>').text(PTL.tr('In order to keep developing Pétrolette with new features I need your help.')))
.append($('<p>').text(PTL.tr('Please consider to support the Pétrolette project by sending a donation. Even the smallest amount will help a lot.'))));
var $nags = [$nag1, $nag2, $nag3];
var random = Math.floor(Math.random() * $nags.length);
$dialog.append($nags[random]);
var $contentDiv = $dialog.find('div.content'),
$h1 = $('<h1>').text(PTL.tr('Pétrolette needs you')),
$firstParagraph = $('<p>').text(PTL.tr(firstParagraph)),
$secondParagraph = $('<p>').text(PTL.tr(secondParagraph)),
$thirdParagraph = $('<p>').text(PTL.tr(thirdParagraph));
$dialog.dialog({
title: PTL.tr('Support Pétrolette'),
buttons: [
{
text: PTL.tr('Cancel'),
title: PTL.tr('Cancel'),
class: 'ui-state-default translate',
click: function() {
PTL.dialog.kill($dialog);
}
},
{
text: PTL.tr('Donate'),
title: PTL.tr('Send your love to Pétrolette'),
class: 'ui-state-active translate',
click: function() {
window.location.href = 'https://liberapay.com/yPhil/donate';
}
}
],
open: function () {
$contentDiv.append($h1, $firstParagraph, $secondParagraph, $thirdParagraph);
$('.ui-widget-overlay').on('click', function() {
PTL.dialog.kill($dialog);
});
}
}
});
$dialog.dialog('open');
});
}
},
help:function() {
......
......@@ -59,7 +59,8 @@ var PTL = (function() {
});
$('body').on('click','.help-button', function() {
PTL.dialog.help();
// PTL.dialog.help();
PTL.dialog.nagUser();
});
$('body').on('click','.new-feed-button', function() {
......
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
PTL.util = {
nagUser:function() {
PTL.util.console(PTL.tr('Pétrolette needs you'), 'success');
var nextNag = PTL.prefs.readConfig('nextNag');
const dateNow = Date.now();
if (nextNag === 0) {
nextNag = dateNow;
console.log('dateNow: %s (%s)', dateNow);
PTL.prefs.writeConfig('nextNag', dateNow);
PTL.dialog.nagUser();
}
if (dateNow > nextNag) {
console.log('YUP nextNag: %s dateNow: %s (< %s)', nextNag, dateNow, nextNag + 120000 < dateNow);
PTL.prefs.writeConfig('nextNag', dateNow + 300000);
PTL.dialog.nagUser();
} else {
console.log('NOPE nextNag: %s dateNow: %s (< %s)', nextNag, dateNow, nextNag + 120000 < dateNow);
}
},
console:function(output, type) {
var $lines = $('#console div');
......
......@@ -448,6 +448,12 @@
PTL.tab.init();
(function(){
setTimeout(function(){
PTL.util.nagUser();
}, 60000);
})();
});
</script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment