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

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 2月 25日 (木) 20:25:22 JST


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

Log Message:
-----------
expack:
- JavaScriptを一部リファクタリング。

Modified Paths:
--------------
    p2ex/trunk/iv2.php
    p2ex/trunk/js/basic.js
    p2ex/trunk/js/subject.js
    p2ex/trunk/lib/sb_header.inc.php


-------------- next part --------------
Modified: p2ex/trunk/iv2.php
===================================================================
--- p2ex/trunk/iv2.php	2010-02-24 15:41:59 UTC (rev 838)
+++ p2ex/trunk/iv2.php	2010-02-25 11:25:22 UTC (rev 839)
@@ -726,7 +726,7 @@
             // 32400 = 9*60*60 (Žž·•â³)
             $time2date = sprintf('floor((%s + 32400) / 86400)', $db->quoteIdentifier('time'));
         }
-        $orderBy .= sprintf('%s %s, %s ', $time2date, $sort, $db->quoteIdentifier('uri'));
+        $orderBy = sprintf('%s %s, %s ', $time2date, $sort, $db->quoteIdentifier('uri'));
         if ($order == 'date_uri') {
             $orderBy .= $sort;
         } else {

Modified: p2ex/trunk/js/basic.js
===================================================================
--- p2ex/trunk/js/basic.js	2010-02-24 15:41:59 UTC (rev 838)
+++ p2ex/trunk/js/basic.js	2010-02-25 11:25:22 UTC (rev 839)
@@ -1,8 +1,9 @@
-/* p2 - Šî–{JavaScriptƒtƒ@ƒCƒ‹ */
+/* rep2 - Šî–{JavaScriptƒtƒ@ƒCƒ‹ */
 
+var rep2 = { 'util': {}, 'info': {}, 'menu': {}, 'read': {}, 'subject': {} };
+
 // ƒTƒuƒEƒBƒ“ƒhƒE‚ðƒ|ƒbƒvƒAƒbƒv‚·‚é
-function OpenSubWin(inUrl, inWidth, inHeight, boolS, boolR, boolW)
-{
+rep2.util.openSubWindow = function (inUrl, inWidth, inHeight, boolS, boolR, boolW) {
 	var proparty3rd = "width=" + inWidth + ",height=" + inHeight + ",scrollbars=" + boolS + ",resizable=1";
 	SubWin = window.open(inUrl,"",proparty3rd);
 	if (boolR == 1) {
@@ -13,11 +14,12 @@
 		return SubWin;
 	}
 	return false;
-}
+};
 
+var OpenSubWin = rep2.util.openSubWindow;
+
 // HTMLƒhƒLƒ…ƒƒ“ƒg‚̃^ƒCƒgƒ‹‚ðƒZƒbƒg‚·‚é
-function setWinTitle()
-{
+rep2.util.setWindowTitle = function () {
 	if (top != self) {
 		try {
 			top.document.title = self.document.title;
@@ -25,21 +27,12 @@
 			// ‰½‚à‚µ‚È‚¢
 		}
 	}
-}
+};
 
+var setWinTitle = rep2.util.setWindowTitle;
+
 // DOMƒIƒuƒWƒFƒNƒg‚ðŽæ“¾
-function p2GetElementById(id)
-{
-	if (document.getElementById) {
-		return (document.getElementById(id));
-	} else if (document.all) {
-		return (document.all[id]);
-	} else if (document.layers) {
-		return (document.layers[id]);
-	} else {
-		return false;
-	}
-}
+var p2GetElementById = document.getElementById;
 
 // XMLHttpRequest ƒIƒuƒWƒFƒNƒg‚ðŽæ“¾
 function getXmlHttp()
@@ -68,8 +61,7 @@
 function getResponseTextHttp(objHTTP, url, nc)
 {
 	if (nc) {
-		var now = new Date();
-		url = url + '&' + nc + '=' + now.getTime(); // ƒLƒƒƒbƒVƒ…‰ñ”ð—p
+		url = url + '&' + nc + '=' + (new Date()).getTime(); // ƒLƒƒƒbƒVƒ…‰ñ”ð—p
 	}
 	objHTTP.open('GET', url, false);
 	objHTTP.send(null);

Modified: p2ex/trunk/js/subject.js
===================================================================
--- p2ex/trunk/js/subject.js	2010-02-24 15:41:59 UTC (rev 838)
+++ p2ex/trunk/js/subject.js	2010-02-25 11:25:22 UTC (rev 839)
@@ -2,20 +2,11 @@
  * rep2expack - ƒXƒŒˆê———pJavaScript
  */
 
-// {{{ GLOBALS
-
-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;
+	if (rep2.subject.properties.shinchaku_ari) {
+		window.top.document.title = 'š' + rep2.subject.properties.page_title;
 	} else {
 		if (window.top != window.self) {
 			window.top.document.title = window.self.document.title;
@@ -27,42 +18,48 @@
 // {{{ rep2.subject.changeNewAllColor()
 
 rep2.subject.changeNewAllColor = function () {
-	$('#smynum1, #smynum2, a.un_a').css('color', sb_vars.ttcolor);
+	$('#smynum1, #smynum2, a.un_a').css('color', rep2.subject.properties.ttcolor);
 };
 
 // }}}
 // {{{ rep2.subject.changeUnReadColor()
 
 rep2.subject.changeUnReadColor = function (idnum) {
-	$('#un' + idnum).css('color', sb_vars.ttcolor);
+	$('#un' + idnum).css('color', rep2.subject.properties.ttcolor);
 }
 
 // }}}
 // {{{ rep2.subject.changeThreadTitleColor()
 
 rep2.subject.changeThreadTitleColor = function (idnum) {
-	$('#tt' + idnum + ', #to' + idnum).css('color', sb_vars.ttcolor_v);
+	$('#tt' + idnum + ', #to' + idnum).css('color', rep2.subject.properties.ttcolor_v);
 };
 
 // }}}
 // {{{ rep2.subject.deleteLog()
 
 rep2.subject.deleteLog = function (qeury, from) {
-	return deleLog(qeury, sb_vars.pop_size[0], sb_vars.pop_size[1], 'subject', from);
+	var width = rep2.subject.properties.pop_size[0];
+	var height = rep2.subject.properties.pop_size[1];
+	return deleLog(qeury, width, height, 'subject', from);
 };
 
 // }}}
 // {{{ rep2.subject.setFavorite()
 
 rep2.subject.setFavorite = function (query, favdo, from) {
-	return setFavJs(query, favdo, sb_vars.pop_size[0], sb_vars.pop_size[1], 'subject', from);
+	var width = rep2.subject.properties.pop_size[0];
+	var height = rep2.subject.properties.pop_size[1];
+	return setFavJs(query, favdo, width, height, 'subject', from);
 };
 
 // }}}
 // {{{ rep2.subject.openSubWindow()
 
 rep2.subject.openSubWindow = function (url) {
-	return OpenSubWin(url + '&popup=1', sb_vars.pop_size[0], sb_vars.pop_size[1], 0, 0);
+	var width = rep2.subject.properties.pop_size[0];
+	var height = rep2.subject.properties.pop_size[1];
+	return rep2.util.openSubWindow(url + '&popup=1', width, height, 0, 0);
 };
 
 // }}}
@@ -122,17 +119,19 @@
 // {{{ $(document).ready()
 
 $(document).ready(function(){
-	rep2.subject.setWindowTitle();
-	rep2.subject.resizeTitleCell();
+	var _ = rep2.subject;
 
+	_.setWindowTitle();
+	_.resizeTitleCell();
+
 	// Å‹ß“Ç‚ñ‚¾ƒXƒŒ‰ðœ
 	$('.threadlist td.tc a[href$="&offrec=true"]').click(function(){
-		return rep2.subject.offRecent(this);
+		return _.offRecent(this);
 	});
 
 	// î•ñƒEƒCƒ“ƒhƒE•\Ž¦
 	$('.threadlist td.to a.info').click(function(){
-		return rep2.subject.openSubWindow(this.href.toString());
+		return _.openSubWindow(this.href);
 	});
 
 	// URL‚©‚çhost-bbs-key‚𒊏o‚·‚鐳‹K•\Œ»
@@ -144,28 +143,23 @@
 		if (!window.confirm('ƒƒO‚ðíœ‚µ‚Ü‚·‚©H')) {
 			return false;
 		}
-		return rep2.subject.deleteLog(re.exec($(this).attr('href'))[1], this);
+		return _.deleteLog(re.exec(this.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);
+		return _.deleteLog(re.exec(this.href)[1], this);
 	});
 
 	// ”͈͂ðŽw’肵‚ÄŒ³ƒXƒŒ‚ðŠJ‚­¬ƒ|ƒbƒvƒAƒbƒvƒƒjƒ…[
 	var hover = function (event) {
-		rep2.subject.showMotoLsPopUp(event, this);
+		_.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);
-			});
+	var click = function () {
+		var id = this.id.substring(2);
+		_.changeThreadTitleColor(id);
+		if ($(this).hasClass('midoku_ari')) {
+			_.changeUnReadColor(id);
 		}
 	};
 
@@ -176,7 +170,7 @@
 			self.hover(hover, hideMotoLsPopUp);
 		} else {
 			self.attr('title', self.text());
-			self.click(generator(self.attr('id').substring(2), self.hasClass('midoku_ari')));
+			self.click(click);
 		}
 	})
 

Modified: p2ex/trunk/lib/sb_header.inc.php
===================================================================
--- p2ex/trunk/lib/sb_header.inc.php	2010-02-24 15:41:59 UTC (rev 838)
+++ p2ex/trunk/lib/sb_header.inc.php	2010-02-25 11:25:22 UTC (rev 839)
@@ -220,9 +220,9 @@
     <script type="text/javascript" src="js/jquery-1.4.1.min.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript">
     //<![CDATA[
-    var sb_vars = {
+    rep2.subject.properties = {
         'shinchaku_ari': {$shinchaku_attayo_json},
-        'ptitle': {$ptitle_json},
+        'page_title': {$ptitle_json},
         'ttcolor': {$JSTYLE['sb_ttcolor']},
         'ttcolor_v': {$JSTYLE['thre_title_color_v']},
         'pop_size': [{$JSTYLE['info_pop_size']}]



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