diff --git a/static/cosmopolite.js b/static/cosmopolite.js index c57dbc4..adf5e0f 100644 --- a/static/cosmopolite.js +++ b/static/cosmopolite.js @@ -14,6 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. */ +// We use long keys in many places. Provide a method to trim those down for +// human readability. +String.prototype.hashCode = function() { + var hash = 0; + for (i = 0; i < this.length; i++) { + var char = this.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash & hash; + } + return hash; +}; + var cosmopolite = {}; cosmopolite.Client = function(opt_callbacks, opt_urlPrefix, opt_namespace) { diff --git a/static/debug.html b/static/debug.html index 36d3b72..a04be86 100644 --- a/static/debug.html +++ b/static/debug.html @@ -73,7 +73,7 @@ var addMessage = function(message) { var messageDiv = document.createElement('div'); messageDiv.innerHTML = ( (new Date(message['created'] * 1000)).toString() + - ' <' + message['sender'] + '> ' + + ' <????-' + (Math.abs(message['sender'].hashCode()) % 10000) + '> ' + message['message'] ); messages.appendChild(messageDiv);