Skip to content

Instantly share code, notes, and snippets.

View woollsta's full-sized avatar

Pete Woolley woollsta

  • Digital Hive Limited
  • Nottingham, UK
View GitHub Profile
<script>
/**
* This cognosJqFix.ready block can now be used in place of the $(document).ready block
* You can create as many of these blocks as you want.
*/
cognosJqFix.ready(function($){
//This function passes in the jQuery library as the $ variable
//As long as your code stays within this block, you can safely use the $
$('.block').css('background', 'pink');
<script>
/**
* Config block must specifiy a path to the jQuery library
* Can optionally list extra JS files to load in order in the scripts array
* Can optionally list extra CSS files to load in order in the styles array
*/
cognosJqFix.setup({
jqueryPath : 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js',
scripts : [
// Any extra js libraries to load in:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
jQuery(document).ready(function(){
jQuery('.block').css('background', 'pink');
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('.block').css('background', 'pink');
});
</script>
<script>
/**
* Safer method of loading and using jQuery and other libraries into
* an IBM Congos Report (version 10.2)
* Normally this is overkill and you can get away with a simple
* <script src="path/to/jquery.js">
* However when you start to add prompts, because the Prompt API uses
* the same '$' variable as jQuery defaults to, you start to see some
* odd inconsistencies.
*/
@woollsta
woollsta / chunkify.js
Last active December 25, 2023 10:45
Fixes an issue with Google Chrome Speech Synthesis where long texts pause mid-speaking. The function takes in a speechUtterance object and intelligently chunks it into smaller blocks of text that are stringed together one after the other. Basically, you can play any length of text. See http://stackoverflow.com/questions/21947730/chrome-speech-sy…
/**
* Chunkify
* Google Chrome Speech Synthesis Chunking Pattern
* Fixes inconsistencies with speaking long texts in speechUtterance objects
* Licensed under the MIT License
*
* Peter Woolley and Brett Zamir
*/
var speechUtteranceChunker = function (utt, settings, callback) {