Commit 9c40b008 authored by Malcolm Blaney's avatar Malcolm Blaney

Linkify Post->Micropub status message and clean up forms after submit.

parent 6b6ffcc8
Pipeline #17074384 passed with stage
in 1 minute and 7 seconds
......@@ -1285,7 +1285,8 @@ class Post extends Base {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($us_data));
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($ch, $header) {
if (preg_match('/^Location:(.+)$/', $header, $match)) {
$_SESSION['micropub-status'] = 'Published to: ' . $match[1];
$_SESSION['micropub-status'] = 'Published to: ' .
'<a href="' . $match[1] . '">' . $match[1] . '</a>';
}
return strlen($header);
});
......
......@@ -26,7 +26,7 @@
if(!this.dobrado.escrow){dobrado.escrow={};}
(function(){'use strict';var details=null;$(function(){if($('.escrow').length===0){return;}
$('#escrow-start').button().click(start);$('#escrow-web-address').keypress(function(event){if(event.which===13){event.preventDefault();start();}});$('#escrow-payment-description').val('').click(function(){if(!$('.extended').dialog('isOpen')){dobrado.escrow.showEditor();}});$('#escrow-payment-submit').button().click(submit);});function start(){var address=$('#escrow-web-address').val();if(address==='')return false;$('.escrow-start-info').html('');dobrado.log('Checking web address...','info');$.post('/php/request.php',{request:'escrow',action:'start',address:address,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'escrow start')){return;}
$('#escrow-start').button().click(start);$('#escrow-web-address').keypress(function(event){if(event.which===13){event.preventDefault();start();}});$('#escrow-payment-description').val('').click(function(){if(!$('.extended').dialog('isOpen')){dobrado.escrow.showEditor();}});$('#escrow-payment-submit').button().click(submit);});function start(){var address=$('#escrow-web-address').val();if(address==='')return false;$('.escrow-start-info').html('');$('.escrow-submit-info').html('');dobrado.log('Checking web address...','info');$.post('/php/request.php',{request:'escrow',action:'start',address:address,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'escrow start')){return;}
$('#escrow-web-address').val('');var recipient=JSON.parse(response);if(recipient.success){details=recipient.details;$('.escrow-recipient-info').html(recipient.success);$('#escrow-form').show();if($(dobrado.current).data('label')!=='escrow'){dobrado.escrow.showEditor();}}
else if(recipient.fail){$('.escrow-recipient-info').html('');$('#escrow-form').hide();$('.escrow-start-info').html(recipient.fail);}});}
function submit(){if(!details||details.url===''){$('.escrow-submit-info').html('Recipient\'s details not found.');return false;}
......@@ -35,6 +35,8 @@ else{description=$('#escrow-payment-description').val();}
$.post('/php/request.php',{request:'escrow',action:'submit',recipient:details.url,name:details.name,type:$('input[name=escrow-payment-type]:checked').val(),amount:$('#escrow-payment-amount').val(),description:description,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'escrow submit')){return;}
var post=JSON.parse(response);if(post.success){$.post('/php/request.php',{request:'post',action:'updated',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'escrow updated')){return;}
var updated=JSON.parse(response);$('.escrow-submit-info').html(updated.status);});}
else if(post.fail){$('.escrow-submit-info').html(post.fail);$('#escrow-post').val(post.content);$('.escrow-no-micropub').show();}});return false;}
else if(post.fail){$('.escrow-submit-info').html(post.fail);$('#escrow-post').val(post.content);$('.escrow-no-micropub').show();}
$('#escrow-payment-amount').val('');if(dobrado.editor){dobrado.editor.setData('');}
else{$('#escrow-payment-description').val('');}});return false;}
dobrado.escrow.showEditor=function(){if(dobrado.editMode){dobrado.closeEditor();}
$('#escrow-payment-description').parents('div').each(function(){if(/^dobrado-/.test($(this).attr('id'))){dobrado.current='#'+$(this).attr('id');return false;}});$(dobrado.current).data('label','escrow');dobrado.editor=CKEDITOR.replace('escrow-payment-description',{allowedContent:true,autoGrow_minHeight:$('#escrow-payment-description').height(),autoGrow_onStartup:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,extraPlugins:'autogrow,extended',filebrowserBrowseUrl:'/php/browse.php',removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,toolbar:[['Undo','Redo','-','Bold','Italic','-','Link','Unlink','-','Image','Extended']]});};}());
\ No newline at end of file
......@@ -62,6 +62,7 @@ if (!this.dobrado.escrow) {
if (address === '') return false;
$('.escrow-start-info').html('');
$('.escrow-submit-info').html('');
dobrado.log('Checking web address...', 'info');
$.post('/php/request.php',
{ request: 'escrow', action: 'start', address: address,
......@@ -132,6 +133,14 @@ if (!this.dobrado.escrow) {
$('#escrow-post').val(post.content);
$('.escrow-no-micropub').show();
}
// Reset the details in the payment form.
$('#escrow-payment-amount').val('');
if (dobrado.editor) {
dobrado.editor.setData('');
}
else {
$('#escrow-payment-description').val('');
}
});
return false;
}
......
......@@ -55,6 +55,8 @@ if(recipients===""){info="Please add a recipient for the email.";$("#organiser-e
if(subject===""){info="Please add a subject for the email.";$("#organiser-email-form .info").html(info);return false;}
if(message===""){info="Please add a message for the email.";$("#organiser-email-form .info").html(info);return false;}
$.post("/php/request.php",{request:"organiser",action:"send-message",recipients:recipients,subject:subject,message:message,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"organiser send message")){return false;}
if(dobrado.editor){dobrado.editor.setData('');}
else{$("#organiser-email-textarea").val('');}
$("#organiser-email-form .info").html("Message sent.");});return false;}
dobrado.organiser.showEditor=function(){if(dobrado.editMode){dobrado.closeEditor();}
$('#organiser-email-textarea').parents('div').each(function(){if(/^dobrado-/.test($(this).attr('id'))){dobrado.current='#'+$(this).attr('id');return false;}});$(dobrado.current).data('label','organiser');dobrado.editor=CKEDITOR.replace('organiser-email-textarea',{allowedContent:true,autoGrow_minHeight:$('#organiser-email-textarea').height(),autoGrow_onStartup:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,extraPlugins:'autogrow,extended',filebrowserBrowseUrl:'/php/browse.php',removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,toolbar:[['Undo','Redo','-','Bold','Italic','-','Link','Unlink','-','Image','Extended']]});};}());
\ No newline at end of file
......@@ -315,6 +315,12 @@ if (!this.dobrado.organiser) {
if (dobrado.checkResponseError(response, "organiser send message")) {
return false;
}
if (dobrado.editor) {
dobrado.editor.setData('');
}
else {
$("#organiser-email-textarea").val('');
}
$("#organiser-email-form .info").html("Message sent.");
});
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment