Skip to content

Instantly share code, notes, and snippets.

@iraniamir
Created October 2, 2017 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iraniamir/fa2b34ad20956d241b8d15109eaa344c to your computer and use it in GitHub Desktop.
Save iraniamir/fa2b34ad20956d241b8d15109eaa344c to your computer and use it in GitHub Desktop.
titleNotifier
<html>
<head>
<title> search in array </title>
</head>
<body>
<script src="jquery.js"></script>
<script src='index.js'></script>
<script>
var nt;
$(function () {
nt = titlenoti();
});
</script>
</body>
</html>
"use strict";
+(function (tn) {
window.titlenoti = function (options) {
var settings = tn.extend({
notyfCount: 0,
maxCount: 100,
withtitle: true
}, options),
_this = this;
var title = (settings.withtitle == false) ? " " : $('title')[0].text;
$('title')[0].text = title;
return {
add: function () {
settings.notyfCount++;
if (settings.notyfCount <= settings.maxCount) {
$('title')[0].text = "(" + settings.notyfCount + ") " + title;
} else {
$('title')[0].text = "(many) " + title;
}
},
sub: function () {
settings.notyfCount--;
if (settings.notyfCount > 0) {
if (settings.notyfCount <= settings.maxCount) {
$('title')[0].text = "(" + settings.notyfCount + ") " + title;
} else {
$('title')[0].text = "(many) " + title;
}
} else {
settings.notyfCount = 0;
$('title')[0].text = title;
}
},
reset: function () {
settings.notyfCount = 0;
$('title')[0].text = title;
},
get: function () {
return settings.notyfCount;
},
max: function (mx) {
settings.maxCount = mx;
}
}
}
}(jQuery))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment