240921 Paste Upload and Default Visibility
This commit is contained in:
parent
7cdfd4e99e
commit
82e7743091
@ -59,6 +59,10 @@ if (isset($_POST['action']) && $_POST['action'] == "settings"){
|
||||
$user_settings['emoji'] = intval($value);
|
||||
break;
|
||||
|
||||
case "defscope":
|
||||
$user_settings['defscope'] = intval($value);
|
||||
break;
|
||||
|
||||
case "text":
|
||||
$user_settings['text'] = ($value == "on" ? "on" : "off");
|
||||
break;
|
||||
@ -71,6 +75,7 @@ if (isset($_POST['action']) && $_POST['action'] == "settings"){
|
||||
$user_settings['replies'] = ($value == "on" ? "on" : "off");
|
||||
break;
|
||||
|
||||
|
||||
case "reblog":
|
||||
$user_settings['reblog'] = ($value == "on" ? "on" : "off");
|
||||
break;
|
||||
|
@ -393,31 +393,50 @@ $query = http_build_query(array_filter(array(
|
||||
});
|
||||
|
||||
|
||||
/* paste to upload */
|
||||
document.onpaste = function(event){
|
||||
|
||||
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||
/*Make Sure Only One File is Copied*/
|
||||
if (items.length != 1) {
|
||||
return;
|
||||
}
|
||||
var item = items[0];
|
||||
/*Verify If The Copied Item is File*/
|
||||
if (item.kind === 'file') {
|
||||
|
||||
for (var i = 0 ; i < items.length ; i++) {
|
||||
|
||||
var item = items[i];
|
||||
|
||||
if (item.type.indexOf("image") != -1) {
|
||||
|
||||
var file = item.getAsFile();
|
||||
var filename = file.name;
|
||||
/*Get File Extension*/
|
||||
var ext = filename.split('.').reverse()[0].toLowerCase();
|
||||
/*Check Image File Extensions*/
|
||||
if (jQuery.inArray(ext, ['jpg', 'png']) > -1) {
|
||||
/*Create FormData Instance*/
|
||||
var data = new FormData();
|
||||
data.append('file', file);
|
||||
/*Request Ajax With File*/
|
||||
request_ajax_file('upload.php', data, file_uploaded);
|
||||
} else {
|
||||
alert('Invalid File');
|
||||
console.log(file);
|
||||
upload_file_with_ajax(file,file_uploaded);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function upload_file_with_ajax(file, ajax_callback){
|
||||
$("#postform .status").html('<span id="loading" class="animate-spin fontello"></span>');
|
||||
var formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
$.ajax('./upload.php' , {
|
||||
|
||||
type: 'POST',
|
||||
contentType: false,
|
||||
processData: false,
|
||||
data: formData,
|
||||
error: function() {
|
||||
console.log("error");
|
||||
},
|
||||
success: function (response) {
|
||||
if (typeof ajax_callback == 'function') {
|
||||
ajax_callback(response);
|
||||
} else if (typeof ajax_callback == 'string') {
|
||||
if (ajax_callback != '') {
|
||||
eval(ajax_callback + '(response)');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function file_uploaded(data) {
|
||||
if ($("#postform .uploadBox").length < 1){
|
||||
@ -435,26 +454,7 @@ $query = http_build_query(array_filter(array(
|
||||
$("#postform .status").html('');
|
||||
}
|
||||
|
||||
/*Function to Make AJAX Request With File*/
|
||||
function request_ajax_file(ajax_url, ajax_data, ajax_callback) {
|
||||
$("#postform .status").html('<span id="loading" class="animate-spin fontello"></span>');
|
||||
jQuery.ajax({
|
||||
url: ajax_url,
|
||||
data: ajax_data,
|
||||
type: 'POST',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (response) {
|
||||
if (typeof ajax_callback == 'function') {
|
||||
ajax_callback(response);
|
||||
} else if (typeof ajax_callback == 'string') {
|
||||
if (ajax_callback != '') {
|
||||
eval(ajax_callback + '(response)');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function upload_files() {
|
||||
$("#postform .status").html('<span id="loading" class="animate-spin fontello"></span>');
|
||||
|
@ -245,10 +245,10 @@ endif; ?>
|
||||
</span>
|
||||
<span style='float:right;' class="scope">
|
||||
<select name='scope' id='scope'>
|
||||
<option value="1"> Public</option>
|
||||
<option value="2"> Unlisted</option>
|
||||
<option value="3"> Private</option>
|
||||
<option value="4"> Direct</option>
|
||||
<option value="1" <?php echo ($user_settings['defscope'] == '1' ? "selected" : ""); ?>> Public</option>
|
||||
<option value="2" <?php echo ($user_settings['defscope'] == '2' ? "selected" : ""); ?>> Unlisted</option>
|
||||
<option value="3" <?php echo ($user_settings['defscope'] == '3' ? "selected" : ""); ?>> Private</option>
|
||||
<option value="4" <?php echo ($user_settings['defscope'] == '4' ? "selected" : ""); ?>> Direct</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
@ -44,6 +44,17 @@
|
||||
<fieldset>
|
||||
<legend>Timeline</legend>
|
||||
<?php if ($logedin): ?>
|
||||
|
||||
<h2>Default post vsibility</h2>
|
||||
<div class="setting">
|
||||
<select name='defscope' id='scope'>
|
||||
<option value="1" <?php echo ($user_settings['defscope'] == '1' ? "selected" : ""); ?>> Public</option>
|
||||
<option value="2" <?php echo ($user_settings['defscope'] == '2' ? "selected" : ""); ?>> Unlisted</option>
|
||||
<option value="3" <?php echo ($user_settings['defscope'] == '3' ? "selected" : ""); ?>> Private</option>
|
||||
<option value="4" <?php echo ($user_settings['defscope'] == '4' ? "selected" : ""); ?>> Direct</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<h2>Show replies</h2>
|
||||
<div class='setting'>
|
||||
<select name="replies">
|
||||
|
Loading…
Reference in New Issue
Block a user