MediaWiki:Result Code Details.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 106: | Line 106: | ||
//Generate a $(this) target for a given hash | //Generate a $(this) target for a given hash | ||
function hashThisOut(pageHash){ | function hashThisOut(pageHash){ | ||
console.log($ | console.log($("a").href(pageHash)); | ||
console.log("PageHash: " + pageHash); | console.log("PageHash: " + pageHash); | ||
} | } |
Revision as of 01:14, 23 January 2015
//Result Code - Product Association Arrays //===================================================================== var resultcodes_AddressObject = ["AS01", "AS02", "AS03", "AS09", "AS10", "AS12", "AS13", "AS14", "AS15", "AS16", "AS17", "AS18", "AS20", "AS22", "AS23", "AE01", "AE02", "AE03", "AE04", "AE05", "AE06", "AE07", "AE08", "AE09", "AE10", "AE11", "AE12", "AE13", "AE14", "AE15", "AE16", "AE17", "AE19", "AE20", "AC01", "AC02", "AC03", "AC04", "AC05", "AC06", "AC07", "AC08", "AC09", "AC10", "AC11", "AC12", "AC13", "AC14"]; var resultcodes_EmailObject = ["ES01", "ES02", "ES03", "ES04", "ES05", "ES06", "ES10", "ES11", "ES12", "ES13", "EE01", "EE02", "EE03", "EE04", "EE05"]; var resultcodes_NameObject = ["NS01", "NS02", "NS03", "NS04", "NS05", "NS06", "NS07", "NS08", "NE01", "NE02", "NE03", "NE04", "NE05", "NE06"]; var resultcodes_PhoneObject = ["PS01", "PS02", "PS03", "PS04", "PS05", "PS06", "PS07", "PS08", "PS09", "PS10", "PS11", "PS12", "PS13", "PS14", "PC01", "PE01", "PE02", "PE03", "PE04", "PE05", "PE06", "PE08", "PE09", "PE10"]; var resultcodes_GeoCoderObject = ["GS01", "GS02", "GS03", "GS05", "GS06", "GE01", "GE02", "GE03", "GE04"]; var resultcodes_GlobalAddressObject = ["AC01", "AC02", "AC03", "AC09", "AC10", "AC11", "AC12", "AC13", "AC14", "AC15", "AC16", "AC17", "AC18", "AC19", "AC21", "AE01", "AE02", "AE03", "AE05", "AE08", "AE09", "AE10", "AE11", "AE12", "AE13", "AE14", "AE17", "AV11", "AV12", "AV13", "AV14", "AV15", "AV21", "AV22", "AV23", "AV24", "AV25", "DF00", "DF21", "DF22", "DF23", "DF24", "DF25", "DF26", "DF27", "DF28", "DF51", "DF52", "DF53", "DF54", "DF55", "DF99", "DI00", "DI70", "DI80", "DI99", "DM00", "DM99", "DO00", "DO80", "DO99", "DT00", "DT80", "DT99", "F1", "F2", "F3", "MTE1", "MTE2", "MTE3", "MTE4", "MTE5", "MTE6", "MTE7", "MTE8", "MTE9", "MTE10", "MTE11", "MTE12", "MTE13", "MTE14", "MTE15", "MTE16", "MTS1", "MTS2", "MTS3", "MTS4", "MTS5", "MTS6", "MTS7", "MTS8", "MTS9", "MTS10", "MTS11", "MTS12", "MTS13", "MTS14", "MTS15", "MTS16", "RMAA", "RMLC", "RMSN", "RMFS", "RMHN", "RMPC", "TX??"]; var resultcodes_IPLocatorObject = ["IS01", "IS02", "IE01", "IE02"]; var resultcodes_MatchUpObject = ["MS01", "MS02", "MS03", "MS04", "MS05", "MS06", "MS07", "MS08", "MS09", "MS10", "MS11", "MS12", "MS13", "MS14", "MS15", "MS16", "MS17", "MS18", "MS19", "MS20", "MS21", "MS30", "MS31"]; var resultcodes_PresortObject = ["No Codes"]; var resultcodes_ProfilerObject = ["QS01", "QS03", "QS04", "QS05", "QS06", "QS07", "QS08", "QS09", "QS10", "QS11", "QS12", "QS13", "QS14", "QS15", "QS16", "QS17", "QS18", "QS19", "QS20", "QS21", "QS22", "QS30", "QS40", "QS50", "QS60", "QS61", "QS62", "QE01", "QE03", "QE04", "QE05", "QE06", "QE07", "QE08", "QE09", "QE10", "QE11", "QE12", "QE13", "QE14", "QE30", "QE40", "QE41", "QE42", "QE43", "QE50", "QE60", "QE61", "QE70"]; var resultcodes_RightFielderObject = ["RS01", "RS02", "RE01", "RE02", "RE03"]; var resultcodes_StyleListObject = ["Deprecated"]; //===================================================================== //Changes the Header to act like a button $(".TileLayoutHead p").css({"cursor":"pointer"});//Cursor change $(".TileLayoutHead p").hover(function(){$(this).parent().css({"background-color":"#ffffff"});},function(){$(this).parent().css({"background-color":"#f6f6f6"});});//Hover change //Changes Result Tile Head to have no padding $(".ResultTileLayoutHead .TileLayoutBody").css({"padding":"0"}); //Fixes Result Code Header padding $(".ResultTileLayoutHead h3").css({"padding-left":"20px","margin":"0","background-color":"grey","color":"white"}); $(".ResultTileLayoutHead table").css({"width":"100%"});//Table margin //Slide-out Effect $(".TileLayoutHead p").click(function(){ $(this).siblings(".TileLayoutBody").toggle(500, tileResetCheck($(this)));//Category Rollout $(this).parent().siblings(".TileLayoutHead").toggle(500);//Other Category Hide $(".ResultTileLayoutHead").slideUp(500);//Ensures the Result Code table holder is hidden. setTimeout(function(){ $(".ResultTileLayoutHead").css({"background-color":"#f6f6f6"});//Resets Result Head back color. //$(".ResultTileLayoutHeat").children("p").first().text("Result Codes");//Resets Result Head text to default. $(".ResultTileLayoutHeat p").first().text("Result Codes");//Resets Result Head text to default. }, 500); //$(".ResultTileLayoutHead").animate().css({"display":"none","background-color":"#f6f6f6"});//Ensures the Result Code table holder is hidden. //$(this).siblings(".TileLayoutBody").children().css({"display":"inline-block"});//Ensure Tiles are reset. // tileResetCheck(); }); //Ensure Tiles Are Reset function tileResetCheck(that){ if (that.siblings().css("display") === "block"){//Checks state of Category Rollout. setTimeout(function(){//Ensures tiles don't appear till after the cateogry hide rollout is done. that.siblings(".TileLayoutBody").children().css({"display":"inline-block"}); }, 500); }; } //Click handler on tiles. $(".TileLayoutBody a").click(function (){ hashChecker($(this)); }); //Sets the state according to the hash function hashChecker(that){ //Matches the hash with a class to know what to hide. Class is set by the TileLayoutTile template. var hashTarget = that.attr("href"); var trimmedHashTarget = hashTarget.slice(hashTarget.indexOf("#") + 1,(hashTarget.length)); cleanedHashTarget = trimmedHashTarget.replace(/[_:]|\.2B|\.2A/g, ""); //Removes spaces, colons, pluses, and asterisks. spacedHashTarget = trimmedHashTarget.replace(/_/g, " ");//Readies the hash to be a header with spaces. spacedHashTarget = spacedHashTarget.replace(/.2A/g, "*");//Readies the hash to be a header with asterisks. spacedHashTarget = spacedHashTarget.replace(/.2B/g, "+");//Readies the hash to be a header with pluses. $(".TLT_" + cleanedHashTarget).siblings().toggle(250);//Hides the other tiles. hideResultCodes();//Hides the result code tables $(".ResultTileLayoutHead").toggle(500);//Shows the Result Code table holder. var resultBackColor; //Sets the color variable for the Result Head according to the product selected. switch (that.closest(".TileLayoutHead").children("p").first().text()){ case "APIs": resultBackColor = "#005cbe"; break; case "Enterprise Solutions": resultBackColor = "#009245"; break; case "Web Services": resultBackColor = "#ff9000"; break; case "Legacy Services": resultBackColor = "#a31616"; break; case "Software": resultBackColor = "#c02040"; break; case "Reference Data": resultBackColor = "#6f1ba5"; break; default: resultBackColor = "#f6f6f6"; } $(".ResultTileLayoutHead").css({"background-color":resultBackColor});//Sets the Result Head back color to the product. $(".ResultTileLayoutHead").children("p").first().text(spacedHashTarget + " Result Codes");//Sets the Result Head text to the selected tile. selectedResultCodeDisplayer(cleanedHashTarget); } //Hides the result codes tables function hideResultCodes(){ $(".ResultTileLayoutHead .TileLayoutBody table tbody tr").css({"display":"none"});//Handles code $(".ResultTileLayoutHead .TileLayoutBody table").css({"display":"none"});//Handles table $(".ResultTileLayoutHead .TileLayoutBody h3").css({"display":"none"});//Handles header } //Handles the result codes to be displayed, depending on the selected product. function selectedResultCodeDisplayer(cleanedHashTarget) { var resultcodesTarget = window["resultcodes_" + cleanedHashTarget];//source array // Single Array Check $(".ResultTileLayoutHead .TileLayoutBody table tbody tr td:first-child").each(function(){ for (i = 0, l = resultcodesTarget.length; i < l; i++) { if ($.trim($(this).text()) === resultcodesTarget[i]) { $(this).parent("tr").css({"display":"table-row"});//Shows code $(this).closest("table").css({"display":"table"});//Shows table $(this).closest("table").find("tr:first-child").css({"display":"table-row"});//Shows table head $(this).closest("table").prev("h3").css({"display":"block"});//Shows header } } }); } //Generate a $(this) target for a given hash function hashThisOut(pageHash){ console.log($("a").href(pageHash)); console.log("PageHash: " + pageHash); } //Check On Page Load $(document).ready(function() { var pageHash = window.location.hash; console.log(pageHash); if (pageHash != "") { console.log("Something!"); hashThisOut(pageHash); //hashChecker(that); } }); //$(window).on('hashchange', TileLayoutTileHider);//Check on hashchange