[P2-php-svn] [819] スレの削除リンクのJavaScript動作を非同期に変更した。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 27日 (水) 20:20:41 JST


Revision: 819
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=819
Author:   akid
Date:     2010-01-27 20:20:41 +0900 (Wed, 27 Jan 2010)

Log Message:
-----------
スレの削除リンクのJavaScript動作を非同期に変更した。

Modified Paths:
--------------
    p2/trunk/js/basic.js
    p2/trunk/js/delelog.js
    p2/trunk/lib/read_header.inc.php
    p2/trunk/lib/sb_header.inc.php
    p2/trunk/lib/sb_print.inc.php
    p2/trunk/read_new.php
    p2/trunk/read_new_i.php


-------------- next part --------------
Modified: p2/trunk/js/basic.js
===================================================================
--- p2/trunk/js/basic.js	2010-01-27 08:56:29 UTC (rev 818)
+++ p2/trunk/js/basic.js	2010-01-27 11:20:41 UTC (rev 819)
@@ -62,23 +62,39 @@
 	return xmlHttpObj;
 }
 
-// xmlHttpObj ‚Æurl‚ð“n‚µ‚āAŒ‹‰ÊƒeƒLƒXƒg‚ðŽæ“¾‚·‚éB“¯ŠúB
-// @param nc string|false Žw’è‚·‚é‚Æ‚±‚ê‚ðƒL[‚Æ‚µ‚½ƒLƒƒƒbƒVƒ…‰ñ”ð‚Ì‚½‚߂̃_ƒ~[ƒNƒGƒŠ[‚ª’ljÁ‚³‚ê‚é
-function getResponseTextHttp(xmlHttpObj, url, nc)
+// xmlHttpObj ‚Æurl‚ð“n‚µ‚āAŒ‹‰ÊƒeƒLƒXƒg‚ðŽæ“¾‚·‚éB
+// @param nc string|false|void Žw’è‚·‚é‚Æ‚±‚ê‚ðƒL[‚Æ‚µ‚½ƒLƒƒƒbƒVƒ…‰ñ”ð‚Ì‚½‚߂̃_ƒ~[ƒNƒGƒŠ[‚ª’ljÁ‚³‚ê‚é
+function getResponseTextHttp(xmlHttpObj, url, nc, async, func)
 {
 	if (nc) {
 		var now = new Date();
 		url = url + '&' + nc + '=' + now.getTime(); // ƒLƒƒƒbƒVƒ…‰ñ”ð—p
 	}
-	xmlHttpObj.open('GET', url, false);
+	xmlHttpObj.open('GET', url, async);
 	xmlHttpObj.send(null);
 	
-	if (xmlHttpObj.readyState == 4) {
-		if (xmlHttpObj.status == 200) {
-			return xmlHttpObj.responseText.replace(/^<\?xml .+?\?>\n?/, '');
-		} else {
-			// rt = '<em>HTTP Error:<br />' + req.status + ' ' + req.statusText + '</em>';
+	if (async) {
+		if (func) {
+			if (isSafari()) {
+				xmlHttpObj.onload = function(){ func(xmlHttpObj); }
+			} else {
+				xmlHttpObj.onreadystatechange = function() {
+					if (xmlHttpObj.readyState == 4 && xmlHttpObj.status == 200) {
+						func(xmlHttpObj);
+					}
+				}
+			}
+			return;
 		}
+		return;
+	} else {
+		if (xmlHttpObj.readyState == 4) {
+			if (xmlHttpObj.status == 200) {
+				return xmlHttpObj.responseText.replace(/^<\?xml .+?\?>\n?/, '');
+			} else {
+				// rt = '<em>HTTP Error:<br />' + req.status + ' ' + req.statusText + '</em>';
+			}
+		}
 	}
 	return false;
 }

Modified: p2/trunk/js/delelog.js
===================================================================
--- p2/trunk/js/delelog.js	2010-01-27 08:56:29 UTC (rev 818)
+++ p2/trunk/js/delelog.js	2010-01-27 11:20:41 UTC (rev 819)
@@ -7,44 +7,41 @@
 	// read.php‚ł́Aƒy[ƒW‚̓ǂݍž‚Ý‚ªŠ®—¹‚µ‚Ä‚¢‚È‚¯‚ê‚΁A‚È‚É‚à‚µ‚È‚¢
 	// iread.php ‚͓ǂݍž‚ÝŠ®—¹Žž‚Éidx‹L˜^‚ª¶¬‚³‚ê‚邽‚߁j
 	if ((page == 'read') && !gIsPageLoaded) {
-		return false;
+		return true;
 	}
-	
+
 	var xmlHttpObj = getXmlHttp();
-	
+
 	if (!xmlHttpObj) {
 		// alert("Error: XMLHTTP ’ʐMƒIƒuƒWƒFƒNƒg‚̍쐬‚ÉŽ¸”s‚µ‚Ü‚µ‚½B") ;
 		// XMLHTTPi‚Æ obj.parentNode.innerHTMLj ‚É–¢‘Ήž‚Ȃ珬‘‹‚Å
 		infourl = 'info.php?' + tquery + '&popup=2&dele=true';
-		return !openSubWin(infourl,info_pop_width,info_pop_height,0,0);
+		return openSubWin(infourl,info_pop_width,info_pop_height,0,0);
 	}
 
 	var url = 'httpcmd.php?' + tquery + '&cmd=delelog'; // ƒXƒNƒŠƒvƒg‚ƁAƒRƒ}ƒ“ƒhŽw’è
 	
-	var res = getResponseTextHttp(xmlHttpObj, url, 'nc');
-	var rmsg = "";
-	if (res) {
+	var func = function(xobj){
+		var rmsg = '';
+		var res = xmlHttpObj.responseText.replace(/^<\?xml .+?\?>\n?/, '');;
 		if (res == '1') {
-			if (page == 'subject') {
-				rmsg = 'í';
-			} else {
-				rmsg = 'Š®—¹';
-			}
+			rmsg = (page == 'subject') ? 'í' : 'Š®—¹';
 		} else if (res == '2') {
-			if (page == 'subject') {
-				rmsg = '–³';
-			} else {
-				rmsg = 'Š®—¹';
-			}
+			rmsg = (page == 'subject') ? '–³' : 'Š®—¹';
 		}
 		if (rmsg) {
+			// Gray() ‚Í IE ActiveX—p
 			if (page == 'read_new') {
-				obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.filter = 'Gray()'; // IE ActiveX—p
+				obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.filter = 'Gray()';
 			} else if (page == 'read') {
-				document.body.style.filter = 'Gray()'; // IE ActiveX—p
+				document.body.style.filter = 'Gray()';
 			}
 			obj.parentNode.innerHTML = rmsg;
 		}
-	}
-	return false;
+	};
+
+	obj.style.color = 'gray';
+	getResponseTextHttp(xmlHttpObj, url, 'nc', true, func);
+
+	return true;
 }

Modified: p2/trunk/lib/read_header.inc.php
===================================================================
--- p2/trunk/lib/read_header.inc.php	2010-01-27 08:56:29 UTC (rev 818)
+++ p2/trunk/lib/read_header.inc.php	2010-01-27 11:20:41 UTC (rev 819)
@@ -225,7 +225,7 @@
             $_conf['pc_accesskey']['dele']
         ),
         'target'    => 'info',
-        'onclick'   => "return deleLog('{$deleLogJs_query_es}', {$STYLE['info_pop_size']}, 'read', this);"
+        'onclick'   => "return !deleLog('{$deleLogJs_query_es}', {$STYLE['info_pop_size']}, 'read', this);"
     )
 );
 
@@ -294,11 +294,11 @@
 ?>
 	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
 
-	<script type="text/javascript" src="js/basic.js?v=20090502"></script>
+	<script type="text/javascript" src="js/basic.js?v=20100127"></script>
 	<script type="text/javascript" src="js/respopup.js?v=20061206"></script>
 	<script type="text/javascript" src="js/htmlpopup.js?v=20061206"></script>
 	<script type="text/javascript" src="js/setfavjs.js?v=20090428"></script>
-	<script type="text/javascript" src="js/delelog.js?v=20061206"></script>
+	<script type="text/javascript" src="js/delelog.js?v=20100127"></script>
 	<script type="text/javascript" src="js/showhide.js?v=20090416"></script>
 <?php
 if (!UA::isIPhoneGroup()) {

Modified: p2/trunk/lib/sb_header.inc.php
===================================================================
--- p2/trunk/lib/sb_header.inc.php	2010-01-27 08:56:29 UTC (rev 818)
+++ p2/trunk/lib/sb_header.inc.php	2010-01-27 11:20:41 UTC (rev 819)
@@ -175,9 +175,9 @@
     ?>
 	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
 	
-	<script type="text/javascript" src="js/basic.js?v=20090429"></script>
+	<script type="text/javascript" src="js/basic.js?v=20100127"></script>
 	<script type="text/javascript" src="js/setfavjs.js?v=20090428"></script>
-	<script type="text/javascript" src="js/delelog.js?v=20061206"></script>
+	<script type="text/javascript" src="js/delelog.js?v=20100127"></script>
 	<script language="JavaScript">
 	<!--
 	function setWinTitle(){

Modified: p2/trunk/lib/sb_print.inc.php
===================================================================
--- p2/trunk/lib/sb_print.inc.php	2010-01-27 08:56:29 UTC (rev 818)
+++ p2/trunk/lib/sb_print.inc.php	2010-01-27 11:20:41 UTC (rev 819)
@@ -197,7 +197,7 @@
         if ($aThread->isKitoku()) {
             
             // $ttitle_en_q ‚͐ߌ¸È—ª
-            $onclick_at = " onClick=\"return deleLog('host={$aThread->host}{$bbs_q}{$key_q}{$sid_q}', {$STYLE['info_pop_size']}, 'subject', this);\"";
+            $onclick_at = " onClick=\"return !deleLog('host={$aThread->host}{$bbs_q}{$key_q}{$sid_q}', {$STYLE['info_pop_size']}, 'subject', this);\"";
             $title_at = ' title="ƒNƒŠƒbƒN‚·‚é‚ƃƒOíœ"';
             
             $unum_ht_c = "<a class=\"un\" href=\"{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}{$spmode_q}&amp;dele=1\" target=\"_self\"{$onclick_at}{$title_at}>{$aThread->unum}</a>";
@@ -235,7 +235,7 @@
                     array(
                         'id' => "un{$i}", 'class' => 'un_a', 'target' => '_self', 'title' => 'ƒNƒŠƒbƒN‚·‚é‚ƃƒOíœ',
                         'onClick' => sprintf(
-                            "return deleLog('%s', %s, 'subject', this);",
+                            "return !deleLog('%s', %s, 'subject', this);",
                             str_replace("'", "\\'", $dele_log_q), $STYLE['info_pop_size']
                         )
                     )
@@ -247,7 +247,7 @@
             // subject.txt‚É‚È‚¢Žž
             if (!$aThread->isonline) {
                 // JavaScript‚Å‚ÌŠm”Fƒ_ƒCƒAƒƒO‚ ‚è
-                $unum_ht_c = "<a class=\"un_n\" href=\"{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}{$spmode_q}&amp;dele=true\" target=\"_self\" onClick=\"if (!window.confirm('ƒƒO‚ðíœ‚µ‚Ü‚·‚©H')) {return false;} return deleLog('host={$aThread->host}{$bbs_q}{$key_q}{$sid_q}', {$STYLE['info_pop_size']}, 'subject', this)\"{$title_at}>-</a>";
+                $unum_ht_c = "<a class=\"un_n\" href=\"{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}{$spmode_q}&amp;dele=true\" target=\"_self\" onClick=\"if (!window.confirm('ƒƒO‚ðíœ‚µ‚Ü‚·‚©H')) {return false;} return !deleLog('host={$aThread->host}{$bbs_q}{$key_q}{$sid_q}', {$STYLE['info_pop_size']}, 'subject', this)\"{$title_at}>-</a>";
             }
 
         }

Modified: p2/trunk/read_new.php
===================================================================
--- p2/trunk/read_new.php	2010-01-27 08:56:29 UTC (rev 818)
+++ p2/trunk/read_new.php	2010-01-27 11:20:41 UTC (rev 819)
@@ -123,11 +123,11 @@
 P2View::printIncludeCssHtml('style');
 P2View::printIncludeCssHtml('read');
 ?>
-	<script type="text/javascript" src="js/basic.js?v=20090429"></script>
+	<script type="text/javascript" src="js/basic.js?v=20100127"></script>
 	<script type="text/javascript" src="js/respopup.js?v=20061206"></script>
 	<script type="text/javascript" src="js/htmlpopup.js?v=20061206"></script>
 	<script type="text/javascript" src="js/setfavjs.js?v=20090428"></script>
-	<script type="text/javascript" src="js/delelog.js?v=20061206"></script>
+	<script type="text/javascript" src="js/delelog.js?v=20100127"></script>
 	<script type="text/javascript" src="js/showhide.js?v=20090416"></script>
 	
 	<script type="text/javascript" src="./js/yui-ext/yui.js"></script>
@@ -506,7 +506,7 @@
 
 		<span class="setfav" style="white-space: nowrap;"><a href="{$info_url_hs}{$setfav_q}{$sid_q}" target="info" onClick="return setFavJs('{$js_q_hs}', '{$favvalue}', {$STYLE['info_pop_size']}, 'read_new', this);" title="{$favtitle}">‚¨‹C‚É{$favmark}</a></span>
 
-		<span style="white-space: nowrap;"><a href="{$info_url_hs}&amp;dele=1" target="info" onClick="return deleLog('{$js_q_hs}', {$STYLE['info_pop_size']}, 'read_new',  this);" title="ƒƒO‚ðíœ‚·‚éBŽ©“®‚Łu‚¨‹C‚ɃXƒŒvu“a“°v‚©‚ç‚àŠO‚ê‚Ü‚·B">{$dele_st}</a></span>
+		<span style="white-space: nowrap;"><a href="{$info_url_hs}&amp;dele=1" target="info" onClick="return !deleLog('{$js_q_hs}', {$STYLE['info_pop_size']}, 'read_new',  this);" title="ƒƒO‚ðíœ‚·‚éBŽ©“®‚Łu‚¨‹C‚ɃXƒŒvu“a“°v‚©‚ç‚àŠO‚ê‚Ü‚·B">{$dele_st}</a></span>
 
 <!--		<a style="white-space: nowrap;" href="{$info_url_hs}&amp;taborn=2" target="info" onClick="return !openSubWin('{$info_url_hs}&amp;popup=2&amp;taborn=2{$sid_q}',{$STYLE['info_pop_size']},0,0)" title="ƒXƒŒƒbƒh‚Ì‚ ‚ځ[‚ñó‘Ô‚ðƒgƒOƒ‹‚·‚é">‚ ‚Ú‚ñ</a> -->
 

Modified: p2/trunk/read_new_i.php
===================================================================
--- p2/trunk/read_new_i.php	2010-01-27 08:56:29 UTC (rev 818)
+++ p2/trunk/read_new_i.php	2010-01-27 11:20:41 UTC (rev 819)
@@ -148,10 +148,10 @@
 EOHEADER;
 
 /*
-    <script type="text/javascript" src="js/basic.js?v=20090429"></script>
+    <script type="text/javascript" src="js/basic.js?v=20100127"></script>
     <script type="text/javascript" src="js/respopup.js?v=20061206"></script>
     <script type="text/javascript" src="js/setfavjs.js?v=20090428"></script>
-    <script type="text/javascript" src="js/delelog.js?v=20061206"></script>
+    <script type="text/javascript" src="js/delelog.js?v=20100127"></script>
 */
 
 $onload_script = '';



P2-php-svn メーリングリストの案内
Back to archive index