From 039bbfde2d2e1efc90fa9828811566ea1f328722 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 29 Jan 2012 17:39:54 +0100 Subject: automatically show advanced options when no sqlite is available --- core/js/setup.js | 12 ++++++++++++ core/templates/installation.php | 3 +++ 2 files changed, 15 insertions(+) (limited to 'core') diff --git a/core/js/setup.js b/core/js/setup.js index 94097785e42..6e056cc90d1 100644 --- a/core/js/setup.js +++ b/core/js/setup.js @@ -1,4 +1,11 @@ +var dbtypes $(document).ready(function() { + dbtypes={ + sqlite:!!$('#hasSQLite').val(), + mysql:!!$('#hasMySQL').val(), + postgresql:!!$('#hasPostgreSQL').val(), + } + $('#selectDbType').buttonset(); $('#datadirContent').hide(250); $('#databaseField').hide(250); @@ -60,4 +67,9 @@ $(document).ready(function() { form.submit(); return false; }); + + if(!dbtypes.sqlite){ + $('#showAdvanced').click(); + $('input[type="radio"]').first().click(); + } }); diff --git a/core/templates/installation.php b/core/templates/installation.php index f1cde6b3904..4558f97bc08 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -1,3 +1,6 @@ +'> +'> +'>
-- cgit v1.2.3 From 45038af948cd07ffc74efc8d4b0282fa11b7de7e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 30 Jan 2012 20:19:51 +0100 Subject: provide small wrapper around server side events and provide a fallback for IE --- core/js/eventsource.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/base.php | 1 + lib/eventsource.php | 73 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 core/js/eventsource.js create mode 100644 lib/eventsource.php (limited to 'core') diff --git a/core/js/eventsource.js b/core/js/eventsource.js new file mode 100644 index 00000000000..422f97657bd --- /dev/null +++ b/core/js/eventsource.js @@ -0,0 +1,94 @@ +/** + * ownCloud + * + * @author Robin Appelman + * @copyright 2012 Robin Appelman icewind1991@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see . + * + */ + +/** + * wrapper for server side events (http://en.wikipedia.org/wiki/Server-sent_events) + * includes a fallback for older browsers and IE + * + * use server side events with causion, to many open requests can hang the server + */ + +OC.EventSource=function(src){ + if(!this.useFallBack && typeof EventSource !='undefined'){ + this.source=new EventSource(src); + this.source.onmessage=function(e){ + for(var i=0;i'); + this.iframe.attr('id',iframeId); + this.iframe.hide(); + this.iframe.attr('src',src+'?fallback=true&fallback_id='+OC.EventSource.iframeCount); + $('body').append(this.iframe); + this.useFallBack=true; + OC.EventSource.iframeCount++ + + } +} +OC.EventSource.fallBackSources=[]; +OC.EventSource.iframeCount=0;//number of fallback iframes +OC.EventSource.fallBackCallBack=function(id,type,data){ + OC.EventSource.fallBackSources[id].fallBackCallBack(type,JSON.parse(data)); +} +OC.EventSource.prototype={ + typelessListeners:[], + iframe:null, + listeners:{},//only for fallback + useFallBack:false, + fallBackCallBack:function(type,data){ + if(type){ + for(var i=0;i. +* +*/ + +/** + * wrapper for server side events (http://en.wikipedia.org/wiki/Server-sent_events) + * includes a fallback for older browsers and IE + * + * use server side events with causion, to many open requests can hang the server + */ +class OC_EventSource{ + private $fallback; + private $fallBackId=0; + + public function __construct(){ + ob_end_clean(); + header('Cache-Control: no-cache'); + $this->fallback=isset($_GET['fallback']) and $_GET['fallback']=='true'; + if($this->fallback){ + $fallBackId=$_GET['fallback_id']; + header("Content-Type: text/html"); + echo str_repeat(''.PHP_EOL,10); //dummy data to keep IE happy + }else{ + header("Content-Type: text/event-stream"); + } + flush(); + + } + + /** + * send a message to the client + * @param string type + * @param object data + * + * if only one paramater is given, a typeless message will be send with that paramater as data + */ + public function send($type,$data=null){ + if(is_null($data)){ + $data=$type; + $type=null; + } + if($this->fallback){ + $response=''.PHP_EOL; + echo $response; + }else{ + if($type){ + echo 'event: '.$type.PHP_EOL; + } + echo 'data: '.json_encode($data).PHP_EOL; + } + echo PHP_EOL; + flush(); + } +} \ No newline at end of file -- cgit v1.2.3 From 6a1121ab2e91a362ed1e13e18c44fca40761f97a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 30 Jan 2012 23:19:43 +0100 Subject: provide server side close option for EventStream --- core/js/eventsource.js | 7 ++++++- lib/eventsource.php | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/js/eventsource.js b/core/js/eventsource.js index 422f97657bd..30b942f59e8 100644 --- a/core/js/eventsource.js +++ b/core/js/eventsource.js @@ -44,8 +44,13 @@ OC.EventSource=function(src){ $('body').append(this.iframe); this.useFallBack=true; OC.EventSource.iframeCount++ - } + //add close listener + this.listen('__internal__',function(data){ + if(data=='close'){ + this.close(); + } + }.bind(this)); } OC.EventSource.fallBackSources=[]; OC.EventSource.iframeCount=0;//number of fallback iframes diff --git a/lib/eventsource.php b/lib/eventsource.php index c123eb4b837..b0450ff3d55 100644 --- a/lib/eventsource.php +++ b/lib/eventsource.php @@ -70,4 +70,11 @@ class OC_EventSource{ echo PHP_EOL; flush(); } + + /** + * close the connection of the even source + */ + public function close(){ + $this->send('__internal__','close');//server side closing can be an issue, let the client do it + } } \ No newline at end of file -- cgit v1.2.3