diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-04-10 20:10:07 -0400 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-04-10 20:10:07 -0400 |
commit | ac2d14101cc15d62d238c1299eb02e341c2e0c07 (patch) | |
tree | 1b6890fe756637df1183930ab9ae8f5f2c0c9070 /core | |
parent | 64d3301523dce1032f7e20f03452573c125f8b17 (diff) | |
parent | 9f547a1b3987838fda8db238a8999c9f474bb542 (diff) | |
download | nextcloud-server-ac2d14101cc15d62d238c1299eb02e341c2e0c07.tar.gz nextcloud-server-ac2d14101cc15d62d238c1299eb02e341c2e0c07.zip |
Merge branch 'master' into calendar_sharing
Diffstat (limited to 'core')
-rw-r--r-- | core/css/styles.css | 7 | ||||
-rw-r--r-- | core/img/filetypes/application-sgf.png | bin | 0 -> 725 bytes | |||
-rw-r--r-- | core/js/eventsource.js | 12 | ||||
-rw-r--r-- | core/js/js.js | 8 | ||||
-rw-r--r-- | core/js/oc-dialogs.js | 122 | ||||
-rw-r--r-- | core/js/oc-vcategories.js | 4 | ||||
-rw-r--r-- | core/lostpassword/index.php | 2 | ||||
-rw-r--r-- | core/templates/login.php | 2 |
8 files changed, 131 insertions, 26 deletions
diff --git a/core/css/styles.css b/core/css/styles.css index 720fe578b92..e5380b1b6b0 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -131,3 +131,10 @@ li.error { width:640px; margin:4em auto; padding:1em 1em 1em 4em; background:#ff .separator { display: inline; border-left: 1px solid #d3d3d3; border-right: 1px solid #fff; height: 10px; width:0px; margin: 4px; } a.bookmarklet { background-color: #ddd; border:1px solid #ccc; padding: 5px;padding-top: 0px;padding-bottom: 2px; text-decoration: none; margin-top: 5px } + +/* ---- DIALOGS ---- */ + +#dirtree {width: 100%;} +#filelist {height: 270px; overflow:scroll; background-color: white;} +.filepicker_element_selected { background-color: lightblue;} +.filepicker_loader {height: 120px; width: 100%; background-color: #333; opacity: 0.3; visibility: visible; position:absolute; top:0; left:0; text-align:center; padding-top: 150px;} diff --git a/core/img/filetypes/application-sgf.png b/core/img/filetypes/application-sgf.png Binary files differnew file mode 100644 index 00000000000..f171f5579e7 --- /dev/null +++ b/core/img/filetypes/application-sgf.png diff --git a/core/js/eventsource.js b/core/js/eventsource.js index dece1a69d04..08259e02cae 100644 --- a/core/js/eventsource.js +++ b/core/js/eventsource.js @@ -33,8 +33,12 @@ */ OC.EventSource=function(src,data){ var dataStr=''; - for(name in data){ - dataStr+=name+'='+encodeURIComponent(data[name])+'&'; + this.typelessListeners=[]; + this.listeners={}; + if(data){ + for(name in data){ + dataStr+=name+'='+encodeURIComponent(data[name])+'&'; + } } if(!this.useFallBack && typeof EventSource !='undefined'){ this.source=new EventSource(src+'?'+dataStr); @@ -42,7 +46,7 @@ OC.EventSource=function(src,data){ for(var i=0;i<this.typelessListeners.length;i++){ this.typelessListeners[i](JSON.parse(e.data)); } - } + }.bind(this); }else{ iframeId='oc_eventsource_iframe_'+OC.EventSource.iframeCount; OC.EventSource.fallBackSources[OC.EventSource.iframeCount]=this; @@ -64,7 +68,7 @@ OC.EventSource=function(src,data){ 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.fallBackSources[id].fallBackCallBack(type,data); } OC.EventSource.prototype={ typelessListeners:[], diff --git a/core/js/js.js b/core/js/js.js index df1b5c6ce76..44b4f503b8c 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -126,7 +126,13 @@ OC={ }); } }, - dialogs:OCdialogs + dialogs:OCdialogs, + mtime2date:function(mtime) { + mtime = parseInt(mtime); + var date = new Date(1000*mtime); + var ret = date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear()+', '+date.getHours()+':'+date.getMinutes(); + return ret; + } }; OC.search.customResults={}; OC.search.currentResult=-1; diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index c11ac13332b..a3aa1e8c149 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -17,7 +17,6 @@ * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * - * todo(bartek): add select option in form */ /** @@ -30,9 +29,9 @@ OCdialogs = { * @param title dialog title * @param callback which will be triggered when user press OK */ - alert:function(text, title, callback) { + alert:function(text, title, callback, modal) { var content = '<p><span class="ui-icon ui-icon-alert"></span>'+text+'</p>'; - OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback); + OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal); }, /** * displays info dialog @@ -40,9 +39,9 @@ OCdialogs = { * @param title dialog title * @param callback which will be triggered when user press OK */ - info:function(text, title, callback) { + info:function(text, title, callback, modal) { var content = '<p><span class="ui-icon ui-icon-info"></span>'+text+'</p>'; - OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback); + OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal); }, /** * displays confirmation dialog @@ -50,9 +49,9 @@ OCdialogs = { * @param title dialog title * @param callback which will be triggered when user press YES or NO (true or false would be passed to callback respectively) */ - confirm:function(text, title, callback) { + confirm:function(text, title, callback, modal) { var content = '<p><span class="ui-icon ui-icon-notice"></span>'+text+'</p>'; - OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback); + OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback, modal); }, /** * prompt for user input @@ -60,9 +59,9 @@ OCdialogs = { * @param title dialog title * @param callback which will be triggered when user press OK (input text will be passed to callback) */ - prompt:function(text, title, default_value, callback) { + prompt:function(text, title, default_value, callback, modal) { var content = '<p><span class="ui-icon ui-icon-pencil"></span>'+text+':<br/><input type="text" id="oc-dialog-prompt-input" value="'+default_value+'" style="width:90%"></p>'; - OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback); + OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback, modal); }, /** * prompt user for input with custom form @@ -71,7 +70,7 @@ OCdialogs = { * @param title dialog title * @param callback which will be triggered when user press OK (user answers will be passed to callback in following format: [{name:'return name', value: 'user value'},...]) */ - form:function(fields, title, callback) { + form:function(fields, title, callback, modal) { var content = '<table>'; for (var a in fields) { content += '<tr><td>'+fields[a].text+'</td><td>'; @@ -84,16 +83,63 @@ OCdialogs = { } else content += '>'; } else if (type == 'text' || type == 'password' && fields[a].value) content += ' value="'+fields[a].value+'">'; + } else if (type == 'select') { + content += '<select name="'+fields[a].name+'"'; + if (fields[a].value != undefined) + content += ' value="'+fields[a].value+'"'; + content += '>'; + for (var o in fields[a].options) + content += '<option value="'+fields[a].options[o].value+'">'+fields[a].options[o].text+'</option>'; + content += '</select>'; } - content += "</td></tr>" + content += '</td></tr>'; } - content += "</table>"; - OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback); + content += '</table>'; + OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback, modal); }, - message:function(content, title, dialog_type, buttons, callback) { + filepicker:function(title, callback, multiselect, mimetype_filter, modal) { + var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content'; + var c_id = '#'+c_name; + var d = '<div id="'+c_name+'" title="'+title+'"><select id="dirtree"><option value="0">'+OC.currentUser+'</option></select><div id="filelist"></div><div class="filepicker_loader"><img src="'+OC.filePath('gallery','img','loading.gif')+'"></div></div>'; + if (!modal) modal = false; + if (!multiselect) multiselect = false; + $('body').append(d); + $(c_id + ' #dirtree').focus(function() { var t = $(this); t.data('oldval', t.val())}) + .change({dcid: c_id}, OC.dialogs.handleTreeListSelect); + $(c_id).ready(function(){ + $.getJSON(OC.webroot+'/files/ajax/rawlist.php', {mimetype: mimetype_filter} ,function(r){OC.dialogs.fillFilePicker(r, c_id, callback)}); + }).data('multiselect', multiselect).data('mimetype',mimetype_filter); + // build buttons + var b = [ + {text: t('dialogs', 'Choose'), click: function(){ + if (callback != undefined) { + var p; + if ($(c_id).data('multiselect') == true) { + p = []; + $(c_id+' .filepicker_element_selected #filename').each(function(i, elem) { + p.push(($(c_id).data('path')?$(c_id).data('path'):'')+'/'+$(elem).text()); + }); + } else { + var p = $(c_id).data('path'); + if (p == undefined) p = ''; + p = p+'/'+$(c_id+' .filepicker_element_selected #filename').text() + } + callback(p); + $(c_id).dialog('close'); + } + } + }, + {text: t('dialogs', 'Cancel'), click: function(){$(c_id).dialog('close'); }} + ]; + $(c_id).dialog({width: 4*$(document).width()/9, height: 400, modal: modal, buttons: b}); + OCdialogs.dialogs_counter++; + }, + // guts, dont use, dont touch + message:function(content, title, dialog_type, buttons, callback, modal) { var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content'; var c_id = '#'+c_name; var d = '<div id="'+c_name+'" title="'+title+'">'+content+'</div>'; + if (modal == undefined) modal = false; $('body').append(d); var b = []; switch (buttons) { @@ -107,7 +153,7 @@ OCdialogs = { var f; switch(dialog_type) { case OCdialogs.ALERT_DIALOG: - f = function(){$(c_id).dialog('close'); }; + f = function(){$(c_id).dialog('close'); callback();}; break; case OCdialogs.PROMPT_DIALOG: f = function(){OCdialogs.prompt_ok_handler(callback, c_id)}; @@ -120,7 +166,7 @@ OCdialogs = { break; } var possible_height = ($('tr', d).size()+1)*30; - $(c_id).dialog({width: 4*$(document).width()/9, height: possible_height + 120, modal: false, buttons: b}); + $(c_id).dialog({width: 4*$(document).width()/9, height: possible_height + 120, modal: modal, buttons: b}); OCdialogs.dialogs_counter++; }, // dialogs buttons types @@ -144,7 +190,7 @@ OCdialogs = { if (callback != undefined) { var r = []; var c = 0; - $(c_id + ' input').each(function(i, elem) { + $(c_id + ' input, '+c_id+' select').each(function(i, elem) { r[c] = {name: $(elem).attr('name'), value: OCdialogs.determineValue(elem)}; c++; }); @@ -153,5 +199,47 @@ OCdialogs = { } else { $(c_id).dialog('close'); } + }, + fillFilePicker:function(r, dialog_content_id) { + var entry_template = '<div onclick="javascript:OC.dialogs.handlePickerClick(this, \'*ENTRYNAME*\',\''+dialog_content_id+'\')" data="*ENTRYTYPE*"><img src="*MIMETYPEICON*" style="margin-right:1em;"><span id="filename">*NAME*</span><div style="float:right;margin-right:1em;">*LASTMODDATE*</div></div>'; + var names = ''; + for (var a in r.data) { + names += entry_template.replace('*LASTMODDATE*', OC.mtime2date(r.data[a].mtime)).replace('*NAME*', r.data[a].name).replace('*MIMETYPEICON*', r.data[a].mimetype_icon).replace('*ENTRYNAME*', r.data[a].name).replace('*ENTRYTYPE*', r.data[a].type); + } + $(dialog_content_id + ' #filelist').html(names); + $(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden'); + }, + handleTreeListSelect:function(event) { + var newval = parseInt($(this).val()); + var oldval = parseInt($(this).data('oldval')); + while (newval != oldval && oldval > 0) { + $('option:last', this).remove(); + $('option:last', this).attr('selected','selected'); + oldval--; + } + var skip_first = true; + var path = ''; + $(this).children().each(function(i, element) { if (skip_first) {skip_first = false; return; }path += '/'+$(element).text(); }); + $(event.data.dcid).data('path', path); + $(event.data.dcid + ' .filepicker_loader').css('visibility', 'visible'); + $.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: path, mimetype: $(event.data.dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, event.data.dcid)}); + }, + // this function is in early development state, please dont use it unlsess you know what you are doing + handlePickerClick:function(element, name, dcid) { + var p = $(dcid).data('path'); + if (p == undefined) p = ''; + p = p+'/'+name; + if ($(element).attr('data') == 'file'){ + if ($(dcid).data('multiselect') != true) + $(dcid+' .filepicker_element_selected').removeClass('filepicker_element_selected'); + $(element).toggleClass('filepicker_element_selected'); + return; + } + $(dcid).data('path', p); + $(dcid + ' #dirtree option:last').removeAttr('selected'); + var newval = parseInt($(dcid + ' #dirtree option:last').val())+1; + $(dcid + ' #dirtree').append('<option selected="selected" value="'+newval+'">'+name+'</option>'); + $(dcid + ' .filepicker_loader').css('visibility', 'visible'); + $.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: p, mimetype: $(dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, dcid)}); } }; diff --git a/core/js/oc-vcategories.js b/core/js/oc-vcategories.js index a6dcccf88e0..e3b1abba08d 100644 --- a/core/js/oc-vcategories.js +++ b/core/js/oc-vcategories.js @@ -19,7 +19,7 @@ OCCategories={ height: 350, minHeight:200, width: 250, minWidth: 200, buttons: { 'Delete':function() { - OCCategories.delete(); + OCCategories.doDelete(); }, 'Rescan':function() { OCCategories.rescan(); @@ -53,7 +53,7 @@ OCCategories={ } }); }, - delete:function(){ + doDelete:function(){ var categories = $('#categorylist').find('input[type="checkbox"]').serialize(); categories += '&app=' + OCCategories.app; console.log('OCCategories.delete: ' + categories); diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php index da0428e3ced..a9b7d10804f 100644 --- a/core/lostpassword/index.php +++ b/core/lostpassword/index.php @@ -12,7 +12,7 @@ require_once('../../lib/base.php'); // Someone lost their password: if (isset($_POST['user'])) { if (OC_User::userExists($_POST['user'])) { - $token = sha1($_POST['user']+uniqId()); + $token = sha1($_POST['user'].md5(uniqid(rand(), true))); OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token); $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', ''); if (!empty($email)) { diff --git a/core/templates/login.php b/core/templates/login.php index 82222c82129..4ba92221a7d 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -7,7 +7,7 @@ <?php endif; ?> <p class="infield"> <label for="user" class="infield"><?php echo $l->t( 'Username' ); ?></label> - <input type="text" name="user" id="user" value="<?php echo !empty($_POST['user'])?$_POST['user'].'"':'" autofocus'; ?> autocomplete="off" required /> + <input type="text" name="user" id="user" value="<?php echo !empty($_POST['user'])?htmlentities($_POST['user']).'"':'" autofocus'; ?> autocomplete="off" required /> </p> <p class="infield"> <label for="password" class="infield"><?php echo $l->t( 'Password' ); ?></label> |