yeungalan 5 jaren geleden
bovenliggende
commit
7339b35975

BIN
Slideshow/.DS_Store


+ 11 - 0
Slideshow/backend/iodb.js

@@ -0,0 +1,11 @@
+newDBTableIfNotExists("PhotoSlideShow");
+
+writeDBItem("PhotoSlideShow", "folder", path);
+writeDBItem("PhotoSlideShow", "interval", interval);
+
+/*
+writeDBItem("PhotoSlideShow", "folder", "user:/Photo/Photo/uploads/");
+writeDBItem("PhotoSlideShow", "interval", "200000");
+*/
+HTTP_HEADER = "text/html";
+sendResp('<meta http-equiv="refresh" content="0; URL=/Slideshow/setting.html?c=c">Completed. Click <a href="/Slideshow/setting.html?c=c">here</p> to return');

+ 26 - 0
Slideshow/backend/listFile.js

@@ -0,0 +1,26 @@
+var loadedfile = requirelib("filelib");
+if (!loadedfile) {
+    console.log("Failed to load lib filelib, terminated.");
+}
+
+//Get all the files filesize on desktop
+var folder = readDBItem("PhotoSlideShow", "folder");
+//var folder = "user:/Photo/Photo/uploads/";
+var interval = readDBItem("PhotoSlideShow", "interval");
+
+var fileList = filelib.glob(folder + "*.*");
+var results = [];
+for (var i = 0; i < fileList.length; i++) {
+    if (!filelib.isDir(fileList[i])) { //Well I don't had isFile, then use !isDir have same effect.
+        var subFilename = fileList[i].split(".").pop().toLowerCase();
+        if (["jpg", "jpeg", "gif", "png"].indexOf(subFilename) >= 0) {
+            //imagelib.resizeImage(src, dest, width, height)
+            var filename = fileList[i].split("/").pop();
+
+            results.push("/media/?file=" + folder + filename);
+        }
+    }
+}
+
+var returnArray = { "interval": interval, "results": results };
+sendJSONResp(JSON.stringify(returnArray));

+ 149 - 0
Slideshow/backup_html.html

@@ -0,0 +1,149 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
+    <style>
+        body {
+            background-color: black;
+            height: 100%;
+            overflow: hidden;
+        }
+        
+        .slide {
+            display: none;
+            /**/
+        }
+        
+        .slide.active {
+            display: block !important;
+            /**/
+        }
+        
+        img {
+            vertical-align: middle;
+            height: auto;
+            max-height: 100vh;
+            max-width: 100vw;
+            overflow: hidden;
+            object-fit: cover;
+        }
+        
+        .slideshow {
+            max-width: 100vw;
+            position: relative;
+            margin: auto;
+        }
+        
+        .dot {
+            cursor: pointer;
+            height: 10px;
+            width: 10px;
+            margin: 0 2px;
+            background-color: #b7c6d8;
+            border-radius: 50%;
+            display: inline-block;
+        }
+        
+        .dot.active,
+        .dot:hover {
+            background-color: #0067e6;
+        }
+    </style>
+</head>
+
+<body>
+
+    <div class="slideshow">
+
+
+    </div>
+    <br>
+
+    <script>
+        var endpoint = "/system/ajgi/interface?script=/DemoPhoto/backend/listFile.js";
+        var image = [];
+        var interval = 0;
+
+        $.getJSON(endpoint, function(data) {
+            image = data["results"];
+            interval = data["interval"];
+        }).done(function() {
+            $(".slideshow").append('<div class="selector" style="text-align: center; position: absolute; top: ; bottom: 20px; left: 15px; "></div>');
+            for (var i = 0; i < image.length; i++) {
+                $('<div class="slide"><img src="' + image[i] + '" style="width:100% "></div>').insertBefore(".slideshow > .selector");
+                $(".slideshow > .selector").append('<span class="dot" onclick="showSlides(' + (i + 1) + ') "></span>');
+            }
+            //realigin to center
+            upd();
+            showSlides(1);
+            $('.slideshow .slide').on('load', function() {
+                upd();
+
+            });
+            $(window).on('resize', function() {
+                upd();
+            });
+
+            //auto refresh
+            setInterval(function() {
+                var selector = $(".slideshow > .selector > .dot.active").next();
+                if (selector.length > 0) {
+                    selector.click();
+                } else {
+                    $(".slideshow > .selector > .dot").first().click();
+                }
+            }, interval);
+        });
+
+
+
+
+        function showSlides(n) {
+            $(".slideshow .slide").fadeOut(500, "linear");
+            $(".slideshow .slide").attr("class", "slide")
+            $(".slideshow .slide:nth-child(" + (n) + ")").attr("class", "slide active")
+            $(".slideshow .slide:nth-child(" + (n) + ")").fadeIn("linear");
+            //dot
+            $(".slideshow .dot.active").attr("class", "dot")
+            $(".slideshow .dot:nth-child(" + (n) + ")").attr("class", "dot active")
+            upd();
+        }
+
+        function upd() {
+            //ascept ratio calculator, use to resize the image
+            var selector = $(".slideshow > .slide.active > img");
+            var img_width = selector.prop("naturalWidth");
+            var img_height = selector.prop("naturalHeight");
+            console.log(img_width, img_height);
+            var win_width = window.innerWidth;
+            var win_height = window.innerHeight;
+            var final_w = 0;
+            var final_h = 0;
+
+            final_h = win_height;
+            final_w = img_width * (win_height / img_height);
+            //reszie until everything fit the screen
+            while (final_w >= win_width) {
+                final_w *= 0.999;
+                final_h *= 0.999;
+            }
+            selector.height(final_h);
+            selector.width(final_w);
+
+            if (img_width < win_width && img_height < win_height) {
+                selector.height(img_height);
+                selector.width(img_width);
+            }
+
+            $('.slide.active').css('margin-left', (window.innerWidth - selector.width()) / 2);
+            $('.slide.active').css('margin-top', (window.innerHeight - selector.height()) / 2);
+
+
+        }
+    </script>
+
+</body>
+
+</html>

BIN
Slideshow/img/baseline_login_black_48dp.png


BIN
Slideshow/img/function_icon.png


BIN
Slideshow/img/function_icon.psd


BIN
Slideshow/img/small_icon.png


BIN
Slideshow/img/small_icon.psd


+ 153 - 0
Slideshow/index.html

@@ -0,0 +1,153 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
+    <style>
+        body {
+            background-color: black;
+            height: 100%;
+            overflow: hidden;
+        }
+        
+        .slide {
+            display: none;
+            /**/
+        }
+        
+        .slide.active {
+            display: block !important;
+            /**/
+        }
+        
+        img {
+            vertical-align: middle;
+            height: auto;
+            max-height: 100vh;
+            max-width: 100vw;
+            overflow: hidden;
+            object-fit: cover;
+        }
+        
+        .slideshow {
+            max-width: 100vw;
+            position: relative;
+            margin: auto;
+        }
+        
+        .dot {
+            cursor: pointer;
+            height: 10px;
+            width: 10px;
+            margin: 0 2px;
+            background-color: #b7c6d8;
+            border-radius: 50%;
+            display: inline-block;
+        }
+        
+        .dot.active,
+        .dot:hover {
+            background-color: #0067e6;
+        }
+    </style>
+</head>
+
+<body>
+
+    <div class="slideshow">
+
+
+    </div>
+    <br>
+    <div style="text-align: center; position: absolute; bottom: 0px; right: 0px;width:100px;height:100px" onclick="toSetting()"></div>
+    <script>
+        var endpoint = "/system/ajgi/interface?script=/Slideshow/backend/listFile.js";
+        var image = [];
+        var interval = 0;
+
+        $.getJSON(endpoint, function(data) {
+            image = data["results"];
+            interval = data["interval"];
+        }).done(function() {
+            $("body").append('<div class="selector" style="text-align: center; position: absolute; bottom: 20px; left: 15px; "></div>');
+            for (var i = 0; i < image.length; i++) {
+                $("body > .slideshow").append('<div class="slide"><img src="' + image[i] + '" style="width:100% "></div>');
+                $("body > .selector").append('<span class="dot" onclick="showSlides(' + (i + 1) + ') "></span>');
+            }
+            //realigin to center
+            upd();
+            showSlides(1);
+            $('.slideshow .slide').on('load', function() {
+                upd();
+
+            });
+            $(window).on('resize', function() {
+                upd();
+            });
+
+            //auto refresh
+            setInterval(function() {
+                var selector = $("body > .selector > .dot.active").next();
+                if (selector.length > 0) {
+                    selector.click();
+                } else {
+                    $("body > .selector > .dot").first().click();
+                }
+            }, interval);
+        });
+
+
+
+
+        function showSlides(n) {
+            $(".slideshow .slide").fadeOut(500, "linear");
+            $(".slideshow .slide").attr("class", "slide")
+            $(".slideshow .slide:nth-child(" + (n) + ")").attr("class", "slide active")
+            $(".slideshow .slide:nth-child(" + (n) + ")").fadeIn("linear");
+            //dot
+            $("body .dot.active").attr("class", "dot")
+            $("body .dot:nth-child(" + (n) + ")").attr("class", "dot active")
+            upd();
+        }
+
+        function upd() {
+            //ascept ratio calculator, use to resize the image
+            var selector = $(".slideshow > .slide.active > img");
+            var img_width = selector.prop("naturalWidth");
+            var img_height = selector.prop("naturalHeight");
+            console.log(img_width, img_height);
+            var win_width = window.innerWidth;
+            var win_height = window.innerHeight;
+            var final_w = 0;
+            var final_h = 0;
+
+            final_h = win_height;
+            final_w = img_width * (win_height / img_height);
+            //reszie until everything fit the screen
+            while (final_w >= win_width) {
+                final_w *= 0.999;
+                final_h *= 0.999;
+            }
+            selector.height(final_h);
+            selector.width(final_w);
+
+            if (img_width < win_width && img_height < win_height) {
+                selector.height(img_height);
+                selector.width(img_width);
+            }
+
+            $('.slide.active').css('margin-left', (window.innerWidth - selector.width()) / 2);
+            $('.slide.active').css('margin-top', (window.innerHeight - selector.height()) / 2);
+
+
+        }
+
+        function toSetting() {
+            window.location.href = "setting.html";
+        }
+    </script>
+
+</body>
+
+</html>

+ 18 - 0
Slideshow/init.agi

@@ -0,0 +1,18 @@
+/*
+	Dummy Module Registration Information
+	
+	Do not try to call any AJGI users / filepath functions in this script.
+*/
+
+
+//Define the launchInfo for the module
+var moduleLaunchInfo = {
+    Name: "Photo M",
+	Group: "Interface Module",
+	IconPath: "DemoPhoto/img/small_icon.png",
+	Version: "0.1",
+	StartDir: "DemoPhoto/index.html"
+}
+
+//Register the module
+registerModule(JSON.stringify(moduleLaunchInfo));

+ 34 - 0
Slideshow/setting.html

@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
+    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
+    <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
+</head>
+
+<body>
+    <div id="alert"></div>
+    <form class="ui form" id="form" action="/system/ajgi/interface?script=/Slideshow/backend/iodb.js" method="post">
+        <div class="field">
+            <label>Folder Path</label>
+            <input type="text" name="path" placeholder="Folder Path">
+        </div>
+        <div class="field">
+            <label>Interval</label>
+            <input type="text" name="interval" placeholder="Interval (ms)">
+        </div>
+        <button class="ui button" type="submit">Update</button>
+    </form>
+
+</body>
+<Script>
+    var url = new URL(window.location);
+    var c = url.searchParams.get("c");
+    if (c == "c") {
+        $("#alert").html('<div class="ui green message">Completed!</div>');
+    }
+</Script>
+
+</html>