Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. <script type="text/javascript">
  2. /* ustawianie podpowiedzi dla pola id="pick_champ" */
  3. var availableTags = ['.$champ_names_to_array.'];
  4. $(function() {
  5. $("#pick_champ").autocomplete({source: availableTags});
  6. });
  7. /* ustawianie wybranych przedmiotów onclick */
  8. var selectedItems = 0;
  9. var itemsIDs = [];
  10. console.log("dziala");
  11.  
  12. $(".item_icon_small").each(function() {
  13. $(this).attr("isActive", false);
  14. console.log("ustawiono false");
  15. });
  16. $(".item_icon_small").click(function() {
  17. /* wybranie 6th elementu jest możliwe, ale nie 7th */
  18. if ($(this).attr("isActive") == "false" && selectedItems < 6)
  19. {
  20. /* aktywujemy element */
  21. $(this).removeClass("item_icon_small").addClass("item_icon_small_active");
  22. $(this).attr("isActive", true);
  23. selectedItems++;
  24. itemsIDs[selectedItems - 1] = $(this).attr("item_id");
  25. }
  26. else if ($(this).attr("isActive") == "true")
  27. {
  28. /* dezaktywujemy element */
  29. $(this).removeClass("item_icon_small_active").addClass("item_icon_small");
  30. $(this).attr("isActive", false);
  31.  
  32. console.log("Usuwam item o id = " + $(this).attr("item_id"));
  33. itemsIDs = itemsIDs.filter(value => value !== $(this).attr("item_id"));
  34. selectedItems--;
  35. }
  36. else
  37. {
  38. /* aktywujemy element, ale już wybrano 6 */
  39. alert("Wybrałeś już 6 przedmiotów!");
  40. }
  41. }
  42. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement