146 echo "var tracking_keywords = ".json_encode(array($config['hashtag'])).";"; |
146 echo "var tracking_keywords = ".json_encode(array($config['hashtag'])).";"; |
147 } |
147 } |
148 ?> |
148 ?> |
149 <?php if (isset($config['suggested_keywords'])) echo "var suggested_keywords = ".json_encode($config['suggested_keywords']).";"; ?> |
149 <?php if (isset($config['suggested_keywords'])) echo "var suggested_keywords = ".json_encode($config['suggested_keywords']).";"; ?> |
150 <?php if (isset($config['js_config'])) echo "\n".$config['js_config']."\n"; ?> |
150 <?php if (isset($config['js_config'])) echo "\n".$config['js_config']."\n"; ?> |
151 l10n = { "rechercher" : "<?php echo $translate->_('Rechercher'); ?>" } |
151 var l10n = { |
|
152 "rechercher" : "<?php echo $translate->_('Rechercher'); ?>", |
|
153 "loading_messages" : "<?php echo $translate->_('loading_messages'); ?>", |
|
154 "loading_messages_error" : "<?php echo $translate->_('loading_messages_error'); ?>", |
|
155 }; |
|
156 var annotations; |
152 if (typeof annotations == "undefined" || !annotations) { |
157 if (typeof annotations == "undefined" || !annotations) { |
153 var annotations = JSON.parse("<?php echo addslashes(json_encode($annotations)); ?>"); |
158 annotations = JSON.parse("<?php echo addslashes(json_encode($annotations)); ?>"); |
154 for(var annot_cat in annotations) { |
159 for(var annot_cat in annotations) { |
155 if("keywords" in annotations[annot_cat]) { |
160 if("keywords" in annotations[annot_cat]) { |
156 annotations[annot_cat]['keywords'] = [ new RegExp(annotations[annot_cat]['keywords']), ]; |
161 annotations[annot_cat]['keywords'] = [ new RegExp(annotations[annot_cat]['keywords']), ]; |
157 } |
162 } |
158 } |
163 } |
159 } |
164 } |
160 global.annotations = annotations; |
|
161 console.log("ANNOTATIONS",annotations); |
|
162 </script> |
165 </script> |
163 <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?> |
166 <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?> |
164 <script type="text/javascript" src="<?php echo(URL_ROOT); ?>res/js/live-polemic.js" ></script> |
167 <script type="text/javascript" src="<?php echo(URL_ROOT); ?>res/js/live-polemic.js" ></script> |
165 <?php } ?> |
168 <?php } ?> |
166 <script type="text/javascript"> |
169 <script type="text/javascript"> |
211 $("#sendTweet").click(function(e){ |
214 $("#sendTweet").click(function(e){ |
212 if($('#sendTweet').prop('disabled')) { |
215 if($('#sendTweet').prop('disabled')) { |
213 console.log("Send disabled") |
216 console.log("Send disabled") |
214 return; |
217 return; |
215 } |
218 } |
|
219 var MyStatus = $('#status').val(); |
|
220 if(MyStatus.length == 0) { |
|
221 return; |
|
222 } |
216 $('#sendTweet').prop('disabled', true); |
223 $('#sendTweet').prop('disabled', true); |
217 $('#sendTweet').toggleClass('sending sendTweetDisabled'); |
224 $('#sendTweet').toggleClass('sending sendTweetDisabled'); |
218 var MyStatus = $('#status').val(); |
225 |
219 $.post('tweet_ajax.php', { |
226 $.ajax({ |
220 status:MyStatus, |
227 url: 'tweet_ajax.php', |
221 social_network: "<?php echo($config['social_network']) ?>", |
228 type: 'POST', |
222 domain: "<?php echo(isset($_SESSION['SOCIAL_LOGIN_DOMAIN'])?$_SESSION['SOCIAL_LOGIN_DOMAIN']:'') ?>", |
229 data:{ |
223 hashtag: "<?php echo($config['hashtag']) ?>", |
230 status:MyStatus, |
224 group: "<?php echo($config['group'] ?? "") ?>" |
231 social_network: "<?php echo($config['social_network']) ?>", |
225 } |
232 domain: "<?php echo(isset($_SESSION['SOCIAL_LOGIN_DOMAIN'])?$_SESSION['SOCIAL_LOGIN_DOMAIN']:'') ?>", |
226 ,function(data) { |
233 hashtag: "<?php echo($config['hashtag']) ?>", |
227 |
234 group: "<?php echo($config['group'] ?? "") ?>" |
228 $('#sendTweet').toggleClass('sending sendTweetDisabled'); |
235 }, |
229 $('#sendTweet').prop('disabled', false); |
236 success: function(data) { |
230 if(data=="true"){ |
237 $('#sendTweet').toggleClass('sending sendTweetDisabled'); |
231 $("#messageSuccess").show('fast'); |
238 $('#sendTweet').prop('disabled', false); |
232 $("#messageSuccess").delay(800).hide('slow'); |
239 if(data=="true"){ |
233 $('#status').val("<?php echo($config['hashtag']); ?>"); |
240 $("#messageSuccess").show('fast'); |
234 $('#status').change(); |
241 $("#messageSuccess").delay(800).hide('slow'); |
235 }else{ |
242 $('#status').val(""); |
236 $("#error").text(data); |
243 $('#status').change(); |
|
244 }else{ |
|
245 $("#error").text(data); |
|
246 $("#messageFailed").show('fast'); |
|
247 $("#messageFailed").delay(800).hide('slow'); |
|
248 } |
|
249 }, |
|
250 timeout: 10000, |
|
251 error: function(jqXHR, textStatus, errorThrown) { |
|
252 $("#error").text(textStatus); |
237 $("#messageFailed").show('fast'); |
253 $("#messageFailed").show('fast'); |
238 $("#messageFailed").delay(800).hide('slow'); |
254 $("#messageFailed").delay(800).hide('slow'); |
239 } |
255 } |
240 |
|
241 }); |
256 }); |
242 |
257 |
243 }); |
258 }); |
244 |
259 |
245 |
260 |
453 </li> |
468 </li> |
454 </ul> |
469 </ul> |
455 </div> |
470 </div> |
456 <div id="twwWrap"> |
471 <div id="twwWrap"> |
457 <div id="tweetWriter"> |
472 <div id="tweetWriter"> |
458 <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])): ?> |
473 <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { |
459 <div id="tweetCounter"><?php echo(TWEET_LENGTH-strlen($config['hashtag']));?></div> |
474 $socialNetwork = isset($config['social_network'])?$config['social_network']:'Twitter'; |
460 <?php endif;?> |
475 ?> |
|
476 <div id="tweetLoader"></div> |
|
477 <div id="tweetCounter"><?php if($socialNetwork === 'Twitter') { echo(TWEET_LENGTH-strlen($config['hashtag'])); }?></div> |
|
478 <?php };?> |
461 <h3 class="tweetWriterTitle"><?php print $translate->_("ClientTitle1 :"); ?></h3> |
479 <h3 class="tweetWriterTitle"><?php print $translate->_("ClientTitle1 :"); ?></h3> |
462 |
480 |
463 <?php if (!isset($_SESSION['SOCIAL_ACCESS_TOKEN'])){ |
481 <?php if (!isset($_SESSION['SOCIAL_ACCESS_TOKEN'])){ |
|
482 $socialNetwork = isset($config['social_network'])?$config['social_network']:'Twitter'; |
464 $loginform = "<div class='loginbutton'>"; |
483 $loginform = "<div class='loginbutton'>"; |
465 $socialNetwork = isset($config['social_network'])?$config['social_network']:'Twitter'; |
|
466 if($socialNetwork === 'Twitter') { |
484 if($socialNetwork === 'Twitter') { |
467 $loginform .= "<a href='".URL_ROOT."$rep/client.php?CONNECT=true' target='_top' class='loginlink'>".$translate->_("Vous n'êtes pas connecté.")."</a>"; |
485 $loginform .= "<a href='".URL_ROOT."$rep/client.php?CONNECT=true' target='_top' class='loginlink'>".$translate->_("Vous n'êtes pas connecté.")."</a>"; |
468 } else { |
486 } else { |
469 $loginform .= "<form action='".URL_ROOT."$rep/client.php' method='GET' target='_top'>"; |
487 $loginform .= "<form action='".URL_ROOT."$rep/client.php' method='GET' target='_top'>"; |
470 $loginform .= "<div class='loginlink'>".$translate->_("Vous n'êtes pas connecté à Mastodon.")."</div>"; |
488 $loginform .= "<div class='loginlink'>".$translate->_("Vous n'êtes pas connecté à Mastodon.")."</div>"; |
478 } |
496 } |
479 $loginform .= "</div>"; |
497 $loginform .= "</div>"; |
480 echo($loginform); |
498 echo($loginform); |
481 } else { |
499 } else { |
482 echo('<form action="tweet.php" method="post" id="statusform" >'); |
500 echo('<form action="tweet.php" method="post" id="statusform" >'); |
483 echo("<textarea name='status' id='status' rows='3' cols='50'>$config[hashtag]</textarea>"); |
501 echo("<textarea name='status' id='status' rows='3' cols='50'></textarea>"); |
484 } |
502 } |
485 ?> |
503 ?> |
486 <div id="messageSuccess" style="background-color:lightgreen; display: none;"> |
504 <div id="messageSuccess" style="background-color:lightgreen; display: none;"> |
487 <?php print $translate->_("Envoyé"); ?><br/><br/> |
505 <?php print $translate->_("Envoyé"); ?><br/><br/> |
488 </div> |
506 </div> |