//-------Logon--------------------- $(function () { $("#txtUsername").val(GetCacheValue("username")); }); function TryLogon() { var username = $("#txtUsername").val(); var password = $("#txtPassword").val(); var errMsg = ""; if (username == "") { errMsg = "Please enter your username\r\n"; } if (password == "") { errMsg += "Please enter your password\r\n"; } if (errMsg != "") { alert(errMsg) return; } $.mobile.showPageLoadingMsg(); SaveCache("username", username); Log("Start log on:" + username); APILogonRemoteServer(username, password, LogonCallback); } function LogonCallback(apiResult) { if (apiResult.Status == 0) {//Need logon. } else if (apiResult.Status == -1) {//Error. $.mobile.hidePageLoadingMsg(); alert("Send your request failed. Please check your network and try again."); } else if (apiResult.Status = 1) { var s = GetAPIValue("SESSIONID", apiResult.ReturnData); if (s == "" || s == "0") { $.mobile.hidePageLoadingMsg(); alert("Your username or password is incorrect! please check and try again."); } else { SaveCache(SESSIONKEY, s); dhqSesID = s; var username = GetAPIValue("USERNAME", apiResult.ReturnData); Log("SessionID:" + s); Log("Username:" + username); SaveCache(USERNAMEKEY, username); GotoPage("cameralist"); GetCameraList(); } } } //-------End Logon----------------- var cachedCameras = null; //-------Camera List -------------- function GetCameraList() { $.mobile.showPageLoadingMsg(); APIGetCameraList(onGetCamListSucc); } function onGetCamListSucc(apiResult) { $.mobile.hidePageLoadingMsg(); var json = ""; if (apiResult.Status == 0) {//Need logon. $.mobile.hidePageLoadingMsg(); alert("Your session has timed out! Please re-log on!"); GotoPage("logon"); return; } else if (apiResult.Status == -1) {//Error. alert("Send your request failed. Please check your network and try again."); return; } else if (apiResult.Status = 1) { json = (apiResult.ReturnData); } if (json == "1") { //need logon GotoPage("logon"); } else if (json == "") { showEmpty(); } else { try { cachedCameras = eval(json); $(".cameralistContainer").css("display", ""); $(".cameralistContainer").empty(); var markup = "
  • "; markup += "
    "; markup += "      
    ${name}
    "; markup += "
    "; // markup += "" markup += "\ \ \ \ " markup += "
    "; markup += "
    "; markup += "
  • "; /* Compile markup string as a named template */ $.template("camlistContent", markup); /* Render the named template */ $.tmpl("camlistContent", cachedCameras).appendTo(".cameralistContainer"); } catch (ex) { //something is wrong, //Goto("index.html"); showEmpty(); } } $.mobile.hidePageLoadingMsg(); } function PayCamera(cameraID, name, sID) { parentID = cameraID; cameraname = name; if (sID > 0) { shareID = sID; } else { shareID = 0; } GotoPage("camerashow"); StartCameraShow(); } function SlideShow(cameraID, name) { parentID = cameraID; cameraname = name; ct = null; GotoPage("slideshow"); StartSlideShow(); } //--------Camera List-------- //--------Account------------ function CameraAccount() { GotoPage("account"); $.mobile.showPageLoadingMsg(); APIGetAcctBalance(RefreshCameraAccountResult); } function RefreshCameraAccountResult(apiResult) { $.mobile.hidePageLoadingMsg(); if (apiResult.Status == 0) {//Need logon. alert("Your session has timed out! Please re-log on!"); GotoPage("logon"); } else if (apiResult.Status == -1) {//Error. alert("Send your request failed. Please check your network and try again."); } else if (apiResult.Status = 1) { try { var acctResult = eval(apiResult.ReturnData)[0]; $("#act_username").html(acctResult.username); $("#act_emailaddr").html(acctResult.emailAddr); $("#act_accttype").html(acctResult.acctType); $("#act_maxlicense").html(acctResult.maxCamLicense); $("#act_usedlicenses").html(acctResult.usedCamLicense); $("#act_cashbal").html("$"+acctResult.cashBalance); } catch (ex) {Log(ex); } } } //---------Config------------ function CameraConfig(isRefresh) { GotoPage("config"); $.mobile.showPageLoadingMsg(); Log(isRefresh); if (isRefresh) { APIGetCameraList(function (apiResult) { if (apiResult.ReturnData != null) { cachedCameras = eval(apiResult.ReturnData); } SetCameraConfigInfo(cachedCameras); }, null, null); } else { SetCameraConfigInfo(cachedCameras); } } function SetCameraConfigInfo(cachedCameras) { $.mobile.hidePageLoadingMsg(); var cameras = ""; if (cachedCameras == null || cachedCameras.length == 0) cameras = "No Camera"; else { for (var i = 0; i < cachedCameras.length; i++) { cameras += "\\" + cachedCameras[i].name + "
    "; } } $("#cameraList").html(cameras); $("#config_username").html(GetUserName()); } //---------End Config-------- //--------Camera Show-------- var parentID = location.search.getValueByKey("cameraID"); var cameraname = location.search.getValueByKey("name"); var shareID = location.search.getValueByKey("shareID"); var sesID = GetSesID(); var wcfURL = Settings.host + "/Service/WCF/BatchGetImages.svc/BatchGetImage"; var currMaxDateTime, currIndex = 0, fileID = 0; var dataSource = new Array(); var maxCacheItemNum = 120; var showImgTimer = null, getImgTimer = null, showImgDelay = 1000, getImgDelay = 1000 * 1; var stopped = false; var showTime = true; var initDate = '2000-1-1'; var isSearch = 0; var isFullScreen = false; var stopTimer = null; var isGrayNext = false; var isGrayPre = false; var playfor = 1000 * 60 * 30;//only play for 30mins. var Task = Jscex.Async.Task; var recursivePullTask = null; var ct = null; function ShowByDate(dtDateTime, misSearch) { if (xhr != null) xhr.abort(); var imgContainer = $("#idImgContainer"); if (imgContainer.find("#idImgContainer").length == 0) { $("#idImgContainer").html(""); } dataSource = new Array(); currIndex = 0; if (misSearch == undefined) isSearch = 1; else isSearch = misSearch; stopped = false; ShowLoading(); currMaxDateTime = dtDateTime; checkExists = true; CancelToken(); ct = new Jscex.Async.CancellationToken(); if (recursivePullTask == null) { recursivePullTask = eval(Jscex.compile("async", function (ct) { var i = 0; while (!(stopped || ct.isCancellationRequested)) { if (currIndex + 30 >= dataSource.length || dataSource.length == 0) { // need to buffer more images var a = $await(GetImgAsync()); Log("a.d:" + a.d + " checkExists:" + checkExists + "currIndex:" + currIndex + " dataSourceLength:" + dataSource.length + " currMaxDateTime=" + currMaxDateTime); if (a.d != null && String(a.d).length > 0) { if (!checkExists) { if (dataSource.length + a.d.length > maxCacheItemNum) { for (var i = 0; i < dataSource.length + a.d.length - maxCacheItemNum; i++) { var d = dataSource.shift(); delete d; d = null; } currIndex -= (dataSource.length + a.d.length - maxCacheItemNum); if (currIndex < 0) currIndex = 0; } } var totalLen = dataSource.length + a.d.length; var speedCounter = new Object(); var maxspeed = 1, sameCount = 0, prevName; var startPoint = dataSource.length; for (var i = 0; i < a.d.length; i++) { dataSource.push(a.d[i]); currMaxDateTime = a.d[i].filetime; //.replace(/"\/Date\((\d+)\)\/"/g, 'new Date($1)'); if (detectSpeed) { var name = a.d[i].fileName; //only support this format 20111213091000 791.jpg if (name != "" && name.length > 14) { var shortName = name.substring(0, 14); if (prevName == shortName) { sameCount++; } else { prevName = shortName; if (sameCount > maxspeed) maxspeed = sameCount; sameCount = 0; } } } } if (detectSpeed && maxspeed > 1) { detectSpeed = false; var speed = parseInt(1000 / maxspeed); showImgDelay = speed; } if (checkExists) { currIndex = startPoint; ShowImg(1); } Log("Get remote images, total:" + a.d.length + " total images" + (dataSource.length) + " in datasource."); if( currIndex + 30 >= dataSource.length ) getImgDelay = 1 * 1000; // not enough image buffered, so set smaller delay to get more images asap. else getImgDelay = 10 * 1000; } else {//No DATA if (checkExists) { Stop(); NoImg(); break; } if (isSearch == 0) // sequentially looking for next images. Since there are no more images, it has reached to the end. Wait longer in this case. getImgDelay = 30 * 1000; else getImgDelay = 1 * 1000; } } if (stopped || ct.isCancellationRequested) { break; } try { //alert("before wait " + getImgDelay); $await(Jscex.Async.sleep(getImgDelay, ct)); // delay xs. } catch (ex) { Log(CancelledError.isTypeOf(ex)); // true Log(task.status); // canceled } isSearch = 0; // sequentially look for next images to play checkExists = false; } runningStatus = 0; })); } //End Asynchronous taks define. var task = recursivePullTask(ct); task.start(); ChangeStationImg(0); } var getImgAsync = null; function ShowImg(startIndex) { Log("Status:" + (stopped ? "T" : "F")); currIndex = startIndex; if (getImgAsync == null) { getImgAsync = eval(Jscex.compile("async", function () { while (!stopped) { var i = currIndex + 1; if (i >= 0 && i < dataSource.length) { SetImg(i); currIndex = i; } Log("Show Image:" + currIndex + "/" + dataSource.length + " Delay:" + showImgDelay); $await(Jscex.Async.sleep(showImgDelay)); } })); } var task = getImgAsync(); task.start(); } function ShowLoading() { $("#cameraImg").attr("src", "Images/Camera/CameraLoading.gif"); $("#fileName").html(""); } function Start(checkExists) { ShowByDate(currMaxDateTime); ChangeStationImg(0); } function Stop() { ChangeStationImg(0); stopped = true; Log("Stopped") CancelToken(); } function CancelToken() { if (ct != null && (ct.isCancellationRequested != undefined && !ct.isCancellationRequested) && (ct._handlers != undefined && ct._handlers != null)) { try { ct.cancel(); } catch (ex) { } } } function GoTo(seq) { Stop(); if (seq == 2) { $("#LastBtn").attr("src", "Images/Camera/LastDownBtn.png"); currIndex = dataSource.length; var date = new Date((new Date()).getTime() + 1000 * 60 * 60 * 24 * 365); // 1 year before ShowByDate(GetJOSNDate(date)); } else if (seq == -2) { var date = new Date(); date.setFullYear(2011, 0, 1); ShowByDate(GetJOSNDate(date), 0); } else { currIndex += seq; if (dataSource.length != 0 && currIndex >= 0 && currIndex < dataSource.length) SetImg(currIndex); ChangeStationImg(0); if (seq == -1) $("#PreBtn").attr("src", "Images/Camera/PreDownBtn.png"); else $("#NextBtn").attr("src", "Images/Camera/NextDownBtn.png"); } if (seq == 1)//set gray { if (currIndex + 1 >= dataSource.length) { $("#NextBtn").attr("src", "Images/Camera/NextDisableBtn.png"); $("#NextBtn").parent().attr("title", "The last image"); $("#NextBtn").css("cursor", "default"); isGrayNext = true; } else { $("#PreBtn").attr("src", "Images/Camera/PreBtn.png"); $("#PreBtn").parent().attr("title", "Previous image"); $("#PreBtn").css("cursor", "pointer"); isGrayPre = false; } } if (seq == -1) { if (currIndex <= 1) { $("#PreBtn").attr("src", "Images/Camera/PreDisableBtn.png"); $("#PreBtn").parent().attr("title", "The first image"); $("#PreBtn").css("cursor", "default"); isGrayPre = true; } else { $("#NextBtn").attr("src", "Images/Camera/NextBtn.png"); $("#NextBtn").parent().attr("title", "Next image"); $("#NextBtn").css("cursor", "pointer"); isGrayNext = false; } } else if (seq == -2) { //Begin. } } function ChangeStationImg(flag) { var text = "Stop"; var url = "Images/Camera/PauseBtn.png"; if (flag==1) { text = "Start"; url = "Images/Camera/PlayBtn.png"; } $(".campalyerbtn").children(0).children(0).text(text); $(".campalyerbtn").children(0).children(0).attr("src", url); } function changeSize(flag) { if (flag == "1") { if (isFullScreen) $("#imgScreen").attr("src", "Images/Camera/OriginalScreenOverBtn.png"); else $("#imgScreen").attr("src", "Images/Camera/LargeScreenOverBtn.png"); } else { if (isFullScreen) $("#imgScreen").attr("src", "Images/Camera/OriginalScreenBtn.png"); else $("#imgScreen").attr("src", "Images/Camera/LargeScreenBtn.png"); } } function StartOrStop(obj) { stopped = !stopped; if (!stopped) { Start(); ChangeStationImg(0); } else { ChangeStationImg(1); } } function SetImg(i) { var keyprex = "_file_" + i; var fileName = dataSource[i].fileName; var date = ConvertJSONDate(dataSource[i].datetime); SyncUI(date); $("#cameraImg").attr("src", "data:image/jpg;base64," + dataSource[i].imgContent); if (i == 0 || $("#fileName").html() == "") { AdjustScreenSize(); } $("#fileName").html(fileName); } function FormatTime(v) { if (v < 10 && v > -10) return "0" + v; else return v; } var xhr = null; var pushDataTimer = null; var detectSpeed = false; function GetImgAsync() { var sesID = GetSesID(); return Task.create(function (t) { xhr = $.ajax({ type: 'post', url: wcfURL, contentType: 'text/json', data: '{"sesID":"' + sesID + '","fileID":' + fileID + ',"dtStartTime":"' + currMaxDateTime + '","search":' + isSearch + ',"parentID":' + parentID + ',"shareID":' + shareID + '}', beforeSend: function (xhr) { }, success: function (msg) { t.complete("success", msg); }, error: function (e) { t.complete("failure", e); }, abort: function (e) { t.complete("failure", e); }, complete: function (e) { //t.complete("complete", e); } }); }); } function ConvertJSONDate(strJson) { var okDate = /Date\([-+]?(\d+)[-+]?\d+\)/.exec(strJson); if (okDate) { try { var rDate = okDate[1]; var when = new Date(eval(rDate)) return when; } catch (e) { return new Date(); } } else { return new Date(); } } function GetJOSNDate(d) { var timezone = d.getTimezoneOffset() / 60 * -1; var c = timezone > 0 ? "+" : "-"; timezone = (timezone < 0 ? timezone * -1 : timezone); var v = "/Date(" + (d.getTime()) + c + "" + FormatTime(timezone) + "00" + ")/"; return v; } function NoImg() { $("#idImgContainer").html("
    No camera images at the selected time. Click to play the next images.
    "); $("#fileName").html(""); } function CheckBrowser() { var ua = $.browser; if (ua.msie && ua.version < 8.0) { return false; } else { if (ua.msie && ua.version == 8.0) { isIE8 = true; } isSupport = true; return true; } } function getClientBounds() { var clientWidth; var clientHeight; if ($.browser.msie) { clientWidth = document.body.clientWidth; clientHeight = document.body.clientHeight; } else if ($.browser.safari) { clientWidth = window.innerWidth; clientHeight = window.innerHeight; } else if ($.browser.Opera) { clientWidth = Math.min(window.innerWidth, document.body.clientWidth); clientHeight = Math.min(window.innerHeight, document.body.clientHeight); } else { clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth); clientHeight = Math.min(window.innerHeight, document.documentElement.clientHeight); } return { width: clientWidth, height: clientHeight }; } function AdjustScreenSize(type) { var h = 600, w = 800; h = $(window).height(); w = $(window).width(); h = window.innerHeight; w = window.innerWidth; AdjustSize(w - 20, h - 30, 0); // Log("h:" + h + " w:" + w); // var imgObj = $("#cameraImg"); // Log("img:h:" + $(imgObj).height() + " w:" + $(imgObj).width()); // if ($(imgObj).height() > h || $(imgObj).width() > w) { // $(imgObj).height(h); // $(imgObj).width(w); // } } function GetInitDate() { var date = new Date(); date.setFullYear(2000, 0, 1); // 2000, Jan, 1 return date; } function GetSlideDate(value) { var strCurrDate = $(".datePicker").val(); var currDate = new Date(); if (strCurrDate != null && strCurrDate != "") { strCurrDate = strCurrDate.replace(/-/g, "/"); currDate = new Date(Date.parse(strCurrDate)); } if (value > 0) { currDate.setHours(parseInt(value / 60)); currDate.setMinutes(parseInt(value % 60)); currDate.setSeconds(0); } return currDate; } function Resize(i) { var img = $("#cameraImg"); if (img == null) { return; } var sizes = GetImageSizes(); if (sizes != null && sizes.length == 2 && i != 0) { AdjustSize(sizes[0], sizes[1], i); } else if (dataSource != null && dataSource.length > 0) { var temImage = new Image(); temImage.onload = function () { AdjustSize(temImage.width, temImage.height, i); }; temImage.src = "data:image/jpg;base64," + dataSource[0].imgContent; } } function AdjustSize(width, height, balance) { var img = $("#cameraImg"); if (img == null || img[0]==null || img[0].src.indexOf("CameraLoading.gif") > 0) { return; } //debugger; var h, w; switch (balance) { case 0: h = height; w = width; break; case 1: h = height + 30; w = width + 30; break; case -1: if (height < 30) { height = 30; } if (width < 30) { width = 30; } h = height - 30; w = width - 30; break; } var temImage = new Image(); temImage.onload = function () { //AdjustSize(temImage.width, temImage.height, i); var oh = temImage.height, ow = temImage.width; var h_scale = (h) / oh; //John, 10/4/2012, reduce height by 100 var w_scale = w / ow; var scale = Math.min(h_scale, w_scale); img.height(oh * scale); img.width(ow * scale); //img.resize(oh * scale, ow * scale); Log("h:" + img.height() + " w:" + img.width()); //alert("h:" + img.height() + " w:" + img.width() + " Scale:" + scale); SetImageSize(img.height(), img.width()); }; temImage.src = "data:image/jpg;base64," + dataSource[0].imgContent; } function GetImageSizes() { var hight = localStorage.getItem("imgHeight") if (hight != null && hight != undefined && hight + "" != "0") { hight = parseInt(hight); var width = localStorage.getItem("imgWidth"); width = parseInt(width); return new Array(width, hight); } else { return null; } } function SetImageSize(hight, width) { localStorage.setItem("imgHeight", hight); localStorage.setItem("imgWidth", width); } function onFinishSlide(obj) { $.mobile.hidePageLoadingMsg("b"); Log("--" + (pressing ? "Pressing" : "Not Pressing")); if (pressing) { pressing = false; var d = GetSlideDate(); var v = GetJOSNDate(d); if ($(obj).parent().siblings(0).attr("name") == "pro_camerashow") { ShowByDate(v); } else { GetOnePackageImages(v); } } } var pressing = false; function BindEvent() { var slideControl = $('.slider').next().children('a'); slideControl.unbind("vmousedown"); slideControl.unbind("vmouseup"); $('.slider').unbind("change"); $(document).unbind("vmouseup"); slideControl.bind('vmousedown', function () { Stop(); pressing = true; }); $('.slider').bind("change", function (event, ui) { var slider_value = this.value; var d = GetSlideDate(slider_value); var str = d.getFullYear() + "-" + FormatTime(d.getMonth() + 1) + "-" + FormatTime(d.getDate()) + " " + FormatTime(d.getHours()) + ":" + FormatTime(d.getMinutes()) + ":" + FormatTime(d.getSeconds()); $(".datePicker").val(str); if (pressing) $.mobile.showPageLoadingMsg("b", str, true); }); $('.slider').next().children('a').bind('vmouseup', function (event) { onFinishSlide(this); }); $(document).bind('vmouseup', function () { if (pressing) { slideControl.trigger("mouseup"); } }); var beforeDate = null; var now = new Date(); var min = new Date(); min.setTime(now.getTime() - (1000 * 24 * 60 * 60 * 1000)); var beforeStatusRunning = !stopped; $('.datePicker').scroller({ preset: 'datetime', minDate: new Date(min.getFullYear(), min.getMonth(), min.getDate(), min.getHours(), min.getMinutes(), min.getSeconds()), maxDate: new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds()), theme: 'sense-ui', display: 'modal', mode: 'calbox', dateFormat: 'yy-mm-dd', timeFormat: 'HH:ii:ss', onShow: function (html, inst) { showTime = false; beforeDate = $(".datePicker").val(); beforeStatusRunning = !stopped; Stop(); }, onSelect: function (dateText, inst) { showTime = true; if (beforeDate == dateText) { if (beforeStatusRunning) { Start(); } return; } try{ $('.slider').slider('enable'); }catch(e){} dateText = dateText.replace(/-/g, "/"); d = new Date(Date.parse(dateText)); var v = GetJOSNDate(d); if ($(this).attr("name") == "dt_camerashow") { ShowByDate(v); } else { GetOnePackageImages(v); } return; }, onCancel: function () { $('.slider').slider('enable'); if (beforeStatusRunning) { Start(); } } }); Log("Event Binding..."); } function StartCameraShow() { $("#cameraImg").load(function () { $(this).data = null; }); BindEvent(); detectSpeed = true; AdjustScreenSize(0); $(window).resize(function () { AdjustScreenSize(1); }); var date = GetInitDate(); // set it to Jan 1, 2000 isSearch = 1; // Search for the last image; ShowByDate(GetJOSNDate(date)); // Starts playing at the last image zip file; $(".cameraname").html(cameraname); stopTimer = setTimeout("Stop()", playfor); } //--------End Camera Show--- //--------Slide Show-------- var imgPreWidth = 80, imgPreHeight = 60; function GetShortName(name) { if (name.length > 10) return name.substring(0, 5) + "..." + name.substring(name.length - 3); return name; } var cacheItems = new Array(); var pullOnePackageTask = null; function GetOnePackageImages(dtDateTime) { currMaxDateTime = dtDateTime; stopped = false; ct = new Jscex.Async.CancellationToken(); $(".imgListBox").html(""); if (pullOnePackageTask == null) { pullOnePackageTask = eval(Jscex.compile("async", function (ct) { if (stopped || ct.isCancellationRequested) { return; } var a = $await(GetImgAsync()); if (a.d != null && String(a.d).length > 0) { var rowHTML = ""; var date = ConvertJSONDate(a.d[0].filetime); SyncUI(date); for (var i = 0; i < a.d.length && !stopped; i++) { /* pushDataTimer = setTimeout((function (a, j) { return function () { } })(a.d[i], i), i * 50);*/ /*javascript:popupShowLargeImg(" + i + ")*/ var imgData = "data:image/jpg;base64," + a.d[i].imgContent; rowHTML = "
  • "; rowHTML += ""; rowHTML += "" + GetShortName(a.d[i].fileName) + ""; rowHTML += "
  • "; $("#imgList").append(rowHTML); /*var elem = document.getElementById("canvas" + i); var context = elem.getContext('2d'); if (context) { //context.fillRect(0, 0, imgPreWidth, imgPreHeight); } var img = new Image(); img.onload = function () { context.drawImage(img, 0, 0, imgPreWidth, imgPreHeight); } img.src = "data:image/jpg;base64," + a.imgContent; a.imgContent = img;*/ if (stopped) { break; } $await(Jscex.Async.sleep(50)); currMaxDateTime = (a.d[i].filetime); } cacheItems = a.d; date = ConvertJSONDate(currMaxDateTime); Log("Get One Package:" + date) SyncUI(date); /* var options = {preventHide: true, zIndex:0, getToolbar: function () { return '
    Close
    Play
    Previous
    Next
    Say Hi!
    '; // NB. Calling PhotoSwipe.Toolbar.getToolbar() wil return the default toolbar HTML } }, instance = window.Code.PhotoSwipe.attach(window.document.querySelectorAll('#imgList a'), options); instance.show(0); */ } else {//No DATA $(".imgListBox").html("
    No camera images at the selected time. Click to play the next images.
    "); } $.mobile.hidePageLoadingMsg(); })); } //End Asynchronous task define. $.mobile.showPageLoadingMsg(); var task = pullOnePackageTask(ct); task.start(); } var pushDataTimer = null; function PlayBeginImage() { var dateText = $('.datePicker').val(); if (dateText == "") { return; } else { dateText = dateText.replace(/-/g, "/"); } var currDate = new Date(Date.parse(dateText)); currMaxDateTime = GetJOSNDate(currDate); GoTo(0); } function StartSlideShow() { BindEvent(); var date = GetInitDate(); GetOnePackageImages(GetJOSNDate(date)); $(".cameraname").html(cameraname); // $(document).bind("scrollstart", function (event, data) { // Log("Scroll Starting"); // }); // $(document).bind("scrollstop", function (event, data) { // Log("Scroll Stopping"); // }); } function SyncUI(date) { Log("Refresh control:" + date); try { //$('.slider1').val(date.getHours() * 60 + date.getMinutes()).slider('refresh'); $('.slider2').val(date.getHours() * 60 + date.getMinutes()).slider('refresh'); } catch (e) { } try{ $('.slider1').val(date.getHours() * 60 + date.getMinutes()).slider('refresh'); } catch (e) { } var d = date; var str = d.getFullYear() + "-" + FormatTime(d.getMonth() + 1) + "-" + FormatTime(d.getDate()) + " " + FormatTime(d.getHours()) + ":" + FormatTime(d.getMinutes()) + ":" + FormatTime(d.getSeconds()); try { $(".datePicker").val(str); } catch (e) { } } var currentIndex = 0; var instance = null; function popupShowLargeImg(id) { if (id >= cacheItems.length) { return; } currentIndex = id; //showPreviewImage(0); GotoPage("imgview"); if (instance != null) { window.Code.PhotoSwipe.unsetActivateInstance(instance); window.Code.PhotoSwipe.detatch(instance); } instance = window.Code.PhotoSwipe.attach( window.document.querySelectorAll('.imgCanvas'), { target: window.document.querySelectorAll('.imgPrevContainer')[0], preventHide: true, autoStartSlideshow: false, getImageSource: function (obj) { return obj.src; }, getImageCaption: function (obj) { return obj.caption; } } ); $(".imgPrevContainer").height($(window).height()-100); instance.show(id); return; } var isRunning = false; function PlayPreviewImage(obj) { var text = ""; if (isRunning) { instance.stop(); text = "Start"; } else { instance.play(); text = "Stop"; } $(".prevFooter .ui-btn-text").html(text); isRunning = !isRunning; } function showPreviewImage(goto) { var id = currentIndex + goto; if (id >= cacheItems.length || id < 0) { return; } currentIndex = id; var elem = document.getElementById("imgPreview"); elem.src = "data:image/jpg;base64," + cacheItems[currentIndex].imgContent; $(".imgName").text(cacheItems[currentIndex].fileName); } //--------End Slide Show----