<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>鬼の领地 &#187; CSS</title>
	<atom:link href="http://blog.upsuper.org/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.upsuper.org</link>
	<description>the place where there are some ghost appearing...</description>
	<lastBuildDate>Wed, 19 Oct 2011 13:21:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>一中2009音乐征集系统 推荐平台</title>
		<link>http://blog.upsuper.org/2009-recommend-platform-of-music-recruiter-for-fuzhou-no1-middle-school/</link>
		<comments>http://blog.upsuper.org/2009-recommend-platform-of-music-recruiter-for-fuzhou-no1-middle-school/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 06:47:19 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[我的计划]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[学校]]></category>
		<category><![CDATA[福州一中]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=877</guid>
		<description><![CDATA[经过约两周的努力编写和调试，终于在昨天晚上完成了。因为做这个网站的缘故，再次新学习了大量东西，比如 jQuery，以及 Linux 下 Photoshop 的替代品 GIMP 等。同时也权当是一次练手，毕竟很久没写这种东西了。不过这次又一次与 IE 的 bug 及非标准化进行了顽强的斗争…… 我要记录下在这个过程中遇到的种种问题和解决方法，以后再遇到就有地方查了~ 客户端部分 很早就听说了 jQuery，上次看完 wp-codebox 的代码才顿觉 jQuery 的强大，因此这次选择了这个。经过短暂的学习就基本了解了，还是比较简单的。此外，jQuery 的插件库相当强大，里面找到了所有我需要的东西，包括上传文件的插件和播放器的插件等。 编写客户端代码最艰苦的部分就是配色和设计界面，以及在各个浏览器中调试。关于兼容性的问题放在后面说，前面先写点关于 JavaScript 代码的事。 第一个比较有趣的问题是关于浮点数保留精度的问题。虽然保留精度大是件好事，可是 JavaScript 没有如 C 中的 printf 那么方便的东西（不过网上似乎也有类似实现，不过 JavaScript 实现这个东西……还是算了吧……）。而一下把很长很长的浮点数显示在用户面前，也绝对不是件好事。经过搜寻，最后使用下面代码实现： 1 2 3 4 5 6 Number.prototype.fix = function &#40;num&#41; &#123; with &#40;Math&#41; return round&#40;this.valueOf&#40;&#41; * pow&#40;10, num&#41;&#41; / pow&#40;10, num&#41;; &#125;; [...]]]></description>
			<content:encoded><![CDATA[<p>经过约两周的努力编写和调试，终于在昨天晚上完成了。因为做这个网站的缘故，再次新学习了大量东西，比如 jQuery，以及 Linux 下 Photoshop 的替代品 GIMP 等。同时也权当是一次练手，毕竟很久没写这种东西了。不过这次又一次与 IE 的 bug 及非标准化进行了顽强的斗争……</p>
<p>我要记录下在这个过程中遇到的种种问题和解决方法，以后再遇到就有地方查了~<br />
<span id="more-877"></span></p>
<h3>客户端部分</h3>
<p>很早就听说了 jQuery，<a href="http://blog.upsuper.org/modify-code-highlight-plugin/">上次看完 wp-codebox 的代码</a>才顿觉 jQuery 的强大，因此这次选择了这个。经过短暂的学习就基本了解了，还是比较简单的。此外，jQuery 的插件库相当强大，里面找到了所有我需要的东西，包括上传文件的插件和播放器的插件等。</p>
<p>编写客户端代码最艰苦的部分就是配色和设计界面，以及在各个浏览器中调试。关于兼容性的问题放在后面说，前面先写点关于 JavaScript 代码的事。</p>
<p>第一个比较有趣的问题是关于浮点数保留精度的问题。虽然保留精度大是件好事，可是 JavaScript 没有如 C 中的 printf 那么方便的东西（不过网上似乎也有类似实现，不过 JavaScript 实现这个东西……还是算了吧……）。而一下把很长很长的浮点数显示在用户面前，也绝对不是件好事。经过搜寻，最后使用下面代码实现：</p>

<div class="wp_codebox"><table><tr id="p8775"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p877code5"><pre class="javascript" style="font-family:monospace;">Number.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">fix</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">with</span> <span style="color: #009900;">&#40;</span>Math<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> round<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">valueOf</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> pow<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> num<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> pow<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> num<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
String.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">fix</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> parseFloat<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fix</span><span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>第二个问题就是关于 MP3 播放器背景的问题。我用的这个播放器插件极具可定制性，背景色和前景色都能定制，不过要求都要使用十六进制的形式传入。为了更好的适应主题颜色，我就使用 jQuery 的 .css 方法在脚本中现场获取当前在 CSS 中定义的前景色和背景色。结果发现，其在 Firefox 内返回的是类似 rgb(0, 0, 0) 这样的颜色表大形式。据说在 Firefox 中永远放回这种形式，而 IE 中则总是返回你实际设置时使用的格式。针对这个问题，我写了下面代码来解决（毋庸置疑，这又是抄的）：</p>

<div class="wp_codebox"><table><tr id="p8776"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code" id="p877code6"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> hex <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'00'</span><span style="color: #339933;">;</span>
  n <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">||</span> isNaN<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'00'</span><span style="color: #339933;">;</span>
  n <span style="color: #339933;">=</span> Math.<span style="color: #660066;">round</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> n <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">255</span><span style="color: #009900;">&#41;</span> n <span style="color: #339933;">=</span> <span style="color: #CC0000;">255</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'0123456789abcdef'</span>.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>n <span style="color: #339933;">-</span> n <span style="color: #339933;">%</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
         <span style="color: #3366CC;">'0123456789abcdef'</span>.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>n <span style="color: #339933;">%</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> color2hex <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>color.<span style="color: #660066;">search</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/rgb/i</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    color <span style="color: #339933;">=</span> color.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> color.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> hex<span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> hex<span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> hex<span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'#'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    color <span style="color: #339933;">=</span> color.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>color.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
             color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
             color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> color<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>另外就是，为了防止大家大量重复提交同样音乐，这次加入了搜索功能，而且在提交一个音乐的时候就会自动进行搜索，并提示用户检查是否已有相同曲目被提交。至于搜索的实现，采用的是客户端搜索，算法上采用了非常著名而简单的 LCS (Longest common subsequence, 最长公共子序列) 这一 oier 的居家旅行杀人放火必备算法。事实证明，这一算法其实是很有效的~</p>

<div class="wp_codebox"><table><tr id="p8777"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p877code7"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> lcs<span style="color: #009900;">&#40;</span>str1<span style="color: #339933;">,</span> str2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> str1 <span style="color: #339933;">||</span> <span style="color: #339933;">!</span> str2<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> str1.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> str2.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">?</span> arr<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> j <span style="color: #339933;">?</span> arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>str1.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> str2.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> i <span style="color: #339933;">&amp;&amp;</span> j <span style="color: #339933;">?</span> arr<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> arr<span style="color: #009900;">&#91;</span>str1.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>str2.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>搜索算法：</p>

<div class="wp_codebox"><table><tr id="p8778"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p877code8"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> search<span style="color: #009900;">&#40;</span>type<span style="color: #339933;">,</span> text<span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  text <span style="color: #339933;">=</span> text.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\s+/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> threshold <span style="color: #339933;">=</span> text.<span style="color: #660066;">length</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.25</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> result <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  getList<span style="color: #009900;">&#40;</span>type<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> value <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">typeof</span> value <span style="color: #339933;">==</span> <span style="color: #3366CC;">'number'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      callback<span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #003366; font-weight: bold;">var</span> itemtext<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">,</span> i<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> value.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #339933;">=</span> value<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      itemtext <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">source</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">title</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\s+/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">len</span> <span style="color: #339933;">=</span> itemtext.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">lcs</span> <span style="color: #339933;">=</span> lcs<span style="color: #009900;">&#40;</span>text<span style="color: #339933;">,</span> itemtext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">lcs</span> <span style="color: #339933;">&gt;</span> threshold<span style="color: #009900;">&#41;</span> result.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    result.<span style="color: #660066;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>item1<span style="color: #339933;">,</span> item2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item1.<span style="color: #660066;">lcs</span> <span style="color: #339933;">&gt;</span> item2.<span style="color: #660066;">lcs</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item1.<span style="color: #660066;">lcs</span> <span style="color: #339933;">&lt;</span> item2.<span style="color: #660066;">lcs</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item1.<span style="color: #660066;">len</span> <span style="color: #339933;">&lt;</span> item2.<span style="color: #660066;">len</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item1.<span style="color: #660066;">len</span> <span style="color: #339933;">&gt;</span> item2.<span style="color: #660066;">len</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    callback<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>还有一个是关于换肤的。<a href="http://blog.upsuper.org/replace-css-based-on-jquery/">上一次有一篇文章</a>测试过了基于更换 link 标签 href 属性换肤的可行性分析，这次就应用于了这个平台上。但在测试中发现 IE 并不像想像的那么完美。事实上，IE 在这个的测试过程中是非常废品的，几乎相当于不能换。经过多次实验，发现原因出在——IE6 在页面加载完毕后永远不会显示其还没有下载的样式信息。也就是说，更改 href 后，虽然 IE6 将原来的样式表无效化了，但此时发现新的样式表不在其缓存中，便拒绝启用新的样式表。但奇怪的是，IE6 这个时候事实上会连接服务器下载新的样式，因此在下一次访问的时候上次点过的皮肤就可以用了。这说明，我们只要要求 IE 预装载以后可能用到的东西就可以了。因此我就在页面底部加入了一个隐藏的 iframe 用于下载样式表和需要的图片。</p>
<p>除此之外，就是一些关于样式的新发现。我第一次知道当一个元素的 position 属性设置为 relative 的时候，对这个对象本身没有影响，但却使得其使用 position 属性的子元素的位移变由相对页面的位移变为相对该元素的位移。这的上传进度条的实现方法便是应用这一机制。</p>
<p>说到上传进度条，不得不说 Uploadify 这一插件真的很强大……我将其默认的上传进度和管理通过对各个必要函数绑定返回 false 来屏蔽掉了。</p>
<p>最后是关于 jQuery 优化的问题。虽然 jQuery 的官方测试表明，jQuery 的效率非常惊人，但优化下总归是有好处的。参考的资料见下面了，说说我大体做了哪些优化吧。一是缓存 jQuery 对象，防止重复调用选择器带来的性能损失。第二个是为选择器加上上下文限制，第三个是将部分效果移至 $(window).load 里。</p>
<p>在客户端的脚本部分的最最后，小小的埋怨一下 JavaScript 这个语言……我觉得实在是没有 Python 优美啊！什么时候 Python 能成为通用的客户端脚本啊，那个时候用 Python 就可以通吃服务器端和客户端了……</p>
<p>说完了脚本，来说说这次的界面。这次界面个人还是很满意的。在界面设计中，我自认为值得一提的是那个圆角，为什么呢？因为我以前一直以为 GIMP 不能画圆角。这次去网上找了才知道，GIMP 远比我想象的强大的多！猜猜圆角是怎么画出来的？是通过高斯模糊+调整色阶。具体的实现方法放在下面参考资料里面了，这里就不详述了。但我真的觉得很强大，虽然 GIMP 和 Photoshop 等商业软件还有差距，不过对于我来说，看来足够了。</p>
<p>最后再提下这次发现的不同浏览器的兼容性问题：</p>
<dl>
<dt>对于不显示的 Flash，IE 无法与其交互</dt>
<dt>对于曾经被隐藏但再次出现的 Flash，IE6 无法与其交互</dt>
<dd>解决方案：完全销毁原有 Flash 对象并重建</dd>
<dt>IE 中隐藏的 Flash MP3 播放器可以发出声音，但 Firefox 不行</dt>
<dd>解决方案：统一的办法就是直接销毁播放器，而非单单让其隐藏</dd>
<dt>IE 的 JavaScript 解析器不支持用 [index] 的方式索引字符</dt>
<dd>解决方案：使用原有标准的 .charAt(index) 方式索引</dd>
<dt>在 IE6 中，显示时尚未下载完成的 CSS 元素永远不会显示（如背景图片）</dt>
<dd>解决方案：在页面中加入一个隐藏的 iframe 用于预加载</dd>
<dt>IE6 中的双倍外边距 bug</dt>
<dd>解决方案：给相应对象加上 display:inline; 属性，或通过 hack 专门调低在 IE6 下的外边距</dd>
<dt>IE6 对于 display 的 inline-block 属性支持不完善</dt>
<dd>解决方案：给相应对象加上 zoom:1; 属性</dd>
<dt>IE6 不支持半透明的 png 图片</dt>
<dd>解决方案：采用 IE 专有的过滤器 filter:progid:DXImageTransform.Microsoft.AlphaImageLoader 可以完美解决</dd>
</dl>
<p>IE 的兼容性烦死人啊……看看我的 ie6-fix.css 和 ie7-fix.css 就知道了……</p>
<h4>使用部件</h4>
<ul>
<li><a href="http://jquery.com/">jQuery: The Write Less, Do More, JavaScript Library</a></li>
<li><a href="http://www.uploadify.com/">Uploadify &#8211; jQuery File Upload Plugin Script</a></li>
<li><a href="http://code.google.com/p/swfobject/">SWFObject</a></li>
<li><a href="http://www.sean-o.com/jquery/jmp3/">jMP3: Sean O&#8217;s JavaScript MP3 Player / jQuery plugin</a></li>
<li><a href="http://code.google.com/p/jquery-json/">JSON plugin for jQuery</a></li>
</ul>
<h4>参考资料</h4>
<ul>
<li><a href="http://www.k99k.com/jQuery_getting_started.html">jQuery中文入门教程</a></li>
<li><a href="http://topic.csdn.net/t/20031109/21/2443654.html">如何格式化浮点数计算结果 JavaScript &#8211; CSDN社区</a></li>
<li><a href="http://plugins.jquery.com/files/jquery.sifr.js_1.txt">jQuery.sifrSettings</a></li>
<li><a href="http://www.rainbk.net/post/199.html">jQuery性能优化指南 (全部) &#8211; 烟雨博客</a></li>
<li><a href="http://blog.chinaunix.net/u1/55011/showart.php?id=468782">1.3 圆整圆角 &#8211; The Gimp &#8211; 思魂轩</a></li>
<li><a href="http://www.uploadify.com/forum/viewtopic.php?f=7&#038;t=1878">Uploadify &bull; View topic &#8211; Uploadify doesnt fire uploadifyUpload/uploadifyClearQueue</a></li>
<li><a href="http://feiyu.asgard.cn/article_157.html">IE6下margin双倍问题 &#8211; 绯雨的天空</a></li>
<li><a href="http://www.howtocreate.co.uk/alpha.html">Making Internet Explorer use PNG Alpha transparency</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/2009-recommend-platform-of-music-recruiter-for-fuzhou-no1-middle-school/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>基于 jQuery 的 CSS 更换术</title>
		<link>http://blog.upsuper.org/replace-css-based-on-jquery/</link>
		<comments>http://blog.upsuper.org/replace-css-based-on-jquery/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 12:56:39 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=854</guid>
		<description><![CDATA[最近开始写一中的新选歌系统，这次要大改，顺便练手。 想加入换肤功能（不然女生肯定觉得老是蓝色不好……），而且我想到的换肤，最简单的方式就是换 CSS，把界面颜色、图形相关的内容放入皮肤的 CSS 中就很容易了~不过问题是换肤呢？ 正好新系统中因为客户端代码可能非常强大，准备引入 jQuery 框架来简化开发，便学了一些。于是我就想，能不能通过 jQuery 来解决呢？ 首先，我给出了下面这个简单的页面： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34; xml:lang=&#34;zh-CN&#34;&#62; &#60;head profile=&#34;http://gmpg.org/xfn/11&#34;&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34; /&#62; &#60;title&#62;福州一中 学校音乐征集&#60;/title&#62; &#60;link rel=&#34;stylesheet&#34; href=&#34;&#34; id=&#34;theme&#34; type=&#34;text/css&#34; media=&#34;all&#34; /&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>最近开始写一中的新选歌系统，这次要大改，顺便练手。</p>
<p>想加入换肤功能（不然女生肯定觉得老是蓝色不好……），而且我想到的换肤，最简单的方式就是换 CSS，把界面颜色、图形相关的内容放入皮肤的 CSS 中就很容易了~不过问题是换肤呢？</p>
<p>正好新系统中因为客户端代码可能非常强大，准备引入 jQuery 框架来简化开发，便学了一些。于是我就想，能不能通过 jQuery 来解决呢？</p>
<p>首先，我给出了下面这个简单的页面：</p>

<div class="wp_codebox"><table><tr id="p85416"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p854code16"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span>
<span style="color: #00bbdd;">  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xml:<span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;zh-CN&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span> <span style="color: #000066;">profile</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://gmpg.org/xfn/11&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>福州一中 学校音乐征集<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;theme&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;all&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;theme.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span>
html, body { height: 100%; width: 100%; }
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
Hello world!
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<p>然后我开始用了一段 jQuery 手册里的<a href="http://docs.jquery.com/Core/jQuery#htmlownerDocument">某段示例代码</a>：</p>

<div class="wp_codebox"><table><tr id="p85417"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p854code17"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;link rel=&quot;stylesheet&quot; href=&quot;'</span> <span style="color: #339933;">+</span> 
    <span style="color: #009900;">&#40;</span>t<span style="color: #339933;">++</span> <span style="color: #339933;">&amp;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.css&quot; id=&quot;theme&quot; type=&quot;text/css&quot; media=&quot;all&quot; /&gt;'</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>成功了，不过查看处理后的代码，发现大量冗余代码出现在 head 尾部……又查了查，发现了 jQuery 里面的<a href="http://docs.jquery.com/Manipulation/replaceAll#selector">另外一个好用的函数</a>，于是上面代码就改为：</p>

<div class="wp_codebox"><table><tr id="p85418"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p854code18"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;link rel=&quot;stylesheet&quot; href=&quot;'</span> <span style="color: #339933;">+</span> 
    <span style="color: #009900;">&#40;</span>t<span style="color: #339933;">++</span> <span style="color: #339933;">&amp;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.css&quot; id=&quot;theme&quot; type=&quot;text/css&quot; media=&quot;all&quot; /&gt;'</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #660066;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#theme&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>没有冗余代码出现，而且 IE6 都可以正常使用！jQuery 的兼容性果然超群……</p>
<p>然后我们想，这样每次都要重建标签，会不会很慢呢？如果能直接改属性或许不错~再查查，我们发现下面方法：</p>

<div class="wp_codebox"><table><tr id="p85419"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p854code19"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#theme&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> href<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>t<span style="color: #339933;">++</span> <span style="color: #339933;">&amp;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.css'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>又简洁看过去又高效~再试试 IE6，仍然没有问题哦~<br />
<span id="more-854"></span><br />
最后给出实验用各完整代码：</p>

<div class="wp_codebox"><table><tr id="p85420"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p854code20"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> t <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#theme&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> href<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>t<span style="color: #339933;">++</span> <span style="color: #339933;">&amp;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.css'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p85421"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p854code21"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">yellow</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p85422"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p854code22"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/replace-css-based-on-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>修改代码高亮插件</title>
		<link>http://blog.upsuper.org/modify-code-highlight-plugin/</link>
		<comments>http://blog.upsuper.org/modify-code-highlight-plugin/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 13:55:24 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[博客]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=844</guid>
		<description><![CDATA[我一直在使用 wp-codebox 这个代码高亮插件。这个代码高亮插件似乎很久没有更新了，而且作者的网站也不能访问了（被墙了？），不知道是不是停止维护了？虽然在插件主页上显示这个插件仅支持到 2.5.1，我这个 2.8+ 的 WordPress 也并没有提示不兼容……虽然这个插件似乎对 SEO 有影响，而且可能停止维护，不过我暂时不打算更换插件，大不了我自己维护自己的版本…… 今天就修改了一下……因为昨天发的那文章很多用这个来显示高亮代码，而且最后一个长代码我还使用了自动收缩。可是自动收缩没效果！下载栏也没有显示。今天查一下，发现是插件的功能栏被我关了……启用以后觉得很难看，很厚，而且和我的蓝色主题很不搭调，于是就决定自己修改了。 先是改了 CSS，把那功能栏调好看了些。然后开始改 main.php，把后面失效的帮助链接给删掉了。然后我让代码小等于5行，又不提供文件下载的代码段自动隐藏功能栏，而对于大于70行的代码，如果没有显示声明展开则自动收缩。最后，觉得那个收缩很卡，就让他直接消失好了……查了下插件用的 jQuery，新版本改进了执行效率，而且没有改变插件里面用的那些函数的特性，就直接下下来更新了…… 这里把我修改后的插件也贴出来供大家参考吧：wp-codebox-upsuper.tar.lzma (577.8 KB) 顺便说一声，配的也是最新版的 GeSHi，虽然只更新了一个小小版本……]]></description>
			<content:encoded><![CDATA[<p>我一直在使用 <a href="http://wordpress.org/extend/plugins/wp-codebox/">wp-codebox</a> 这个代码高亮插件。这个代码高亮插件似乎很久没有更新了，而且作者的网站也不能访问了（被墙了？），不知道是不是停止维护了？虽然在插件主页上显示这个插件仅支持到 2.5.1，我这个 2.8+ 的 WordPress 也并没有提示不兼容……虽然这个插件似乎对 SEO 有影响，而且可能停止维护，不过我暂时不打算更换插件，大不了我自己维护自己的版本……</p>
<p>今天就修改了一下……因为<a href="http://blog.upsuper.org/optimize-leap-year-checking-and-other/">昨天发的那文章</a>很多用这个来显示高亮代码，而且最后一个长代码我还使用了自动收缩。可是自动收缩没效果！下载栏也没有显示。今天查一下，发现是插件的功能栏被我关了……启用以后觉得很难看，很厚，而且和我的蓝色主题很不搭调，于是就决定自己修改了。</p>
<p>先是改了 CSS，把那功能栏调好看了些。然后开始改 main.php，把后面失效的帮助链接给删掉了。然后我让代码小等于5行，又不提供文件下载的代码段自动隐藏功能栏，而对于大于70行的代码，如果没有显示声明展开则自动收缩。最后，觉得那个收缩很卡，就让他直接消失好了……查了下插件用的 jQuery，新版本改进了执行效率，而且没有改变插件里面用的那些函数的特性，就直接下下来更新了……</p>
<p>这里把我修改后的插件也贴出来供大家参考吧：<a href="http://down.upsuper.org/wp-codebox-upsuper.tar.lzma">wp-codebox-upsuper.tar.lzma</a> (577.8 KB)</p>
<p>顺便说一声，配的也是最新版的 GeSHi，虽然只更新了一个小小版本……</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/modify-code-highlight-plugin/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>the Ship of Culture, we are ready!</title>
		<link>http://blog.upsuper.org/the-ship-of-culture-we-are-ready/</link>
		<comments>http://blog.upsuper.org/the-ship-of-culture-we-are-ready/#comments</comments>
		<pubDate>Sat, 24 May 2008 15:36:09 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[琐事杂谈]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mondialogo]]></category>
		<category><![CDATA[排版]]></category>
		<category><![CDATA[网站]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=97</guid>
		<description><![CDATA[今天基本完成了我网页制作的任务，其他人的幻灯片和书应该也基本完成了。刚刚把那个上传的上面：http://mondialogo.upsuper.org/。 最早是Neipoor初稿设计的，后来为了体现交流，对其设计做了些许修改，就成了现在的样子。主要修改在几个地方：一是宽度由原来的1024减为980；然后是在那边加了两国国旗；还有就是给那三行字加了我很喜欢的投影效果~另外就是加了很美的鼠标放到链接上时会有发亮的效果，不过IE不支持（使用IE7测试），我的Firefox和Opera都支持。据说支持没有href属性的标签使用hover伪类是CSS2的特性，所以IE不能完全支持……另外就是加了下面的footer，是我后来使用Neipoor留下的素材独立制作的，个人觉得效果蛮赞的说。 这次里面的导航栏完全没有使用A标签或者MAP标签，而是用了新的方式——DIV+Javascript。我个人觉得这种很大的好处是链接放置的位置相当自由，而且很符合我要在背景图上放链接的要求。这次的排版是靠TABLE排的，不过可以几乎认为是absoluted的DIV。个人觉得这次做的不错~]]></description>
			<content:encoded><![CDATA[<p>今天基本完成了我网页制作的任务，其他人的幻灯片和书应该也基本完成了。刚刚把那个上传的上面：<a href="http://mondialogo.upsuper.org/">http://mondialogo.upsuper.org/</a>。</p>
<p>最早是Neipoor初稿设计的，后来为了体现交流，对其设计做了些许修改，就成了现在的样子。主要修改在几个地方：一是宽度由原来的1024减为980；然后是在那边加了两国国旗；还有就是给那三行字加了我很喜欢的投影效果~另外就是加了很美的鼠标放到链接上时会有发亮的效果，不过IE不支持（使用IE7测试），我的Firefox和Opera都支持。据说支持没有href属性的标签使用hover伪类是CSS2的特性，所以IE不能完全支持……另外就是加了下面的footer，是我后来使用Neipoor留下的素材独立制作的，个人觉得效果蛮赞的说。</p>
<p>这次里面的导航栏完全没有使用A标签或者MAP标签，而是用了新的方式——DIV+Javascript。我个人觉得这种很大的好处是链接放置的位置相当自由，而且很符合我要在背景图上放链接的要求。这次的排版是靠TABLE排的，不过可以几乎认为是absoluted的DIV。个人觉得这次做的不错~</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/the-ship-of-culture-we-are-ready/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

