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
5b7241cf
Commit
5b7241cf
authored
Jun 08, 2022
by
Александр Чаплыгин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
логика выставления текущего состоянии по архивным данным и данным из черновика
parent
ef1d50d0
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
174 additions
and
88 deletions
+174
-88
styles-main.css
src/public/css/styles-main.css
+8
-3
fotos.dat
src/public/fotos.dat
+2
-0
common.js
src/public/js/common.js
+2
-1
script-main.js
src/public/js/script-main.js
+122
-74
Index.php
src/src/App/Action/Admin/Index.php
+17
-5
Main.php
src/src/App/Action/Admin/Main.php
+17
-3
main.phtml
src/templates/app/main.phtml
+6
-2
No files found.
src/public/css/styles-main.css
View file @
5b7241cf
...
...
@@ -22,6 +22,10 @@
overflow-y
:
auto
;
}
.b-list_folders.active
{
display
:
block
;
}
.b-list_folders-item
{
position
:
relative
;
...
...
@@ -153,17 +157,18 @@
border-radius
:
4px
;
overflow
:
hidden
;
cursor
:
pointer
;
height
:
450px
;
height
:
calc
(
50vh
-
30px
)
;
}
.b-foto_inner-
emul
.b-foto_inner-
fict
{
height
:
450px
;
height
:
calc
(
50vh
-
30px
)
;
}
.b-foto_inner.single-row
{
height
:
auto
;
max-height
:
calc
(
100vh
-
60px
);
}
.b-folder-content.has-selected
.b-foto_inner.paired
{
...
...
src/public/fotos.dat
View file @
5b7241cf
{"10-foto":{"1":["a1654670926-1.jpg","a1654670926-10.jpg"],"2":["a1654670926-2.jpg","a1654670926-3.jpg"],"3":["a1654670926-4.jpg","a1654670926-5.jpg"]},"2-foto":{"1":["a1654670926-1.jpg","a1654670926-2.jpg"]},"3-foto":{"1":["a1654665594-1.jpg","a1654665594-2.jpg"]},"4-foto":{"1":["a1654663117-1.jpg","a1654663117-2.jpg"]},"5-foto":"","6-foto":{"1":["a1654670995-1.jpg","a1654670995-3.jpg"],"2":["a1654670995-2.jpg","a1654670995-4.jpg"]},"7-foto":"","8-foto":"","9-foto":"","B-KazwCAcxM":{"1":["a1654670926-1.jpg","a1654670926-4.jpg"],"2":["a1654670926-2.jpg","a1654670926-3.jpg"]},"B24WGzEo8v_":"","B9RwSi4oPAh":""}
\ No newline at end of file
src/public/js/common.js
View file @
5b7241cf
$
(
document
).
ready
(
function
(){
console
.
log
(
'AAA common.js'
);
//
console.log('AAA common.js');
});
\ No newline at end of file
src/public/js/script-main.js
View file @
5b7241cf
...
...
@@ -2,6 +2,7 @@ $(document).ready(function(){
var
$body
=
$
(
'body'
),
$selectFoldersType
=
$
(
'.b-list_select-folders'
),
$listFolders
=
$
(
'.b-list_folders'
),
$listFoldersNew
=
$
(
'.b-list_folders.new'
),
$listFoldersArch
=
$
(
'.b-list_folders.arch'
),
...
...
@@ -14,6 +15,9 @@ $(document).ready(function(){
colorsActive
=
$foldersContentWrap
.
data
(
'colors'
),
pairsCount
=
$foldersContentWrap
.
data
(
'pairs_count'
),
storageName
=
'im_fotos'
,
dataLS
=
null
,
folderTypeStorage
=
null
,
folderStorage
=
null
,
dataStorage
=
null
,
currentNumToSelect
=
{},
// Номер пары для очередного выбора
hasSelectedFoto
=
{},
// Выбрали одну картинку (есть подсвеченное фото)
...
...
@@ -38,7 +42,6 @@ $(document).ready(function(){
function
MarkFolderSelected
(
$folder
,
type
)
{
var
$foldersList
=
getFoldersList
(
type
);
$
(
'.b-list_folders-item'
,
$foldersList
).
removeClass
(
'active'
);
$folder
.
addClass
(
'active'
);
}
...
...
@@ -46,10 +49,10 @@ $(document).ready(function(){
function
MarkNewFolderViewed
(
$folderName
,
type
)
{
if
(
type
==
'new'
)
{
//console.log('AAA MarkNewFolderViewed');
if
(
!
$folderName
.
hasClass
(
'viewed'
))
{
$folderName
.
addClass
(
'viewed'
);
$saveButton
.
removeClass
(
'disabled'
);
SaveLsState
();
}
}
}
...
...
@@ -57,6 +60,7 @@ $(document).ready(function(){
function
MarkArchFolderViewed
(
folderName
,
$this
)
{
if
(
$this
.
parents
(
'.b-preview_inner'
).
hasClass
(
'arch'
))
{
//console.log('AAA MarkArchFolderViewed');
$
(
'.b-list_folders-item[data-folder="'
+
folderName
+
'"]'
).
addClass
(
'viewed'
);
$saveButton
.
removeClass
(
'disabled'
);
}
...
...
@@ -85,13 +89,9 @@ $(document).ready(function(){
' <div class="b-foto-double col">'
+
' <% } %>'
+
' <% }) %>
\
n'
+
' <% if ((files.length % 2) != 0) { %>'
+
' <div class="b-foto"><div class="b-foto_inner-
emul
"></div></div>'
+
' <div class="b-foto"><div class="b-foto_inner-
fict
"></div></div>'
+
' <% } %>'
+
' </div>'
+
'</div>'
),
...
...
@@ -135,7 +135,7 @@ $(document).ready(function(){
function
SetPairedFotos
(
folderName
,
folderType
)
{
console
.
log
(
'AAA SetPairedFotos '
,
folderName
,
dataStorag
e
);
console
.
log
(
'AAA SetPairedFotos '
,
folderName
,
folderTyp
e
);
var
sourceData
=
null
;
...
...
@@ -159,8 +159,8 @@ $(document).ready(function(){
if
(
folderType
==
'arch'
)
{
if
(
archiveData
[
folderName
])
sourceData
=
archiveData
[
folderName
];
if
(
dataStorage
[
folderName
])
sourceData
=
dataStorage
[
folderName
];
if
(
archiveData
&&
archiveData
[
folderName
])
sourceData
=
archiveData
[
folderName
];
if
(
dataStorage
&&
dataStorage
[
folderName
])
sourceData
=
dataStorage
[
folderName
];
if
(
sourceData
)
{
var
pairs
=
Object
.
keys
(
sourceData
);
...
...
@@ -173,8 +173,6 @@ $(document).ready(function(){
});
}
}
}
}
...
...
@@ -326,55 +324,66 @@ $(document).ready(function(){
function
ShowFoldersNew
()
{
$listFoldersNew
.
show
();
//console.log('AAA ShowFoldersNew');
$listFolders
.
removeClass
(
'active'
);
$foldersContentWrapInner
.
removeClass
(
'active'
);
$listFoldersNew
.
addClass
(
'active'
);
$foldersNewContentWrap
.
addClass
(
'active'
);
}
function
ShowFoldersArch
()
{
$listFoldersArch
.
show
();
//console.log('AAA ShowFoldersArch');
$listFolders
.
removeClass
(
'active'
);
$foldersContentWrapInner
.
removeClass
(
'active'
);
$listFoldersArch
.
addClass
(
'active'
);
$foldersArchContentWrap
.
addClass
(
'active'
);
}
function
SaveLsState
()
{
var
data
=
GetFoldersDataState
();
var
data
=
{
data
:
GetFoldersDataState
(),
folder
:
$
(
'.b-list_folders.active .b-list_folders-item.active'
).
data
(
'folder'
),
type
:
$
(
'.b-list_folders.active'
).
data
(
'type'
),
};
console
.
log
(
'AAA SaveLsState '
,
data
);
localStorage
.
setItem
(
storageName
,
JSON
.
stringify
(
data
));
}
function
SetStateFromLs
(
folder
)
function
SetStateFromLs
()
{
var
data
=
localStorage
.
getItem
(
storageName
);
if
(
data
)
{
dataStorage
=
JSON
.
parse
(
data
);
console
.
log
(
'AAA SetStateFromLs '
,
dataStorage
);
console
.
log
(
'AAA SetStateFromLs'
);
dataLS
=
JSON
.
parse
(
localStorage
.
getItem
(
storageName
));
folderTypeStorage
=
dataLS
.
type
;
folderStorage
=
dataLS
.
folder
;
dataStorage
=
dataLS
.
data
;
if
(
folderTypeStorage
==
'new'
)
ShowFoldersNew
();
if
(
folderTypeStorage
==
'arch'
)
ShowFoldersArch
();
$selectFoldersType
.
val
(
folderTypeStorage
);
if
(
folder
==
'new'
||
folder
==
'arch'
)
{
Object
.
keys
(
dataStorage
).
forEach
(
function
(
item
){
console
.
log
(
'AAA '
,
item
);
$
(
'.b-list_folders-item[data-folder="'
+
item
+
'"]'
,
$listFolders
).
addClass
(
'viewed'
);
if
(
dataStorage
[
item
])
{
$
(
'.b-list_folders-item[data-folder="'
+
item
+
'"] b'
,
$listFolders
).
text
(
Object
.
keys
(
dataStorage
[
item
]).
length
);
}
});
}
else
{
}
}
$
(
'.b-list_folders-item[data-folder="'
+
folderStorage
+
'"]'
).
trigger
(
"click"
,
{
data
:
'emul'
});
$saveButton
.
removeClass
(
'disabled'
);
}
function
GetFoldersDataState
()
{
// Формируем данные о картинках-парах:
var
data
=
{};
if
(
dataStorage
)
{
data
=
dataStorage
;
}
$
(
'.b-list_folders-item'
).
each
(
function
(){
var
$this
=
$
(
this
);
...
...
@@ -387,6 +396,11 @@ $(document).ready(function(){
$pairedFoto
=
$
(
'.b-foto_inner.paired'
,
folderContent
);
data
[
folderName
]
=
null
;
if
(
folderContent
.
length
==
0
)
{
//console.log('AAA Берём данные из LS, если они там имеются ');
if
(
dataStorage
[
folderName
])
data
[
folderName
]
=
dataStorage
[
folderName
];
}
else
{
if
(
$pairedFoto
.
length
>
0
)
{
$pairedFoto
.
each
(
function
(){
var
...
...
@@ -401,10 +415,51 @@ $(document).ready(function(){
data
[
folderName
]
=
dataPaired
;
}
}
}
});
return
data
;
}
function
GetArchiveData
(
callback
)
{
//console.log('AAA получаем архивные данные');
var
$form
=
$
(
'#load-folders-list-form'
),
action
=
$form
.
attr
(
'action'
),
method
=
$form
.
attr
(
'method'
);
StartLoading
();
$
.
ajax
(
action
,
{
type
:
method
,
success
:
function
(
data
)
{
console
.
log
(
'AAA success'
,
data
);
StopLoading
();
archiveData
=
data
[
'archive'
];
// Выставляем кол-во пар в архивных сетах
if
(
archiveData
)
{
Object
.
keys
(
archiveData
).
forEach
(
function
(
item
){
if
(
archiveData
[
item
])
{
$
(
'.b-list_folders-item[data-folder="'
+
item
+
'"] b'
,
$listFoldersArch
).
text
(
Object
.
keys
(
archiveData
[
item
]).
length
);
}
});
}
if
(
callback
&&
$
.
isFunction
(
callback
))
{
callback
();
}
},
error
:
function
(
rew
,
status
,
err
)
{
console
.
log
(
status
,
err
);
}
});
}
// Обработка нажатия клавиш:
$body
.
keyup
(
function
(
e
)
{
...
...
@@ -543,7 +598,12 @@ $(document).ready(function(){
});
// Клик на папку для загрузки фотографий:
$listFolders
.
on
(
'click'
,
'.b-list_folders-item'
,
function
(){
$listFolders
.
on
(
'click'
,
'.b-list_folders-item'
,
function
(
event
,
param
){
var
isEmul
=
false
;
if
(
param
&&
(
param
[
'data'
]
==
'emul'
))
{
isEmul
=
true
;
}
var
$this
=
$
(
this
),
...
...
@@ -562,11 +622,15 @@ $(document).ready(function(){
$foldersContent
.
hide
().
removeClass
(
'active'
);
if
(
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
).
length
>
0
)
{
//console.log('AAA отображаем
'
);
//console.log('AAA отображаем
', folderName
);
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
).
show
().
addClass
(
'active'
);
MarkFolderSelected
(
$this
,
folderType
);
//if (folderType == 'new') {
SaveLsState
();
//}
}
else
{
//console.log('AAA подгружаем
'
);
//console.log('AAA подгружаем
', folderName
);
StartLoading
();
$
.
ajax
(
action
,
{
type
:
method
,
...
...
@@ -578,6 +642,10 @@ $(document).ready(function(){
SetPairedFotos
(
folderName
,
folderType
);
MarkFolderSelected
(
$this
,
folderType
);
MarkNewFolderViewed
(
$this
,
folderType
);
//if (!isEmul && folderType == 'new') {
if
(
!
isEmul
)
{
SaveLsState
();
}
},
error
:
function
(
rew
,
status
,
err
)
{
console
.
log
(
status
,
err
);
...
...
@@ -589,19 +657,20 @@ $(document).ready(function(){
return
false
;
});
// Изменение типа отображаем
ой папки
:
$
(
'.b-list_select-folders'
)
.
on
(
'change'
,
function
(){
var
type
=
$
(
this
).
val
(
);
// Изменение типа отображаем
ых папок
:
$
selectFoldersType
.
on
(
'change'
,
function
(){
console
.
log
(
'AAA Изменение типа отображаемых папок:'
);
$listFolders
.
hide
();
$foldersContentWrapInner
.
removeClass
(
'active'
);
var
type
=
$
(
this
).
val
();
if
(
type
==
'new'
)
ShowFoldersNew
();
if
(
type
==
'arch'
)
ShowFoldersArch
();
SaveLsState
();
// Загрузка списка папок:
/*
if ($('li', $('.b-list_folders.' + type)).length == 0) {
//console.log('AAA загружаем список папок');
var
...
...
@@ -627,45 +696,17 @@ $(document).ready(function(){
console.log(status, err);
}
});
}
*/
});
// Клик на "Сохранить"
для объявления
:
// Клик на "Сохранить":
$saveButton
.
on
(
'click'
,
function
(){
if
(
!
confirm
(
'Применить действия над изображениями?'
))
return
false
;
// Формируем данные о картинках-парах:
var
data
=
{};
$
(
'.b-list_folders-item'
).
each
(
function
(){
var
$this
=
$
(
this
);
if
(
$this
.
hasClass
(
'viewed'
))
{
var
dataPaired
=
{},
folderName
=
$this
.
data
(
'folder'
),
folderContent
=
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
),
$pairedFoto
=
$
(
'.b-foto_inner.paired'
,
folderContent
);
data
[
folderName
]
=
null
;
if
(
$pairedFoto
.
length
>
0
)
{
$pairedFoto
.
each
(
function
(){
var
$this
=
$
(
this
),
pairNum
=
$this
.
data
(
'num'
);
if
(
!
dataPaired
[
pairNum
])
{
dataPaired
[
pairNum
]
=
[];
}
dataPaired
[
pairNum
].
push
(
$this
.
data
(
'foto'
));
});
data
[
folderName
]
=
dataPaired
;
}
}
});
var
data
=
GetFoldersDataState
();
var
$form
=
$
(
'#save-folders-form'
),
...
...
@@ -673,7 +714,7 @@ $(document).ready(function(){
method
=
$form
.
attr
(
'method'
);
console
.
log
(
'AAA data = '
,
data
);
return
false
;
//
return false;
$
.
ajax
(
action
,
{
type
:
method
,
...
...
@@ -701,8 +742,14 @@ $(document).ready(function(){
});
GetArchiveData
(
function
(){
// Отображаем содержимое первой папки new при загрузке страницы:
if
(
localStorage
.
getItem
(
storageName
))
{
SetStateFromLs
();
}
else
{
ShowFoldersNew
();
SetStateFromLs
(
'new'
);
$
(
'.b-list_folders-item'
,
$listFoldersNew
).
first
().
trigger
(
"click"
,
{
data
:
'emul'
});
}
});
});
\ No newline at end of file
src/src/App/Action/Admin/Index.php
View file @
5b7241cf
...
...
@@ -45,13 +45,24 @@ class Index extends Common
{
chdir
(
'public/fotos'
);
$dir
=
getcwd
();
$dir
_new
=
getcwd
();
chdir
(
'../..'
);
$folders
=
scandir
(
$dir
);
$folders
_new
=
scandir
(
$dir_new
);
foreach
(
$folders
as
$key
=>
$folder_name
)
{
chdir
(
'public/fotos-arch'
);
$dir_arch
=
getcwd
();
chdir
(
'../..'
);
$folders_arch
=
scandir
(
$dir_arch
);
foreach
(
$folders_new
as
$key
=>
$folder_name
)
{
if
(
strpos
(
$folder_name
,
'.'
)
>
-
1
)
{
unset
(
$folders_new
[
$key
]);
}
}
foreach
(
$folders_arch
as
$key
=>
$folder_name
)
{
if
(
strpos
(
$folder_name
,
'.'
)
>
-
1
)
{
unset
(
$folders
[
$key
]);
unset
(
$folders
_arch
[
$key
]);
}
}
...
...
@@ -70,7 +81,8 @@ class Index extends Common
'lang'
=>
$request
->
getAttribute
(
'layoutInfo'
)
->
getLang
(),
'colors_active'
=>
$this
->
container
->
get
(
'config'
)[
'foto_conf'
][
'colors_active'
],
'pairs_count'
=>
$this
->
container
->
get
(
'config'
)[
'foto_conf'
][
'pairs_count'
],
'folders'
=>
$folders
,
'folders_new'
=>
$folders_new
,
'folders_arch'
=>
$folders_arch
,
'dir'
=>
$dir
,
];
...
...
src/src/App/Action/Admin/Main.php
View file @
5b7241cf
...
...
@@ -68,7 +68,8 @@ class Main extends Common
$response
=
$this
->
loadFolder
(
$request
);
break
;
case
self
::
LOAD_FOLDERS_LIST
:
$response
=
$this
->
loadFoldersList
(
$request
);
//$response = $this->loadFoldersList($request);
$response
=
$this
->
getArchiveData
(
$request
);
break
;
default
:
}
...
...
@@ -178,7 +179,6 @@ class Main extends Common
return
new
JsonResponse
(
$resp
);
}
private
function
loadFolder
(
ServerRequestInterface
$request
)
{
$data
=
$request
->
getParsedBody
();
...
...
@@ -215,7 +215,6 @@ class Main extends Common
return
$response
;
}
private
function
loadFoldersList
(
ServerRequestInterface
$request
)
{
$data
=
$request
->
getParsedBody
();
...
...
@@ -258,4 +257,18 @@ class Main extends Common
return
$response
;
}
private
function
getArchiveData
(
ServerRequestInterface
$request
)
{
chdir
(
'public/'
);
$file_name
=
"fotos.dat"
;
$archive_data
=
json_decode
(
file_get_contents
(
$file_name
),
true
);
chdir
(
'..'
);
$resp
=
[
'archive'
=>
$archive_data
];
return
new
JsonResponse
(
$resp
);
}
}
\ No newline at end of file
src/templates/app/main.phtml
View file @
5b7241cf
...
...
@@ -39,7 +39,8 @@ $form_load_link = $this->url('adm.main.loadfolder');
$form_loadlist_link
=
$this
->
url
(
'adm.main.loadfolderslist'
);
$colors_active
=
$this
->
colors_active
;
$folders
=
$this
->
folders
;
$folders_new
=
$this
->
folders_new
;
$folders_arch
=
$this
->
folders_arch
;
$dir
=
$this
->
dir
;
?>
...
...
@@ -54,12 +55,15 @@ $dir = $this->dir;
</select>
<ul
class=
"b-list_folders new"
data-type=
"new"
>
<?php
foreach
(
$folders
as
$folder
)
:
?>
<?php
foreach
(
$folders
_new
as
$folder
)
:
?>
<li
class=
"b-list_folders-item"
data-folder=
"
<?=
$folder
?>
"
>
<?=
$folder
?>
<b></b></li>
<?php
endforeach
;
?>
</ul>
<ul
class=
"b-list_folders arch"
data-type=
"arch"
>
<?php
foreach
(
$folders_arch
as
$folder
)
:
?>
<li
class=
"b-list_folders-item"
data-folder=
"
<?=
$folder
?>
"
>
<?=
$folder
?>
<b></b></li>
<?php
endforeach
;
?>
</ul>
<form
id=
"load-folders-list-form"
action=
"
<?=
$form_loadlist_link
?>
"
method=
"POST"
></form>
...
...
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