Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- /* ustawianie podpowiedzi dla pola id="pick_champ" */
- var availableTags = ['.$champ_names_to_array.'];
- $(function() {
- $("#pick_champ").autocomplete({source: availableTags});
- });
- /* ustawianie wybranych przedmiotów onclick */
- var selectedItems = 0;
- var itemsIDs = [];
- console.log("dziala");
- $(".item_icon_small").each(function() {
- $(this).attr("isActive", false);
- console.log("ustawiono false");
- });
- $(".item_icon_small").click(function() {
- /* wybranie 6th elementu jest możliwe, ale nie 7th */
- if ($(this).attr("isActive") == "false" && selectedItems < 6)
- {
- /* aktywujemy element */
- $(this).removeClass("item_icon_small").addClass("item_icon_small_active");
- $(this).attr("isActive", true);
- selectedItems++;
- itemsIDs[selectedItems - 1] = $(this).attr("item_id");
- }
- else if ($(this).attr("isActive") == "true")
- {
- /* dezaktywujemy element */
- $(this).removeClass("item_icon_small_active").addClass("item_icon_small");
- $(this).attr("isActive", false);
- console.log("Usuwam item o id = " + $(this).attr("item_id"));
- itemsIDs = itemsIDs.filter(value => value !== $(this).attr("item_id"));
- selectedItems--;
- }
- else
- {
- /* aktywujemy element, ale już wybrano 6 */
- alert("Wybrałeś już 6 przedmiotów!");
- }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement