--- a/web/client.php Fri Nov 15 02:01:12 2024 +0100
+++ b/web/client.php Fri Nov 15 17:17:09 2024 +0100
@@ -148,17 +148,20 @@
?>
<?php if (isset($config['suggested_keywords'])) echo "var suggested_keywords = ".json_encode($config['suggested_keywords']).";"; ?>
<?php if (isset($config['js_config'])) echo "\n".$config['js_config']."\n"; ?>
- l10n = { "rechercher" : "<?php echo $translate->_('Rechercher'); ?>" }
+ var l10n = {
+ "rechercher" : "<?php echo $translate->_('Rechercher'); ?>",
+ "loading_messages" : "<?php echo $translate->_('loading_messages'); ?>",
+ "loading_messages_error" : "<?php echo $translate->_('loading_messages_error'); ?>",
+ };
+ var annotations;
if (typeof annotations == "undefined" || !annotations) {
- var annotations = JSON.parse("<?php echo addslashes(json_encode($annotations)); ?>");
+ annotations = JSON.parse("<?php echo addslashes(json_encode($annotations)); ?>");
for(var annot_cat in annotations) {
if("keywords" in annotations[annot_cat]) {
annotations[annot_cat]['keywords'] = [ new RegExp(annotations[annot_cat]['keywords']), ];
}
}
}
- global.annotations = annotations;
- console.log("ANNOTATIONS",annotations);
</script>
<?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?>
<script type="text/javascript" src="<?php echo(URL_ROOT); ?>res/js/live-polemic.js" ></script>
@@ -213,31 +216,43 @@
console.log("Send disabled")
return;
}
+ var MyStatus = $('#status').val();
+ if(MyStatus.length == 0) {
+ return;
+ }
$('#sendTweet').prop('disabled', true);
$('#sendTweet').toggleClass('sending sendTweetDisabled');
- var MyStatus = $('#status').val();
- $.post('tweet_ajax.php', {
- status:MyStatus,
- social_network: "<?php echo($config['social_network']) ?>",
- domain: "<?php echo(isset($_SESSION['SOCIAL_LOGIN_DOMAIN'])?$_SESSION['SOCIAL_LOGIN_DOMAIN']:'') ?>",
- hashtag: "<?php echo($config['hashtag']) ?>",
- group: "<?php echo($config['group'] ?? "") ?>"
- }
- ,function(data) {
- $('#sendTweet').toggleClass('sending sendTweetDisabled');
- $('#sendTweet').prop('disabled', false);
- if(data=="true"){
- $("#messageSuccess").show('fast');
- $("#messageSuccess").delay(800).hide('slow');
- $('#status').val("<?php echo($config['hashtag']); ?>");
- $('#status').change();
- }else{
- $("#error").text(data);
+ $.ajax({
+ url: 'tweet_ajax.php',
+ type: 'POST',
+ data:{
+ status:MyStatus,
+ social_network: "<?php echo($config['social_network']) ?>",
+ domain: "<?php echo(isset($_SESSION['SOCIAL_LOGIN_DOMAIN'])?$_SESSION['SOCIAL_LOGIN_DOMAIN']:'') ?>",
+ hashtag: "<?php echo($config['hashtag']) ?>",
+ group: "<?php echo($config['group'] ?? "") ?>"
+ },
+ success: function(data) {
+ $('#sendTweet').toggleClass('sending sendTweetDisabled');
+ $('#sendTweet').prop('disabled', false);
+ if(data=="true"){
+ $("#messageSuccess").show('fast');
+ $("#messageSuccess").delay(800).hide('slow');
+ $('#status').val("");
+ $('#status').change();
+ }else{
+ $("#error").text(data);
+ $("#messageFailed").show('fast');
+ $("#messageFailed").delay(800).hide('slow');
+ }
+ },
+ timeout: 10000,
+ error: function(jqXHR, textStatus, errorThrown) {
+ $("#error").text(textStatus);
$("#messageFailed").show('fast');
$("#messageFailed").delay(800).hide('slow');
}
-
});
});
@@ -455,14 +470,17 @@
</div>
<div id="twwWrap">
<div id="tweetWriter">
- <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])): ?>
- <div id="tweetCounter"><?php echo(TWEET_LENGTH-strlen($config['hashtag']));?></div>
- <?php endif;?>
+ <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) {
+ $socialNetwork = isset($config['social_network'])?$config['social_network']:'Twitter';
+ ?>
+ <div id="tweetLoader"></div>
+ <div id="tweetCounter"><?php if($socialNetwork === 'Twitter') { echo(TWEET_LENGTH-strlen($config['hashtag'])); }?></div>
+ <?php };?>
<h3 class="tweetWriterTitle"><?php print $translate->_("ClientTitle1 :"); ?></h3>
<?php if (!isset($_SESSION['SOCIAL_ACCESS_TOKEN'])){
+ $socialNetwork = isset($config['social_network'])?$config['social_network']:'Twitter';
$loginform = "<div class='loginbutton'>";
- $socialNetwork = isset($config['social_network'])?$config['social_network']:'Twitter';
if($socialNetwork === 'Twitter') {
$loginform .= "<a href='".URL_ROOT."$rep/client.php?CONNECT=true' target='_top' class='loginlink'>".$translate->_("Vous n'ĂȘtes pas connectĂ©.")."</a>";
} else {
@@ -480,7 +498,7 @@
echo($loginform);
} else {
echo('<form action="tweet.php" method="post" id="statusform" >');
- echo("<textarea name='status' id='status' rows='3' cols='50'>$config[hashtag]</textarea>");
+ echo("<textarea name='status' id='status' rows='3' cols='50'></textarea>");
}
?>
<div id="messageSuccess" style="background-color:lightgreen; display: none;">