bianbian coding life

便便代码人生: 关注技术, 翻译文档, 偶尔动动手

bianbian.org

[啊] 淘宝整天改版,自动发货又升级

Posted by bianbian on 2007-11-16 22:02


本文Tags: , ,

自动发货的又要改了。
现在淘宝的发货页面用了Yahoo UI Library,每个按钮都用了后期事件绑定,每个事件又和很多代码相关,于是分析起来比较困难。估计是故意的。
经过1个小时的代码分析。终于搞定。
其实偷偷告诉大家,不需要分析那些事件到底改动了哪些form里的数值。
因为我们的脚本能控制页面的所有元素,把form改成我们需要的样子submit上去就OK了。
帖主要代码:

  1. //发货
  2. gFrm["_fmu.g._0.goo"].value = gTips[gID];
  3. //先把页面里的几个发货单全删了
  4. $(d, "reComPartners").parentNode.removeChild($(d, "reComPartners"));
  5. $(d, "otherPartners").parentNode.removeChild($(d, "otherPartners"));
  6.  
  7. var div = d.createElement("DIV");
  8. var divHTML;
  9. if (gID <= 1) //邮政
  10. {
  11.     divHTML = '<input type="hidden" name="companyCode1"  value="POST"/>' +
  12.         '<input type="hidden" name="checked1" class="hidden logis:chooseCompanyId"   value="true"  />' +
  13.         '<input name="mailNo1" value="' + (gID > 0 ? hh : "POST") + '" />';
  14.     gFrm["methordId"].value = 0;
  15. }
  16. else if (gID == 4) //韵达
  17. {
  18.     divHTML = '<input name="orderType" type="hidden" value="2" />' +
  19.         '<input type="hidden" name="companyId"  value="102"/>' +
  20.         '<input type="hidden" name="companyCode"  value="YUNDA"/>' +
  21.         '<input type="hidden" name="checked" class="hidden logis:chooseCompanyId" value="true" />' +
  22.         '<input name="mailNo" value="' + hh + '" />';
  23.     gFrm["methordId"].value = 1;
  24. }
  25. else if (gID == 2) //南京100
  26. {
  27.     divHTML = '<input name="companyCode1" value="OTHER" />' +
  28.         '<input value="南京壹零零速递" name="companyName"/>' +
  29.         '<input name="checked1" value="true">' +
  30.         '<input name="mailNo1" value="' + hh + '" />';
  31.     gFrm["methordId"].value = 0;
  32. }
  33.    
  34. div.innerHTML = divHTML;
  35. gFrm.appendChild(div);
  36. gFrm.submit();
标签: , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in JavaScript, Technology | No Comments »

[嗯] 毕业后准备为GPL做贡献

Posted by bianbian on 2007-11-16 18:43


本文Tags:

现在好东西真多,当了很多年sourceforge的下载党了。。。。
今天先推荐一个:http://www.wxwidgets.org/
wxWidgets lets developers create applications for Win32, Mac OS X, GTK+, X11, Motif, WinCE, and more using one codebase. It can be used from languages such as C++, Python, Perl, and C#/.NET. Unlike other cross-platform toolkits, wxWidgets applications look and feel native. This is because wxWidgets uses the platform’s own native controls rather than emulating them. It’s also extensive, free, open-source, and mature.

Distributed FTP Daemon
A distributed FTP daemon written in java. Instead of conventional server<->client transfer it uses master<->client for control connections and slave<->client for (most) data transfers, the master must tell the slave to initiate/respond to a transfer

sharehound
Sharehound is a network file systems indexer and searcher written in Java. Currently supports SMB file shares (i.e. MS Windows-based shares) and FTP resources. Web UI is used for search and crawl monitoring. RSS feed is provided for search results.

compass
Compass is a first class open source Java Search Engine Framework, enabling the power of Search Engine semantics to your application stack decoratively. Built on top of the amazing Lucene Search Engine, Compass integrates seamlessly to popular development frameworks like Hibernate and Spring. It provides search capability to your application data model and synchronizes changes with the datasource. With Compass: write less code, find data quicker.
As of version 0.8, Compass also provides a Lucene Jdbc Directory implementation, allowing storing Lucene index within a database for both pure Lucene applications and Compass enabled applications. Note, when using Compass, using a database as the index storage requires only updating configuration settings.

标签:

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in Technology | 1 Comment »

[嗯]新增小百合文档网域名

Posted by bianbian on 2007-10-31 23:28


本文Tags:

lilydoc.net
准备放小百合(LILYBBS)内的优秀文档,否则淹没在一片水中太可惜了。
现在也增加了BT服务器(拿我那台破机器做的,仅供校内访问):bt.lilydoc.net

标签:

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in Uncategorized | No Comments »

[原]一种blog日历的JSON压缩输出算法

Posted by bianbian on 2007-10-17 11:56


本文Tags: , , ,

一般高效的blog日历会将所有发表日期单独存储到js中,由客户端脚本负责输出日历链接。
以前都是按yyyymmdd输出blog日历的,如果发文多的话会特别长(特别是几年下来)。
最近用JSON输出blog日历的时候,发现一种更简单、更高效、更省数据量的方法:

{
"年份":["一月天", "二月天", ...., "五月天", .... , "十二月天"]
}

即年份作为JSON属性,值是十二个月天数构成的数组(五月天纯粹是增加关键字 - -)。
一个月最多有31天,如果用数字表示得用62个长度的字符。我决定用单个可打印字符的ASCII码代替。
在ASCII表里找了一段:从61-91(”=>?@ABCDEF……UVWXYZ[”)满足要求(刚好是天数+60)
于是,原来比如2006每个月各发表1篇blog的数据从:

"20060111,20060212,20060313,20060414,20060515,20060616,20060717,20060818,20060919,20061020,20061121,20061222"

就可以压缩到(106是linux下struct tm的year,是1900+的,106+1900=2006):

{"106":["G","H","I","J","K","L","M","N","O","P","Q","R"]}

当然这只是一个特殊例子,实际上用户写blog都有一段时间的连续性。用这种办法输出的日历数据在
数据量大的情况下会更加省空间。(显然原来的方法重复了很多年份、月份数据)。
下面是一个勤劳用户从04到07年的blog日历(几乎天天有文章更新):
总数据量1K不到,如果用yyyymmdd的方法估计要是这个的5-6倍

b_date={"104":["=@DEGJO[","?CGHLP","BDEHIPTUY[","?ELNOPQRSUVZ","?ABGIKLMOPSTZ[",">CHIJLMNOPSUX",">AFGNT[",">GNOPQV","DUWZ","BDGHKNOQR","=?CDFLNOSTUVXYZ","=>?@BCDEFIJOPQSTWXYZ["],
"105":["?@BCEFGHIJMNOPQSTUV[","=>?@ABCGIJKLMNOPQRSTUVWX","=>?@ABCDEFGHIJKLMNOP","VWXYZ","=>ABCDEFGHIJLMN","BCDEFIJKLMOPQRSUWXYZ","=?@BCDEFGHIJNOPQRUVWY","=>BNRSUVWZ",">ABCDFGHIJKMOQTVWYZ","DEFGHIJLNOPQRUVW[","=>?@BCDEFGHIJKLQSTWXZ","=>@AHIJKNOPQRSVYZ"],
"106":["@ABFILMOPSTU",">DEFGIJKMNPQ",">BCDEFGHIJKOPQSTWXYZ","=?@ABEFGHIJLMNOPQRSTUVWX","DFLNORY[",">ABEFGHIJLOPQSUVWZ","=>ABCEFIJMNQUVW[","=>CEIJORSTUXYZ[","=>ACEGHKOPQRTUVWX","?@BDEFGHIJLNOPQSTUVWX","=>?AFHIJOPQSTWXYZ","=ABCGJNORUV["],
"107":[">@JKLNOPQRSTUVWXY[","=>?BDFGIKLSTUVWX",">@ABCEGHIKOPQRUVWXY[","=ABEFGHIKLMOPQSUVWXZ","?CDFHIJKLMNOQRSTUVWYZ","=?@ABCDEFGHIKLMNOPQRUWY","=?ADFGHIKMNOPSUWZ[","=>?@ABCDFGHIKLMNOPRSVWXY",">?@ABCDEFGIJKMNPQRTVXY",">ACDEGHJKL","",""]
}

用客户端Javascript解析的时候也比原来方便直接。原来需要split然后循环判断(如果排序了可以用二分法)。而JSON不需要这种解析,直接可以拿来用:使用String.fromCharCode(60+天)获得某天的字符,然后在当月中查找一下:

  1. //b_date={}
  2. function HasPost(Y, M, D)
  3. {
  4.     if (!b_date)
  5.         return false;
  6.     if (!b_date[Y])
  7.         return false;
  8.     var ds = b_date[Y][M];
  9.     return (ds.indexOf(String.fromCharCode(60+D)) > -1);
  10. }

(当然,如果要更省空间,甚至可以把各月的数据用一个字符串表示、用逗号隔开;不过这样就得在客户端split然后再解析了。我认为这是不必要的:每年只省下22个字节而已)

标签: , , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in JavaScript, Technology | 1 Comment »

[晕] nginx的internal属性的bug

Posted by bianbian on 2007-10-16 14:17


本文Tags: , ,

文档上说,internal用来禁止用户直接通过地址访问。
syntax: internal
default: no
context: location

internal indicates that the matching location can be used only for so called “internal” requests.
For external requests it will return the error “Not found” (404).
Internal requests are the following:
1) requests redirected by the instruction error_page
2) subrequests created by the command include virtual of the “ngx_http_ssi_module” module
3) requests changed by the instruction rewrite of the “ngx_http_rewrite_module” module

An example to prevent clients fetching error pages directly:

  1. error_page   404   /404.html;
  2. location  /404.html {
  3.     internal;
  4. }

实际发现,rewrite的用internal修饰后就挂了。像下面这个配置,如果/realpath/设了internal,用/proxypath/访问就是404。
这个跟本意是违背的(本意只能通过/proxypath/访问,而隐藏/realpath/),应该是nginx的bug(我的版本0.5.32)

  1. location /proxypath/ {
  2.    root     /realpathroot;
  3.    rewrite ^/proxypath/(.+)$  /realpath/$1? last;
  4. }
  5. location /realpath/ {
  6.   internal;
  7. }
标签: , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in Linux, Technology | No Comments »