TAILIEUCHUNG - Practical prototype and scipt.aculo.us part 17

Practical prototype and part 17: The information in this book is distributed on an "as is" basis, without warranty Although every pre-caution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. | 84 CHAPTER 4 AJAX ADVANCED CLIENT SERVER COMMUNICATION WR makes one catch every 2 minutes for 25 yds and does not score. class WR2 extends Player function stats yards floor this- time 120 25 return array yards yards TD 0 points floor yards 10 summary yards . yards receiving 0 TD These classes all return data in the same format. They only differ in the script they follow the way they turn that original time value into a point total. Each team will start only one tight end so we needn t bother with more than one version of tight end. TE makes one catch at minute 8 for a 20-yard TD. class TE extends Player function stats yards this- time 480 20 0 tds this- time 480 1 0 return array yards yards TD tds points floor yards 10 6 tds summary yards . yards receiving . tds . TD There s only one thing left to do organize these players into teams. At the bottom of we ll add the code to do this and output to JSON. Adds a player s score to a running total used to compute a team s total score function score_sum a b a b points return a CHAPTER 4 AJAX ADVANCED CLIENT SERVER COMMUNICATION 85 qb new QB rb1 new RB1 rb2 new RB2 wr1 new WR1 wr2 new WR2 te new TE team1 array team 1 will score more points so we give it the better versions of RB and WR team1 players array QB qb- stats RB1 rb1- stats RB2 rb1- stats WR1 wr1- stats WR2 wr1- stats TE te- stats take the sum of all the players scores team1 points array_reduce team1 players score_sum team2 array team 2 will score fewer points so we give it both versions of RB and WR team2 players array QB qb- stats RB1 rb1- stats RB2 rb2- stats WR1 wr1- stats WR2 wr2- stats TE te- stats take the sum of all the players scores team2 score array_reduce team2 players score_sum deliver it in one large JSON chunk echo json_encode array team_1 team1 team_2 team2 86 CHAPTER 4 AJAX ADVANCED CLIENT SERVER COMMUNICATION To paraphrase Blaise Pascal I apologize for writing a long script but I lack the time to write a short one. We could have taken .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.