68 lines
1.5 KiB
JavaScript
68 lines
1.5 KiB
JavaScript
#include common.js
|
|
#include utility.js
|
|
|
|
var AmiChatTitle = function(parent, title) {
|
|
var elem = $e({ attrs: { id: 'chatTitle' }, child: title});
|
|
parent.appendChild(elem);
|
|
|
|
return {
|
|
setTitle: function(title) {
|
|
elem.textContent = title;
|
|
},
|
|
};
|
|
};
|
|
|
|
var AmiWindowTitle = function(title) {
|
|
var baseTitle = '',
|
|
activeFlash = undefined;
|
|
|
|
var setTitle = function(text) {
|
|
document.title = text;
|
|
};
|
|
|
|
var setBaseTitle = function(title) {
|
|
baseTitle = title;
|
|
if(activeFlash === undefined)
|
|
setTitle(baseTitle);
|
|
};
|
|
|
|
setBaseTitle(title);
|
|
|
|
var clearTitle = function() {
|
|
if(activeFlash !== undefined) {
|
|
clearInterval(activeFlash);
|
|
activeFlash = undefined;
|
|
setTitle(baseTitle);
|
|
}
|
|
};
|
|
|
|
var flashTitle = function(titles, interval, repeat) {
|
|
if(interval === undefined) interval = 500;
|
|
if(repeat === undefined) repeat = 5;
|
|
|
|
var round = 0,
|
|
target = titles.length * repeat;
|
|
|
|
clearTitle();
|
|
setTitle(titles[0]);
|
|
|
|
activeFlash = setInterval(function() {
|
|
if(round >= target) {
|
|
clearTitle();
|
|
setTitle(baseTitle);
|
|
return;
|
|
}
|
|
|
|
++round;
|
|
setTitle(titles[round % titles.length]);
|
|
}, interval);
|
|
};
|
|
|
|
return {
|
|
setBaseTitle: setBaseTitle,
|
|
setTitle: setTitle,
|
|
clearTitle: clearTitle,
|
|
flashTitle: flashTitle,
|
|
};
|
|
};
|