Skip to content
Browse files

safari app added

  • Loading branch information...
1 parent ccbfeec commit 4080d5092377fe330a1bae508360b3664740a6eb @altryne committed Nov 24, 2010
View
3 app.php
@@ -36,7 +36,8 @@
<h1>I have yet to implement this app in this ipad experiment. soon.</h1>
<h3 style="margin-bottom:15px !important;">
In the meanwhie, you are welcome to checkout my blog : <a href="http://alexw.me/">alexw.me</a> <br />
- You can also fork this at https://github.com/altryne/Ipad-Simulator and hack on this and do cool stuff because open souce rulez
+ You can also fork this at <a href="https://github.com/altryne/Ipad-Simulator">https://github.com/altryne/Ipad-Simulator</a> <br/>
+ and hack on this and do cool stuff because open souce rulez
</h3>
<h4>
Things that work :
View
BIN img/flash_lego_block.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN img/google_maps_pin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN img/safari_sprites.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
5 index.php
@@ -43,10 +43,11 @@
<meta name="description" content="This is a jquery iPad simulator, this is only an experiment of what can be done with javascript in ast browsers">
<meta name="keywords" content="Ipad, ipad simulator, apple ipad, alexw.me, altryne, alex wolkov, ipad javascript simulator">
<link rel="stylesheet" href="style/ipad.css" type="text/css" media="screen"/>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
- <script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.2.min.js"%3E%3C/script%3E'))</script>
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
+ <script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery-1.4.4.min.js"%3E%3C/script%3E'))</script>
<script type="text/javascript" src="js/jquery-ui-1.8.1.custom.min.js"></script>
<script type="text/javascript" src="js/plugins.js"></script>
+ <script type="text/javascript" src="js/jquery.ui.ipad.js"></script>
<script type="text/javascript" src="js/ipad.js"></script>
</head>
<body id="ipad">
View
246 js/cookies.js
@@ -0,0 +1,246 @@
+
+
+//Cookies: getCookie, setCookie, deleteCookie
+getCookie = function(name){
+ var start = document.cookie.indexOf( name + "=" );
+ var len = start + name.length + 1;
+ if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
+ return null;
+ }
+ if ( start == -1 ) return null;
+ var end = document.cookie.indexOf( ';', len );
+ if ( end == -1 ) end = document.cookie.length;
+ return unescape( document.cookie.substring( len, end ) );
+}
+setCookie = function(name, value, expires, path, domain, secure){
+ var today = new Date();
+ today.setTime( today.getTime() );
+ if ( expires ) {
+ expires = expires * 1000 * 60 * 60 * 24;
+ }
+ var expires_date = new Date( today.getTime() + (expires) );
+ document.cookie = name+'='+escape( value ) +
+ ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
+ ( ( path ) ? ';path=' + path : '' ) +
+ ( ( domain ) ? ';domain=' + domain : '' ) +
+ ( ( secure ) ? ';secure' : '' );
+
+}
+deleteCookie = function(name, path, domain){
+ if ( getCookie( name ) ) document.cookie = name + '=' +
+ ( ( path ) ? ';path=' + path : '') +
+ ( ( domain ) ? ';domain=' + domain : '' ) +
+ ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
+}
+
+
+/*
+ * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
+ *
+ * Uses the built in easing capabilities added In jQuery 1.1
+ * to offer multiple easing options
+ *
+ * TERMS OF USE - jQuery Easing
+ *
+ * Open source under the BSD License.
+ *
+ * Copyright © 2008 George McGinley Smith
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * Neither the name of the author nor the names of contributors may be used to endorse
+ * or promote products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+
+// t: current time, b: begInnIng value, c: change In value, d: duration
+jQuery.easing['jswing'] = jQuery.easing['swing'];
+
+jQuery.extend( jQuery.easing,
+{
+ def: 'easeOutQuad',
+ swing: function (x, t, b, c, d) {
+ //alert(jQuery.easing.default);
+ return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
+ },
+ easeInQuad: function (x, t, b, c, d) {
+ return c*(t/=d)*t + b;
+ },
+ easeOutQuad: function (x, t, b, c, d) {
+ return -c *(t/=d)*(t-2) + b;
+ },
+ easeInOutQuad: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t + b;
+ return -c/2 * ((--t)*(t-2) - 1) + b;
+ },
+ easeInCubic: function (x, t, b, c, d) {
+ return c*(t/=d)*t*t + b;
+ },
+ easeOutCubic: function (x, t, b, c, d) {
+ return c*((t=t/d-1)*t*t + 1) + b;
+ },
+ easeInOutCubic: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t*t + b;
+ return c/2*((t-=2)*t*t + 2) + b;
+ },
+ easeInQuart: function (x, t, b, c, d) {
+ return c*(t/=d)*t*t*t + b;
+ },
+ easeOutQuart: function (x, t, b, c, d) {
+ return -c * ((t=t/d-1)*t*t*t - 1) + b;
+ },
+ easeInOutQuart: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
+ return -c/2 * ((t-=2)*t*t*t - 2) + b;
+ },
+ easeInQuint: function (x, t, b, c, d) {
+ return c*(t/=d)*t*t*t*t + b;
+ },
+ easeOutQuint: function (x, t, b, c, d) {
+ return c*((t=t/d-1)*t*t*t*t + 1) + b;
+ },
+ easeInOutQuint: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
+ return c/2*((t-=2)*t*t*t*t + 2) + b;
+ },
+ easeInSine: function (x, t, b, c, d) {
+ return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
+ },
+ easeOutSine: function (x, t, b, c, d) {
+ return c * Math.sin(t/d * (Math.PI/2)) + b;
+ },
+ easeInOutSine: function (x, t, b, c, d) {
+ return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
+ },
+ easeInExpo: function (x, t, b, c, d) {
+ return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
+ },
+ easeOutExpo: function (x, t, b, c, d) {
+ return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
+ },
+ easeInOutExpo: function (x, t, b, c, d) {
+ if (t==0) return b;
+ if (t==d) return b+c;
+ if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
+ return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
+ },
+ easeInCirc: function (x, t, b, c, d) {
+ return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
+ },
+ easeOutCirc: function (x, t, b, c, d) {
+ return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
+ },
+ easeInOutCirc: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
+ return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
+ },
+ easeInElastic: function (x, t, b, c, d) {
+ var s=1.70158;var p=0;var a=c;
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ },
+ easeOutElastic: function (x, t, b, c, d) {
+ var s=1.70158;var p=0;var a=c;
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
+ },
+ easeInOutElastic: function (x, t, b, c, d) {
+ var s=1.70158;var p=0;var a=c;
+ if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
+ },
+ easeInBack: function (x, t, b, c, d, s) {
+ if (s == undefined) s = 1.70158;
+ return c*(t/=d)*t*((s+1)*t - s) + b;
+ },
+ easeOutBack: function (x, t, b, c, d, s) {
+ if (s == undefined) s = 1.70158;
+ return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
+ },
+ easeInOutBack: function (x, t, b, c, d, s) {
+ if (s == undefined) s = 1.70158;
+ if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
+ return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
+ },
+ easeInBounce: function (x, t, b, c, d) {
+ return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
+ },
+ easeOutBounce: function (x, t, b, c, d) {
+ if ((t/=d) < (1/2.75)) {
+ return c*(7.5625*t*t) + b;
+ } else if (t < (2/2.75)) {
+ return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
+ } else if (t < (2.5/2.75)) {
+ return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
+ } else {
+ return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
+ }
+ },
+ easeInOutBounce: function (x, t, b, c, d) {
+ if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
+ return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
+ }
+});
+
+/*
+ *
+ * TERMS OF USE - EASING EQUATIONS
+ *
+ * Open source under the BSD License.
+ *
+ * Copyright © 2001 Robert Penner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * Neither the name of the author nor the names of contributors may be used to endorse
+ * or promote products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+// Monkey patch jQuery 1.3.1+ css() method to support CSS 'transform'
+ // property uniformly across Webkit/Safari/Chrome and Firefox 3.5.
+ // 2009-2010 Zachary Johnson www.zachstronaut.com
+ // Updated 2010.11.06
View
621 js/ipad.js
@@ -1,308 +1,313 @@
-/**
- * Created by IntelliJ IDEA.
- * User: Altryne
- * Date: Nov 20, 2010
- * Time: 4:55:41 AM
- * To change this template use File | Settings | File Templates.
- */
-
-var intervall = 0;
-var can_run_apps = false;
-var tick;
-
-var canScroll = true;
-
-$('.delete').live('click', function(event) {
- event.stopPropagation();
- event.stopImmediatePropagation();
- if(confirm('Are you sure you want to delete this app from you iPad?')){
- $(this).parent().css({'width':74,'height':99}).children('.delete, span').hide();
- $(this).siblings('.app_logo')
- .stop()
- .css('position','absolute')
- .animate({left:"50%",width:1,top:"50%",height: 1},'easeInQuint',function(){$(this).parent().remove()})
- }
-
-});
-
-$('.apps li').live('mousedown mouseup', function(event) {
- if (event.type == 'mousedown') {
- $(this).addClass('mousedown');
- if (!$('#drag').hasClass('ui-draggable-dragging') && !$('body').hasClass('editMode')) {
- can_run_apps = true;
- intervall = setTimeout("edit_mode()", '2000');
- }
- } else {
- $(this).removeClass('mousedown');
- clearTimeout(intervall);
- if(!can_run_apps)
- clearTimeout(intervall);
- else if((!$('#drag').hasClass('ui-draggable-dragging') && !$('body').hasClass('editMode'))){
- launchApp($(this).attr('id'));
- }
-
- }
-});
-
-$('#search_result li.show').live('click',function(){
- launchApp($(this).attr('id'));
-});
-
-
-
-$('#slider').live('mousedown mouseup', function(event) {
- if (event.type == 'mousedown') {
- $('#slide_here').css('background-position','1500px 1500px');
- } else {
- $('#slide_here').css('background-position','right 50%');
- }
-});
-
-$('#home').live('click',homeBtnClick);
-
-$('#sleep').live('click',function(){
- $('#lockscreen').addClass('hidden').addClass('asleep').show();
- $('#content').addClass('hide_spring');
-});
-
-function updateClock(){
- var currentDate = new Date();
- datestring = addZero(currentDate.getHours()) + ':' + addZero(currentDate.getMinutes());
- $('.time').html(datestring);
-}
-function addZero(num){
- return (num<10)?num="0"+num:num;
-}
-
-// ####### document ready $$$$$$$$$$$
-$(document).ready(function(){
- _page = 1;
- _pages = $('ul.page').length;
-
- reflectDock();
-// _page=0; unlockSpring(); slideToPage(0); //temporary - todo:remove this
-
-// create elements in quick search
- $('.apps li').each(function(){
- if($(this).attr('id') != ''){
- _img = $('.app_logo',this).css('background-image').replace('"','\'');
- _elm = $('<li><div class="app_logo" style="background-image:'+_img+'"></div><span class="search_str">' +$(this).attr('id')+ '</span> </li>');
- _elm.appendTo('#search_result');
- }
- });
-
- $('#search').liveUpdate($('#search_result'));
- $('#search_result').draggable({axis:'y',distance:20,revert:'invalid'});
-
- tick = setInterval('updateClock()', 1000 );
- $('#slider').draggable({axis:'x',containment: 'parent',revert:'invalid'})
-
- $('#drop').droppable({
- drop: unlockSpring
- });
-
-
-
-
- $('#drag').draggable({
- axis: 'x',
- distance: 20,
- start:function(){
- window['_dragStart'] = $('#drag').css('left');
- },
- stop:function(){
- window['_dragEnd'] = $('#drag').css('left');
- if(parseInt(window['_dragStart']) < parseInt(window['_dragEnd'])){
- if(_page > 0){
- slideToPage(_page - 1);
- }else{
- slideToPage(_page);
- }
- }else{
- if(_page < _pages){
- slideToPage(_page + 1);
- }else{
- slideToPage(_page);
- }
- }
-
- }
- });
- //add left and right keys to navigate to pages for convenience
- $(document).keydown(function(e){
- if(e.keyCode == 39){
- slideToPage(_page+1);
- }else if(e.keyCode == 37){
- slideToPage(_page-1);
- }
- });
- });
-
-function slideToPage(page){
- if(canScroll && page >= 0 && page <= _pages){
- canScroll = false; $('#drag').draggable('disable');
- $('#pages li').removeClass('active').eq(page).addClass('active');
- if(page == 0){
- $('#black,.corner').animate({opacity:1},300,"easeOutQuad",function(){$('#search').focus();});
- }
- else{
- $('#black,.corner').animate({opacity:0},100,"easeOutQuad");
- }
- $('#general_wrap').scrollTo('#page'+page,800,{
- "easing":'easeOutQuint',
- onAfter : function(){
- canScroll = true;
- $('#drag').draggable('enable');
- _page = page;
- }
-
- });
-
- }
-};
-function unlockSpring() {
- $('#general_wrap').scrollTo('#page'+1,0);
- $('#lockscreen').addClass('hidden').delay(200).fadeOut();
- $('#content').removeClass('hide_spring');
- $('#slider').css('left', 0);
- animateDock('in');
-}
-function homeBtnClick(){
- if($('.asleep')){
- $('.asleep').removeClass('asleep').removeClass('hidden');
- }
- if($('body').hasClass('editMode')){
- //destroy sortable
- $('body').removeClass('editMode');
- $('.apps').sortable('destroy');
- }else if($('#window').is('.out')){
- closeApp();
- }
- else{
- $('#drag').css('left',0);
- slideToPage(1); //go back home
- }
-};
-function edit_mode(){
- can_run_apps = false;
- clearTimeout(intervall);
-
- $('body').addClass('editMode');
- $('.apps').sortable({
- revert : true,
- handle : '.app_logo',
- connectWith: '.apps',
- appendTo: '#content',
- helper: 'clone',
- distance: 0,
- over: function(event, ui) {
- if($(ui.placeholder).parents('#drag').length)
- slideToPage($('#drag ul').index($(ui.placeholder).parent()));
- },
- change: function(event, ui){
- $(ui.placeholder).animate({width:75,'margin-right':50,'margin-left':50},150);
- },
- start: function(event, ui) {
- $(ui.placeholder).animate({width:1,'margin-right':0,'margin-left':0,overflow:'hidden'},150);
- },
- stop: function(event, ui) {
- reflectDock();
- $(ui.item).removeClass('mousedown');
- }
- });
-
- window.clearInterval(intervall);
-
-};
-//css "reflection" hehe
-function reflectDock(){
- $('.reflection').remove();
- $('#dock li .app_logo').each(function(){
- $(this).clone().addClass('reflection').appendTo($(this).parent());
- })
-}
-//define custom animation based on app icon location. so Icons spead out like in iOS
-function animateDock(mode){
- $('#page'+_page+'.apps li').each(function(){
- _origLeft = $(this).position().left;
- _origTop = $(this).position().top;
- switch(_origLeft){
- case 0:
- case -200:
- _newLeft = -200;
- break;
- case 174:
- case -250:
- _newLeft = -250;
- break;
- case 348:
- case 0:
- _newLeft = 0;
- break;
- case 522:
- case 250:
- _newLeft = 250;
- break;
- case 696:
- case 200:
- _newLeft = 200;
- break;
- }
- switch(_origTop){
- case 10:
- case -200:
- _newTop = -200;
- break;
- case 139:
- case -250:
- _newTop = -250;
- break;
- case 268:
- case 250:
- _newTop = +250;
- break;
- case 397:
- case 200:
- _newTop = +200;
- break;
- }
-
- switch(mode)
- {
- case 'in':
- $(this)
- .css({'left':(_newLeft),'top':(_newTop),'position':'relative'})
- .animate({'left':0,'top':0},500,'easeOutQuad');
- break;
- case 'outin':
- $(this)
- .animate({'left':0,'top':0},500,'easeOutQuad');
- break;
- default:
- $(this).css({'position':'relative'})
- .animate({'left':(_newLeft),'top':(_newTop)},500,'easeOutQuad');
- break;
- }
- })
- switch(mode)
- {
- case 'out':
- $('#dock,#pages')
- .animate({'bottom':-120},500,'easeOutQuad');
- break;
- case 'in':
- case 'outin':
- $('#dock').animate({'bottom':0},500,'easeOutQuad');
- $('#pages').animate({'bottom':120},500,'easeOutQuad');
- break;
- }
-}
-function closeApp(){
-$('#window').removeClass('out').stop().html('').animate({left:"50%",width:1,top:"50%",height: 1,opacity:0},'easeInQuint');
-animateDock('outin');
-}
-function launchApp(app_id){
-animateDock('out');
-_appToLaunch = '?appid='+app_id || null;
-$('#window').addClass('out').stop().html('<iframe src="app.html'+_appToLaunch+'" scrolling="no" width="884" height="658"></iframe>').animate({left:"0%",width:884,top:"0%",height:662,opacity:1},'easeInQuint');
-}
+/**
+ * Created by IntelliJ IDEA.
+ * User: Altryne
+ * Date: Nov 20, 2010
+ * Time: 4:55:41 AM
+ * To change this template use File | Settings | File Templates.
+ */
+
+var intervall = 0;
+var can_run_apps = false;
+var tick;
+
+var canScroll = true;
+
+$('.delete').live('click', function(event) {
+ event.stopPropagation();
+ event.stopImmediatePropagation();
+ if(confirm('Are you sure you want to delete this app from you iPad?')){
+ $(this).parent().css({'width':74,'height':99}).children('.delete, span').hide();
+ $(this).siblings('.app_logo')
+ .stop()
+ .css('position','absolute')
+ .animate({left:"50%",width:1,top:"50%",height: 1},'easeInQuint',function(){$(this).parent().remove()})
+ }
+
+});
+
+$('.apps li').live('mousedown mouseup', function(event) {
+ if (event.type == 'mousedown') {
+ $(this).addClass('mousedown');
+ if (!$('#drag').hasClass('ui-draggable-dragging') && !$('body').hasClass('editMode')) {
+ can_run_apps = true;
+ intervall = setTimeout("edit_mode()", '2000');
+ }
+ } else {
+ $(this).removeClass('mousedown');
+ clearTimeout(intervall);
+ if(!can_run_apps)
+ clearTimeout(intervall);
+ else if((!$('#drag').hasClass('ui-draggable-dragging') && !$('body').hasClass('editMode'))){
+ launchApp($(this).attr('id'));
+ }
+
+ }
+});
+
+$('#search_result li.show').live('click',function(){
+ launchApp($(this).attr('id'));
+});
+
+
+$('#slider').live('mousedown mouseup', function(event) {
+ if (event.type == 'mousedown') {
+ $('#slide_here').css('background-position','1500px 1500px');
+ } else {
+ $('#slide_here').css('background-position','right 50%');
+ }
+});
+
+$('#home').live('click',homeBtnClick);
+
+$('#sleep').live('click',function(){
+ $('#lockscreen').addClass('hidden').addClass('asleep').show();
+ $('#content').addClass('hide_spring');
+});
+
+function updateClock(){
+ var currentDate = new Date();
+ datestring = addZero(currentDate.getHours()) + ':' + addZero(currentDate.getMinutes());
+ $('.time').html(datestring);
+}
+function addZero(num){
+ return (num<10)?num="0"+num:num;
+}
+
+// ####### document ready $$$$$$$$$$$
+$(document).ready(function(){
+ _page = 1;
+ _pages = $('ul.page').length;
+
+
+ reflectDock();
+// _page=0; unlockSpring(); slideToPage(0); //temporary - todo:remove this
+
+// create elements in quick search
+ $('.apps li').each(function(){
+ if($(this).attr('id') != ''){
+ _img = $('.app_logo',this).css('background-image').replace('"','\'');
+ _elm = $('<li><div class="app_logo" style="background-image:'+_img+'"></div><span class="search_str">' +$(this).attr('id')+ '</span> </li>');
+ _elm.appendTo('#search_result');
+ }
+ });
+
+ $('#search').liveUpdate($('#search_result'));
+ $('#search_result').draggable({axis:'y',distance:20,revert:'invalid'});
+
+ tick = setInterval('updateClock()', 1000 );
+ $('#slider').draggable({axis:'x',containment: 'parent',revert:'invalid'})
+
+ $('#drop').droppable({
+ drop: unlockSpring
+ });
+
+
+
+
+ $('#drag').draggable({
+ axis: 'x',
+ distance: 20,
+ start:function(){
+ window['_dragStart'] = $('#drag').css('left');
+ },
+ stop:function(){
+ window['_dragEnd'] = $('#drag').css('left');
+ if(parseInt(window['_dragStart']) < parseInt(window['_dragEnd'])){
+ if(_page > 0){
+ slideToPage(_page - 1);
+ }else{
+ slideToPage(_page);
+ }
+ }else{
+ if(_page < _pages){
+ slideToPage(_page + 1);
+ }else{
+ slideToPage(_page);
+ }
+ }
+
+ }
+ });
+ //add left and right keys to navigate to pages for convenience
+ $(document).keydown(function(e){
+ if(e.keyCode == 39){
+ slideToPage(_page+1);
+ }else if(e.keyCode == 37){
+ slideToPage(_page-1);
+ }
+ });
+ });
+
+function slideToPage(page){
+ if(canScroll && page >= 0 && page <= _pages){
+ canScroll = false; $('#drag').draggable('disable');
+ $('#pages li').removeClass('active').eq(page).addClass('active');
+ if(page == 0){
+ $('#black,.corner').animate({opacity:1},300,"easeOutQuad",function(){$('#search').focus();});
+ }
+ else{
+ $('#black,.corner').animate({opacity:0},100,"easeOutQuad");
+ }
+ $('#general_wrap').scrollTo('#page'+page,800,{
+ "easing":'easeOutQuint',
+ onAfter : function(){
+ canScroll = true;
+ $('#drag').draggable('enable');
+ _page = page;
+ }
+
+ });
+
+ }
+};
+function unlockSpring() {
+ $('#general_wrap').scrollTo('#page'+1,0);
+ $('#lockscreen').addClass('hidden').delay(200).fadeOut();
+ $('#content').removeClass('hide_spring');
+ $('#slider').css('left', 0);
+ animateDock('in');
+}
+function homeBtnClick(){
+ if($('.asleep')){
+ $('.asleep').removeClass('asleep').removeClass('hidden');
+ }
+ if($('body').hasClass('editMode')){
+ //destroy sortable
+ $('body').removeClass('editMode');
+ $('.apps').sortable('destroy');
+ }else if($('#window').is('.out')){
+ closeApp();
+ }
+ else{
+ $('#drag').css('left',0);
+ slideToPage(1); //go back home
+ }
+};
+function edit_mode(){
+ can_run_apps = false;
+ clearTimeout(intervall);
+
+ $('body').addClass('editMode');
+ $('.apps').sortable({
+ revert : true,
+ handle : '.app_logo',
+ connectWith: '.apps',
+ appendTo: '#content',
+ helper: 'clone',
+ distance: 0,
+ over: function(event, ui) {
+ if($(ui.placeholder).parents('#drag').length)
+ slideToPage($('#drag ul').index($(ui.placeholder).parent()));
+ },
+ change: function(event, ui){
+ $(ui.placeholder).animate({width:75,'margin-right':50,'margin-left':50},150);
+ },
+ start: function(event, ui) {
+ $(ui.placeholder).animate({width:1,'margin-right':0,'margin-left':0,overflow:'hidden'},150);
+ },
+ stop: function(event, ui) {
+ reflectDock();
+ $(ui.item).removeClass('mousedown');
+ }
+ });
+
+ window.clearInterval(intervall);
+
+};
+//css "reflection" hehe
+function reflectDock(){
+ $('.reflection').remove();
+ $('#dock li .app_logo').each(function(){
+ $(this).clone().addClass('reflection').appendTo($(this).parent());
+ })
+}
+//define custom animation based on app icon location. so Icons spead out like in iOS
+function animateDock(mode){
+ $('#page'+_page+'.apps li').each(function(){
+ _origLeft = $(this).position().left;
+ _origTop = $(this).position().top;
+ switch(_origLeft){
+ case 0:
+ case -200:
+ _newLeft = -200;
+ break;
+ case 174:
+ case -250:
+ _newLeft = -250;
+ break;
+ case 348:
+ case 0:
+ _newLeft = 0;
+ break;
+ case 522:
+ case 250:
+ _newLeft = 250;
+ break;
+ case 696:
+ case 200:
+ _newLeft = 200;
+ break;
+ }
+ switch(_origTop){
+ case 10:
+ case -200:
+ _newTop = -200;
+ break;
+ case 139:
+ case -250:
+ _newTop = -250;
+ break;
+ case 268:
+ case 250:
+ _newTop = +250;
+ break;
+ case 397:
+ case 200:
+ _newTop = +200;
+ break;
+ }
+
+ switch(mode)
+ {
+ case 'in':
+ $(this)
+ .css({'left':(_newLeft),'top':(_newTop),'position':'relative'})
+ .animate({'left':0,'top':0},500,'easeOutQuad');
+ break;
+ case 'outin':
+ $(this)
+ .animate({'left':0,'top':0},500,'easeOutQuad');
+ break;
+ default:
+ $(this).css({'position':'relative'})
+ .animate({'left':(_newLeft),'top':(_newTop)},500,'easeOutQuad');
+ break;
+ }
+ })
+ switch(mode)
+ {
+ case 'out':
+ $('#dock,#pages')
+ .animate({'bottom':-120},500,'easeOutQuad');
+ break;
+ case 'in':
+ case 'outin':
+ $('#dock').animate({'bottom':0},500,'easeOutQuad');
+ $('#pages').animate({'bottom':120},500,'easeOutQuad');
+ break;
+ }
+}
+function closeApp(){
+ $('#window').removeClass('out').stop().html('').animate({left:"50%",width:1,top:"50%",height: 1,opacity:0},'easeInQuint');
+ animateDock('outin');
+ $('.topbar').removeClass('inapp');
+}
+function launchApp(app_id){
+ animateDock('out');
+ _appToLaunch = '?appid='+app_id || null;
+ $('#window').addClass('out')
+ .stop()
+ .html('<iframe src="app.html'+_appToLaunch+'" scrolling="no" width="884" height="641"></iframe>')
+ .animate({left:"0%",width:884,top:"0%",height:662,opacity:1},'easeInQuint');
+ $('.topbar').addClass('inapp');
+}
View
0 js/jquery-1.4.2.min.js → js/jquery-1.4.4.min.js
File renamed without changes.
View
223 js/jquery.ui.ipad.js
@@ -0,0 +1,223 @@
+/**
+* jQuery.UI.iPad plugin
+* Copyright (c) 2010 Stephen von Takach
+* licensed under MIT.
+* Date: 27/8/2010
+*
+* Project Home:
+* http://code.google.com/p/jquery-ui-for-ipad-and-iphone/
+*/
+
+
+$(function() {
+ //
+ // Extend jQuery feature detection
+ //
+ $.extend($.support, {
+ touch: typeof Touch == "object"
+ });
+
+ //
+ // Hook up touch events
+ //
+ if ($.support.touch) {
+ document.addEventListener("touchstart", iPadTouchHandler, false);
+ document.addEventListener("touchmove", iPadTouchHandler, false);
+ document.addEventListener("touchend", iPadTouchHandler, false);
+ document.addEventListener("touchcancel", iPadTouchHandler, false);
+ }
+});
+
+
+var lastTap = null; // Holds last tapped element (so we can compare for double tap)
+var tapValid = false; // Are we still in the .6 second window where a double tap can occur
+var tapTimeout = null; // The timeout reference
+
+function cancelTap() {
+ tapValid = false;
+}
+
+
+var rightClickPending = false; // Is a right click still feasible
+var rightClickEvent = null; // the original event
+var holdTimeout = null; // timeout reference
+var cancelMouseUp = false; // prevents a click from occuring as we want the context menu
+
+
+function cancelHold() {
+ if (rightClickPending) {
+ window.clearTimeout(holdTimeout);
+ rightClickPending = false;
+ rightClickEvent = null;
+ }
+}
+
+function startHold(event) {
+ if (rightClickPending)
+ return;
+
+ rightClickPending = true; // We could be performing a right click
+ rightClickEvent = (event.changedTouches)[0];
+ holdTimeout = window.setTimeout("doRightClick();", 800);
+}
+
+
+function doRightClick() {
+ rightClickPending = false;
+
+ //
+ // We need to mouse up (as we were down)
+ //
+ var first = rightClickEvent,
+ simulatedEvent = document.createEvent("MouseEvent");
+ simulatedEvent.initMouseEvent("mouseup", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
+ false, false, false, false, 0, null);
+ first.target.dispatchEvent(simulatedEvent);
+
+ //
+ // emulate a right click
+ //
+ simulatedEvent = document.createEvent("MouseEvent");
+ simulatedEvent.initMouseEvent("mousedown", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
+ false, false, false, false, 2, null);
+ first.target.dispatchEvent(simulatedEvent);
+
+ //
+ // Show a context menu
+ //
+ simulatedEvent = document.createEvent("MouseEvent");
+ simulatedEvent.initMouseEvent("contextmenu", true, true, window, 1, first.screenX + 50, first.screenY + 5, first.clientX + 50, first.clientY + 5,
+ false, false, false, false, 2, null);
+ first.target.dispatchEvent(simulatedEvent);
+
+
+ //
+ // Note:: I don't mouse up the right click here however feel free to add if required
+ //
+
+
+ cancelMouseUp = true;
+ rightClickEvent = null; // Release memory
+}
+
+
+//
+// mouse over event then mouse down
+//
+function iPadTouchStart(event) {
+ var touches = event.changedTouches,
+ first = touches[0],
+ type = "mouseover",
+ simulatedEvent = document.createEvent("MouseEvent");
+ //
+ // Mouse over first - I have live events attached on mouse over
+ //
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
+ false, false, false, false, 0, null);
+ first.target.dispatchEvent(simulatedEvent);
+
+ type = "mousedown";
+ simulatedEvent = document.createEvent("MouseEvent");
+
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
+ false, false, false, false, 0, null);
+ first.target.dispatchEvent(simulatedEvent);
+
+
+ if (!tapValid) {
+ lastTap = first.target;
+ tapValid = true;
+ tapTimeout = window.setTimeout("cancelTap();", 600);
+ startHold(event);
+ }
+ else {
+ window.clearTimeout(tapTimeout);
+
+ //
+ // If a double tap is still a possibility and the elements are the same
+ // Then perform a double click
+ //
+ if (first.target == lastTap) {
+ lastTap = null;
+ tapValid = false;
+
+ type = "click";
+ simulatedEvent = document.createEvent("MouseEvent");
+
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
+ false, false, false, false, 0/*left*/, null);
+ first.target.dispatchEvent(simulatedEvent);
+
+ type = "dblclick";
+ simulatedEvent = document.createEvent("MouseEvent");
+
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
+ false, false, false, false, 0/*left*/, null);
+ first.target.dispatchEvent(simulatedEvent);
+ }
+ else {
+ lastTap = first.target;
+ tapValid = true;
+ tapTimeout = window.setTimeout("cancelTap();", 600);
+ startHold(event);
+ }
+ }
+}
+
+function iPadTouchHandler(event) {
+ var type = "",
+ button = 0; /*left*/
+
+ if (event.touches.length > 1)
+ return;
+
+ switch (event.type) {
+ case "touchstart":
+ if ($(event.changedTouches[0].target).is("select")) {
+ return;
+ }
+ iPadTouchStart(event); /*We need to trigger two events here to support one touch drag and drop*/
+ event.preventDefault();
+ return false;
+ break;
+
+ case "touchmove":
+ cancelHold();
+ type = "mousemove";
+ event.preventDefault();
+ break;
+
+ case "touchend":
+ if (cancelMouseUp) {
+ cancelMouseUp = false;
+ event.preventDefault();
+ return false;
+ }
+ cancelHold();
+ type = "mouseup";
+ break;
+
+ default:
+ return;
+ }
+
+ var touches = event.changedTouches,
+ first = touches[0],
+ simulatedEvent = document.createEvent("MouseEvent");
+
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
+ false, false, false, false, button, null);
+
+ first.target.dispatchEvent(simulatedEvent);
+
+ if (type == "mouseup" && tapValid && first.target == lastTap) { // This actually emulates the ipads default behaviour (which we prevented)
+ simulatedEvent = document.createEvent("MouseEvent"); // This check avoids click being emulated on a double tap
+
+ simulatedEvent.initMouseEvent("click", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
+ false, false, false, false, button, null);
+
+ first.target.dispatchEvent(simulatedEvent);
+ }
+}
+
+
View
1 js/plugins.js
@@ -216,3 +216,4 @@ jQuery.extend({
}
});
+
View
27 js/proxy.js
@@ -0,0 +1,27 @@
+/**
+ * Created by IntelliJ IDEA.
+ * User: Altryne
+ * Date: Nov 22, 2010
+ * Time: 12:40:54 AM
+ * To change this template use File | Settings | File Templates.
+ */
+
+parent.extractTitle();
+
+function load(){
+
+
+ var all = document.getElementsByTagName("a");
+ for (var i=0;i<all.length;i++) {
+ all[i].onclick = liClickHandler;
+ }
+
+}
+
+function liClickHandler(e)
+ {
+ alert('cliiiick');
+ parent.navigate(this.href);
+ return false;
+ }
+
View
3 maps.php
@@ -8,7 +8,8 @@
#map_canvas { height: 100%;width:100%; }
</style>
<!-- google and cloudmade maps api -->
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
+ <script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.4.min.js"%3E%3C/script%3E'))</script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<!-- <script type="text/javascript" src="http://tile.cloudmade.com/wml/latest/web-maps-lite.js"></script>-->
View
321 proxy.php
@@ -0,0 +1,321 @@
+<?PHP
+error_reporting(0);
+// Script: Simple PHP Proxy: Get external HTML, JSON and more!
+//
+// *Version: 1.6, Last updated: 1/24/2009*
+//
+// Project Home - http://benalman.com/projects/php-simple-proxy/
+// GitHub - http://github.com/cowboy/php-simple-proxy/
+// Source - http://github.com/cowboy/php-simple-proxy/raw/master/ba-simple-proxy.php
+//
+// About: License
+//
+// Copyright (c) 2010 "Cowboy" Ben Alman,
+// Dual licensed under the MIT and GPL licenses.
+// http://benalman.com/about/license/
+//
+// About: Examples
+//
+// This working example, complete with fully commented code, illustrates one way
+// in which this PHP script can be used.
+//
+// Simple - http://benalman.com/code/projects/php-simple-proxy/examples/simple/
+//
+// About: Release History
+//
+// 1.6 - (1/24/2009) Now defaults to JSON mode, which can now be changed to
+// native mode by specifying ?mode=native. Native and JSONP modes are
+// disabled by default because of possible XSS vulnerability issues, but
+// are configurable in the PHP script along with a url validation regex.
+// 1.5 - (12/27/2009) Initial release
+//
+// Topic: GET Parameters
+//
+// Certain GET (query string) parameters may be passed into ba-simple-proxy.php
+// to control its behavior, this is a list of these parameters.
+//
+// url - The remote URL resource to fetch. Any GET parameters to be passed
+// through to the remote URL resource must be urlencoded in this parameter.
+// mode - If mode=native, the response will be sent using the same content
+// type and headers that the remote URL resource returned. If omitted, the
+// response will be JSON (or JSONP). <Native requests> and <JSONP requests>
+// are disabled by default, see <Configuration Options> for more information.
+// callback - If specified, the response JSON will be wrapped in this named
+// function call. This parameter and <JSONP requests> are disabled by
+// default, see <Configuration Options> for more information.
+// user_agent - This value will be sent to the remote URL request as the
+// `User-Agent:` HTTP request header. If omitted, the browser user agent
+// will be passed through.
+// send_cookies - If send_cookies=1, all cookies will be forwarded through to
+// the remote URL request.
+// send_session - If send_session=1 and send_cookies=1, the SID cookie will be
+// forwarded through to the remote URL request.
+// full_headers - If a JSON request and full_headers=1, the JSON response will
+// contain detailed header information.
+// full_status - If a JSON request and full_status=1, the JSON response will
+// contain detailed cURL status information, otherwise it will just contain
+// the `http_code` property.
+//
+// Topic: POST Parameters
+//
+// All POST parameters are automatically passed through to the remote URL
+// request.
+//
+// Topic: JSON requests
+//
+// This request will return the contents of the specified url in JSON format.
+//
+// Request:
+//
+// > ba-simple-proxy.php?url=http://example.com/
+//
+// Response:
+//
+// > { "contents": "<html>...</html>", "headers": {...}, "status": {...} }
+//
+// JSON object properties:
+//
+// contents - (String) The contents of the remote URL resource.
+// headers - (Object) A hash of HTTP headers returned by the remote URL
+// resource.
+// status - (Object) A hash of status codes returned by cURL.
+//
+// Topic: JSONP requests
+//
+// This request will return the contents of the specified url in JSONP format
+// (but only if $enable_jsonp is enabled in the PHP script).
+//
+// Request:
+//
+// > ba-simple-proxy.php?url=http://example.com/&callback=foo
+//
+// Response:
+//
+// > foo({ "contents": "<html>...</html>", "headers": {...}, "status": {...} })
+//
+// JSON object properties:
+//
+// contents - (String) The contents of the remote URL resource.
+// headers - (Object) A hash of HTTP headers returned by the remote URL
+// resource.
+// status - (Object) A hash of status codes returned by cURL.
+//
+// Topic: Native requests
+//
+// This request will return the contents of the specified url in the format it
+// was received in, including the same content-type and other headers (but only
+// if $enable_native is enabled in the PHP script).
+//
+// Request:
+//
+// > ba-simple-proxy.php?url=http://example.com/&mode=native
+//
+// Response:
+//
+// > <html>...</html>
+//
+// Topic: Notes
+//
+// * Assumes magic_quotes_gpc = Off in php.ini
+//
+// Topic: Configuration Options
+//
+// These variables can be manually edited in the PHP file if necessary.
+//
+// $enable_jsonp - Only enable <JSONP requests> if you really need to. If you
+// install this script on the same server as the page you're calling it
+// from, plain JSON will work. Defaults to false.
+// $enable_native - You can enable <Native requests>, but you should only do
+// this if you also whitelist specific URLs using $valid_url_regex, to avoid
+// possible XSS vulnerabilities. Defaults to false.
+// $valid_url_regex - This regex is matched against the url parameter to
+// ensure that it is valid. This setting only needs to be used if either
+// $enable_jsonp or $enable_native are enabled. Defaults to '/.*/' which
+// validates all URLs.
+//
+// ############################################################################
+
+// Change these configuration options if needed, see above descriptions for info.
+$enable_jsonp = false;
+$enable_native = true;
+$valid_url_regex = '/.*/';
+
+// ############################################################################
+
+//$url1 = "http://alexw.me/wp-content/themes/WpStream/css/screen.css";
+//$url2 = "/wp-content/themes/WpStream/css/screen.css";
+//
+//die(print_r(rel2abs($url2,'http://alexw.me')));
+
+$url = $_GET['url'];
+
+if ( !$url ) {
+
+ // Passed url not specified.
+ $contents = 'ERROR: url not specified';
+ $status = array( 'http_code' => 'ERROR' );
+
+} else if ( !preg_match( $valid_url_regex, $url ) ) {
+
+ // Passed url doesn't match $valid_url_regex.
+ $contents = 'ERROR: invalid url';
+ $status = array( 'http_code' => 'ERROR' );
+
+} else {
+
+ //cache
+ $filename = 'safari_cache/'.urlencode(str_replace(Array('http:','https:','www','/'),'',$url)).'.html';
+// die(print_r(file_exists($filename),true));
+ if (file_exists($filename)) { //check if cache file exists
+ $now = time();
+ $file_cache_date = filemtime($filename);
+ $time_difference = ($now - $file_cache_date) / 60 / 60; //in hours
+
+ if($time_difference < 5 && !isset($_REQUEST['cc']) && strpos('alexw.me',$url) === false ){
+ die(file_get_contents($filename));
+ die(file_get_html($filename));
+ }
+ }
+
+ $ch = curl_init( $url );
+
+ if ( strtolower($_SERVER['REQUEST_METHOD']) == 'post' ) {
+ curl_setopt( $ch, CURLOPT_POST, true );
+ curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST );
+ }
+
+ if ( $_GET['send_cookies'] ) {
+ $cookie = array();
+ foreach ( $_COOKIE as $key => $value ) {
+ $cookie[] = $key . '=' . $value;
+ }
+ if ( $_GET['send_session'] ) {
+ $cookie[] = SID;
+ }
+ $cookie = implode( '; ', $cookie );
+
+ curl_setopt( $ch, CURLOPT_COOKIE, $cookie );
+ }
+
+ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
+ curl_setopt( $ch, CURLOPT_HEADER, true );
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
+
+ curl_setopt( $ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] );
+
+
+// $response = preg_split( '/(<!doctype|<!DOCTYPE|\<html)/', curl_exec( $ch ));
+ $response = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ));
+ $response = preg_split( '/([\r\n][\r\n]){2}/', curl_exec( $ch ),2);
+ $header = $response[0];
+ $contents = $response[1];
+
+ $status = curl_getinfo( $ch );
+
+ curl_close( $ch );
+}
+
+// Split header text into an array.
+$header_text = preg_split( '/[\r\n]+/', $header );
+
+if ( $_GET['mode'] == 'native' ) {
+ if ( !$enable_native ) {
+ $contents = 'ERROR: invalid mode';
+ $status = array( 'http_code' => 'ERROR' );
+ }
+
+ // Propagate headers to response.
+ $html =false;
+ foreach ( $header_text as $header ) {
+ if ( preg_match( '/text\/html/i', $header ) ) {
+ $html =true;
+ }
+ if ( preg_match( '/^(?:Content-Type|Content-Language|Set-Cookie):/i', $header ) ) {
+ header( $header );
+ }
+
+ }
+
+ $contents = preg_replace('/url\((["|\']?(.*)["|\']?)\)/i','url('.rel2abs('${1}',$url).')',$contents);
+ $contents = preg_replace('/href=\"([^\"]*)\"/ie',"'href=\"'.rel2abs('\\1','$url').'\"'",$contents);
+ $contents = preg_replace('/src=\"([^\"]*)\"/ie',"'src=\"'.rel2abs('\\1','$url').'\"'",$contents);
+
+ $contents = preg_replace('/(<\/head>)/i','<script type="text/javascript" src="js/proxy.js"></script>${1}',$contents);
+ $contents = preg_replace('/<object?.*width="(.*?)".*object>/smi','<div style="width:$1px;min-height:150px;background:#fff url(img/flash_lego_block.png) 50% 50% no-repeat"></div>', $contents);
+
+ $contents = preg_replace('/(<body)/i','<body onload="load()"',$contents);
+
+ //write to cache
+
+ if($html){
+ $fh = fopen($filename, 'w') or die('something went terribly wrong');
+ fwrite($fh, $contents);
+ fclose($fh);
+ }
+ print $contents;
+
+} else {
+
+ // $data will be serialized into JSON data.
+ $data = array();
+
+ // Propagate all HTTP headers into the JSON data object.
+ if ( $_GET['full_headers'] ) {
+ $data['headers'] = array();
+
+ foreach ( $header_text as $header ) {
+ preg_match( '/^(.+?):\s+(.*)$/', $header, $matches );
+ if ( $matches ) {
+ $data['headers'][ $matches[1] ] = $matches[2];
+ }
+ }
+ }
+
+ // Propagate all cURL request / response info to the JSON data object.
+ if ( $_GET['full_status'] ) {
+ $data['status'] = $status;
+ } else {
+ $data['status'] = array();
+ $data['status']['http_code'] = $status['http_code'];
+ }
+
+ // Set the JSON data object contents, decoding it from JSON if possible.
+ $decoded_json = json_decode( $contents );
+ $data['contents'] = $decoded_json ? $decoded_json : $contents;
+
+ // Generate appropriate content-type header.
+ $is_xhr = strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
+ header( 'Content-type: application/' . ( $is_xhr ? 'json' : 'x-javascript' ) );
+
+ // Get JSONP callback.
+ $jsonp_callback = $enable_jsonp && isset($_GET['callback']) ? $_GET['callback'] : null;
+
+ // Generate JSON/JSONP string
+ $json = json_encode( $data );
+
+ print $jsonp_callback ? "$jsonp_callback($json)" : $json;
+
+}
+
+
+function rel2abs($rel, $base)
+{
+ if (parse_url($rel, PHP_URL_SCHEME) != '') return $rel;
+
+ if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel;
+ extract(parse_url($base));
+
+ $path = preg_replace('#/[^/]*$#', '', $path);
+
+ if ($rel[0] == '/') $path = '';
+
+ $abs = "$host$path/$rel";
+
+ /* replace '//' or '/./' or '/foo/../' with '/' */
+ $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#');
+ for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {}
+
+ return $scheme.'://'.$abs;
+}
+?>
+
View
159 safari.php
@@ -0,0 +1,159 @@
+<!DOCTYPE html>
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <title>Ipad simulator</title>
+ <meta name="description" content="This is a jquery iPad simulator, this is only an experiment o what can be done with javascript in ast browsers">
+ <meta name="keywords" content="Ipad, ipad simulator, apple ipad, alexw.me, altryne, alex wolkov, ipad javascript simulator">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link rel="stylesheet" href="style/grid.css" type="text/css" media="screen"/>
+ <link rel="stylesheet" href="style/main.css" type="text/css" media="screen"/>
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
+ <script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery-1.4.4.min.js"%3E%3C/script%3E'))</script>
+
+ <script type="text/javascript" src="js/cookies.js"></script>
+<!-- <script type="text/javascript" src="js/safari.js"></script>-->
+ <script type="text/javascript">
+ var cur_tab = (getCookie('tab')) ? getCookie('tab') : 0 ;
+ var curr_url = [];
+ var safari_user_agent = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10';
+ $(document).ready(function(){
+ navigate($('#url').val());
+ $('#urlgo').submit(function(){
+ _url = ($('#url').val().indexOf('http://') != -1) ? $('#url').val() : 'http://'+$('#url').val() ;
+ navigate(_url);
+ return false;
+ });
+ $('#searchgo').submit(function(){
+ _search = $('#search').val();
+ navigate('http://www.google.com/search?q='+_search);
+ return false;
+ });
+ $('#tabs').click(function(){
+ openTabs();
+ });
+ $('.tab').bind('click',function(e){
+ _left = $(this).offset().left;
+ _top = $(this).offset().top;
+ cur_tab = $(this).attr('id').replace('tab','');
+ $('#navbar').animate({opacity:1},200);
+ $('#browser_overlay')
+// .css('background-image',$('#tab'+cur_tab).css('background-image'))
+ .css({'z-index':150,left:_left,top:_top,'padding-top':50}).removeClass('small')
+ .animate({
+ left:0,
+ top:0,
+ width: '100%',
+ height: 591
+ },200,'swing',function(){
+ var iframe = $('<iframe name="tab0" src="" width="100%" height="591"></iframe>').attr('src','proxy.php?url='+encodeURI($('#tab'+cur_tab).data('url'))+'&mode=native&user_agent='+safari_user_agent+'&send_cookies=1&send_session=1');
+ $('#url').val($('#tab'+cur_tab).data('url'));
+ $('#browser_overlay').append(iframe);
+ });
+ });
+ });
+ function extractTitle(){
+ cur_tab_title = $('#browser_overlay iframe').contents().find('title').html() || curr_url.replace('http://','').split('/')[0];
+ $('#title').html(cur_tab_title);
+ $('#tab'+cur_tab+' .tabtitle').html(cur_tab_title);
+
+ }
+ function navigate(url){
+ $('#url').val(url);
+ curr_url = $('#url').val();
+
+ $('#browser_overlay iframe').attr('src','proxy.php?url='+encodeURI(url)+'&mode=native&user_agent='+safari_user_agent+'&send_cookies=1&send_session=1');
+
+ }
+ function openTabs(){
+
+// $('#browser_overlay').find('iframe').hide().end().css('background-image',thumb);
+// $('#tab'+cur_tab).css('background-image',thumb);
+ $('#navbar').animate({opacity:0},200);
+ _left = $('#tab'+cur_tab).offset().left;
+ _top = $('#tab'+cur_tab).offset().top;
+ $('#browser_overlay').addClass('small').animate({
+ left:_left,
+ top:_top,
+ width: 265,
+ height: 170,
+ 'padding-top':0
+ },200,'swing',function(){
+ $(this).css('z-index',50);
+ $('#tab'+cur_tab).data('url',curr_url).find('iframe').attr('src','proxy.php?url='+encodeURI(curr_url)+'&mode=native&user_agent='+safari_user_agent+'&send_cookies=1&send_session=1');
+ $('#browser_overlay').find('iframe').remove();
+ });
+ }
+ </script>
+ </head>
+ <body>
+ <div id="safari">
+ <div id="navbar">
+ <div id="title"> Untitled </div>
+ <div id="back" class="icon">&lt;</div>
+ <div id="forward" class="icon">&gt;</div>
+ <div id="tabs" class="icon">0</div>
+ <div id="bookmarks" class="icon">book</div>
+ <div id="add" class="icon">+</div>
+ <div id="urlCont">
+ <form id="urlgo">
+ <input type="text" id="url" value="http://www.alexw.me"/>
+ </form>
+ <div id="refresh">R</div>
+ <div id="stop">S</div>
+ </div>
+ <div id="searchCont">
+ <form id="searchgo">
+ <input type="text" id="search"/>
+ </form>
+ </div>
+ </div>
+ <div id="tabs_cont">
+ <div id="browser_overlay">
+
+ <iframe src="" width="884" height="591" scrolling="no"></iframe>
+ </div>
+ <div id="tab0" class="tab">
+ <div class="iframe_overlay"></div>
+ <iframe src="" width="884" height="591" scrolling="no"></iframe>
+ <div class="tabtitle">Untitled</div>
+ </div>
+ <div id="tab1" class="tab">
+ <div class="iframe_overlay"></div>
+ <iframe src="" width="884" height="591" scrolling="no"></iframe>
+ <div class="tabtitle">Untitled</div>
+ </div>
+ <div id="tab2" class="tab">
+ <div class="iframe_overlay"></div>
+ <iframe src="" width="884" height="591" scrolling="no"></iframe>
+ <div class="tabtitle">Untitled</div>
+ </div>
+ <div id="tab3" class="tab">
+ <div class="iframe_overlay"></div>
+ <iframe src="" width="884" height="591" scrolling="no"></iframe>
+ <div class="tabtitle">Untitled</div>
+ </div>
+ <div id="tab4" class="tab">
+ <div class="iframe_overlay"></div>
+ <iframe src="" width="884" height="591" scrolling="no"></iframe>
+ <div class="tabtitle">Untitled</div>
+ </div>
+ <div id="newtab" class="tab100">
+ <div class="iframe_overlay"></div>
+ <div class="tabtitle">New Page</div>
+ </div>
+ </div>
+
+ </div>
+
+ <script>
+ var _gaq = [['_setAccount', 'UA-7437527-1'], ['_trackPageview']];
+ (function(d, t) {
+ var g = d.createElement(t),
+ s = d.getElementsByTagName(t)[0];
+ g.async = true;
+ g.src = ('https:' == location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ s.parentNode.insertBefore(g, s);
+ })(document, 'script');
+ </script>
+</body>
+</html>
View
1 safari_cache/.htaccess
@@ -0,0 +1 @@
+deny from all
View
9 style/ipad.css
@@ -352,6 +352,10 @@ li {
line-height:20px;
z-index:600;
}
+.topbar.inapp{
+ z-index:3000;
+ background-color:#000;
+}
.time,.percentage{
font-size:12px;
color:#fff;
@@ -452,4 +456,9 @@ li {
background:#000;
z-index:2000;
opacity:0;
+}
+
+iframe{
+ border:0;
+ margin-top:17px;
}
View
182 style/main.css
@@ -182,4 +182,184 @@ h1 a{
button{
font-size:16px;
}
-/*canvas end*/
+/*canvas end*/
+
+
+/*
+safari app for ipad simulator
+*/
+#safari{
+ background:#000;
+ width:100%;
+}
+#safari iframe{
+ border:0;
+ -webkit-border-radius:0 0 10px 10px;
+ -moz-border-radius:0 0 10px 10px;
+ border-radius:0 0 10px 10px;
+}
+#navbar{
+ height:50px;
+ background:-webkit-gradient(linear,left bottom,left top,color-stop(0, rgb(191,195,203)),color-stop(1, rgb(245,245,247)));
+ background:-moz-linear-gradient( center bottom, rgb(191,195,203) 0%, rgb(245,245,247) 100%);
+ -webkit-border-radius:10px 10px 0 0;
+ -moz-border-radius:10px 10px 0 0;
+ padding:0 1.5%;
+ border-bottom:1px solid #3f3f3f;
+ position:relative;
+ z-index:200;
+}
+#navbar.hidden{
+ display:none;
+}
+#title{
+ text-align:center;
+ font-size:12px;
+ font-weight:bold;
+ line-height:15px;
+ height:15px;
+ color:#656565;
+}
+.icon{
+ width:4%;
+ margin-right:1%;
+ float:left;
+ line-height:30px;
+ background:url(../img/safari_sprites.png) left 5px no-repeat;
+ text-indent:-9999px;
+ cursor:pointer;
+}
+#back{
+ background-position:left -93px;
+ opacity:0.3;
+}
+#forward{
+ background-position:left -191px;
+ opacity:0.3;
+}
+#bookmarks{
+ background-position:left -387px;
+ opacity:0.3;
+}
+#tabs{
+ background-position:left -484px;
+ color:#fff;
+ font-size:11px;
+ text-indent:10px;
+ line-height:34px;
+ font-weight:bold;
+}
+#urlCont,#searchCont{
+ width:50%;
+ margin-top:4px;
+ float:left;
+ background:#fff;
+ -webkit-border-radius:3px;
+ -moz-border-radius:3px;
+ border-radius:3px;
+ -webkit-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.8);
+ -moz-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.8);
+ box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.8);
+ padding:2px 8px;
+ position:relative;
+ cursor:pointer;
+}
+#searchCont{
+ width:19%;
+ margin-left:2%;
+ -webkit-border-radius:10px;
+ -moz-border-radius:10px;
+ border-radius:10px;
+
+}
+#urlCont input,#searchCont input{
+ border:0;
+ float:left;
+ width:98%;
+}
+#refresh,#stop{
+ position:absolute;
+ top:-1px;right:0;
+ height:22px;
+ width:22px;
+ background:url(../img/safari_sprites.png) left -291px no-repeat;
+ text-indent:-9999px;
+}
+#tabs_cont{
+ background:#000;
+ overflow:hidden;
+}
+
+.tab{
+ z-index:100;
+ /*display:none;*/
+ background:#fff;
+ float:left;
+ width:30%;
+ margin:0 2% 40px;
+ height:170px;
+ -webkit-border-radius:3px;
+ -moz-border-radius:3px;
+ border-radius:3px;
+ position:relative;
+ cursor:pointer;
+}
+.iframe_overlay{
+ position:absolute;
+ z-index:95;
+ left:0;top:0;
+ height:100%;width:100%;
+ background:#fff;
+ opacity:0;
+}
+.tab:nth-child(3n+1){
+ margin:0 5px 40px 20px;
+}
+.tab:nth-child(3n+2){
+ margin:0 20px 40px 5px;
+}
+.tab iframe{
+ -webkit-transform: scale(0.3, 0.29);
+ -moz-transform: scale(0.3, 0.29);
+ transform: scale(0.3, 0.29);
+ -moz-transform-origin:0 0;
+ -webkit-transform-origin:0 0;
+ transform-origin:0 0;
+ position:relative;
+ z-index:90;
+ -webkit-border-radius:3px;
+ -moz-border-radius:3px;
+ border-radius:3px;
+}
+.tabtitle{
+ color:#fff;
+ width:100%;
+ position:absolute;
+ left:0;
+ text-align:center;
+ bottom:-15px;
+ font-weight:bold;
+ font-size:12px;
+}
+#browser_overlay{
+ position:absolute;
+ left:0;top:0;
+ padding-top:50px;
+ width:100%;
+ height:591px;
+ background-color:#fff;
+ z-index:150;
+ -webkit-background-size: 100% 100%;
+ -moz-background-size: 100% 100%;
+ -o-background-size: 100% 100%;
+ background-size: 100% 100%;
+ background-repeat:no-repeat;
+}
+#browser_overlay.small{
+ -webkit-border-radius:3px;
+ -moz-border-radius:3px;
+ border-radius:3px;
+}
+#browser_overlay.small iframe{
+ display:none;
+}

0 comments on commit 4080d50

Please sign in to comment.
Something went wrong with that request. Please try again.