Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change position of on/offline

  • Loading branch information...
commit e3690c221a4fb9e50c042f0447c2fe96200fd84e 1 parent 4a5ee0d
unknown authored
View
38 css/hotpost.css
@@ -1,19 +1,19 @@
-.webim-hotpost {
- padding:1em .5em;
- overflow-x: hidden;
- overflow-y: auto;
- max-height: 300px;
-}
-* html .webim-menu{
- height: expression(this.offsetHeight > 300 ? 300+'px' : 'auto');
-}
-.webim-hotpost .webim-hotpost-empty{
-
-}
-.webim-hotpost ul{
- list-style: none;
-}
-.webim-hotpost ul li{
- overflow: hidden;
- padding:.1em 0;
-}
+.webim-hotpost {
+ padding:1em .5em;
+ overflow-x: hidden;
+ overflow-y: auto;
+ max-height: 300px;
+}
+* html .webim-menu{
+ height: expression(this.offsetHeight > 300 ? 300+'px' : 'auto');
+}
+.webim-hotpost .webim-hotpost-empty{
+
+}
+.webim-hotpost ul{
+ list-style: none;
+}
+.webim-hotpost ul li{
+ overflow: hidden;
+ padding:.1em 0;
+}
View
86 css/icons.css
@@ -1,44 +1,44 @@
-.webim-icon{
- background-image:url(../images/icons/icon16.gif);
-}
-.webim-icon-home{
- background-position:0 0;
-
- }
- .webim-icon-buddy{
- background-position:-16px 0;
-
- }
- .webim-icon-notification{
- background-position:-32px 0;
-
- }
- .webim-icon-setting{
-
- background-position:-48px 0;
-
-
- }
- .webim-icon-chat{
- background-position:0 -16px;
-
- }
- .webim-icon-clear{
- background-position:-16px -16px;
-
- }
- .webim-icon-emot{
- background-position:-32px -16px;
-
- }
- .webim-icon-unblock{
- background-position:0 -32px;
-
- }
- .webim-icon-block{
- background-position:-16px -32px;
-
- }
- .webim-icon-hotpost{
- background-image:url(../images/icons/hotpost.jpg);
+.webim-icon{
+ background-image:url(../images/icons/icon16.gif);
+}
+.webim-icon-home{
+ background-position:0 0;
+
+ }
+ .webim-icon-buddy{
+ background-position:-16px 0;
+
+ }
+ .webim-icon-notification{
+ background-position:-32px 0;
+
+ }
+ .webim-icon-setting{
+
+ background-position:-48px 0;
+
+
+ }
+ .webim-icon-chat{
+ background-position:0 -16px;
+
+ }
+ .webim-icon-clear{
+ background-position:-16px -16px;
+
+ }
+ .webim-icon-emot{
+ background-position:-32px -16px;
+
+ }
+ .webim-icon-unblock{
+ background-position:0 -32px;
+
+ }
+ .webim-icon-block{
+ background-position:-16px -32px;
+
+ }
+ .webim-icon-hotpost{
+ background-image:url(../images/icons/hotpost.jpg);
}
View
53 css/setting.css
@@ -1,20 +1,33 @@
-/*
- * widget setting
- */
-#webim-setting{
- padding: 1em 0;
-
-}
-#webim-setting ul{
- list-style: none;
-}
-#webim-setting ul li{
- margin: .5em 1em;
-}
-#webim-setting ul li input{
- vertical-align: middle;
-}
-
-#webim-setting ul li label{
- padding-left: .2em;
-}
+/*
+ * widget setting
+ */
+#webim-setting{
+ padding: 1em 0;
+
+}
+#webim-setting ul{
+ list-style: none;
+}
+#webim-setting ul li{
+ margin: .5em 1em;
+}
+#webim-setting ul li input{
+ vertical-align: middle;
+}
+
+#webim-setting ul li label{
+ padding-left: .2em;
+}
+.webim-setting-offline{
+ float:right;
+ position:absolute;
+ bottom:.5em;
+ left:19em;
+}
+.webim-setting-online{
+ float:right;
+ position:absolute;
+ bottom:.5em;
+ left:19em;
+ display:none;
+}
View
72 im/index.html
@@ -1,36 +1,36 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <title>webim - test</title>
- <link href="css/core.css" media="all" type="text/css" rel="stylesheet"/>
- <!-- base start -->
- <script type="text/javascript" src="src/core.js" ></script>
- <script type="text/javascript" src="src/objectExtend.js" ></script>
- <script type="text/javascript" src="src/ajax.js" ></script>
- <script type="text/javascript" src="src/json.js" ></script>
- <script type="text/javascript" src="src/comet.js" ></script>
- <script type="text/javascript" src="src/cookie.js" ></script>
- <script type="text/javascript" src="src/log.js" ></script>
- <!-- base end -->
- <!-- webim start -->
- <script type="text/javascript" src="src/webim.js" ></script>
- <script type="text/javascript" src="src/setting.js" ></script>
- <script type="text/javascript" src="src/status.js" ></script>
- <script type="text/javascript" src="src/buddy.js" ></script>
- <script type="text/javascript" src="src/notification.js" ></script>
- <script type="text/javascript" src="src/history.js" ></script>
- <script type="text/javascript" src="src/hotpost.js" ></script>
- <!-- webim end -->
- </head>
- <body>
- <div id="wrap-body">
- <div id = "webim-log">
- <p>
- <b>log</b>
- </p>
- </div>
- </div>
- <script type="text/javascript" src="index.js" ></script>
- </body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>webim - test</title>
+ <link href="css/core.css" media="all" type="text/css" rel="stylesheet"/>
+ <!-- base start -->
+ <script type="text/javascript" src="src/core.js" ></script>
+ <script type="text/javascript" src="src/objectExtend.js" ></script>
+ <script type="text/javascript" src="src/ajax.js" ></script>
+ <script type="text/javascript" src="src/json.js" ></script>
+ <script type="text/javascript" src="src/comet.js" ></script>
+ <script type="text/javascript" src="src/cookie.js" ></script>
+ <script type="text/javascript" src="src/log.js" ></script>
+ <!-- base end -->
+ <!-- webim start -->
+ <script type="text/javascript" src="src/webim.js" ></script>
+ <script type="text/javascript" src="src/setting.js" ></script>
+ <script type="text/javascript" src="src/status.js" ></script>
+ <script type="text/javascript" src="src/buddy.js" ></script>
+ <script type="text/javascript" src="src/notification.js" ></script>
+ <script type="text/javascript" src="src/history.js" ></script>
+ <script type="text/javascript" src="src/hotpost.js" ></script>
+ <!-- webim end -->
+ </head>
+ <body>
+ <div id="wrap-body">
+ <div id = "webim-log">
+ <p>
+ <b>log</b>
+ </p>
+ </div>
+ </div>
+ <script type="text/javascript" src="index.js" ></script>
+ </body>
+</html>
View
76 im/speed/index.html
@@ -1,38 +1,38 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <title>im speed</title>
- <script type="text/javascript" src="benchmark/benchmark.js"></script>
- <script type="text/javascript" src="benchmark/benchmark_perlish.js"></script>
- <link rel="stylesheet" href="benchmark/benchmark.css" type="text/css" />
- <!-- base start -->
- <script type="text/javascript" src="../src/core.js" ></script>
- <script type="text/javascript" src="../src/objectExtend.js" ></script>
- <script type="text/javascript" src="../src/ajax.js" ></script>
- <script type="text/javascript" src="../src/json.js" ></script>
- <script type="text/javascript" src="../src/comet.js" ></script>
- <script type="text/javascript" src="../src/cookie.js" ></script>
- <script type="text/javascript" src="../src/log.js" ></script>
- <!-- base end -->
- <!-- webim start -->
- <script type="text/javascript" src="../src/webim.js" ></script>
- <script type="text/javascript" src="../src/setting.js" ></script>
- <script type="text/javascript" src="../src/status.js" ></script>
- <script type="text/javascript" src="../src/buddy.js" ></script>
- <script type="text/javascript" src="../src/notification.js" ></script>
- <script type="text/javascript" src="../src/history.js" ></script>
- <!-- webim end -->
- <script type="text/javascript" src="index.js" ></script>
- </head>
- <body>
- <div id="wrap-body">
- <div id = "webim-log">
- <p>
- <b>log</b>
- </p>
- </div>
- </div>
- </body>
-
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>im speed</title>
+ <script type="text/javascript" src="benchmark/benchmark.js"></script>
+ <script type="text/javascript" src="benchmark/benchmark_perlish.js"></script>
+ <link rel="stylesheet" href="benchmark/benchmark.css" type="text/css" />
+ <!-- base start -->
+ <script type="text/javascript" src="../src/core.js" ></script>
+ <script type="text/javascript" src="../src/objectExtend.js" ></script>
+ <script type="text/javascript" src="../src/ajax.js" ></script>
+ <script type="text/javascript" src="../src/json.js" ></script>
+ <script type="text/javascript" src="../src/comet.js" ></script>
+ <script type="text/javascript" src="../src/cookie.js" ></script>
+ <script type="text/javascript" src="../src/log.js" ></script>
+ <!-- base end -->
+ <!-- webim start -->
+ <script type="text/javascript" src="../src/webim.js" ></script>
+ <script type="text/javascript" src="../src/setting.js" ></script>
+ <script type="text/javascript" src="../src/status.js" ></script>
+ <script type="text/javascript" src="../src/buddy.js" ></script>
+ <script type="text/javascript" src="../src/notification.js" ></script>
+ <script type="text/javascript" src="../src/history.js" ></script>
+ <!-- webim end -->
+ <script type="text/javascript" src="index.js" ></script>
+ </head>
+ <body>
+ <div id="wrap-body">
+ <div id = "webim-log">
+ <p>
+ <b>log</b>
+ </p>
+ </div>
+ </div>
+ </body>
+
+</html>
View
338 im/src/core.js
@@ -1,169 +1,169 @@
-function now() {
- return (new Date).getTime();
-}
-
-var _toString = Object.prototype.toString;
-function isFunction( obj ){
- return _toString.call(obj) === "[object Function]";
-}
-
-function isArray( obj ){
- return _toString.call(obj) === "[object Array]";
-}
-function isObject( obj ){
- return obj && _toString.call(obj) === "[object Object]";
-}
-
-function trim( text ) {
- return (text || "").replace( /^\s+|\s+$/g, "" );
-}
-
-function checkUpdate (old, add){
- var added = false;
- if (isObject(add)) {
- old = old || {};
- for (var key in add) {
- var val = add[key];
- if (old[key] != val) {
- added = added || {};
- added[key] = val;
- }
- }
- }
- return added;
-}
-function makeArray( array ){
- var ret = [];
- if( array != null ){
- var i = array.length;
- // The window, strings (and functions) also have 'length'
- if( i == null || typeof array === "string" || isFunction(array) || array.setInterval )
- ret[0] = array;
- else
- while( i )
- ret[--i] = array[i];
- }
- return ret;
-}
-
-function extend() {
- // copy reference to target object
- var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !isFunction(target) )
- target = {};
- for ( ; i < length; i++ )
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null )
- // Extend the base object
- for ( var name in options ) {
- var src = target[ name ], copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy )
- continue;
-
- // Recurse if we're merging object values
- if ( deep && copy && typeof copy === "object" && !copy.nodeType )
- target[ name ] = extend( deep,
- // Never move original objects, clone them
- src || ( copy.length != null ? [ ] : { } )
- , copy );
-
- // Don't bring in undefined values
- else if ( copy !== undefined )
- target[ name ] = copy;
-
- }
-
- // Return the modified object
- return target;
-}
-
-function each( object, callback, args ) {
- var name, i = 0,
- length = object.length,
- isObj = length === undefined || isFunction(object);
-
- if ( args ) {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.apply( object[ name ], args ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.apply( object[ i++ ], args ) === false ) {
- break;
- }
- }
- }
-
- // A special, fast, case for the most common use of each
- } else {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
- break;
- }
- }
- } else {
- for ( var value = object[0];
- i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
- }
- }
-
- return object;
-}
-
-
-function inArray( elem, array ) {
- for ( var i = 0, length = array.length; i < length; i++ ) {
- if ( array[ i ] === elem ) {
- return i;
- }
- }
-
- return -1;
-}
-
-
-function grep( elems, callback, inv ) {
- var ret = [];
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( var i = 0, length = elems.length; i < length; i++ ) {
- if ( !inv !== !callback( elems[ i ], i ) ) {
- ret.push( elems[ i ] );
- }
- }
-
- return ret;
-}
-
-function map( elems, callback ) {
- var ret = [], value;
-
- // Go through the array, translating each of the items to their
- // new value (or values).
- for ( var i = 0, length = elems.length; i < length; i++ ) {
- value = callback( elems[ i ], i );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
-
- return ret.concat.apply( [], ret );
-}
+function now() {
+ return (new Date).getTime();
+}
+
+var _toString = Object.prototype.toString;
+function isFunction( obj ){
+ return _toString.call(obj) === "[object Function]";
+}
+
+function isArray( obj ){
+ return _toString.call(obj) === "[object Array]";
+}
+function isObject( obj ){
+ return obj && _toString.call(obj) === "[object Object]";
+}
+
+function trim( text ) {
+ return (text || "").replace( /^\s+|\s+$/g, "" );
+}
+
+function checkUpdate (old, add){
+ var added = false;
+ if (isObject(add)) {
+ old = old || {};
+ for (var key in add) {
+ var val = add[key];
+ if (old[key] != val) {
+ added = added || {};
+ added[key] = val;
+ }
+ }
+ }
+ return added;
+}
+function makeArray( array ){
+ var ret = [];
+ if( array != null ){
+ var i = array.length;
+ // The window, strings (and functions) also have 'length'
+ if( i == null || typeof array === "string" || isFunction(array) || array.setInterval )
+ ret[0] = array;
+ else
+ while( i )
+ ret[--i] = array[i];
+ }
+ return ret;
+}
+
+function extend() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !isFunction(target) )
+ target = {};
+ for ( ; i < length; i++ )
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null )
+ // Extend the base object
+ for ( var name in options ) {
+ var src = target[ name ], copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy )
+ continue;
+
+ // Recurse if we're merging object values
+ if ( deep && copy && typeof copy === "object" && !copy.nodeType )
+ target[ name ] = extend( deep,
+ // Never move original objects, clone them
+ src || ( copy.length != null ? [ ] : { } )
+ , copy );
+
+ // Don't bring in undefined values
+ else if ( copy !== undefined )
+ target[ name ] = copy;
+
+ }
+
+ // Return the modified object
+ return target;
+}
+
+function each( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+}
+
+
+function inArray( elem, array ) {
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+
+function grep( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+}
+
+function map( elems, callback ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+}
View
206 im/src/history.js
@@ -1,103 +1,103 @@
-/*
-history // 消息历史记录
-attributes:
-data []所有信息 readonly
-methods:
-get(id)
-load(ids)
-clear(ids)
-init(data)
-handle(data) //handle data and distribute events
-
-events:
-data //id,data
-clear //
-*/
-
-model("history",{
- urls:{load:"", clear:""}
-}, {
- _init:function(){
- this.data = this.data || {};
- },
- get: function(id){
- return this.data[id];
- },
- handle:function(addData){
- var self = this, data = self.data, cache = {};
- addData = makeArray(addData);
- var l = addData.length , v, id, userId = self.options.userInfo.id;
- if(!l)return;
- for(var i = 0; i < l; i++){
- //for(var i in addData){
- v = addData[i];
- id = v.to == userId ? v.from : v.to;
- if(id){
- cache[id] = cache[id] || [];
- cache[id].push(v);
- }
- }
- var ids = [];
- for (var key in cache) {
- var v = cache[key];
- if(data[key]){
- data[key] = data[key].concat(v);
- self._triggerMsg(key, v);
- }else{
-
- ids.push(key);
- }
- }
- self.load(ids);
-
- },
- _triggerMsg: function(id, data){
- //this.trigger("message." + id, [data]);
- this.trigger("data", [id, data]);
- },
- clear: function(ids){
- ids = idsArray(ids);
- var self = this, l = ids.length, options = self.options, id;
- if(l){
- for(var i = 0; i < l; i++){
- id = ids[i];
- self.data[id] = [];
- self.trigger("clear", [id]);
- }
- ajax({
- url: options.urls.clear,
- cache: false,
- dataType: "json",
- data:{ ids: ids.join(",")}
- });
- }
-
- },
- init:function(data){
- var self = this.self || this, v;
- for(var key in data){
- v = data[key];
- self.data[key] = v;
- self._triggerMsg(key, v);
- }
- },
- load: function(ids){
- ids = idsArray(ids);
- if(ids.length){
- var self = this, options = self.options;
- for(var i = 0; i < ids.length; i++){
- self.data[ids[i]] = [];
- }
- ajax({
- url: options.urls.load,
- cache: false,
- dataType: "json",
- data:{ ids: ids.join(",")},
- context: self,
- success: self.init
- });
- }
- }
-
-});
-
+/*
+history // 消息历史记录
+attributes:
+data []所有信息 readonly
+methods:
+get(id)
+load(ids)
+clear(ids)
+init(data)
+handle(data) //handle data and distribute events
+
+events:
+data //id,data
+clear //
+*/
+
+model("history",{
+ urls:{load:"", clear:""}
+}, {
+ _init:function(){
+ this.data = this.data || {};
+ },
+ get: function(id){
+ return this.data[id];
+ },
+ handle:function(addData){
+ var self = this, data = self.data, cache = {};
+ addData = makeArray(addData);
+ var l = addData.length , v, id, userId = self.options.userInfo.id;
+ if(!l)return;
+ for(var i = 0; i < l; i++){
+ //for(var i in addData){
+ v = addData[i];
+ id = v.to == userId ? v.from : v.to;
+ if(id){
+ cache[id] = cache[id] || [];
+ cache[id].push(v);
+ }
+ }
+ var ids = [];
+ for (var key in cache) {
+ var v = cache[key];
+ if(data[key]){
+ data[key] = data[key].concat(v);
+ self._triggerMsg(key, v);
+ }else{
+
+ ids.push(key);
+ }
+ }
+ self.load(ids);
+
+ },
+ _triggerMsg: function(id, data){
+ //this.trigger("message." + id, [data]);
+ this.trigger("data", [id, data]);
+ },
+ clear: function(ids){
+ ids = idsArray(ids);
+ var self = this, l = ids.length, options = self.options, id;
+ if(l){
+ for(var i = 0; i < l; i++){
+ id = ids[i];
+ self.data[id] = [];
+ self.trigger("clear", [id]);
+ }
+ ajax({
+ url: options.urls.clear,
+ cache: false,
+ dataType: "json",
+ data:{ ids: ids.join(",")}
+ });
+ }
+
+ },
+ init:function(data){
+ var self = this.self || this, v;
+ for(var key in data){
+ v = data[key];
+ self.data[key] = v;
+ self._triggerMsg(key, v);
+ }
+ },
+ load: function(ids){
+ ids = idsArray(ids);
+ if(ids.length){
+ var self = this, options = self.options;
+ for(var i = 0; i < ids.length; i++){
+ self.data[ids[i]] = [];
+ }
+ ajax({
+ url: options.urls.load,
+ cache: false,
+ dataType: "json",
+ data:{ ids: ids.join(",")},
+ context: self,
+ success: self.init
+ });
+ }
+ }
+
+});
+
View
72 im/src/hotpost.js
@@ -1,36 +1,36 @@
-/**/
-/*
-hotpost//
-attributes
-methods
-handle(data) //handle data and distribute events
-events
-data
-*/
-/*
-* {"from":"","text":"","link":""}
-*/
-
-model("hotpost",{
- url: "webim/hotpost"
-},{
- grep: function(val, n){
- return val && val.text;
- },
- handle: function(data){
- var self = this;
- data = grep(makeArray(data), self.grep);
- if(data.length)self.trigger("data", [data]);
- },
- load: function(){
- var self = this, options = self.options;
- ajax({
- url: options.url,
- cache: false,
- dataType: "json",
- context: self,
- success: self.handle
- });
- }
-});
-
+/**/
+/*
+hotpost//
+attributes
+methods
+handle(data) //handle data and distribute events
+events
+data
+*/
+/*
+* {"from":"","text":"","link":""}
+*/
+
+model("hotpost",{
+ url: "webim/hotpost"
+},{
+ grep: function(val, n){
+ return val && val.text;
+ },
+ handle: function(data){
+ var self = this;
+ data = grep(makeArray(data), self.grep);
+ if(data.length)self.trigger("data", [data]);
+ },
+ load: function(){
+ var self = this, options = self.options;
+ ajax({
+ url: options.url,
+ cache: false,
+ dataType: "json",
+ context: self,
+ success: self.handle
+ });
+ }
+});
+
View
114 im/src/objectExtend.js
@@ -1,57 +1,57 @@
-var objectExtend = {
- option: function(key, value) {
- var options = key, self = this;
- self.options = self.options || {};
- if (typeof key == "string") {
- if (value === undefined) {
- return self.options[key];
- }
- options = {};
- options[key] = value;
- }
- extend(self.options, options);
- return self;
- },
-
- bind: function(type, fn){
- var self = this, _events = self._events = self._events || {};
- if (isFunction(fn)){
- _events[type] = _events[type] || [];
- _events[type].push(fn);
- }
- return this;
- },
-
- trigger: function(type, args){
- var self = this, _events = self._events = self._events || {}, fns = _events[type];
- if (!fns) return this;
- args = isArray(args) ? args : makeArray(args);
- for (var i = 0, l = fns.length; i < l; i++){
- fns[i].apply(this, args);
- }
- return this;
- },
-
- unbind: function(type, fn){
- var self = this, _events = self._events = self._events || {};
- if (!_events[type]) return this;
- if (isFunction(fn)){
- var _e = _events[type];
- for (var i = _e.length; i--; i){
- if (_e[i] === fn || _e[i] === fn._proxy) _e.splice(i, 1);
- }
- } else {
- delete _events[type];
- }
- return this;
- },
- one: function(type, fn){
- if (!isFunction(fn)) return this;
- var self = this,
- one = fn._proxy = fun._proxy || function(){
- self.unbind(type, one);
- return fn.apply(this, arguments);
- };
- self.bind(type, one);
- }
-};
+var objectExtend = {
+ option: function(key, value) {
+ var options = key, self = this;
+ self.options = self.options || {};
+ if (typeof key == "string") {
+ if (value === undefined) {
+ return self.options[key];
+ }
+ options = {};
+ options[key] = value;
+ }
+ extend(self.options, options);
+ return self;
+ },
+
+ bind: function(type, fn){
+ var self = this, _events = self._events = self._events || {};
+ if (isFunction(fn)){
+ _events[type] = _events[type] || [];
+ _events[type].push(fn);
+ }
+ return this;
+ },
+
+ trigger: function(type, args){
+ var self = this, _events = self._events = self._events || {}, fns = _events[type];
+ if (!fns) return this;
+ args = isArray(args) ? args : makeArray(args);
+ for (var i = 0, l = fns.length; i < l; i++){
+ fns[i].apply(this, args);
+ }
+ return this;
+ },
+
+ unbind: function(type, fn){
+ var self = this, _events = self._events = self._events || {};
+ if (!_events[type]) return this;
+ if (isFunction(fn)){
+ var _e = _events[type];
+ for (var i = _e.length; i--; i){
+ if (_e[i] === fn || _e[i] === fn._proxy) _e.splice(i, 1);
+ }
+ } else {
+ delete _events[type];
+ }
+ return this;
+ },
+ one: function(type, fn){
+ if (!isFunction(fn)) return this;
+ var self = this,
+ one = fn._proxy = fun._proxy || function(){
+ self.unbind(type, one);
+ return fn.apply(this, arguments);
+ };
+ self.bind(type, one);
+ }
+};
View
102 im/src/setting.js
@@ -1,51 +1,51 @@
-/*
-* 配置(数据库永久存储)
-* Methods:
-* get
-* set
-*
-* Events:
-* update
-*
-*/
-model("setting",{
- url:"/webim/setting",
- data:{
- play_sound:true,
- buddy_sticky:true,
- minimize_layout: false,
- msg_auto_pop:true
- }
-},{
- _init:function(){
- var self = this;
- self.data = extend({}, self.options.data, self.data);
- },
- get: function(key){
- return this.data[key];
- },
- set: function(key, value){
- var self = this, options = key;
- if(!key)return;
- if (typeof key == "string") {
- options = {};
- options[key] = value;
- }
- var _old = self.data,
- up = checkUpdate(_old, options);
- if ( up ) {
- each(up,function(key,val){
- self.trigger("update",[key,val]);
- });
- var _new = extend({}, _old, options);
- self.data = _new;
- ajax({
- type: 'post',
- url: self.options.url,
- dataType: 'json',
- cache: false,
- data: {data: JSON.encode(_new)}
- });
- }
- }
-});
+/*
+* 配置(数据库永久存储)
+* Methods:
+* get
+* set
+*
+* Events:
+* update
+*
+*/
+model("setting",{
+ url:"/webim/setting",
+ data:{
+ play_sound:true,
+ buddy_sticky:true,
+ minimize_layout: false,
+ msg_auto_pop:true
+ }
+},{
+ _init:function(){
+ var self = this;
+ self.data = extend({}, self.options.data, self.data);
+ },
+ get: function(key){
+ return this.data[key];
+ },
+ set: function(key, value){
+ var self = this, options = key;
+ if(!key)return;
+ if (typeof key == "string") {
+ options = {};
+ options[key] = value;
+ }
+ var _old = self.data,
+ up = checkUpdate(_old, options);
+ if ( up ) {
+ each(up,function(key,val){
+ self.trigger("update",[key,val]);
+ });
+ var _new = extend({}, _old, options);
+ self.data = _new;
+ ajax({
+ type: 'post',
+ url: self.options.url,
+ dataType: 'json',
+ cache: false,
+ data: {data: JSON.encode(_new)}
+ });
+ }
+ }
+});
View
108 im/src/status.js
@@ -1,54 +1,54 @@
-/*
-* 状态(cookie临时存储[刷新页面有效])
-* webim.status.init(status);//初始化状态
-* webim.status.all //所有状态
-* webim.status(key);//get
-* webim.status(key,value);//set
-*/
-//var d = {
-// tabs:{1:{n:5}}, // n -> notice count
-// tabIds:[1],
-// p:5, //tab prevCount
-// a:5, //tab activeTabId
-// b:0, //is buddy open
-// o:0 //has offline
-//}
-model("status",{
- key:"_webim"
-},{
- _init:function(){
- var self = this, data = self.data;
- if (!data){
- var c = cookie(self.options.key);
- self.data = c ? JSON.decode(c) : {};
- }else{
- self._save(data);
- }
- },
- set: function(key, value){
- var options = key, self = this;
- if (typeof key == "string") {
- options = {};
- options[key] = value;
- }
- var old = self.data;
- if (checkUpdate(old, options)) {
- var _new = extend({}, old, options);
- self._save(_new);
- }
- },
- get: function(key){
- return this.data[key];
- },
- clear:function(){
- this._save({});
- },
- _save: function(data){
- this.data = data;
- cookie(this.options.key, JSON.encode(data), {
- path: '/',
- domain: document.domain
- });
- }
-});
-
+/*
+* 状态(cookie临时存储[刷新页面有效])
+* webim.status.init(status);//初始化状态
+* webim.status.all //所有状态
+* webim.status(key);//get
+* webim.status(key,value);//set
+*/
+//var d = {
+// tabs:{1:{n:5}}, // n -> notice count
+// tabIds:[1],
+// p:5, //tab prevCount
+// a:5, //tab activeTabId
+// b:0, //is buddy open
+// o:0 //has offline
+//}
+model("status",{
+ key:"_webim"
+},{
+ _init:function(){
+ var self = this, data = self.data;
+ if (!data){
+ var c = cookie(self.options.key);
+ self.data = c ? JSON.decode(c) : {};
+ }else{
+ self._save(data);
+ }
+ },
+ set: function(key, value){
+ var options = key, self = this;
+ if (typeof key == "string") {
+ options = {};
+ options[key] = value;
+ }
+ var old = self.data;
+ if (checkUpdate(old, options)) {
+ var _new = extend({}, old, options);
+ self._save(_new);
+ }
+ },
+ get: function(key){
+ return this.data[key];
+ },
+ clear:function(){
+ this._save({});
+ },
+ _save: function(data){
+ this.data = data;
+ cookie(this.options.key, JSON.encode(data), {
+ path: '/',
+ domain: document.domain
+ });
+ }
+});
+
View
516 im/src/webim.js
@@ -1,258 +1,258 @@
-/*
-*
-* Depends:
-* core.js
-*
-* options:
-*
-* attributes:
-* data
-* status
-* setting
-* history
-* buddy
-* connection
-*
-*
-* methods:
-* online
-* offline
-* autoOnline
-* sendMsg
-* sendStatus
-* setStranger
-*
-* events:
-* ready
-* go
-* stop
-*
-* message
-* presence
-* status
-*/
-
-
-function webim(element, options){
- var self = this;
- self.options = extend({}, webim.defaults, options);
- this._init(element, options);
-}
-
-extend(webim.prototype, objectExtend,{
- _init:function(){
- var self = this;
- self.data = {user:{}};
- self.status = new webim.status();
- self.setting = new webim.setting();
- self.buddy = new webim.buddy();
- self.room = new webim.room();
- self.history = new webim.history();
- self.notification = new webim.notification();
- self.hotpost= new webim.hotpost();
- self.connection = new comet(null,{jsonp:true});
- self._initEvents();
- //self.online();
- },
- ready: function(){
- var self = this;
- self._unloadFun = window.onbeforeunload;
- window.onbeforeunload = function(){
- self.refresh();
- };
- self.trigger("ready");
- },
- go: function(){
- var self = this, data = self.data, history = self.history, buddy = self.buddy, room = self.room;
- self.connection.connect(data.connection);
- history.option("userInfo", data.user);
- history.init(data.histories);
- buddy.handle(data.buddies);
- //buddy load delay
- buddy.online(data.buddy_online_ids, true);
- //rooms
- //blocked rooms
- var b = self.setting.get("block_list"), roomData = data.rooms;
- isArray(b) && roomData && each(b,function(n,v){
- roomData[v] && (roomData[v].blocked = true);
- });
- room.handle(roomData);
- room.options.ticket = data.connection.ticket;
- //handle new messages
- var n_msg = data.new_messages;
- if(n_msg && n_msg.length)
- self.trigger("message",[n_msg]);
-
- self.trigger("go",[data]);
- },
- stop: function(msg){
- var self = this;
- window.onbeforeunload = self._unloadFun;
- self.data.user.presence = "offline";
- self.buddy.clear();
- self.trigger("stop", msg);
-
- },
- autoOnline: function(){
- return !this.status.get("o");
- },
- _initEvents: function(){
- var self = this, status = self.status, setting = self.setting, history = self.history, connection = self.connection;
- connection.bind("connect",function(e, data){
- }).bind("data",function(data){
- self.handle(data);
- }).bind("error",function(data){
- self.stop("connect error");
- }).bind("close",function(data){
- self.stop("disconnect");
- });
- },
- handle:function(data){
- var self = this;
- data.messages && data.messages.length && self.trigger("message",[data.messages]);
- data.presences && data.presences.length && self.trigger("presence",[data.presences]);
- data.statuses && data.statuses.length && self.trigger("status",[data.statuses]);
- },
- sendMsg: function(msg){
- var self = this;
- msg.ticket = self.data.connection.ticket;
- ajax({
- type: 'post',
- url: self.options.urls.message,
- type: 'post',
- cache: false,
- data: msg
- });
- },
- sendStatus: function(msg){
- var self = this;
- msg.ticket = self.data.connection.ticket;
- ajax({
- type: 'post',
- url: self.options.urls.status,
- type: 'post',
- cache: false,
- data: msg
- });
- },
- // online_list:function(){
- // var self = this;
- // ajax({
- // type:"post",
- // dataType: "json",
- // url: self.options.urls.online_list,
- // success: function(data){
- // self.trigger("online_list", [data]);
- // },
- // error: function(data){
- // log(data, "online:error");
- // }
- // });
- //
- // },
- setStranger: function(ids){
- this.stranger_ids = idsArray(ids);
- },
- stranger_ids:[],
- online:function(){
- var self = this, status = self.status, buddy_ids = [], tabs = status.get("tabs"), tabIds = status.get("tabIds");
- //set auto open true
- status.set("o", false);
- self.ready();
- tabIds && tabIds.length && tabs && each(tabs, function(k,v){
- v["t"] == "buddy" && buddy_ids.push(k);
- });
- ajax({
- type:"post",
- dataType: "json",
- data:{
- buddy_ids: buddy_ids.join(","),
- stranger_ids: self.stranger_ids.join(",")
- },
- url: self.options.urls.online,
- success: function(data){
- if(!data || !data.user || !data.connection){
- self.stop("online error");
- }else{
- data.user = extend(self.data.user, data.user);
- self.data = data;
- self.go();
- }
- },
- error: function(data){
- self.stop("online error");
- }
- });
-
- },
- offline:function(){
- var self = this, data = self.data;
- self.status.set("o", true);
- self.connection.close();
- self.stop("offline");
- ajax({
- type: 'post',
- url: self.options.urls.offline,
- type: 'post',
- cache: false,
- data: {
- status: 'offline',
- ticket: data.connection.ticket
- }
- });
-
- },
- refresh:function(){
- var self = this, data = self.data;
- if(!data || !data.connection || !data.connection.ticket) return;
- ajax({
- type: 'post',
- url: self.options.urls.refresh,
- type: 'post',
- cache: false,
- data: {
- ticket: data.connection.ticket
- }
- });
- }
-
-});
-function idsArray(ids){
- return ids && ids.split ? ids.split(",") : (isArray(ids) ? ids : (parseInt(ids) ? [parseInt(ids)] : []));
-}
-function model(name, defaults, proto){
- function m(data,options){
- var self = this;
- self.data = data;
- self.options = extend({}, m.defaults,options);
- isFunction(self._init) && self._init();
- }
- m.defaults = defaults;
- extend(m.prototype, objectExtend, proto);
- webim[name] = m;
-}
-//_webim = window.webim;
-window.webim = webim;
-
-extend(webim,{
- version:"@VERSION",
- defaults:{},
- log:log,
- idsArray: idsArray,
- now: now,
- isFunction: isFunction,
- isArray: isArray,
- isObject: isObject,
- trim: trim,
- makeArray: makeArray,
- extend: extend,
- each: each,
- inArray: inArray,
- grep: grep,
- map: map,
- JSON: JSON,
- ajax: ajax,
- model: model,
- objectExtend: objectExtend
-});
-
+/*
+*
+* Depends:
+* core.js
+*
+* options:
+*
+* attributes:
+* data
+* status
+* setting
+* history
+* buddy
+* connection
+*
+*
+* methods:
+* online
+* offline
+* autoOnline
+* sendMsg
+* sendStatus
+* setStranger
+*
+* events:
+* ready
+* go
+* stop
+*
+* message
+* presence
+* status
+*/
+
+
+function webim(element, options){
+ var self = this;
+ self.options = extend({}, webim.defaults, options);
+ this._init(element, options);
+}
+
+extend(webim.prototype, objectExtend,{
+ _init:function(){
+ var self = this;
+ self.data = {user:{}};
+ self.status = new webim.status();
+ self.setting = new webim.setting();
+ self.buddy = new webim.buddy();
+ self.room = new webim.room();
+ self.history = new webim.history();
+ self.notification = new webim.notification();
+ self.hotpost= new webim.hotpost();
+ self.connection = new comet(null,{jsonp:true});
+ self._initEvents();
+ //self.online();
+ },
+ ready: function(){
+ var self = this;
+ self._unloadFun = window.onbeforeunload;
+ window.onbeforeunload = function(){
+ self.refresh();
+ };
+ self.trigger("ready");
+ },
+ go: function(){
+ var self = this, data = self.data, history = self.history, buddy = self.buddy, room = self.room;
+ self.connection.connect(data.connection);
+ history.option("userInfo", data.user);
+ history.init(data.histories);
+ buddy.handle(data.buddies);
+ //buddy load delay
+ buddy.online(data.buddy_online_ids, true);
+ //rooms
+ //blocked rooms
+ var b = self.setting.get("block_list"), roomData = data.rooms;
+ isArray(b) && roomData && each(b,function(n,v){
+ roomData[v] && (roomData[v].blocked = true);
+ });
+ room.handle(roomData);
+ room.options.ticket = data.connection.ticket;
+ //handle new messages
+ var n_msg = data.new_messages;
+ if(n_msg && n_msg.length)
+ self.trigger("message",[n_msg]);
+
+ self.trigger("go",[data]);
+ },
+ stop: function(msg){
+ var self = this;
+ window.onbeforeunload = self._unloadFun;
+ self.data.user.presence = "offline";
+ self.buddy.clear();
+ self.trigger("stop", msg);
+
+ },
+ autoOnline: function(){
+ return !this.status.get("o");
+ },
+ _initEvents: function(){
+ var self = this, status = self.status, setting = self.setting, history = self.history, connection = self.connection;
+ connection.bind("connect",function(e, data){
+ }).bind("data",function(data){
+ self.handle(data);
+ }).bind("error",function(data){
+ self.stop("connect error");
+ }).bind("close",function(data){
+ self.stop("disconnect");
+ });
+ },
+ handle:function(data){
+ var self = this;
+ data.messages && data.messages.length && self.trigger("message",[data.messages]);
+ data.presences && data.presences.length && self.trigger("presence",[data.presences]);
+ data.statuses && data.statuses.length && self.trigger("status",[data.statuses]);
+ },
+ sendMsg: function(msg){
+ var self = this;
+ msg.ticket = self.data.connection.ticket;
+ ajax({
+ type: 'post',
+ url: self.options.urls.message,
+ type: 'post',
+ cache: false,
+ data: msg
+ });
+ },
+ sendStatus: function(msg){
+ var self = this;
+ msg.ticket = self.data.connection.ticket;
+ ajax({
+ type: 'post',
+ url: self.options.urls.status,
+ type: 'post',
+ cache: false,
+ data: msg
+ });
+ },
+ // online_list:function(){
+ // var self = this;
+ // ajax({
+ // type:"post",
+ // dataType: "json",
+ // url: self.options.urls.online_list,
+ // success: function(data){
+ // self.trigger("online_list", [data]);
+ // },
+ // error: function(data){
+ // log(data, "online:error");
+ // }
+ // });
+ //
+ // },
+ setStranger: function(ids){
+ this.stranger_ids = idsArray(ids);
+ },
+ stranger_ids:[],
+ online:function(){
+ var self = this, status = self.status, buddy_ids = [], tabs = status.get("tabs"), tabIds = status.get("tabIds");
+ //set auto open true
+ status.set("o", false);
+ self.ready();
+ tabIds && tabIds.length && tabs && each(tabs, function(k,v){
+ v["t"] == "buddy" && buddy_ids.push(k);
+ });
+ ajax({
+ type:"post",
+ dataType: "json",
+ data:{
+ buddy_ids: buddy_ids.join(","),
+ stranger_ids: self.stranger_ids.join(",")
+ },
+ url: self.options.urls.online,
+ success: function(data){
+ if(!data || !data.user || !data.connection){
+ self.stop("online error");
+ }else{
+ data.user = extend(self.data.user, data.user);
+ self.data = data;
+ self.go();
+ }
+ },
+ error: function(data){
+ self.stop("online error");
+ }
+ });
+
+ },
+ offline:function(){
+ var self = this, data = self.data;
+ self.status.set("o", true);
+ self.connection.close();
+ self.stop("offline");
+ ajax({
+ type: 'post',
+ url: self.options.urls.offline,
+ type: 'post',
+ cache: false,
+ data: {
+ status: 'offline',
+ ticket: data.connection.ticket
+ }
+ });
+
+ },
+ refresh:function(){
+ var self = this, data = self.data;
+ if(!data || !data.connection || !data.connection.ticket) return;
+ ajax({
+ type: 'post',
+ url: self.options.urls.refresh,
+ type: 'post',
+ cache: false,
+ data: {
+ ticket: data.connection.ticket
+ }
+ });
+ }
+
+});
+function idsArray(ids){
+ return ids && ids.split ? ids.split(",") : (isArray(ids) ? ids : (parseInt(ids) ? [parseInt(ids)] : []));
+}
+function model(name, defaults, proto){
+ function m(data,options){
+ var self = this;
+ self.data = data;
+ self.options = extend({}, m.defaults,options);
+ isFunction(self._init) && self._init();
+ }
+ m.defaults = defaults;
+ extend(m.prototype, objectExtend, proto);
+ webim[name] = m;
+}
+//_webim = window.webim;
+window.webim = webim;
+
+extend(webim,{
+ version:"@VERSION",
+ defaults:{},
+ log:log,
+ idsArray: idsArray,
+ now: now,
+ isFunction: isFunction,
+ isArray: isArray,
+ isObject: isObject,
+ trim: trim,
+ makeArray: makeArray,
+ extend: extend,
+ each: each,
+ inArray: inArray,
+ grep: grep,
+ map: map,
+ JSON: JSON,
+ ajax: ajax,
+ model: model,
+ objectExtend: objectExtend
+});
+
View
72 im/test/index.html
@@ -1,36 +1,36 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <title>im test</title>
- <link href="css/core.css" media="all" type="text/css" rel="stylesheet"/>
- <!-- base start -->
- <script type="text/javascript" src="../src/core.js" ></script>
- <script type="text/javascript" src="../src/objectExtend.js" ></script>
- <script type="text/javascript" src="../src/ajax.js" ></script>
- <script type="text/javascript" src="../src/json.js" ></script>
- <script type="text/javascript" src="../src/comet.js" ></script>
- <script type="text/javascript" src="../src/cookie.js" ></script>
- <script type="text/javascript" src="../src/log.js" ></script>
- <!-- base end -->
- <!-- webim start -->
- <script type="text/javascript" src="../src/webim.js" ></script>
- <script type="text/javascript" src="../src/setting.js" ></script>
- <script type="text/javascript" src="../src/status.js" ></script>
- <script type="text/javascript" src="../src/buddy.js" ></script>
- <script type="text/javascript" src="../src/notification.js" ></script>
- <script type="text/javascript" src="../src/history.js" ></script>
- <!-- webim end -->
- </head>
- <body>
- <div id="wrap-body">
- <div id = "webim-log">
- <p>
- <b>log</b>
- </p>
- </div>
- </div>
- <script type="text/javascript" src="index.js" ></script>
- <script type="text/javascript" src="qunit/json.js" ></script>
- </body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>im test</title>
+ <link href="css/core.css" media="all" type="text/css" rel="stylesheet"/>
+ <!-- base start -->
+ <script type="text/javascript" src="../src/core.js" ></script>
+ <script type="text/javascript" src="../src/objectExtend.js" ></script>
+ <script type="text/javascript" src="../src/ajax.js" ></script>
+ <script type="text/javascript" src="../src/json.js" ></script>
+ <script type="text/javascript" src="../src/comet.js" ></script>
+ <script type="text/javascript" src="../src/cookie.js" ></script>
+ <script type="text/javascript" src="../src/log.js" ></script>
+ <!-- base end -->
+ <!-- webim start -->
+ <script type="text/javascript" src="../src/webim.js" ></script>
+ <script type="text/javascript" src="../src/setting.js" ></script>
+ <script type="text/javascript" src="../src/status.js" ></script>
+ <script type="text/javascript" src="../src/buddy.js" ></script>
+ <script type="text/javascript" src="../src/notification.js" ></script>
+ <script type="text/javascript" src="../src/history.js" ></script>
+ <!-- webim end -->
+ </head>
+ <body>
+ <div id="wrap-body">
+ <div id = "webim-log">
+ <p>
+ <b>log</b>
+ </p>
+ </div>
+ </div>
+ <script type="text/javascript" src="index.js" ></script>
+ <script type="text/javascript" src="qunit/json.js" ></script>
+ </body>
+</html>
View
252 index.html
@@ -1,126 +1,126 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>webim ui</title>
- <!-- base start -->
- <script type="text/javascript" src="im/src/core.js" ></script>
- <script type="text/javascript" src="im/src/objectExtend.js" ></script>
- <script type="text/javascript" src="im/src/ajax.js" ></script>
- <script type="text/javascript" src="im/src/json.js" ></script>
- <script type="text/javascript" src="im/src/comet.js" ></script>
- <script type="text/javascript" src="im/src/cookie.js" ></script>
- <script type="text/javascript" src="im/src/log.js" ></script>
- <!-- base end -->
- <!-- webim start -->
- <script type="text/javascript" src="im/src/webim.js" ></script>
- <script type="text/javascript" src="im/src/setting.js" ></script>
- <script type="text/javascript" src="im/src/status.js" ></script>
- <script type="text/javascript" src="im/src/buddy.js" ></script>
- <script type="text/javascript" src="im/src/room.js" ></script>
- <script type="text/javascript" src="im/src/notification.js" ></script>
- <script type="text/javascript" src="im/src/history.js" ></script>
- <script type="text/javascript" src="im/src/hotpost.js" ></script>
- <!-- webim end -->
- <!-- webim ui start -->
- <link href="css/core.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/ui.core.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/icons.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/layout.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/setting.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/notification.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/hotpost.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/buddy.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/room.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/emot.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/chat.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/menu.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/history.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="css/chatlink.css" media="all" type="text/css" rel="stylesheet"/>
- <link href="themes/redmond/ui.theme.css" media="all" type="text/css" rel="stylesheet"/>
- <script type="text/javascript" src="swfobject-2.1.js" ></script>
- <script type="text/javascript" src="js/core.js" ></script>
- <script type="text/javascript" src="js/date.js" ></script>
- <script type="text/javascript" src="js/notice.js" ></script>
- <script type="text/javascript" src="js/i18n.js" ></script>
- <script type="text/javascript" src="js/ui.js" ></script>
- <script type="text/javascript" src="js/ui.window.js" ></script>
- <script type="text/javascript" src="js/ui.layout.js" ></script>
- <script type="text/javascript" src="js/ui.menu.js" ></script>
- <script type="text/javascript" src="js/ui.hotpost.js" ></script>
- <script type="text/javascript" src="js/ui.buddy.js" ></script>
- <script type="text/javascript" src="js/ui.room.js" ></script>
- <script type="text/javascript" src="js/ui.chat.js" ></script>
- <script type="text/javascript" src="js/ui.chatlink.js" ></script>
- <script type="text/javascript" src="js/ui.emot.js" ></script>
- <script type="text/javascript" src="js/ui.history.js" ></script>
- <script type="text/javascript" src="js/ui.setting.js" ></script>
- <script type="text/javascript" src="js/ui.notification.js" ></script>
- <script type="text/javascript" src="js/i18n/webim-zh-CN.js" ></script>
- <!-- webim ui end -->
- <script type="text/javascript">
- document.location.hash = "space.php?uid=3";
- </script>
- <script type="text/javascript" src="index.js"></script>
- <!--
- <script type="text/javascript" src="../custom.js.php"></script>
- -->
- </head>
- <body>
- <div>
- <h1>webim ui</h1>
- </div>
- <div id="space_mymenu">
- <h2>个人菜单</h2>
- <ul class="line_list">
- <li>
- <img src="image/icon/profile.gif"/><a onclick="getindex('info');" href="javascript:;">个人资料</a>
- </li>
- <li>
- <img src="image/icon/doing.gif"/><a onclick="getindex('doing');" href="javascript:;">记录</a></li>
- <li>
- <img src="image/icon/blog.gif"/><a onclick="getindex('blog');" href="javascript:;">日志</a></li>
- <li><img src="image/icon/album.gif"/><a onclick="getindex('album');" href="javascript:;">相册</a></li>
- <li><img src="image/icon/thread.gif"/><a onclick="getindex('thread');" href="javascript:;">话题</a></li>
- <li><img src="image/icon/poll.gif"/><a onclick="getindex('poll');" href="javascript:;">投票</a></li>
- <li><img src="image/icon/event.gif"/><a onclick="getindex('event');" href="javascript:;">活动</a></li>
- <li><img src="image/icon/share.gif"/><a onclick="getindex('share');" href="javascript:;">分享</a></li>
- <li><img src="image/icon/friend.gif"/><a onclick="getindex('friend');" href="javascript:;">好友</a></li>
- </ul>
- </div>
- <ul>
- <li id="feed_10_li" class="s_clear ">
- <div style="overflow: hidden; width: 100%;">
- <a style="display: none;" title="显示更多选项" id="a_feed_menu_10" class="float_more" href="cp.php?ac=feed&amp;op=menu&amp;feedid=10">菜单</a>
- <a title="只看此类动态" href="space.php?uid=10&amp;do=feed&amp;view=me&amp;appid=2&amp;icon=profile" class="type"><img src="image/icon/profile.gif"/></a>
- <a href="space.php?uid=10" target="_blank">test9</a> 开通了自己的个人主页
-
- <span class="gray">10-30 12:05</span>
-
- </div>
- </li>
- </ul>
- <ul class="avatar_list">
- <li>
- <div class="avatar48"><a href="space.php?uid=11"><img onerror="this.onerror=null;this.src='http://test/uc/ucenter/images/noavatar_small.gif'" src="http://test/uc/ucenter/images/noavatar_small.gif"/></a></div>
- <p title="在线" class="online_icon_p"><a title="test8" href="space.php?uid=11">test8</a></p>
- <p class="gray">10月30日</p>
- </li>
- <li>
- <div class="avatar48"><a href="space.php?uid=10"><img onerror="this.onerror=null;this.src='http://test/uc/ucenter/images/noavatar_small.gif'" src="http://test/uc/ucenter/images/noavatar_small.gif"/></a></div>
- <p><a title="test9" href="space.php?uid=10">test9</a></p>
- <p class="gray">10月30日</p>
- </li>
- <li>
- <div class="avatar48"><a href="space.php?uid=3"><img onerror="this.onerror=null;this.src='http://test/uc/ucenter/images/noavatar_small.gif'" src="http://test/uc/ucenter/images/noavatar_small.gif"/></a></div>
- <p><a title="test1" href="space.php?uid=3">test1</a></p>
- <p class="gray">10月30日</p>
- </li>
- </ul>
- <div id="flash-test"></div>
- <script type="text/javascript">
- swfobject.embedSWF("flash.swf", "flash-test", "600", "400", "9.0.0", null, null, {}, {});
- </script>
- </body>
-</html>
-
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>webim ui</title>
+ <!-- base start -->
+ <script type="text/javascript" src="im/src/core.js" ></script>
+ <script type="text/javascript" src="im/src/objectExtend.js" ></script>
+ <script type="text/javascript" src="im/src/ajax.js" ></script>
+ <script type="text/javascript" src="im/src/json.js" ></script>
+ <script type="text/javascript" src="im/src/comet.js" ></script>
+ <script type="text/javascript" src="im/src/cookie.js" ></script>
+ <script type="text/javascript" src="im/src/log.js" ></script>
+ <!-- base end -->
+ <!-- webim start -->
+ <script type="text/javascript" src="im/src/webim.js" ></script>
+ <script type="text/javascript" src="im/src/setting.js" ></script>
+ <script type="text/javascript" src="im/src/status.js" ></script>
+ <script type="text/javascript" src="im/src/buddy.js" ></script>
+ <script type="text/javascript" src="im/src/room.js" ></script>
+ <script type="text/javascript" src="im/src/notification.js" ></script>
+ <script type="text/javascript" src="im/src/history.js" ></script>
+ <script type="text/javascript" src="im/src/hotpost.js" ></script>
+ <!-- webim end -->
+ <!-- webim ui start -->
+ <link href="css/core.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/ui.core.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/icons.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/layout.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/setting.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/notification.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/hotpost.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/buddy.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/room.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/emot.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/chat.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/menu.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/history.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="css/chatlink.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="themes/redmond/ui.theme.css" media="all" type="text/css" rel="stylesheet"/>
+ <script type="text/javascript" src="swfobject-2.1.js" ></script>
+ <script type="text/javascript" src="js/core.js" ></script>
+ <script type="text/javascript" src="js/date.js" ></script>
+ <script type="text/javascript" src="js/notice.js" ></script>
+ <script type="text/javascript" src="js/i18n.js" ></script>
+ <script type="text/javascript" src="js/ui.js" ></script>
+ <script type="text/javascript" src="js/ui.window.js" ></script>
+ <script type="text/javascript" src="js/ui.layout.js" ></script>
+ <script type="text/javascript" src="js/ui.menu.js" ></script>
+ <script type="text/javascript" src="js/ui.hotpost.js" ></script>
+ <script type="text/javascript" src="js/ui.buddy.js" ></script>
+ <script type="text/javascript" src="js/ui.room.js" ></script>
+ <script type="text/javascript" src="js/ui.chat.js" ></script>
+ <script type="text/javascript" src="js/ui.chatlink.js" ></script>
+ <script type="text/javascript" src="js/ui.emot.js" ></script>
+ <script type="text/javascript" src="js/ui.history.js" ></script>
+ <script type="text/javascript" src="js/ui.setting.js" ></script>
+ <script type="text/javascript" src="js/ui.notification.js" ></script>
+ <script type="text/javascript" src="js/i18n/webim-zh-CN.js" ></script>
+ <!-- webim ui end -->
+ <script type="text/javascript">
+ document.location.hash = "space.php?uid=3";
+ </script>
+ <script type="text/javascript" src="index.js"></script>
+ <!--
+ <script type="text/javascript" src="../custom.js.php"></script>
+ -->
+ </head>
+ <body>
+ <div>
+ <h1>webim ui</h1>
+ </div>
+ <div id="space_mymenu">
+ <h2>个人菜单</h2>
+ <ul class="line_list">
+ <li>
+ <img src="image/icon/profile.gif"/><a onclick="getindex('info');" href="javascript:;">个人资料</a>
+ </li>
+ <li>
+ <img src="image/icon/doing.gif"/><a onclick="getindex('doing');" href="javascript:;">记录</a></li>
+ <li>
+ <img src="image/icon/blog.gif"/><a onclick="getindex('blog');" href="javascript:;">日志</a></li>
+ <li><img src="image/icon/album.gif"/><a onclick="getindex('album');" href="javascript:;">相册</a></li>
+ <li><img src="image/icon/thread.gif"/><a onclick="getindex('thread');" href="javascript:;">话题</a></li>
+ <li><img src="image/icon/poll.gif"/><a onclick="getindex('poll');" href="javascript:;">投票</a></li>
+ <li><img src="image/icon/event.gif"/><a onclick="getindex('event');" href="javascript:;">活动</a></li>
+ <li><img src="image/icon/share.gif"/><a onclick="getindex('share');" href="javascript:;">分享</a></li>
+ <li><img src="image/icon/friend.gif"/><a onclick="getindex('friend');" href="javascript:;">好友</a></li>
+ </ul>
+ </div>
+ <ul>
+ <li id="feed_10_li" class="s_clear ">
+ <div style="overflow: hidden; width: 100%;">
+ <a style="display: none;" title="显示更多选项" id="a_feed_menu_10" class="float_more" href="cp.php?ac=feed&amp;op=menu&amp;feedid=10">菜单</a>
+ <a title="只看此类动态" href="space.php?uid=10&amp;do=feed&amp;view=me&amp;appid=2&amp;icon=profile" class="type"><img src="image/icon/profile.gif"/></a>
+ <a href="space.php?uid=10" target="_blank">test9</a> 开通了自己的个人主页
+
+ <span class="gray">10-30 12:05</span>
+
+ </div>
+ </li>
+ </ul>
+ <ul class="avatar_list">
+ <li>
+ <div class="avatar48"><a href="space.php?uid=11"><img onerror="this.onerror=null;this.src='http://test/uc/ucenter/images/noavatar_small.gif'" src="http://test/uc/ucenter/images/noavatar_small.gif"/></a></div>
+ <p title="在线" class="online_icon_p"><a title="test8" href="space.php?uid=11">test8</a></p>
+ <p class="gray">10月30日</p>
+ </li>
+ <li>
+ <div class="avatar48"><a href="space.php?uid=10"><img onerror="this.onerror=null;this.src='http://test/uc/ucenter/images/noavatar_small.gif'" src="http://test/uc/ucenter/images/noavatar_small.gif"/></a></div>
+ <p><a title="test9" href="space.php?uid=10">test9</a></p>
+ <p class="gray">10月30日</p>
+ </li>
+ <li>
+ <div class="avatar48"><a href="space.php?uid=3"><img onerror="this.onerror=null;this.src='http://test/uc/ucenter/images/noavatar_small.gif'" src="http://test/uc/ucenter/images/noavatar_small.gif"/></a></div>
+ <p><a title="test1" href="space.php?uid=3">test1</a></p>
+ <p class="gray">10月30日</p>
+ </li>
+ </ul>
+ <div id="flash-test"></div>
+ <script type="text/javascript">
+ swfobject.embedSWF("flash.swf", "flash-test", "600", "400", "9.0.0", null, null, {}, {});
+ </script>
+ </body>
+</html>
+
View
140 index.js
@@ -1,70 +1,70 @@
-function imlog(ui){
- var im = ui.im, log = window.webim.log;
- im.connection.bind("data",function(data){
- log(data, "data");
- }).bind("error",function(data){
- log(data, "connect error");
- }).bind("close",function(data){
- log(data, "disconnect");
- });
-}
-(function(webim){
- var path = "";
- //webim.extend(webim.setting.defaults.data,{});
- //webim.extend(webim.setting.defaults.data,{block_list: ["1000001"]});
-
- path = document.location.href.split("/webim");
- path = path.length > 1 ? (path[0] + "/") : "";
- var menu = [{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"album","icon": path + "image\/app\/album.gif","link":"space.php?do=album"},{"title":"blog","icon": path + "image\/app\/blog.gif","link":"space.php?do=blog"},{"title":"thread","icon": path + "image\/app\/mtag.gif","link":"space.php?do=thread"},{"title":"share","icon": path + "image\/app\/share.gif","link":"space.php?do=share"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"},{"title":"doing","icon": path + "image\/app\/doing.gif","link":"space.php?do=doing"}];
- var log = webim.log;
- webim.defaults.urls = {
- online:path + "webim/online.php",
- online_list:path + "webim/online_list.php",
- offline:path + "webim/offline.php",
- message:path + "webim/message.php",
- refresh:path + "webim/refresh.php",
- status:path + "webim/status.php"
- };
- webim.setting.defaults.url = path + "webim/setting.php";
- webim.history.defaults.urls = {
- load: path + "webim/histories.php",
- clear: path + "webim/clear_history.php"
- };
- webim.room.defaults.urls = {
- member: path + "webim/members.php",
- join: path + "webim/join.php",
- leave: path + "webim/leave.php"
- };
- webim.buddy.defaults.url = path + "webim/buddies.php";
- webim.notification.defaults.url = path + "webim/notifications.php";
- webim.hotpost.defaults.url = path + "webim/hotpost.php";
- webim.ui.emot.init({"dir": path + "webim/static/images/emot/default"});
- var soundUrls = {
- lib: path + "webim/static/assets/sound.swf",
- msg: path + "webim/static/assets/sound/msg.mp3"
- };
-
- var body , imUI, im, layout;
- function create(){
- body = document.body;
- imUI = new webim.ui(null,{menu: menu});
- im = imUI.im;
- layout = imUI.layout;
- imUI.addApp("hotpost");
- imUI.addApp("chatlink");
- imUI.addApp("room");
- body.appendChild(layout.element);
- //need timeout
- setTimeout(function(){imUI.initSound(soundUrls)},1000);
- //log
- imlog(imUI);
- }
- function init(){
- layout.buildUI();
- im.autoOnline() && im.online();
- }
- (document.body ? create() : webim.ui.ready(create));
- webim.ui.ready(init);
-
-})(window.webim);
-
+function imlog(ui){
+ var im = ui.im, log = window.webim.log;
+ im.connection.bind("data",function(data){
+ log(data, "data");
+ }).bind("error",function(data){
+ log(data, "connect error");
+ }).bind("close",function(data){
+ log(data, "disconnect");
+ });
+}
+(function(webim){
+ var path = "";
+ //webim.extend(webim.setting.defaults.data,{});
+ //webim.extend(webim.setting.defaults.data,{block_list: ["1000001"]});