Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
neuro-images
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Александр Чаплыгин
neuro-images
Commits
9622aa79
Commit
9622aa79
authored
Jun 03, 2022
by
Александр Чаплыгин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Загрузка архивных картинок, хранение инфы о парах в json.
parent
52c21316
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
59 deletions
+85
-59
styles-main.css
src/public/css/styles-main.css
+2
-1
5.jpg
src/public/fotos-arch/B-KazwCAcxM/5.jpg
+0
-0
fotos.dat
src/public/fotos.dat
+2
-0
script-main.js
src/public/js/script-main.js
+42
-41
Main.php
src/src/App/Action/Admin/Main.php
+39
-17
No files found.
src/public/css/styles-main.css
View file @
9622aa79
...
...
@@ -42,7 +42,8 @@
opacity
:
1
!important
;
}
.b-list_folders.new
.b-list_folders-item.viewed
/*.b-list_folders.new .b-list_folders-item.viewed*/
.b-list_folders-item.viewed
{
opacity
:
0.45
;
}
...
...
src/public/fotos-arch/B-KazwCAcxM/5.jpg
deleted
100644 → 0
View file @
52c21316
200 KB
src/public/fotos.dat
0 → 100644
View file @
9622aa79
{"B-KazwCAcxM":"","B24WGzEo8v_":"","B9RwSi4oPAh":"","B9mWsSwAvo-":{"1":["a1654267236-1.jpg","a1654267236-2.jpg"]}}
\ No newline at end of file
src/public/js/script-main.js
View file @
9622aa79
...
...
@@ -14,7 +14,8 @@ $(document).ready(function(){
colorsActive
=
$foldersContentWrap
.
data
(
'colors'
),
pairsCount
=
$foldersContentWrap
.
data
(
'pairs_count'
),
currentNumToSelect
=
{},
hasSelectedFoto
=
{};
hasSelectedFoto
=
{},
archiveData
=
{};
function
StartLoading
()
{
...
...
@@ -40,10 +41,21 @@ $(document).ready(function(){
$folder
.
addClass
(
'active'
);
}
function
MarkFolderViewed
(
$folderName
)
function
MarkFolderViewed
(
$folderName
,
type
)
{
$folderName
.
addClass
(
'viewed'
);
$saveButton
.
removeClass
(
'disabled'
);
if
(
type
==
'new'
)
{
$folderName
.
addClass
(
'viewed'
);
$saveButton
.
removeClass
(
'disabled'
);
}
}
function
MarkArchFolderViewed
(
folderName
,
$this
)
{
if
(
$this
.
parents
(
'.b-preview_inner'
).
hasClass
(
'arch'
))
{
console
.
log
(
'AAA MarkArchFolderViewed '
,
folderName
);
$
(
'.b-list_folders-item[data-folder="'
+
folderName
+
'"]'
).
addClass
(
'viewed'
);
$saveButton
.
removeClass
(
'disabled'
);
}
}
function
RenderFilesList
(
folderName
,
folderType
,
data
)
...
...
@@ -107,33 +119,25 @@ $(document).ready(function(){
hasSelectedFoto
[
folderName
]
=
false
;
// Выбрали одну картинку (есть подсвеченное фото)
}
function
SetPairedFotos
(
folderName
,
folderType
,
data
)
function
SetPairedFotos
(
folderName
,
folderType
)
{
if
(
folderType
==
'arch'
)
{
console
.
log
(
'AAA data = '
,
data
);
var
pairedFotos
=
{};
data
.
forEach
(
function
(
item
){
var
itemData
=
item
.
split
(
'-'
);
if
(
itemData
.
length
>
1
)
{
if
(
!
pairedFotos
[
itemData
[
0
]])
{
pairedFotos
[
itemData
[
0
]]
=
[];
}
pairedFotos
[
itemData
[
0
]].
push
(
item
);
if
(
archiveData
[
folderName
])
{
var
pairs
=
Object
.
keys
(
archiveData
[
folderName
]);
if
(
pairs
>
0
)
{
var
$folderContentWrap
=
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
,
$foldersArchContentWrap
);
pairs
.
forEach
(
function
(
pair
){
$
(
'.b-foto_inner[data-foto="'
+
archiveData
[
folderName
][
pair
][
0
]
+
'"] '
,
$folderContentWrap
).
click
();
$
(
'.b-foto_inner[data-foto="'
+
archiveData
[
folderName
][
pair
][
1
]
+
'"] '
,
$folderContentWrap
).
click
();
});
$
(
'.b-list_folders-item[data-folder="'
+
folderName
+
'"]'
).
removeClass
(
'viewed'
);
$saveButton
.
addClass
(
'disabled'
);
}
});
console
.
log
(
'AAA pairedFotos = '
,
pairedFotos
);
var
pairs
=
Object
.
keys
(
pairedFotos
);
if
(
pairs
>
0
)
{
pairs
.
forEach
(
function
(
pair
){
$
(
'.b-foto_inner[data-foto="'
+
pairedFotos
[
pair
][
0
]
+
'"] '
,
$foldersArchContentWrap
).
click
();
$
(
'.b-foto_inner[data-foto="'
+
pairedFotos
[
pair
][
1
]
+
'"] '
,
$foldersArchContentWrap
).
click
();
});
}
}
}
function
RenderFoldersList
(
type
,
data
)
...
...
@@ -287,14 +291,12 @@ $(document).ready(function(){
// Клик по фото без рамки
if
(
!
hasSelectedFoto
[
folderName
])
{
// выбор первого фото для пары:
console
.
log
(
'AAA 1-е фото в пару'
);
//console.log('AAA выбор 1-е фото для пары');
num
=
currentNumToSelect
[
folderName
];
hasSelectedFoto
[
folderName
]
=
true
;
$currentFolderWrap
.
addClass
(
'has-selected'
);
}
else
{
// выбор второго фото для пары (пара сформирована):
//console.log('AAA 2-е фото в пару');
//console.log('AAA выбор 2-е фото для пары (пара сформирована)');
num
=
currentNumToSelect
[
folderName
];
$pairedFoto
=
$
(
'.b-foto_inner[data-num="'
+
num
+
'"]'
,
$currentFolderWrap
);
$this
.
addClass
(
'paired'
);
...
...
@@ -311,12 +313,11 @@ $(document).ready(function(){
foto1
.
appendTo
(
$
(
'.sorted'
,
$currentFolderWrap
));
foto2
.
appendTo
(
$
(
'.sorted'
,
$currentFolderWrap
));
SetDataGroupContents
(
$currentFolderWrap
);
MarkArchFolderViewed
(
folderName
,
$this
);
currentNumToSelect
[
folderName
]
=
getCurrenNumToSelect
(
$currentFolderWrap
);
hasSelectedFoto
[
folderName
]
=
false
;
$currentFolderWrap
.
removeClass
(
'has-selected'
);
}
$
(
'.b-foto_number'
,
$this
).
text
(
num
);
...
...
@@ -335,8 +336,7 @@ $(document).ready(function(){
}
else
{
// Клик по фото с рамкой
console
.
log
(
'AAA Клик по фото с рамкой'
);
//console.log('AAA Клик по фото с рамкой');
var
pairedNum
=
parseInt
(
$this
.
attr
(
'data-num'
)),
...
...
@@ -356,6 +356,7 @@ $(document).ready(function(){
foto
.
appendTo
(
$
(
'.not-sorted'
,
$currentFolderWrap
));
});
SetDataGroupContents
(
$currentFolderWrap
);
MarkArchFolderViewed
(
folderName
,
$this
);
}
$
(
'.b-foto_number'
,
$pairedFotos
).
text
(
''
);
...
...
@@ -392,11 +393,11 @@ $(document).ready(function(){
$foldersContent
.
hide
().
removeClass
(
'active'
);
if
(
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
).
length
>
0
)
{
console
.
log
(
'AAA отображаем'
);
//
console.log('AAA отображаем');
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
).
show
().
addClass
(
'active'
);
MarkFolderSelected
(
$this
,
folderType
);
}
else
{
console
.
log
(
'AAA подгружаем'
);
//
console.log('AAA подгружаем');
StartLoading
();
$
.
ajax
(
action
,
{
type
:
method
,
...
...
@@ -405,9 +406,9 @@ $(document).ready(function(){
//console.log('AAA success', data);
StopLoading
();
RenderFilesList
(
folderName
,
folderType
,
data
);
SetPairedFotos
(
folderName
,
folderType
,
data
);
SetPairedFotos
(
folderName
,
folderType
);
MarkFolderSelected
(
$this
,
folderType
);
MarkFolderViewed
(
$this
);
MarkFolderViewed
(
$this
,
folderType
);
},
error
:
function
(
rew
,
status
,
err
)
{
console
.
log
(
status
,
err
);
...
...
@@ -432,7 +433,7 @@ $(document).ready(function(){
// Загрузка списка папок:
if
(
$
(
'li'
,
$
(
'.b-list_folders.'
+
type
)).
length
==
0
)
{
console
.
log
(
'AAA загружаем спис
ок'
);
//console.log('AAA загружаем список пап
ок');
var
$form
=
$
(
'#load-folders-list-form'
),
...
...
@@ -449,8 +450,8 @@ $(document).ready(function(){
success
:
function
(
data
)
{
console
.
log
(
'AAA success'
,
data
);
StopLoading
();
RenderFoldersList
(
type
,
data
);
RenderFoldersList
(
type
,
data
[
'folders'
]
);
archiveData
=
data
[
'archive'
];
},
error
:
function
(
rew
,
status
,
err
)
{
console
.
log
(
status
,
err
);
...
...
src/src/App/Action/Admin/Main.php
View file @
9622aa79
...
...
@@ -89,7 +89,7 @@ class Main extends Common
$data
=
$request
->
getParsedBody
();
$folders_list
=
[];
return
new
JsonResponse
(
$data
);
$unic
=
time
(
);
/*
$resp = [
...
...
@@ -100,6 +100,28 @@ class Main extends Common
*/
chdir
(
'public/'
);
$file_name
=
"fotos.dat"
;
$file_data
=
json_decode
(
file_get_contents
(
$file_name
),
true
);
foreach
(
$data
as
$folder
=>
$pairs
)
{
$data_folder
=
$pairs
;
if
(
is_array
(
$pairs
))
{
$data_folder
=
[];
foreach
(
$pairs
as
$pair
=>
$files
)
{
$data_folder
[
$pair
]
=
[];
foreach
(
$files
as
$file
)
{
$data_folder
[
$pair
][]
=
'a'
.
$unic
.
'-'
.
$file
;
}
}
}
$file_data
[
$folder
]
=
$data_folder
;
}
file_put_contents
(
$file_name
,
json_encode
(
$file_data
));
foreach
(
$data
as
$folder
=>
$pairs
)
{
...
...
@@ -117,20 +139,7 @@ class Main extends Common
while
(
false
!==
(
$entry
=
$d
->
read
()))
{
if
(
$entry
==
"."
||
$entry
==
".."
)
continue
;
if
(
$pairs
)
{
$pair_num
=
''
;
foreach
(
$pairs
as
$pair
=>
$pair_files
)
{
if
(
in_array
(
$entry
,
$pair_files
))
{
$pair_num
=
$pair
.
'-'
;
break
;
}
}
copy
(
"
$from
/
$entry
"
,
"
$to
/
$pair_num$entry
"
);
}
else
{
copy
(
"
$from
/
$entry
"
,
"
$to
/
$entry
"
);
}
copy
(
"
$from
/
$entry
"
,
"
$to
/a
$unic
-
$entry
"
);
}
$d
->
close
();
...
...
@@ -149,7 +158,6 @@ class Main extends Common
chdir
(
'..'
);
$resp
=
[
'result'
=>
true
,
'folders'
=>
$folders_list
,
...
...
@@ -203,6 +211,14 @@ class Main extends Common
if
(
$data
[
'type'
]
==
'new'
)
$folder
=
'fotos'
;
if
(
$data
[
'type'
]
==
'arch'
)
$folder
=
'fotos-arch'
;
if
(
$data
[
'type'
]
==
'arch'
)
{
chdir
(
'public/'
);
$file_name
=
"fotos.dat"
;
$archive_data
=
json_decode
(
file_get_contents
(
$file_name
),
true
);
chdir
(
'..'
);
}
chdir
(
"public/
$folder
"
);
$dir
=
getcwd
();
chdir
(
'../..'
);
...
...
@@ -214,7 +230,13 @@ class Main extends Common
}
}
$response
=
new
JsonResponse
(
$folders
);
$resp
=
[
'folders'
=>
$folders
,
'archive'
=>
$archive_data
];
$response
=
new
JsonResponse
(
$resp
);
}
else
{
$data
=
[
'result'
=>
false
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment