@Panda said in Interesting Widget code, but can’t fetch API:
this particular forum had plans to integrate tools which use API calls into widgets.
Now we reached the point of finding possible reason why API calls dont work, is there anyway round that?
Actually, yes. I had a similar issue with the below (which you might enjoy also) when running in a page widget
https://sudonix.org/cbg
For this to work, I needed to call the script externally, and so used the below widget code as a guide
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<style>
.cbgresult {
margin: 10px 0 15px 0;
padding: 15px;
border-radius: 6px;
font-family: "Source Code Pro", Menlo,Monaco,Consolas,"Courier New",monospace;
font-size: 2rem;
text-align: center;
background: var(--bs-code-block) !important;
}
.cbgresult:after {
content: '"';
}
.cbgresult:before {
content: '"';
}
.cbgheader {
margin-top: 40px;
text-align: center;
}
.generate {
text-align: center;
}
</style>
<script src="/assets/js/cbg.js"></script>
<div class="cbgheader">
<h2>Corporate BS Generator</h2>
<p>
Need a better sounding line? Just click the "Generate Another" button to get another killer phrase.
</p>
</div>
<div id="cbg" class="cbgresult"></div>
<div class="generate">
<button id="reloadme" class="btn btn-primary">Generate Another</button>
</div>
<script>
$(function() { // after page load
$('.cbgresult').fadeOut(0, function() {
$("#cbg").show();
$(this).html(phrase());
});
});
$(document).ready(function(){
$("#cbg").show();
$('#reloadme').click(function(){
$("#cbg").html(phrase());
});
});
</script>
@Panda said in Interesting Widget code, but can't fetch API:
I noticed before this forum has tight restriction times on editing / removing comments. I guess this is intentional. Is your experience that it is better to have this on a forum rather than unlimited edit / delete timer?
This is correct. Posts can only be deleted before a set time period elapses, which is 30 minutes
The intention here is to give you sufficient time to remove something you feel wasn’t relevant, or you really shouldn’t have posted (see policies), but for the sake of conversational flow, posts are then indelible because they add weight and value to the overall thread. For example, if you reference a comment in the thread, but that particular post is deleted, then the discussion becomes diluted.
Using this approach, it makes it easier for anyone else with a similar issue to see how we resolved it.