Skip to content

Commit

Permalink
on exiting slideshow, stay on current image
Browse files Browse the repository at this point in the history
  • Loading branch information
zincarla committed Nov 11, 2021
1 parent 9aa9026 commit 0c835b4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var SessionStore *sessions.CookieStore
var Configuration ConfigurationSettings

//ApplicationVersion Current version of application. This should be incremented every release
var ApplicationVersion = "1.0.4.2"
var ApplicationVersion = "1.0.4.3"

//SessionVariableName is used when checking cookies
var SessionVariableName = "gib-session"
Expand Down
6 changes: 4 additions & 2 deletions http/image-slideshow-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<body>
<script>
SSImageQuery = encodeURI("{{.OldQuery}}");
CurrentID = {{.ImageContentInfo.ID}};
function OnLoadStartNextSlideTimer() {
var time = {{.SlideShowSpeed}};
setTimeout(LoadNextSlide, time*1000) //30seconds
Expand All @@ -18,6 +19,7 @@
$("#ImageGridContainer").empty();
$("#ImageGridContainer").append(EmbedData);
ImageType = GetImageType(jsonData.Images[0].Location);
CurrentID = jsonData.Images[0].ID;
if (ImageType=="image") {
$("#ImageContent").on('load', function() { CorrectImageOrient("IMGContent"); });
}
Expand All @@ -31,7 +33,7 @@
//Replace ImageGridContainer children, with new image
}
function QuitSlideShow() {
window.location.href = "/images?ViewMode=grid&SearchTerms="+SSImageQuery;
window.location.href = "/image?ID="+CurrentID+"&ViewMode=grid&SearchTerms="+SSImageQuery;
}
window.addEventListener('load', OnLoadStartNextSlideTimer());
Mousetrap.bind("enter", QuitSlideShow)
Expand All @@ -52,5 +54,5 @@
{{end}}
</div>
</div>
<div style="position: fixed;bottom: 0px;left: 0px;"><a href="/images?ViewMode=grid&SearchTerms={{.OldQuery}}">Click here</a> or press Enter to exit slide show</div>
<div style="position: fixed;bottom: 0px;left: 0px;"><a href="/images?ViewMode=grid&SearchTerms={{.OldQuery}}" onclick="QuitSlideShow(); return false;">Click here</a> or press Enter to exit slide show</div>
{{template "footer.html" .}}
24 changes: 24 additions & 0 deletions routers/imagerouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@ func ImageGetRouter(responseWriter http.ResponseWriter, request *http.Request) {
var requestedID uint64
var err error

//Change StreamView if requested
if request.FormValue("ViewMode") == "stream" {
TemplateInput.ViewMode = "stream"
_, _, session := getSessionInformation(request)
session.Values["ViewMode"] = "stream"
session.Save(request, responseWriter)
} else if request.FormValue("ViewMode") == "slideshow" {
TemplateInput.ViewMode = "slideshow"
_, _, session := getSessionInformation(request)
session.Values["ViewMode"] = "slideshow"
if request.FormValue("slideshowspeed") != "" {
parsedSSS, err := strconv.ParseInt(request.FormValue("slideshowspeed"), 10, 64)
if err == nil && parsedSSS > 0 {
session.Values["slideshowspeed"] = parsedSSS
}
}
session.Save(request, responseWriter)
} else if request.FormValue("ViewMode") != "" { //default to grid on invalid modes
TemplateInput.ViewMode = "grid"
_, _, session := getSessionInformation(request)
session.Values["ViewMode"] = "grid"
session.Save(request, responseWriter)
}

//ID should come from request
requestedID, err = strconv.ParseUint(request.FormValue("ID"), 10, 32)
if err != nil {
Expand Down

0 comments on commit 0c835b4

Please sign in to comment.