Skip to content

Instantly share code, notes, and snippets.

@RickCogley
Created March 25, 2018 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RickCogley/cf015a834948afd29e8e269dcfe0041c to your computer and use it in GitHub Desktop.
Save RickCogley/cf015a834948afd29e8e269dcfe0041c to your computer and use it in GitHub Desktop.
Limiting a script to a single dbflex page
<!-- Global site tag (gtag.js) - Google Analytics -->
FS.addScript("//www.googletagmanager.com/gtag/js?id=UA-116114222-1", function() {
// google analytics
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-116114222-1');
});
jQuery(function() {
if(jQuery("body#overview_t_93336").length) {
// this should run on utility page
// START password
function PasswordGenerator_generate(){
num = jQuery('#PasswordGenerator_num').val();
if(num != '') {
var password = jQuery('#PasswordGenerator_type').val();
password1 = password.replace('+',' ');
jQuery('#PasswordGenerator_result').html('<span class="note">Generating '+num+' characters '+password1+' Password...</span>');
var xml_parser = 'http://api.wolframalpha.com/v2/query?input=generate+'+num+'+character+'+password+'+password&appid=AXKHRH-GW2HEE737W&format=plaintext&podindex=2&includepodid=Result';
script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + xml_parser + '"') + '&format=xml&callback=PasswordGenerator_parseXML';
jQuery("#PasswordGenerator_xmlHolder").html( script );
}
else {
jQuery('#PasswordGenerator_result').html('Put Character Limit...');
}
}
function PasswordGenerator_parseXML(data) {
myXML = data.results[0];
xmlDoc = jQuery.parseXML( myXML ),
$xml = $( xmlDoc ),
$title = $xml.find("plaintext");
if($title.eq(0).text() != ''){
basenum = $title.eq(0).text();
basenum = basenum.split('_');
jQuery('#PasswordGenerator_result').html(basenum[0]);
}
else
jQuery('#PasswordGenerator_result').html('Parser cannot process your request...');
}
jQuery(document).ready(function(){
$('#PasswordGenerator_num').keypress(function (e) {
if (e.which == 13) {
PasswordGenerator_generate();
return false; //<---- Add this line
}
});
});
// END password
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment