Created
October 2, 2017 12:13
-
-
Save iraniamir/fa2b34ad20956d241b8d15109eaa344c to your computer and use it in GitHub Desktop.
titleNotifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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