mvcStudentXD 1.2.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +13 -0
  3. data/{mvcStudentXD/CHANGELOG.md → CHANGELOG.md} +5 -5
  4. data/{mvcStudentXD/CODE_OF_CONDUCT.md → CODE_OF_CONDUCT.md} +84 -84
  5. data/Gemfile +4 -6
  6. data/Gemfile.lock +97 -101
  7. data/README.md +34 -2
  8. data/{mvcStudentXD/Rakefile → Rakefile} +16 -16
  9. data/{mvcStudentXD/lib → lib}/mvcStudentXD/version.rb +5 -5
  10. data/lib/mvcStudentXD.rb +10 -0
  11. data/mvcStudentXD-1.2.2.gem +0 -0
  12. data/mvcStudentXD.gemspec +38 -0
  13. data/{mvcStudentXD/sig → sig}/mvcStudentXD.rbs +4 -4
  14. metadata +42 -91
  15. data/Lab1/arr1_3.txt +0 -1
  16. data/Lab1/lb1_1.rb +0 -19
  17. data/Lab1/lb1_2.rb +0 -28
  18. data/Lab1/lb1_3.rb +0 -46
  19. data/Lab1/lb1_4.rb +0 -82
  20. data/Lab2/1Class.jpg +0 -0
  21. data/Lab2/Web/main.rb +0 -89
  22. data/Lab2/Web/views/add.html +0 -168
  23. data/Lab2/Web/views/main.html +0 -233
  24. data/Lab2/data_storage/students1.txt +0 -1
  25. data/Lab2/data_storage/studentsRead.json +0 -36
  26. data/Lab2/data_storage/studentsRead.txt +0 -3
  27. data/Lab2/data_storage/studentsRead.yaml +0 -26
  28. data/Lab2/data_storage/studentsWrite.json +0 -42
  29. data/Lab2/data_storage/studentsWrite.txt +0 -4
  30. data/Lab2/data_storage/studentsWrite.yaml +0 -31
  31. data/Lab2/examples/Strategy.rb +0 -38
  32. data/Lab2/examples/adapter.rb +0 -30
  33. data/Lab2/examples/database.rb +0 -15
  34. data/Lab2/examples/observer_example.rb +0 -51
  35. data/Lab2/examples/pattern_pattern.rb +0 -44
  36. data/Lab2/examples/site_example.rb +0 -21
  37. data/Lab2/examples/views/about.erb +0 -11
  38. data/Lab2/examples/views/contact.erb +0 -15
  39. data/Lab2/examples/views/index.erb +0 -11
  40. data/Lab2/main.rb +0 -6
  41. data/Lab2/main_window.rb +0 -31
  42. data/Lab2/student_input_form.rb +0 -71
  43. data/Lab2/tab_students.rb +0 -157
  44. data/Lab2/test/student_test.rb +0 -91
  45. data/mvcStudentXD/Gemfile +0 -22
  46. data/mvcStudentXD/Gemfile.lock +0 -97
  47. data/mvcStudentXD/README.md +0 -35
  48. data/mvcStudentXD/bin/console +0 -11
  49. data/mvcStudentXD/bin/setup +0 -8
  50. data/mvcStudentXD/lib/mvcStudentXD.rb +0 -10
  51. data/mvcStudentXD/mvcStudentXD.gemspec +0 -15
  52. data/mvcStudentXD/pkg/mvcStudentXD-0.1.0.gem +0 -0
  53. data/mvcStudentXD/pkg/mvcStudentXD-1.0.1.gem +0 -0
  54. data/mvcStudentXD/pkg/mvcStudentXD-1.1.1.gem +0 -0
  55. data/mvcStudentXD/test/student_test.rb +0 -91
  56. data/mvcStudentXD/test/test_helper.rb +0 -6
  57. data/mvcStudentXD/test/test_mvcStudentXD.rb +0 -13
  58. /data/{mvcStudentXD/lib → lib}/source/adapters/student_list_adapter.rb +0 -0
  59. /data/{mvcStudentXD/lib → lib}/source/containers/Data_list.rb +0 -0
  60. /data/{mvcStudentXD/lib → lib}/source/containers/Data_list_student_short.rb +0 -0
  61. /data/{mvcStudentXD/lib → lib}/source/containers/Data_table.rb +0 -0
  62. /data/{mvcStudentXD/lib → lib}/source/controllers/student_edit_form_controller.rb +0 -0
  63. /data/{mvcStudentXD/lib → lib}/source/controllers/student_input_form_controller.rb +0 -0
  64. /data/{mvcStudentXD/lib → lib}/source/controllers/student_list_controller.rb +0 -0
  65. /data/{mvcStudentXD/lib → lib}/source/converters/Converter.rb +0 -0
  66. /data/{mvcStudentXD/lib → lib}/source/converters/Converter_json.rb +0 -0
  67. /data/{mvcStudentXD/lib → lib}/source/converters/Converter_txt.rb +0 -0
  68. /data/{mvcStudentXD/lib → lib}/source/converters/Converter_yaml.rb +0 -0
  69. /data/{mvcStudentXD/lib → lib}/source/database/scripts/create_table.sql +0 -0
  70. /data/{mvcStudentXD/lib → lib}/source/database/scripts/insert_data.sql +0 -0
  71. /data/{mvcStudentXD/lib → lib}/source/database/student_list_db.rb +0 -0
  72. /data/{mvcStudentXD/lib → lib}/source/database/students_db.rb +0 -0
  73. /data/{mvcStudentXD/lib → lib}/source/model/Student.rb +0 -0
  74. /data/{mvcStudentXD/lib → lib}/source/model/StudentBase.rb +0 -0
  75. /data/{mvcStudentXD/lib → lib}/source/model/Student_short.rb +0 -0
  76. /data/{mvcStudentXD/lib → lib}/source/repositories/Student_list.rb +0 -0
  77. /data/{mvcStudentXD/lib → lib}/source/repositories/student_list_adv.rb +0 -0
  78. /data/{mvcStudentXD/lib → lib}/source/util/LoggerHolder.rb +0 -0
  79. /data/{mvcStudentXD/mvcStudentXD-1.2.0.gem → mvcStudentXD-1.2.0.gem} +0 -0
metadata CHANGED
@@ -1,113 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mvcStudentXD
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - papaSquid
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2023-05-12 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: win32api
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- description: А simple ruby gem
12
+ dependencies: []
13
+ description: models and controllers
28
14
  email:
29
- - bakladjant@mail.ru
15
+ - mrxameleonx@mail.ru
30
16
  executables: []
31
17
  extensions: []
32
18
  extra_rdoc_files: []
33
19
  files:
20
+ - ".rubocop.yml"
21
+ - CHANGELOG.md
22
+ - CODE_OF_CONDUCT.md
34
23
  - Gemfile
35
24
  - Gemfile.lock
36
- - Lab1/arr1_3.txt
37
- - Lab1/lb1_1.rb
38
- - Lab1/lb1_2.rb
39
- - Lab1/lb1_3.rb
40
- - Lab1/lb1_4.rb
41
- - Lab2/1Class.jpg
42
- - Lab2/Web/main.rb
43
- - Lab2/Web/views/add.html
44
- - Lab2/Web/views/main.html
45
- - Lab2/data_storage/students1.txt
46
- - Lab2/data_storage/studentsRead.json
47
- - Lab2/data_storage/studentsRead.txt
48
- - Lab2/data_storage/studentsRead.yaml
49
- - Lab2/data_storage/studentsWrite.json
50
- - Lab2/data_storage/studentsWrite.txt
51
- - Lab2/data_storage/studentsWrite.yaml
52
- - Lab2/examples/Strategy.rb
53
- - Lab2/examples/adapter.rb
54
- - Lab2/examples/database.rb
55
- - Lab2/examples/observer_example.rb
56
- - Lab2/examples/pattern_pattern.rb
57
- - Lab2/examples/site_example.rb
58
- - Lab2/examples/views/about.erb
59
- - Lab2/examples/views/contact.erb
60
- - Lab2/examples/views/index.erb
61
- - Lab2/main.rb
62
- - Lab2/main_window.rb
63
- - Lab2/student_input_form.rb
64
- - Lab2/tab_students.rb
65
- - Lab2/test/student_test.rb
66
25
  - README.md
67
- - mvcStudentXD/CHANGELOG.md
68
- - mvcStudentXD/CODE_OF_CONDUCT.md
69
- - mvcStudentXD/Gemfile
70
- - mvcStudentXD/Gemfile.lock
71
- - mvcStudentXD/README.md
72
- - mvcStudentXD/Rakefile
73
- - mvcStudentXD/bin/console
74
- - mvcStudentXD/bin/setup
75
- - mvcStudentXD/lib/mvcStudentXD.rb
76
- - mvcStudentXD/lib/mvcStudentXD/version.rb
77
- - mvcStudentXD/lib/source/adapters/student_list_adapter.rb
78
- - mvcStudentXD/lib/source/containers/Data_list.rb
79
- - mvcStudentXD/lib/source/containers/Data_list_student_short.rb
80
- - mvcStudentXD/lib/source/containers/Data_table.rb
81
- - mvcStudentXD/lib/source/controllers/student_edit_form_controller.rb
82
- - mvcStudentXD/lib/source/controllers/student_input_form_controller.rb
83
- - mvcStudentXD/lib/source/controllers/student_list_controller.rb
84
- - mvcStudentXD/lib/source/converters/Converter.rb
85
- - mvcStudentXD/lib/source/converters/Converter_json.rb
86
- - mvcStudentXD/lib/source/converters/Converter_txt.rb
87
- - mvcStudentXD/lib/source/converters/Converter_yaml.rb
88
- - mvcStudentXD/lib/source/database/scripts/create_table.sql
89
- - mvcStudentXD/lib/source/database/scripts/insert_data.sql
90
- - mvcStudentXD/lib/source/database/student_list_db.rb
91
- - mvcStudentXD/lib/source/database/students_db.rb
92
- - mvcStudentXD/lib/source/model/Student.rb
93
- - mvcStudentXD/lib/source/model/StudentBase.rb
94
- - mvcStudentXD/lib/source/model/Student_short.rb
95
- - mvcStudentXD/lib/source/repositories/Student_list.rb
96
- - mvcStudentXD/lib/source/repositories/student_list_adv.rb
97
- - mvcStudentXD/lib/source/util/LoggerHolder.rb
98
- - mvcStudentXD/mvcStudentXD-1.2.0.gem
99
- - mvcStudentXD/mvcStudentXD.gemspec
100
- - mvcStudentXD/pkg/mvcStudentXD-0.1.0.gem
101
- - mvcStudentXD/pkg/mvcStudentXD-1.0.1.gem
102
- - mvcStudentXD/pkg/mvcStudentXD-1.1.1.gem
103
- - mvcStudentXD/sig/mvcStudentXD.rbs
104
- - mvcStudentXD/test/student_test.rb
105
- - mvcStudentXD/test/test_helper.rb
106
- - mvcStudentXD/test/test_mvcStudentXD.rb
26
+ - Rakefile
27
+ - lib/mvcStudentXD.rb
28
+ - lib/mvcStudentXD/version.rb
29
+ - lib/source/adapters/student_list_adapter.rb
30
+ - lib/source/containers/Data_list.rb
31
+ - lib/source/containers/Data_list_student_short.rb
32
+ - lib/source/containers/Data_table.rb
33
+ - lib/source/controllers/student_edit_form_controller.rb
34
+ - lib/source/controllers/student_input_form_controller.rb
35
+ - lib/source/controllers/student_list_controller.rb
36
+ - lib/source/converters/Converter.rb
37
+ - lib/source/converters/Converter_json.rb
38
+ - lib/source/converters/Converter_txt.rb
39
+ - lib/source/converters/Converter_yaml.rb
40
+ - lib/source/database/scripts/create_table.sql
41
+ - lib/source/database/scripts/insert_data.sql
42
+ - lib/source/database/student_list_db.rb
43
+ - lib/source/database/students_db.rb
44
+ - lib/source/model/Student.rb
45
+ - lib/source/model/StudentBase.rb
46
+ - lib/source/model/Student_short.rb
47
+ - lib/source/repositories/Student_list.rb
48
+ - lib/source/repositories/student_list_adv.rb
49
+ - lib/source/util/LoggerHolder.rb
50
+ - mvcStudentXD-1.2.0.gem
51
+ - mvcStudentXD-1.2.2.gem
52
+ - mvcStudentXD.gemspec
53
+ - sig/mvcStudentXD.rbs
107
54
  homepage: https://github.com/KiTTeNqz/mvcStudentXD
108
55
  licenses:
109
56
  - MIT
110
- metadata: {}
57
+ metadata:
58
+ allowed_push_host: https://rubygems.org
59
+ homepage_uri: https://github.com/KiTTeNqz/mvcStudentXD
60
+ source_code_uri: https://github.com/KiTTeNqz/mvcStudentXD
61
+ changelog_uri: https://github.com/KiTTeNqz/mvcStudentXD/blob/master/CHANGELOG.md
111
62
  post_install_message:
112
63
  rdoc_options: []
113
64
  require_paths:
@@ -126,5 +77,5 @@ requirements: []
126
77
  rubygems_version: 3.4.10
127
78
  signing_key:
128
79
  specification_version: 4
129
- summary: DeadInside
80
+ summary: Gem with Student MC
130
81
  test_files: []
data/Lab1/arr1_3.txt DELETED
@@ -1 +0,0 @@
1
- 1 3 -4 6 8 -3 -5 10
data/Lab1/lb1_1.rb DELETED
@@ -1,19 +0,0 @@
1
- puts 'Hello World'
2
- puts "Hello, #{ARGV[0]}."
3
- puts "Какой твой любимый язык?"
4
-
5
- r = STDIN.gets.chomp
6
- case r
7
- when 'ruby'
8
- puts 'Подлиза'
9
- else
10
- puts 'Почему не руби?!'
11
- end
12
-
13
- puts 'Enter ruby command: '
14
- comRuby = STDIN.gets.chomp
15
- system "ruby -e \'#{comRuby}\'"
16
-
17
- puts 'Enter OS command: '
18
- comSys = STDIN.gets.chomp
19
- puts `#{comSys}`
data/Lab1/lb1_2.rb DELETED
@@ -1,28 +0,0 @@
1
- #var2
2
- def vzaimProst(num1, num2)
3
- if(num1.gcd(num2)==1) then true
4
- else false
5
- end
6
- end
7
-
8
- def formArrDel(num)
9
- return 1.upto(num).select{|e| num%e==0}
10
- end
11
-
12
- def meth1(num1)
13
- return 2.upto(num1-1).count{|e| num1.gcd(e)==1}
14
- end
15
-
16
- def meth2(num)
17
- return num.digits.select{|e| e%3==0}.sum
18
- end
19
-
20
- def meth3(num)
21
- #formirovat massiv iz kol-va vzaimno-prostih s dannim
22
- arr = formArrDel(num).map{|e| num.digits.count{|e1| e.gcd(e1)==1}}
23
- return formArrDel(num)[arr.rindex(arr.max)]
24
- end
25
-
26
- puts meth1(16)
27
- puts meth2(161718192023)
28
- puts meth3(17)
data/Lab1/lb1_3.rb DELETED
@@ -1,46 +0,0 @@
1
- def minArr(arr)
2
- minim=arr[0]
3
- for i in 0..arr.length
4
- if arr[i].to_i<minim
5
- then minim=arr[i].to_i
6
- end
7
- end
8
- return minim
9
- end
10
-
11
- def firstPos(arr)
12
- for i in 0..arr.length
13
- return i if arr[i].to_i>0
14
- end
15
- return -1
16
- end
17
-
18
- if ARGV.count<2
19
- puts 'Введите 2 аргумента(метод, путь)!!!'
20
- return
21
- end
22
-
23
- meth = ARGV[0]
24
- path = ARGV[1]
25
-
26
- file = File.open(path)
27
- array = file.readline.split(' ').map(&:to_i)
28
- file.close()
29
-
30
- puts "Array: #{array}\n"
31
-
32
- case meth
33
- when 'minArr'
34
- puts "Min in arr: #{minArr(array)}"
35
- when 'fP'
36
- puts "First positive in arr: #{firstPos(array)}"
37
- else
38
- puts "Unknown method"
39
- end
40
-
41
-
42
-
43
-
44
- #a=[1,3,-4,6,8,-3,-5, 10]
45
- #puts minArr(a)
46
- #puts firstPos(a)
data/Lab1/lb1_4.rb DELETED
@@ -1,82 +0,0 @@
1
- def idxMin(arr)
2
- return arr.index(arr.min)
3
- end
4
-
5
-
6
- def countInterval(arr, a, b)
7
- return arr.slice(a+1...b).length
8
- end
9
-
10
-
11
- def idxLastMin(arr)
12
- return arr.rindex(arr.min)
13
- end
14
-
15
- def betweenMins(arr)
16
- return countInterval(arr,idxMin(arr),idxLastMin(arr))
17
- end
18
-
19
- def countInNums(arr, a, b)
20
- return arr.select{|e| e.between?(a,b)}.length
21
- end
22
-
23
- def differ2Arrs(arr1, arr2)
24
- return arr1.find_all{|x| arr1.count(x)==1}.difference(arr2).union(arr2.find_all{|x| arr2.count(x)==1}.difference(arr1))
25
- end
26
-
27
- #a=[1,3,-4,-5,6,8,-3,-5,10,3]
28
- #b=[2,8,-4,-7,6,12,-15,-3,1,1]
29
-
30
- puts "Вечер добрый! Какую программу запустим?
31
-
32
- 2 - idxMin
33
- 14 - count in countInterval
34
- 26 - betweenMins
35
- 38 - countInNums
36
- 50 - differenceBetween2Arrs"
37
-
38
- meth = gets.chomp.to_i
39
-
40
- case meth
41
- when meth = 2
42
- puts "Введите массив для обработки"
43
- arr = gets.chomp.split(' ').map(&:to_i)
44
- puts "Введённый массив: #{arr.inspect}"
45
- puts idxMin(arr)
46
- when meth = 14
47
- puts "Введите массив для обработки"
48
- arr = gets.chomp.split(' ').map(&:to_i)
49
- puts "Введите a"
50
- a = gets.chomp.to_i
51
- puts "Введите b"
52
- b = gets.chomp.to_i
53
- puts countInterval(arr,a,b)
54
- when meth = 26
55
- puts "Введите массив для обработки"
56
- arr = gets.chomp.split(' ').map(&:to_i)
57
- puts betweenMins(arr)
58
- when meth = 38
59
- puts "Введите массив для обработки"
60
- arr = gets.chomp.split(' ').map(&:to_i)
61
- puts "Введите a"
62
- a = gets.chomp.to_i
63
- puts "Введите b"
64
- b = gets.chomp.to_i
65
- puts countInNums(arr,a,b)
66
- when meth = 50
67
- puts "Введите 1 массив для обработки"
68
- arr1 = gets.chomp.split(' ').map(&:to_i)
69
- puts "Введите 2 массив для обработки"
70
- arr2 = gets.chomp.split(' ').map(&:to_i)
71
- puts differ2Arrs(arr1, arr2)
72
- else
73
- puts "Error"
74
- end
75
-
76
-
77
- #puts "Array: #{a}\n"
78
- #puts idxMin(a)
79
- #puts countInterval(a, 5, -1)
80
- #puts betweenMins(a)
81
- #puts countInNums(a, -1, 10)
82
- #puts differ2Arrs(a, b)
data/Lab2/1Class.jpg DELETED
Binary file
data/Lab2/Web/main.rb DELETED
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'sinatra'
4
- require 'mvcStudentXD'
5
-
6
- set :port, 8000
7
-
8
- puts MvcStudentXD.constants
9
-
10
- students_model = MvcStudentXD::StudentListAdv.new(
11
- MvcStudentXD::StudentsListDBAdapter.new(
12
- MvcStudentXD::StudentListDB.instance))
13
-
14
- main_controller = StudentListController.new(students_model)
15
- main_controller.on_view_created = lambda { }
16
- main_controller.on_add_student_clicked = lambda { }
17
- main_controller.on_edit_student_clicked = lambda { |id| }
18
-
19
- main_controller.selected_page = 0
20
-
21
- editing_id = nil
22
-
23
- get "/" do
24
- send_file 'web/main.html'
25
- end
26
-
27
- post "/students" do
28
- main_controller.refresh_data()
29
- result = main_controller.data_list.map { |student|
30
- student.as_json
31
- }
32
-
33
- result.to_json
34
- end
35
-
36
- post "/next_page" do
37
- main_controller.next_page()
38
- main_controller.refresh_data()
39
- end
40
-
41
- post "/last_page" do
42
- main_controller.last_page()
43
- main_controller.update_table()
44
- end
45
-
46
- get "/get_page" do
47
- (main_controller.selected_page + 1).to_s
48
- end
49
-
50
- get "/get_pages_count" do
51
- main_controller.pages_count.to_s
52
- end
53
-
54
- post "/set_editing_id:id" do
55
- puts params[:id]
56
- editing_id = params[:id]
57
- end
58
-
59
- get "/get_editing_id" do
60
- editing_id.to_s
61
- end
62
-
63
- post "/delete:id" do
64
- main_controller.remove_student(params[:id])
65
- end
66
-
67
- post "/editing:id" do
68
- student = main_controller.get_student(params[:id])
69
- [student.as_json].to_json
70
- end
71
-
72
- get "/add" do
73
- if editing_id == 'null'
74
- main_controller.show_modal_add
75
- else
76
- main_controller.show_modal_edit(editing_id)
77
- end
78
- send_file 'web/add.html'
79
- end
80
-
81
- get "/edit:student" do
82
- student = Student.from_json(JSON.parse(params[:student]))
83
- main_controller.replace_student(student.id, student)
84
- end
85
-
86
- get "/insert:student" do
87
- student = Student.from_json(JSON.parse(params[:student]))
88
- main_controller.add_student(student)
89
- end
@@ -1,168 +0,0 @@
1
- <html>
2
- <style>
3
- .text {
4
- font-size: 20px;
5
- font-weight: bold;
6
- color: #000000;
7
- }
8
-
9
- .txbox {
10
- font-size: 16px;
11
- padding: 7px;
12
- border: 1px solid #050505;
13
- }
14
-
15
- .bt {
16
- font-size: 15px;
17
- padding: 5px 10px;
18
- background-color: #5117d6;
19
- color: #fff;
20
- border: none;
21
- border-radius: 5px;
22
- cursor: pointer;
23
- margin: 16px;
24
- }
25
-
26
- .bt:hover {
27
- background-color: #22b91d;
28
- }
29
- </style>
30
-
31
- <body style="display: flex; flex-direction: column; width: 256px;">
32
- <label class="text" for="user_name">Фамилия</label>
33
- <input class ="txbox" type="text" id="lastname">
34
-
35
- <label class="text" for="user_name">Имя</label>
36
- <input class ="txbox" type="text" id="firstname">
37
-
38
- <label class="text" for="user_name">Отчество</label>
39
- <input class ="txbox" type="text" id="parental_name">
40
-
41
- <label class="text" for="user_name">GitHub</label>
42
- <input class ="txbox" type="text" id="git">
43
-
44
- <label class="text" for="user_name">Телефон</label>
45
- <input class ="txbox" type="text" id="phone">
46
-
47
- <label class="text" for="user_name">Почта</label>
48
- <input class ="txbox" type="text" id="email">
49
-
50
- <label class="text" for="user_name">Телеграм</label>
51
- <input class ="txbox" type="text" id="telegram">
52
-
53
- <button class ="bt" onclick="check_button()">Готово</button>
54
- </body>
55
-
56
- <script>
57
- let is_edit_mode = false
58
- let id = null
59
-
60
- function check_button() {
61
- if (document.getElementById('firstname').value === "") {
62
- alert("Имя не введено")
63
- return
64
- }
65
-
66
- if (document.getElementById('lastname').value === "") {
67
- alert("Фамилия не введена")
68
- return
69
- }
70
-
71
- if (document.getElementById('parental_name').value === "") {
72
- alert("Отчество не введено")
73
- return
74
- }
75
-
76
- if (document.getElementById('git').value !== "" && document.getElementById('git').value.match(/@\w*/) == null) {
77
- alert("Неверно введен GitHub")
78
- return
79
- }
80
-
81
- if (document.getElementById('email').value !== "" && document.getElementById('email').value.match(/\w*@\w*.\w{2,3}/) == null) {
82
- alert("Неверно введена почта")
83
- return
84
- }
85
-
86
- if (document.getElementById('phone').value !== "" && document.getElementById('phone').value.match(/\d-\d{3}-\d{3}-\d{2}-\d{2}/) == null) {
87
- alert("Неверно введен номер телефона")
88
- return
89
- }
90
-
91
- if (document.getElementById('telegram').value !== "" && document.getElementById('telegram').value.match(/@\w*/) == null) {
92
- alert("Неверно введена телеграм")
93
- return
94
- }
95
-
96
- if (document.getElementById('git').value === "" && document.getElementById('phone').value == "" && document.getElementById('email').value == "" && document.getElementById('telegram').value == "") {
97
- alert("Отсутствует контакт")
98
- return
99
- }
100
-
101
- add_student()
102
- }
103
-
104
- function get_editing_student() {
105
- var http = new XMLHttpRequest();
106
- http.open('GET', 'get_editing_id', false);
107
- http.send()
108
-
109
- id = http.responseText
110
-
111
-
112
- if (id !== "null") {
113
- is_edit_mode = true
114
-
115
- http.open('POST', 'editing' + id, false);
116
- http.send()
117
-
118
- let student = JSON.parse(http.responseText)
119
-
120
- document.getElementById('firstname').value = student[0]["firstname"]
121
- document.getElementById('lastname').value = student[0]["lastname"]
122
- document.getElementById('parental_name').value = student[0]["parental_name"]
123
- document.getElementById('git').value = student[0]["git"]
124
- document.getElementById('email').value = student[0]["email"]
125
- document.getElementById('phone').value = student[0]["phone"]
126
- document.getElementById('telegram').value = student[0]["telegram"]
127
- }
128
- }
129
-
130
- function add_student() {
131
- let json = {
132
- "firstname": document.getElementById('firstname').value,
133
- "lastname": document.getElementById('lastname').value,
134
- "parental_name": document.getElementById('parental_name').value
135
- }
136
-
137
- if (id != null) {
138
- json['id'] = id
139
- }
140
- if (document.getElementById('git').value !== "") {
141
- json['git'] = document.getElementById('git').value
142
- }
143
- if (document.getElementById('email').value !== "") {
144
- json['email'] = document.getElementById('email').value
145
- }
146
- if (document.getElementById('phone').value !== "") {
147
- json['phone'] = document.getElementById('phone').value
148
- }
149
- if (document.getElementById('telegram').value !== "") {
150
- json['telegram'] = document.getElementById('telegram').value
151
- }
152
-
153
- var http = new XMLHttpRequest();
154
-
155
- if (is_edit_mode) {
156
- http.open('GET', "edit" + JSON.stringify(json), false);
157
- http.send()
158
- } else {
159
- http.open('GET', "insert" + JSON.stringify(json), false);
160
- http.send()
161
- }
162
-
163
- window.location.replace("/");
164
- }
165
-
166
- get_editing_student()
167
- </script>
168
- </html>