Internship, Day 12 (4 May 2012)
Posted on May 5th, 2012 in computer, CPE, in English, in Thai, personal, PHP, programming | No Comments »

(Photo: Food center, fl. B1)
วันนี้ผมทำกราฟให้กับงานนับอีเมล์ โดยเมื่อวานใช้ Google Chart API แต่ก็ไม่เวิร์ก เพราะพี่บอกว่าอยากให้มีตัวเลขเหนือแท่งกราฟของแต่ละวันด้วย ก็เลยต้องเปลี่ยนไปใช้ jqplot แทน สิ่งที่แตกต่างอย่างเห็นได้ชัดคือ jqplot อ่อนกว่าเรื่อง documentation มาก แต่ก็ยังอยู่ในเกณฑ์ที่ใช้งานได้ง่ายเช่นกัน นอกจากนี้ plugin เยอะและกระจัดกระจายมาก (มี .js ประมาณยี่สิบกว่าไฟล์) ผมเลยแก้ปัญหาง่ายๆ (โค้ดอยู่ตอนท้าย ให้ทายก่อนว่าผมทำอะไรลงไป)
จากนั้นผมจึงส่งงาน (โดยการบอกพี่ว่าเสร็จแล้ว เพราะงานอยู่บนเซิร์ฟเวอร์) แล้วกลับมาทำงานวิดีโอต่อ โดยพี่ทดสอบให้ดูว่า jQuery UI ใช้กับ iPad และอุปกรณ์สัมผัสไม่ได้ สาเหตุก็คือ jQuery UI ใช้ mouse event ในขณะที่การสัมผัสมันไปสร้าง touch event ซึ่งพอไม่เหมือนกัน jQuery ก็ไม่จับ event ให้ ทำให้ไม่สามารถทำงานได้เหมือนปกติ ทางแก้หนึ่งคือการหา plugin ต่างๆ มาใส่ เช่น Touch Punch หรือ jQuery for iPad and iPhone เป็นต้น ซึ่งผมก็ยังไม่ได้ทำ
แต่ส่วนที่ทำแล้วคือ sidebar และเปลี่ยนกล่อง unordered list (UL) ให้แสดงผลเป็นตารางแบบ grid แทนที่จะเป็น list ไล่ลงมาแถวเดียว ซึ่งตรงนี้ไม่ยาก แต่ขอเก็บไว้ตอนท้ายเช่นกัน
Today I fixed the stat graphing for email checker. Yesterday I used Google Chart API but it didn’t go very well because the senior wanted it to display data labels on each bar, which Google Chart API did not support. I switched to jqplot , which was not as well-documented but still very useful. Its another downside is the scattered plugin files (20+ .js files) so I had to kludge it somehow. (Code is at the end)
After finishing the job I told the senior it’s done and got back to work on the video player. The senior tested jQuery UI on iPad which failed because jQuery UI uses mouse events while touchscreens generate touch events, which are not captured by jQuery UI. One way to fix is to install plugins like Touch Punch or jQuery for iPad and iPhone , but I haven’t tried any yet.
There’s something I got done though, and it’s the sidebar and grid-style list.
Kludging scattered files
cat *jqplot*min*js > jqplot.all.js
Sidebar CSS
Add a new div over your sidebar, then add these CSS lines to it
.sidebar{
position: absolute;
top: 0;
right: 0;
z-index: 199;
}
Absolute means the item is pinned to a particular spot on the page (while “fixed” pins the element to the window ). Top and Right properties specify how far from each edge this thing needs to be. In this case, it should be on the top-right. Z-index can be anything high enough that it’s in front of everything.
If you want it to be “integrated” into UI, not extending beyond the confines of your window, and also make it scrollable, just add these two more lines to the sidebar CSS
.sidebar{
height: 100%;
overflow-y: scroll;
}





