1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: jsxc.lib.notice.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: jsxc.lib.notice.js</h1>
<section>
<article>
<pre class="prettyprint source"><code>/**
* This namespace handle the notice system.
*
* @namspace jsxc.notice
* @memberOf jsxc
*/
jsxc.notice = {
/** Number of notices. */
_num: 0,
/**
* Loads the saved notices.
*
* @memberOf jsxc.notice
*/
load: function() {
// reset list
$('#jsxc_notice ul li').remove();
$('#jsxc_notice > span').text('');
jsxc.notice._num = 0;
var saved = jsxc.storage.getUserItem('notices') || [];
var key = null;
for (key in saved) {
if (saved.hasOwnProperty(key)) {
var val = saved[key];
jsxc.notice.add(val.msg, val.description, val.fnName, val.fnParams, key);
}
}
},
/**
* Add a new notice to the stack;
*
* @memberOf jsxc.notice
* @param msg Header message
* @param description Notice description
* @param fnName Function name to be called if you open the notice
* @param fnParams Array of params for function
* @param id Notice id
*/
add: function(msg, description, fnName, fnParams, id) {
var nid = id || Date.now();
var list = $('#jsxc_notice ul');
var notice = $('<li/>');
notice.click(function() {
jsxc.notice.remove(nid);
jsxc.exec(fnName, fnParams);
return false;
});
notice.text(msg);
notice.attr('title', description || '');
notice.attr('data-nid', nid);
list.append(notice);
$('#jsxc_notice > span').text(++jsxc.notice._num);
if (!id) {
var saved = jsxc.storage.getUserItem('notices') || {};
saved[nid] = {
msg: msg,
description: description,
fnName: fnName,
fnParams: fnParams
};
jsxc.storage.setUserItem('notices', saved);
jsxc.notification.notify(msg, description || '', null, true, jsxc.CONST.SOUNDS.NOTICE);
}
},
/**
* Removes notice from stack
*
* @memberOf jsxc.notice
* @param nid The notice id
*/
remove: function(nid) {
var el = $('#jsxc_notice li[data-nid=' + nid + ']');
el.remove();
$('#jsxc_notice > span').text(--jsxc.notice._num || '');
var s = jsxc.storage.getUserItem('notices');
delete s[nid];
jsxc.storage.setUserItem('notices', s);
},
/**
* Check if there is already a notice for the given function name.
*
* @memberOf jsxc.notice
* @param {string} fnName Function name
* @returns {boolean} True if there is >0 functions with the given name
*/
has: function(fnName) {
var saved = jsxc.storage.getUserItem('notices') || [];
var has = false;
$.each(saved, function(index, val) {
if (val.fnName === fnName) {
has = true;
return false;
}
});
return has;
}
};
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="jsxc.Message.html">Message</a></li></ul><h3>Namespaces</h3><ul><li><a href="jsxc.html">jsxc</a></li><li><a href="jsxc.gui.html">gui</a></li><li><a href="jsxc.gui.dialog.html">dialog</a></li><li><a href="jsxc.gui.queryActions.html">queryActions</a></li><li><a href="jsxc.gui.roster.html">roster</a></li><li><a href="jsxc.gui.window.html">window</a></li><li><a href="jsxc.muc.html">muc</a></li><li><a href="jsxc.notification.html">notification</a></li><li><a href="jsxc.options.html">options</a></li><li><a href="jsxc.otr.html">otr</a></li><li><a href="jsxc.storage.html">storage</a></li><li><a href="jsxc.webrtc.html">webrtc</a></li><li><a href="jsxc.xmpp.html">xmpp</a></li><li><a href="jsxc.xmpp.bookmarks.html">bookmarks</a></li><li><a href="jsxc.xmpp.carbons.html">carbons</a></li></ul><h3>Global</h3><ul><li>{boolean}</li><li>{integer}</li><li>{string}</li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Mar 11 2016 17:32:12 GMT+0100 (CET)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
|