javascript - insert into js doc help

Hello, Experts,

I have a block of code that has a drop down box in a page. It is currently showing a list of different categories when you drop down.

I was given code, without instruction of where to insert, and I feel like a deer staring at headlights. Can you guide me?

Current existing code:

/*
* jQuery v1.9.1 included
*/
 
$(document).ready(function() {
 
  // social share popups
  $(".share a").click(function(e) {
    e.preventDefault();
    window.open(this.href, "", "height = 500, width = 500");
  });
 
  // show form controls when the textarea receives focus or backbutton is used and value exists
  var $commentContainerTextarea = $(".comment-container textarea"),
  $commentContainerFormControls = $(".comment-form-controls, .comment-ccs");
 
  $commentContainerTextarea.one("focus", function() {
    $commentContainerFormControls.show();
  });
 
  if ($commentContainerTextarea.val() !== "") {
    $commentContainerFormControls.show();
  }
 
  // Expand Request comment form when Add to conversation is clicked
  var $showRequestCommentContainerTrigger = $(".request-container .comment-container .comment-show-container"),
    $requestCommentFields = $(".request-container .comment-container .comment-fields"),
    $requestCommentSubmit = $(".request-container .comment-container .request-submit-comment");
 
  $showRequestCommentContainerTrigger.on("click", function() {
    $showRequestCommentContainerTrigger.hide();
    $requestCommentFields.show();
    $requestCommentSubmit.show();
    $commentContainerTextarea.focus();
  });
 
  // Mark as solved button
  var $requestMarkAsSolvedButton = $(".request-container .mark-as-solved:not([data-disabled])"),
    $requestMarkAsSolvedCheckbox = $(".request-container .comment-container input[type=checkbox]"),
    $requestCommentSubmitButton = $(".request-container .comment-container input[type=submit]");
 
  $requestMarkAsSolvedButton.on("click", function () {
    $requestMarkAsSolvedCheckbox.attr("checked", true);
    $requestCommentSubmitButton.prop("disabled", true);
    $(this).attr("data-disabled", true).closest("form").submit();
  });
 
  // Change Mark as solved text according to whether comment is filled
  var $requestCommentTextarea = $(".request-container .comment-container textarea");
 
  $requestCommentTextarea.on("keyup", function() {
    if ($requestCommentTextarea.val() !== "") {
      $requestMarkAsSolvedButton.text($requestMarkAsSolvedButton.data("solve-and-submit-translation"));
      $requestCommentSubmitButton.prop("disabled", false);
    } else {
      $requestMarkAsSolvedButton.text($requestMarkAsSolvedButton.data("solve-translation"));
      $requestCommentSubmitButton.prop("disabled", true);
    }
  });
 
  // Disable submit button if textarea is empty
  if ($requestCommentTextarea.val() === "") {
    $requestCommentSubmitButton.prop("disabled", true);
  }
 
  // Submit requests filter form in the request list page
  $("#request-status-select, #request-organization-select")
    .on("change", function() {
      search();
    });
               
  // Submit requests filter form in the request list page
  $("#quick-search").on("keypress", function(e) {
    if (e.which === 13) {
      search();
    }
  });
 
  function search() {
    window.location.search = $.param({
      query: $("#quick-search").val(),
      status: $("#request-status-select").val(),
      organization_id: $("#request-organization-select").val()
    });
  }
 
  $(".header .icon-menu").on("click", function(e) {
    e.stopPropagation();
    var menu = document.getElementById("user-nav");
    var isExpanded = menu.getAttribute("aria-expanded") === "true";
    menu.setAttribute("aria-expanded", !isExpanded);
  });
 
  if ($("#user-nav").children().length === 0) {
    $(".header .icon-menu").hide();
  }
 
  // Submit organization form in the request page
  $("#request-organization select").on("change", function() {
    this.form.submit();
  });
 
  // Toggles expanded aria to collapsible elements
  $(".collapsible-nav, .collapsible-sidebar").on("click", function(e) {
    e.stopPropagation();
    var isExpanded = this.getAttribute("aria-expanded") === "true";
    this.setAttribute("aria-expanded", !isExpanded);
  });
});

Open in new window


New code:

$(window).load(function() {
   var i = 0;
   var cZendesk = false; //assume user is not part of the BlueBerry Organization
   //reserve space for additional organizations
   var checkExist = setInterval(function() {
      i++;
      if ($("a.nesty-input").length){
         clearInterval(checkExist);
         $("a.nesty-input").each(function() {
            $(this).bind( "click", function() {
               for (var c in HelpCenter.user.organizations) {
                  if (HelpCenter.user.organizations[c].name == "Automotive Technicians"){
                     cZendesk = true; //if user is part of the organization called "Automotive Technicians", then set its variable to true.
                  }
                  //reserve space for additional organizations
                  }
                  if (!cZendesk){
                     $("#577128").remove(); //replace the "TICKET_FORM_ID" with the proper id from the dropdown list. Leave the pound sign intact.
                  }
            //reserve space for additional organizations
            });
         });
      }
      if (i > 10){
         clearInterval(checkExist);
      }
   }, 100);
});

Open in new window

sj77Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leonidas DosasCommented:
Can you post HTML code?
0
Julian HansenCommented:
Unless the new code is meant to replace the existing just wrap it in <script></script> tags and place it before your </body> tag
<script>
$(window).load(function() {
   var i = 0;
   var cZendesk = false; //assume user is not part of the BlueBerry Organization
   //reserve space for additional organizations
   var checkExist = setInterval(function() {
      i++;
      if ($("a.nesty-input").length){
         clearInterval(checkExist);
         $("a.nesty-input").each(function() {
            $(this).bind( "click", function() {
               for (var c in HelpCenter.user.organizations) {
                  if (HelpCenter.user.organizations[c].name == "Automotive Technicians"){
                     cZendesk = true; //if user is part of the organization called "Automotive Technicians", then set its variable to true.
                  }
                  //reserve space for additional organizations
                  }
                  if (!cZendesk){
                     $("#577128").remove(); //replace the "TICKET_FORM_ID" with the proper id from the dropdown list. Leave the pound sign intact.
                  }
            //reserve space for additional organizations
            });
         });
      }
      if (i > 10){
         clearInterval(checkExist);
      }
   }, 100);
});
</script>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.