⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 punjab.js

📁 Punjab is a jabber XMLRPC/SOAP/REST client. It is a xmlrpc, soap, or REST server that allows for p
💻 JS
📖 第 1 页 / 共 2 页
字号:
// Javascript code for the non-polling punjab demoimg_array = new Array();var can_progress = 0;function clear_img_array(id) {    id = unescape(id);    img_array[id] = null;}function display_chat(to) {   clear_img_array(to);   get_presence(presence_stream_cb,to);   var win_chat = window.open('/chat.html?to='+escape(to),'chatWin'+escape(trim(to)),'width=540,height=380');}var punjab_roster = new Array();function p_logout(){	set_session('');        try {          punjab_clear_intervals();  	        } catch(e) { alert(e); }	        check_login();	}// A logout handler to response to the logout postURL requestvar logout_cb = {    on_init: function() {        //alert("About to send logout request");    },    on_error: function(status,error) {        alert("Logout Error  ("+status+") "+error+"\n");        p_logout();    },    in_progress: function(response,content,length,offset) {        //alert("Downloaded "+response.length+" of "+length+"\n");    },    on_load: function(result) {	try {	   eval(result);        } catch(e) { alert(e); }	        p_logout();    }};// A login handler to response to the login XMLHTTPRequestvar login_cb = {    on_init: function() {	 try {           document.getElementById("chat").innerHTML = "<div id='roster'> Logging into the server ... <br/></div>";	         } catch(e) { alert(e); }         },    on_error: function(status,error) {        alert("Login Error: ("+status+") "+error+"\n");    },    in_progress: function(response,content,length,offset) {        //alert("Downloaded "+response.length+" of "+length+"\n");        can_progress = 1;    },    on_load: function(result) {			try { eval(result); } catch(e) { alert(e); } 	try {           if (sid!='') {  	      set_session(sid)	      // Send presence	      send_presence(presence_cb,null,null,'Online');                        }           show_login();        } catch(e) {          show_login();        }     }};var status_cb = {    on_error: function(status,error) {        alert("Presence Error: ("+status+") "+error+"\n");    },    on_load: function(result) {	 	// Nothing    }};// A presence POST handler to response to the postURL call to presencevar presence_cb = {    on_init: function() {	 try {           document.getElementById("chat").innerHTML = "<div id='roster'> Sending presence ... <br/></div>";	         } catch(e) { alert(e); }         },    on_error: function(status,error) {        alert("Presence Error: ("+status+") "+error+"\n");    },    on_load: function(result) {	        // Get roster		get_roster(roster_cb);    }};// A presence GET handler to response to the postURL call to presencevar presence_stream_cb = {    on_init: function() {        // Do nothing    },    on_error: function(status,error) {        alert("Presence Stream Error: ("+status+") "+error+"\n");        if (status==500) {       	  p_logout();         }    },    in_progress: function(response,content,length,offset) {		try {	           can_progress = 1;            eval(content);        } catch (e) {            //alert(content);             alert(e); //alert('offset '+offset);// alert('length '+response.length);            self.clearInterval(presence_int);            presence_int = null;        }    },    on_load: function(result) {		try {	           if (can_progress==0) {            eval(result);          }        } catch (e) {            //alert(result);             alert(e);             self.clearInterval(presence_int);            presence_int = null;        }    }};// A message GET handler to response to the postURL call to presencevar message_stream_cb = {    on_init: function() {        // Do nothing    },    on_error: function(status,error) {        alert("Message Stream Error: ("+status+") "+error+"\n");        if (status==500) {       	  p_logout();        }    },    in_progress: function(response,content,length,offset) {		        //alert(content);	try {	           can_progress = 1; 	             eval(content);        } catch (e) {           alert(content);            alert(e); //alert('offset '+offset);// alert('length '+response.length);        }	    },    on_load: function(result) {        try {          if (can_progress==0) {            eval(result);          }        } catch (e) {            //alert(result);            alert(e);            self.clearInterval(message_int);            message_int = null;        }    }};// A roster GET handler to response to the getURL call to rostervar roster_cb = {       on_init: function() {        try {           document.getElementById("chat").innerHTML = "<div id='roster'> Loading Roster ... <br/></div>";	         } catch(e) { alert(e); }         },    on_error: function(status,error) {        alert("Roster Error: ("+status+") "+error+"\n");        p_logout();    },    in_progress: function(response,content,length,offset) {	          try {           document.getElementById("chat").innerHTML = "<div id='roster'> Loading Roster ... ("+response.length+")<br/></div>";	                  } catch(e) { alert(e); }    },    on_load: function(result) {		try { eval(result); } catch(e) { alert(e); }	try { 	   show_roster(roster_node);	         } catch(e) {	  alert(e);          	  punjab_logout(logout_cb);	  punjab_clear_intervals();        }                    }};function punjab_clear_intervals(){     if (presence_int>0) {         self.clearInterval(presence_int);         presence_int = null;     }     if (message_int>0) {        self.clearInterval(message_int);        message_int = null;     }}function check_login() {  if (is_logged_in()) {     // Get roster     get_roster(roster_cb);  } else {    show_login();  }                          }function show_loading(size) {	//alert(size);              //  document.getElementById("chat").innerHTML = "<div id='roster'>\nLoading ... ("+size+")<br/></div>";	}function show_login() {  document.getElementById("chat").innerHTML = "<div id='login'><form name='login' action='' method='get'>Jabber User ID : <input type='text'	name='username' /><br/>Password : <input type='password' name='password'/><br/>Port : <input type='text' name='port' value='5222'/><br/><input type='button' onClick='punjab_login(document.login.username.value,document.login.password.value,document.login.port.value,login_cb);' class='button' value='Login'/><br/></form></div>";}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -