JS Commons
ShowHide, DropDowns, AJAX, Console log with div ect ect
by Jason Doyle
HTML
<div id="divShowOnly">HELLO divShowOnly</div>
<div id="console-log">HELLO</div>
<select name="ctl00$ctl19$g_12d6c781_f745_420a_a4cf_e82799d69600$ctl00$ctl02$ctl00$ctl02$ctl00$ctl00$ctl02$ctl00$ctl00$ctl04$ctl00$Lookup" id="ctl00_ctl19_g_12d6c781_f745_420a_a4cf_e82799d69600_ctl00_ctl02_ctl00_ctl02_ctl00_ctl00_ctl02_ctl00_ctl00_ctl04_ctl00_Lookup" title="Level2 Required Field" class="ct-active">
<option value="25">Doability</option>
<option value="26">Doabiliasdasty</option>
<option value="27">ED Mapping</option>
<option value="22">Financial</option>
<option value="95">Lessons Learned</option>
<option value="60">LPP</option>
<option value="2">LPP Job Aids</option>
<option value="28">OCX - OMX</option>
<option value="16">OCX OMX Job Aids</option>
<option value="1">Release Details</option>
<option value="21">Scrum Master Forum</option>
</select>
JavaScript
// JS COMMONS
// From
//http://www.infed.com/images/btn-plus-minus.gif
//https://www.chicobag.com/images/minus_icon.gif
// to
//http://fossies.org/linux/pac/res/pac_group_closed_16x16.png
//http://icons.iconseeker.com/png/fullsize/aspnet/folder-open-13.png
var consoleLine = "<p class=\"console-line\"></p>";
console = {
log: function (text) {
$("#console-log").append($(consoleLine).html(text));
}
};
hideAllExcept('divShowOnly');
// hide all elements except a few
//hideAllExcept('#ctl00_PlaceHolderMain_gvSummary')
function hideAllExcept(selectrId) {
//$('body > :not(#ctl00_PlaceHolderMain_gvSummary)').hide();
//$('[id*=gvSummary]').appendTo('body');
$('body > :not(' + selectrId + ')').hide();
$('[id*=' + selectrId + ']').show(); //or appendTo('body');
}
// id starts with
//console.log ( ($('[id*=ctl00_ctl19]') == null).toString() );
// does dropdown contain item by text
//$("select[name*='Lookup'][title*='Level2']").find("option:contains('Doability')").length
// get by value
//$("select[name*='Lookup'][title*='Level2']").find("option[value=25]").length
//set text
//$("select[name*='Lookup'][title*='Level2'] option:selected").text('Financial');
// open window
//url = 'google.com';
//childWindow = open(url, 'win4', 'resizable=yes,scrollbars=yes,width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
//if (childWindow.opener == null) childWindow.opener = self;
function Ping() {
return "OK";
}
// 20140812 HotFix
function QueryString(name, defaultValue) {
var res = defaultValue;
try {
if (location.search != null && location.search.length > 0) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
res = (results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")));
}
else {
res =...