記得以前用python寫過一個日報填寫的東西,可是涉及的庫太多,感覺很不好。
今天剛剛看到Watir,變將它重寫了一下:
require 'Watir'

#登陸地址
pform_login_url='http://ip/pform/common/login.jsp'
#填寫日志地址
pform_input_url='http://ip/pform/nbgl/datainputInitAction.do'

ie=Watir::IE.new

#輸入用戶名&密碼
puts '登陸
.'
ie.goto(pform_login_url)
ie.text_field(:name,'j_username').set('工號')
ie.text_field(:name,'j_password').set('密碼')

#提交頁面
ie.button(:name,'submit').click

#轉向日報填寫地址
puts('填寫日報
')
ie.goto(pform_input_url)

#填寫日報時間
ie.text_field(:name,'fillInDate').set('2006-01-24')

#選擇項目
ie.select_list(:name,'detailList[0].projectId').select('***項目')
#具體事項
#ie.select_list(:name,'detailList[0].workId').select('代碼開發')
#工作內容
ie.text_field(:name,'detailList[0].workContent').set('代碼開發')
#正常工作時長
ie.text_field(:name,'detailList[0].workNum').set('8')
#加班工作時長
ie.text_field(:name,'detailList[0].overtimeNum').set('0')

puts('提交日報
')
#提交表單
ie.button(:id,'submit').click

if ie.contains_text('成功')
puts '日報提交成功!'
else
puts '日報提交失敗!'
end

ie.close
#end很簡潔,但是有個問題,就是中文的問題,正好在
http://www.tkk7.com/raimundox/archive/2006/01/12/27676.html 這里看到關于中文處理的方法,改進之,偷懶,直接拷貝過來:)
OK!提交之.
Lightbox JS is a simple, unobtrusive script used to to overlay images on the current page. It's a snap to setup and works on all modern browsers.
http://www.huddletogether.com/projects/lightbox/
http://www.activestate.com/
Komodo is ActiveState's cross-platform, multi-language Integrated Development Environment (IDE). Komodo supports development in numerous languages, including Perl, Python, PHP, Ruby, Tcl, XSLT, JavaScript, and more.
http://www.tkk7.com/Files/martinx/ActiveState.Komodo.v3.5.2.Professional.Incl.Keygen.rar
http://ajaxian.com/archives/mooajax-13kb-for-all-your-asynchronous-needs
Valerio Proietti, the creator of Moo.fx, has now created a micro library for Ajax, moo.ajax.
I noticed many of you requested if it would have been possible to use the full prototype, instead of the lite one I provided with the full download of moofx, to use its ajax capabilities along with the effects. Sure you can, but wouldn’t it be cooler if there was a more lightweigt one?
Just to continue my mission in small javascripting, I have arranged this moo.ajax, in just 1.3kb of uncompressed sweetness.
read more for instructions, or download the script. As always, any comments/corrections/suggestions are highly appreciated.
moo.ajax is a very simple ajax class, to be used with prototype.lite from moo.fx. It’s roughly based on the prototype one, so their usage are very similar.
The request
to make any request just call
new ajax(url, options);
The options
method: choose either post or get. The default is post.
posyBody postBody: if you choose post as method, you can write parameters here.
onComplete: a function that will be fired when your request is complete. The request object will be passed as a parameter of the function.
update: an dom element or an element’s id. This element will be filled with the request’s responsetext.
An example
This will call my script.php via post, setting as parameter sleep=3. When the request is complete I want an alert with the response text, and I want an element to be updated with the responsetext as well.

new ajax ('sleep.php',
{postBody: 'sleep=3', update: $('myelementid'), onComplete: myFunction});

function myFunction(request)
{
alert(request.responseText);
}