[P2-php-svn] [838] expack:

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 2月 25日 (木) 00:41:59 JST


Revision: 838
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=838
Author:   rsk
Date:     2010-02-25 00:41:59 +0900 (Thu, 25 Feb 2010)

Log Message:
-----------
expack:
- lib/sb_print.inc.php でHTMLに直接埋め込んでいたスレ一覧の各種イベントハンドラを
  js/subject.js で動的にバインドするように変更。
- E_NOTICE削減中。

Modified Paths:
--------------
    p2ex/trunk/info.php
    p2ex/trunk/js/subject.js
    p2ex/trunk/lib/sb_print.inc.php
    p2ex/trunk/lib/sb_toolbar.inc.php
    p2ex/trunk/subject.php


-------------- next part --------------
Modified: p2ex/trunk/info.php
===================================================================
--- p2ex/trunk/info.php	2010-02-24 11:03:32 UTC (rev 837)
+++ p2ex/trunk/info.php	2010-02-24 15:41:59 UTC (rev 838)
@@ -319,7 +319,7 @@
     <link rel="stylesheet" type="text/css" href="css.php?css=info&amp;skin={$skin_en}">
     <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">\n
 EOP;
-    if ($_GET['popup'] == 2) {
+    if (isset($_GET['popup']) && $_GET['popup'] == 2) {
         echo <<<EOSCRIPT
     <script type="text/javascript" src="js/closetimer.js?{$_conf['p2_version_id']}"></script>\n
 EOSCRIPT;

Modified: p2ex/trunk/js/subject.js
===================================================================
--- p2ex/trunk/js/subject.js	2010-02-24 11:03:32 UTC (rev 837)
+++ p2ex/trunk/js/subject.js	2010-02-24 15:41:59 UTC (rev 838)
@@ -2,9 +2,18 @@
  * rep2expack - ƒXƒŒˆê———pJavaScript
  */
 
-// {{{ setWinTitle()
+// {{{ GLOBALS
 
-var setWinTitle = function () {
+if (typeof rep2 === 'undefined') {
+	rep2 = {};
+}
+
+rep2.subject = {};
+
+// }}}
+// {{{ rep2.subject.setWindowTitle()
+
+rep2.subject.setWindowTitle = function () {
 	if (sb_vars.shinchaku_ari) {
 		window.top.document.title = 'š' + sb_vars.ptitle;
 	} else {
@@ -15,58 +24,58 @@
 };
 
 // }}}
-// {{{ chNewAllColor()
+// {{{ rep2.subject.changeNewAllColor()
 
-var chNewAllColor = function () {
+rep2.subject.changeNewAllColor = function () {
 	$('#smynum1, #smynum2, a.un_a').css('color', sb_vars.ttcolor);
 };
 
 // }}}
-// {{{ chUnColor()
+// {{{ rep2.subject.changeUnReadColor()
 
-var chUnColor = function (idnum) {
+rep2.subject.changeUnReadColor = function (idnum) {
 	$('#un' + idnum).css('color', sb_vars.ttcolor);
 }
 
 // }}}
-// {{{ chTtColor()
+// {{{ rep2.subject.changeThreadTitleColor()
 
-var chTtColor = function (idnum) {
+rep2.subject.changeThreadTitleColor = function (idnum) {
 	$('#tt' + idnum + ', #to' + idnum).css('color', sb_vars.ttcolor_v);
 };
 
 // }}}
-// {{{ wrapDeleLog()
+// {{{ rep2.subject.deleteLog()
 
-var wrapDeleLog = function (qeury, from) {
+rep2.subject.deleteLog = function (qeury, from) {
 	return deleLog(qeury, sb_vars.pop_size[0], sb_vars.pop_size[1], 'subject', from);
 };
 
 // }}}
-// {{{ wrapSetFavJs()
+// {{{ rep2.subject.setFavorite()
 
-var wrapSetFavJs = function (query, favdo, from) {
+rep2.subject.setFavorite = function (query, favdo, from) {
 	return setFavJs(query, favdo, sb_vars.pop_size[0], sb_vars.pop_size[1], 'subject', from);
 };
 
 // }}}
-// {{{ wrapOpenSubWin()
+// {{{ rep2.subject.openSubWindow()
 
-var wrapOpenSubWin = function (url) {
+rep2.subject.openSubWindow = function (url) {
 	return OpenSubWin(url + '&popup=1', sb_vars.pop_size[0], sb_vars.pop_size[1], 0, 0);
 };
 
 // }}}
-// {{{ wrapShowMotoLsPopUp()
+// {{{ rep2.subject.showMotoLsPopUp()
 
-var wrapShowMotoLsPopUp = function (event, element) {
+rep2.subject.showMotoLsPopUp = function (event, element) {
 	showMotoLsPopUp(event, element, element.nextSibling.innerText)
 };
 
 // }}}
-// {{{ resizeTitleCell()
+// {{{ rep2.subject.resizeTitleCell()
 
-var resizeTitleCell = function () {
+rep2.subject.resizeTitleCell = function () {
 	var w = $(window).width(), d = 0;
 	$.each($('table.threadlist tr').first().find('th'), function(){
 		var self = $(this);
@@ -80,9 +89,9 @@
 };
 
 // }}}
-// {{{ checkAll()
+// {{{ rep2.subject.checkAll()
 
-var checkAll = function () {
+rep2.subject.checkAll = function () {
 	var checboxes = $('.threadlist input:checkbox[name!=allbox]');
 	if ($('#allbox').attr('checked')) {
 		checboxes.attr('checked', 'checked');
@@ -92,9 +101,9 @@
 };
 
 // }}}
-// {{{ offrec_ajax()
+// {{{ rep2.subject.offRecent()
 
-var offrec_ajax = function (anchor) {
+rep2.subject.offRecent = function (anchor) {
 	var url = anchor.href.replace('info.php?', 'httpcmd.php?cmd=offrec&');
 	$.get(url, null, function(text, status){
 		if (status == 'error') {
@@ -113,14 +122,65 @@
 // {{{ $(document).ready()
 
 $(document).ready(function(){
-	setWinTitle();
-	resizeTitleCell();
+	rep2.subject.setWindowTitle();
+	rep2.subject.resizeTitleCell();
+
+	// Å‹ß“Ç‚ñ‚¾ƒXƒŒ‰ðœ
+	$('.threadlist td.tc a[href$="&offrec=true"]').click(function(){
+		return rep2.subject.offRecent(this);
+	});
+
+	// î•ñƒEƒCƒ“ƒhƒE•\Ž¦
+	$('.threadlist td.to a.info').click(function(){
+		return rep2.subject.openSubWindow(this.href.toString());
+	});
+
+	// URL‚©‚çhost-bbs-key‚𒊏o‚·‚鐳‹K•\Œ»
+	var re = /[\?&](host=.+?&bbs=.+?&key=.+?)(&|$)/;
+
+	// ƒƒO‚ðíœ
+	$('.threadlist td.tu').find('a.un, a.un_a, a.un_n').attr('title', 'ƒNƒŠƒbƒN‚·‚é‚ƃƒOíœ');
+	$('.threadlist td.tu a.un_n').click(function(){
+		if (!window.confirm('ƒƒO‚ðíœ‚µ‚Ü‚·‚©H')) {
+			return false;
+		}
+		return rep2.subject.deleteLog(re.exec($(this).attr('href'))[1], this);
+	});
+	$('.threadlist td.tu').find('a.un, a.un_a').click(function(){
+		return rep2.subject.deleteLog(re.exec($(this).attr('href'))[1], this);
+	});
+
+	// ”͈͂ðŽw’肵‚ÄŒ³ƒXƒŒ‚ðŠJ‚­¬ƒ|ƒbƒvƒAƒbƒvƒƒjƒ…[
+	var hover = function (event) {
+		rep2.subject.showMotoLsPopUp(event, this);
+	};
+
+	// ƒXƒŒƒbƒhƒ^ƒCƒgƒ‹‚Ì•¶ŽšF‚ð•ÏX
+	var generator = function (id, midoku_ari) {
+		if (midoku_ari) {
+			return (function(){
+				rep2.subject.changeThreadTitleColor(id);
+				rep2.subject.changeUnReadColor(id);
+			});
+		} else {
+			return (function(){
+				rep2.subject.changeThreadTitleColor(id);
+			});
+		}
+	};
+
+	// Œ³ƒXƒŒ‚ƃXƒŒƒbƒhƒ^ƒCƒgƒ‹
 	$('.threadlist td.tl a').map(function(){
 		var self = $(this);
-		if (!self.hasClass('moto_thre')) {
+		if (self.hasClass('moto_thre')) {
+			self.hover(hover, hideMotoLsPopUp);
+		} else {
 			self.attr('title', self.text());
+			self.click(generator(self.attr('id').substring(2), self.hasClass('midoku_ari')));
 		}
 	})
+
+	// IE‘΍ô
 	if ($.browser.msie) {
 		$('.threadlist td').contents('[nodeType=3]').wrap('<span class="nowrap"></span>');
 	}
@@ -129,7 +189,7 @@
 // }}}
 // {{{ $(window).resize
 
-$(window).resize(resizeTitleCell);
+$(window).resize(rep2.subject.resizeTitleCell);
 
 // }}}
 

Modified: p2ex/trunk/lib/sb_print.inc.php
===================================================================
--- p2ex/trunk/lib/sb_print.inc.php	2010-02-24 11:03:32 UTC (rev 837)
+++ p2ex/trunk/lib/sb_print.inc.php	2010-02-24 15:41:59 UTC (rev 838)
@@ -147,7 +147,7 @@
     // ƒ`ƒFƒbƒNƒ{ƒbƒNƒX
     if ($checkbox_bool) {
         echo <<<EOP
-<th{$class_tc}><input id="allbox" name="allbox" type="checkbox" onclick="checkAll();" title="‚·‚ׂĂ̍€–Ú‚ð‘I‘ðA‚Ü‚½‚Í‘I‘ð‰ðœ"></th>\n
+<th{$class_tc}><input id="allbox" name="allbox" type="checkbox" onclick="rep2.subject.checkAll();" title="‚·‚ׂĂ̍€–Ú‚ð‘I‘ðA‚Ü‚½‚Í‘I‘ð‰ðœ"></th>\n
 EOP;
     }
     // No.
@@ -229,7 +229,7 @@
             $row_class .= ' r_read'; // read‚͉ߋŽ•ªŽŒ
 
             // $ttitle_en_q ‚͐ߌ¸È—ª
-            $delelog_js = "return wrapDeleLog('{$host_bbs_key_q}',this);";
+            $delelog_js = "return rep2.subject.deleLog('{$host_bbs_key_q}',this);";
             $title_at = ' title="ƒNƒŠƒbƒN‚·‚é‚ƃƒOíœ"';
 
             $anum_ht = sprintf('#r%d', min($aThread->rescount, $aThread->rescount - $aThread->nunum + 1 - $_conf['respointer']));
@@ -239,7 +239,7 @@
                 $row_class .= ' r_offline';
                 // JavaScript‚Å‚ÌŠm”Fƒ_ƒCƒAƒƒO‚ ‚è
                 $unum_ht_c = <<<EOP
-<a class="un_n" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true" target="_self" onclick="if (!window.confirm('ƒƒO‚ðíœ‚µ‚Ü‚·‚©H')) {return false;} {$delelog_js}"{$title_at}>-</a>
+<a class="un_n" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true">-</a>
 EOP;
 
             // V’…‚ ‚è
@@ -247,13 +247,13 @@
                 $row_class .= ' r_new';
                 $midoku_ari = true;
                 $unum_ht_c = <<<EOP
-<a id="un{$i}" class="un_a" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true" target="_self" onclick="{$delelog_js}"{$title_at}>{$aThread->unum}</a>
+<a id="un{$i}" class="un_a" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true">{$aThread->unum}</a>
 EOP;
 
             // subject.txt‚É‚Í‚ ‚邪AV’…‚È‚µ
             } else {
                 $unum_ht_c = <<<EOP
-<a class="un" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true" target="_self" onclick="{$delelog_js}"{$title_at}>{$aThread->unum}</a>
+<a class="un" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true">{$aThread->unum}</a>
 EOP;
             }
         }
@@ -283,7 +283,7 @@
 
                 // $ttitle_en_q ‚à•t‚¯‚½•û‚ª‚¢‚¢‚ªAß–ñ‚Ì‚½‚ߏȗª‚·‚é
                 $td['fav'] = <<<EOP
-<td{$class_t}><a class="fav" href="info.php?{$host_bbs_key_q}{$favdo_q}" target="info" onclick="return wrapSetFavJs('{$host_bbs_key_q}','{$favdo}',this);" title="{$favtitle}">{$favmark}</a></td>\n
+<td{$class_t}><a class="fav" href="info.php?{$host_bbs_key_q}{$favdo_q}" target="info" onclick="return rep2.subject.setFav('{$host_bbs_key_q}','{$favdo}',this);" title="{$favtitle}">{$favmark}</a></td>\n
 EOP;
             }
         }
@@ -296,7 +296,7 @@
             $torder_st = $aThread->torder;
         }
         $torder_ht = <<<EOP
-<a id="to{$i}" class="info" href="info.php?{$host_bbs_key_q}" target="_self" onclick="return wrapOpenSubWin(this.href.toString())">{$torder_st}</a>
+<a id="to{$i}" class="info" href="info.php?{$host_bbs_key_q}">{$torder_st}</a>
 EOP;
 
         // title =================================================
@@ -330,19 +330,20 @@
             if (!$aThread->isKitoku()) {
                 $moto_thre_ht = '<a class="thre_title moto_thre" href="'
                               . htmlspecialchars($aThread->getMotoThread(false, ''), ENT_QUOTES)
-                              . '"'
-                              . ' onmouseover="wrapShowMotoLsPopUp(event,this)"'
-                              . ' onmouseout="hideMotoLsPopUp()">E</a>';
+                              . '">E</a>';
             }
         }
 
         // V‹KƒXƒŒ
         if ($aThread->new) {
             $row_class .= ' r_brand_new';
-            $classtitle_q = ' class="thre_title_new"';
+            $title_class = 'thre_title_new';
         } else {
-            $classtitle_q = ' class="thre_title"';
+            $title_class = 'thre_title';
         }
+        if ($midoku_ari) {
+            $title_class .= ' midoku_ari';
+        }
 
         // ƒXƒŒƒŠƒ“ƒN
         if ($word_q) {
@@ -352,9 +353,6 @@
         }
         $thre_url = "{$_conf['read_php']}?{$host_bbs_key_q}{$rescount_q}{$offline_q}{$word_q}{$anum_ht}";
 
-        $chUnColor_js = ($midoku_ari) ? "chUnColor('{$i}');" : '';
-        $change_color = " onclick=\"chTtColor('{$i}');{$chUnColor_js}\"";
-
         // ƒIƒ“ƒŠ[>>1
         if ($only_one_bool) {
             $td['one'] = <<<EOP
@@ -400,7 +398,7 @@
         // Å‹ß“Ç‚ñ‚¾ƒXƒŒ‚̉ðœ
         if ($aThreadList->spmode == 'recent') {
             $td['offrec'] = <<<EOP
-<td{$class_tc}><a href="info.php?{$host_bbs_key_q}&amp;offrec=true" target="_self" onclick="return offrec_ajax(this);">~</a></td>\n
+<td{$class_tc}><a href="info.php?{$host_bbs_key_q}&amp;offrec=true">~</a></td>\n
 EOP;
         }
 
@@ -435,7 +433,7 @@
         echo <<<EOR
 <tr class="{$row_class}">
 {$td['edit']}{$td['offrec']}{$td['unum']}{$td['rescount']}{$td['one']}{$td['checkbox']}<td{$class_to}>{$torder_ht}</td>
-<td{$class_tl}><div class="el">{$moto_thre_ht}<a id="tt{$i}" href="{$thre_url}"{$classtitle_q}{$change_color}>{$ttitle_ht}</a></div></td>
+<td{$class_tl}><div class="el">{$moto_thre_ht}<a id="tt{$i}" href="{$thre_url}" class="{$title_class}">{$ttitle_ht}</a></div></td>
 {$td['ita']}{$td['spd']}{$td['ikioi']}{$td['birth']}{$td['fav']}</tr>\n
 EOR;
 

Modified: p2ex/trunk/lib/sb_toolbar.inc.php
===================================================================
--- p2ex/trunk/lib/sb_toolbar.inc.php	2010-02-24 11:03:32 UTC (rev 837)
+++ p2ex/trunk/lib/sb_toolbar.inc.php	2010-02-24 15:41:59 UTC (rev 838)
@@ -25,7 +25,7 @@
         $shinchaku_num_ht = '';
     }
     $shinchaku_matome_ht =<<<EOP
-<a id="smy{$new_matome_i}" class="matome" href="{$_conf['read_new_php']}?host={$aThreadList->host}&amp;bbs={$aThreadList->bbs}&amp;spmode={$aThreadList->spmode}{$norefresh_q}&amp;nt={$newtime}" onclick="chNewAllColor();">V’…‚Ü‚Æ‚ß“Ç‚Ý{$shinchaku_num_ht}</a>
+<a id="smy{$new_matome_i}" class="matome" href="{$_conf['read_new_php']}?host={$aThreadList->host}&amp;bbs={$aThreadList->bbs}&amp;spmode={$aThreadList->spmode}{$norefresh_q}&amp;nt={$newtime}" onclick="rep2.subject.changeNewAllColor();">V’…‚Ü‚Æ‚ß“Ç‚Ý{$shinchaku_num_ht}</a>
 EOP;
 } else {
     $shinchaku_matome_ht = '';

Modified: p2ex/trunk/subject.php
===================================================================
--- p2ex/trunk/subject.php	2010-02-24 11:03:32 UTC (rev 837)
+++ p2ex/trunk/subject.php	2010-02-24 15:41:59 UTC (rev 838)
@@ -196,7 +196,7 @@
 if (!empty($_GET['dele']) || (isset($_POST['submit']) && $_POST['submit'] == $deletelog_st)) {
     if ($host && $bbs) {
         require_once P2_LIB_DIR . '/dele.inc.php';
-        if ($_POST['checkedkeys']) {
+        if (isset($_POST['checkedkeys'])) {
             $dele_keys = $_POST['checkedkeys'];
         } else {
             $dele_keys = array($_GET['key']);



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