This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var obj = $.parseJSON(msg); | |
| for(var key in obj){ | |
| alert(obj[key]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function numberReplace(s,d) { | |
| return s.replace (/\.?\d[\d.,]*/, d); | |
| } | |
| alert(numberReplace('25 $',12)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Model_User extends Model { | |
| /** | |
| * | |
| * Define the array of rules to be validated against | |
| * the signup information | |
| * @return array rules | |
| */ | |
| public function rules() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| public function formatDate($date, $dateFormat='', $timeFormat='') | |
| { | |
| $_dateMap = array ( '%B %e, %Y'=> 'F d, Y', | |
| '%A, %B %e, %Y' => 'l F d, Y', | |
| '%m/%d/%Y' =>'m/d/Y', | |
| '%d/%m/%Y' => 'd/m/Y' | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // collission detection logic | |
| function checkCollision(){ | |
| if(ball.y+radius==C_HEIGHT && ( | |
| (ball.x < bar.x) || (bar.x + barWidth) < ball.x ) ){ | |
| stopGame(); | |
| } | |
| else if(ball.y+radius==C_HEIGHT ){ | |
| updatePonits(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // function to draw ball | |
| function drawBall(){ | |
| ctx.fillStyle = 'orange'; | |
| ctx.beginPath(); | |
| ctx.arc(ball.x, ball.y,radius,0, 2*PI,false); | |
| ctx.fill(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // get the canvas from options passed to costructor | |
| canvas = $(options.canvas)[0]; | |
| // check if the browser supports canvas and | |
| // get the contect | |
| if(canvas.getContext('2d')){ | |
| ctx = canvas.getContext('2d'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // cross browser event listener for keyboard events | |
| if(window.addEventListener){ | |
| window.addEventListener('keypress',moveBar,false); | |
| if($.browser.webkit){ | |
| window.addEventListener('keydown',moveBar,false); | |
| } | |
| } | |
| else if(window.attachEvent){ | |
| window.attachEvent('keypress',moveBar,false); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function gameLoop(){ | |
| //draw ojects | |
| clearCanvas(); | |
| drawBall(); | |
| placeBar(); | |
| // collision detection | |
| checkCollision(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // call gameLoop in fixed intervals | |
| interval = 1000/30; | |
| timer = setInterval(gameLoop,interval); |