[Phpfreechat-svn] SF.net SVN: phpfreechat: [915] trunk
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-01-04 19:21:26
|
Revision: 915 http://svn.sourceforge.net/phpfreechat/?rev=915&view=rev Author: kerphi Date: 2007-01-04 11:21:26 -0800 (Thu, 04 Jan 2007) Log Message: ----------- improve the error handling process Modified Paths: -------------- trunk/themes/default/chat.js.tpl.php Added Paths: ----------- trunk/data/public/js/compat.js Added: trunk/data/public/js/compat.js =================================================================== --- trunk/data/public/js/compat.js (rev 0) +++ trunk/data/public/js/compat.js 2007-01-04 19:21:26 UTC (rev 915) @@ -0,0 +1,89 @@ + // Cookie handling + var Cookie = + { + read: function (name) + { + var arrCookies = document.cookie.split ('; '); + for (var i=0; i<arrCookies.length; i++) + { + var arrCookie = arrCookies[i].split ('='); + + if (arrCookie[0] == name) + { + return decodeURIComponent (arrCookie[1]); + } + } + return false; + }, + + write: function (name, value, expires, path) + { + if (expires) + { + var date = new Date (); + date.setTime (date.getTime () + (((((expires * 24) * 60) * 60) * 1000))); + expires = '; expires=' + date.toGMTString (); + } + else expires = ''; + + if (!path) path = '/'; + + document.cookie = name+'='+encodeURIComponent (value)+expires+'; path='+path; + }, + + remove: function (name) + { + this.write (name, '', -1); + } + } + + // Detects if can set a cookie in the browser + function browserSupportsCookies() + { + Cookie.write('cookiesEnabled', 1); + var boolCookiesEnabled = Cookie.read('cookiesEnabled'); + Cookie.remove('cookiesEnabled'); + if (boolCookiesEnabled != 1) + { + return false; + } + return true; + } + + // Detects if the browser supports Ajax + function browserSupportsAjax() + { + if (typeof XMLHttpRequest == "undefined" && typeof ActiveXObject == "undefined" && window.createRequest == "undefined") + { + return false; + } + return true + } + + // Detects if the browser can use ActiveX if necessary + function ActiveXEnabledOrUnnecessary () + { + if (typeof ActiveXObject != "undefined") + { + var xhr = null; + try{ + xhr=new ActiveXObject("Msxml2.XMLHTTP"); + }catch (e){ + try{ + xhr=new ActiveXObject("Microsoft.XMLHTTP"); + }catch (e2){ + try{ + xhr=new ActiveXObject("Msxml2.XMLHTTP.4.0"); + }catch (e3){ + xhr=null; + } + } + } + if (xhr == null) + { + return false + } + } + + return true; + } \ No newline at end of file Modified: trunk/themes/default/chat.js.tpl.php =================================================================== --- trunk/themes/default/chat.js.tpl.php 2007-01-04 17:58:02 UTC (rev 914) +++ trunk/themes/default/chat.js.tpl.php 2007-01-04 19:21:26 UTC (rev 915) @@ -40,8 +40,8 @@ var pfc_nickname_color_list = <?php echo $json->encode($nickname_colorlist); ?>; var pfc_proxy_url = '<?php echo $data_public_url."/".$serverid."/proxy.php"; ?>'; var pfc_theme = <?php echo $json->encode($theme); ?>; +var pfc_isready = false; - var xajaxConfig = { requestURI: "<?php echo $c->server_script_url.(isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "" ? "?".$_SERVER["QUERY_STRING"] : ""); ?>", debug: false, @@ -58,7 +58,7 @@ window.onload = function () { pfc = new pfcClient(); - pfc_loadChat(pfc_theme); + if (pfc_isready) pfc_loadChat(pfc_theme); } <?php if ($debugxajax) { ?> @@ -99,6 +99,7 @@ <script type="text/javascript" src="<?php echo $c->data_public_url; ?>/js/xajax.js"></script> +<script type="text/javascript" src="<?php echo $c->data_public_url; ?>/js/compat.js"></script> <script type="text/javascript" src="<?php echo $c->data_public_url; ?>/js/md5.js"></script> <script type="text/javascript" src="<?php echo $c->data_public_url; ?>/js/cookie.js"></script> <script type="text/javascript" src="<?php echo $c->data_public_url; ?>/js/image_preloader.js"></script> @@ -115,35 +116,43 @@ <div id="pfc_container"> + <div style="width:250px;background-color:#FFF;border:1px solid #000;padding:10px;position:relative;margin:auto"> - <p style="padding:0;margin:0;text-align:center;"> + <p style="padding:0 0 10px 0;margin:0;text-align:center;"> <img src="http://img327.imageshack.us/img327/8071/indicatormediumgb6.gif" alt="" style="float:left;margin:0;"/> Chat loading ...<br style="margin:0"/>Please wait -</p> - <img src="http://img332.imageshack.us/img332/1756/helpiv1.gif" -alt="help" -style="position:absolute;bottom:2px;right:2px;margin:0;padding:0;cursor:help" -onmouseover="document.getElementById('pfc_notloading').style.display='block';" -/> + </p> </div> -<div id="pfc_notloading" style="width:270px;background-color:#FFF;border:1px solid #000;text-align:center;display:none;margin:5px auto 0 auto"> +<div id="pfc_notloading" style="width:270px;background-color:#FFF;color:#000;border:1px solid #000;text-align:center;margin:5px auto 0 auto;font-size:10px;background-image:url('http://img402.imageshack.us/img402/3766/stopcc3.gif');background-repeat:no-repeat;background-position:center center;"> + +<noscript> +<p><?php echo _pfc("JavaScript appears to be either disabled or unsupported by your browser. This web application requires JavaScript to work properly. Please enable JavaScript in your browser settings, or upgrade to a browser with JavaScript support and try again."); ?></p> +</noscript> <p> -<?php echo _pfc("Error: the chat cannot be loaded! two possibilities: your browser doesn't support javascript or you didn't setup correctly the server directories rights - don't hesitate to ask some help on the forum"); ?> <a href="http://www.phpfreechat.net/forum/">www.phpfreechat.net/forum</a> -<a href="http://www.phpfreechat.net"><img src="http://www.phpfreechat.net/pub/logo_80x15.gif" alt="PHP FREE CHAT [powered by phpFreeChat-<?php echo $version ?>]" /></a> +<script type="text/javascript"> +if (!browserSupportsCookies()) + document.write('<?php echo _pfc("Cookies appear to be either disabled or unsupported by your browser. This web application requires Cookies to function properly. Please enable Cookies in your browser settings or upgrade to a browser with Cookie support and try again."); ?>'); +else if (!browserSupportsAjax()) + document.write('<?php echo _pfc("Your browser does not appear to support Ajax technology. This web application requires Ajax to function properly. Please upgrade to a browser with Ajax support and try again."); ?>'); +else if (!ActiveXEnabledOrUnnecessary()) + document.write('<?php echo _pfc("ActiveX appears to be disabled in your browser. This web application requires Ajax technology to function properly. In Internet Explorer versions earlier than 7.0, Ajax is implemented using ActiveX. Please enable ActiveX in your browser security settings or upgrade to a browser with Ajax support and try again."); ?>'); +else +{ + $('pfc_notloading').style.display = 'none'; + pfc_isready = true; +} +</script> </p> + +<a href="http://www.phpfreechat.net" style="text-align:center"><img src="http://www.phpfreechat.net/pub/logo_80x15.gif" alt="PHP FREE CHAT [powered by phpFreeChat-<?php echo $version ?>]" /></a> + </div> </div> - -<?php /* ?> -<p><?php echo _pfc("Error: the chat cannot be loaded! two possibilities: your browser doesn't support javascript or you didn't setup correctly the server directories rights - don't hesitate to ask some help on the forum"); ?> <a href="http://www.phpfreechat.net/forum/">www.phpfreechat.net/forum</a></p> -<a href="http://www.phpfreechat.net"><img src="http://www.phpfreechat.net/pub/logo_80x15.gif" alt="PHP FREE CHAT [powered by phpFreeChat-<?php echo $version ?>]" /></a> -<?php */ ?> - </div> <?php if ($debug) { ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |