Архитектурный шаблон "Мрак в моделях" на нескольких языках и платформах
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

memory.html 1.4KB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Память | Memory</title>
  5. </head>
  6. <body>
  7. </body>
  8. <script src="../shared/JavaScript/memorySide.js"></script>
  9. <script src="../shared/model.web.js"></script>
  10. <script>
  11. function memoryItemPositions(M) {
  12. var pos = []
  13. for (var i = 0; i < M.itemsCount; i++) {
  14. let row = Math.floor(i / 4)
  15. let x = memoryGap() + (i - row * 4) * memoryGap()
  16. let y = memoryGap() + row * memoryGap()
  17. pos.push([x, y])
  18. }
  19. return pos
  20. }
  21. </script>
  22. <script>
  23. var items = []
  24. // Section16Buttons.
  25. for (var i = 0; i < 16; i++) {
  26. let item = document.createElement("div")
  27. document.body.appendChild(item)
  28. items.push(item)
  29. item.id = `${i}`
  30. }
  31. // SectionGrid.
  32. var M = {
  33. itemsCount: items.length
  34. };
  35. let positions = memoryItemPositions(M);
  36. for (var id in positions) {
  37. var p = positions[id]
  38. var item = items[id];
  39. item.style.left = `${p[0]}px`
  40. item.style.top = `${p[1]}px`
  41. item.style.width = `${memorySide()}px`
  42. item.style.height = `${memorySide()}px`
  43. item.style.position = "absolute"
  44. item.style.background = "blue"
  45. }
  46. // SectionSelection.
  47. for (let id in items) {
  48. var item = items[id]
  49. item.onclick = function() {
  50. console.log("ИГР select id:", id)
  51. }
  52. }
  53. </script>
  54. </html>