Skip to content

Commit

Permalink
Version 51:
Browse files Browse the repository at this point in the history
* Fixed a bug where the UI could not load if local storage was disabled in the browser (affecting HomeSeer apps).
* Added a setting to the "Extra" section to automatically open the first alert/clip when loading the alert/clip list.  This can be helpful when navigating the UI using only hotkeys.
* Simplified the logic that prevents redundant clip list loads at UI startup.
* The "TabLoaded_XXX" events are now invoked upon the first load of the UI.
  • Loading branch information
bp2008 committed Aug 6, 2018
1 parent 78df56d commit 59bc98a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 15 deletions.
11 changes: 9 additions & 2 deletions ui3.htm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
if (typeof bi_version != "undefined")
biVersionStr = bi_version;
url = url.replace(/\/\/.*?\//, '//censored_hostname/');
alert("An unexpected error has occurred in " + location.pathname + " (v " + uiVersionStr + " / " + biVersionStr + "). A full refresh may solve the problem (CTRL + F5). If you wish to report the error, please SCREENSHOT the browser now.\n\n" + msg + "\nat " + url + " [" + line + ":" + charIdx + "]\n" + navigator.userAgent);
var errStr = "An unexpected error has occurred in " + location.pathname + " (v " + uiVersionStr + " / " + biVersionStr + "). A full refresh may solve the problem (CTRL + F5). If you wish to report the error, please SCREENSHOT the browser now.\n\n" + msg + "\nat " + url + " [" + line + ":" + charIdx + "]\n" + navigator.userAgent;
try
{
if (toaster)
toaster.Error(errStr, 600000);
}
catch (ex) { }
alert(errStr);
}
catch (ex)
{
Expand All @@ -34,7 +41,7 @@
};
</script>
<script type="text/javascript">
var ui_version = "50";
var ui_version = "51";
var bi_version = "%%VERSION%%";
var combined_version = ui_version + "-" + bi_version;
//if (!!navigator.userAgent.match(/ Android /))
Expand Down
5 changes: 5 additions & 0 deletions ui3/ui3.css
Original file line number Diff line number Diff line change
Expand Up @@ -3689,6 +3689,11 @@ body + div
padding: 4px 10px;
}

.settingDesc
{
font-size: 0.85em;
}

.dialogOptionPanel .customCheckboxWrapper label
{
display: block;
Expand Down
61 changes: 48 additions & 13 deletions ui3/ui3.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ var nerdStats = null;
var sessionTimeout = null;

var currentPrimaryTab = "";
var skipTabLoadClipLoad = false;

var togglableUIFeatures =
[
Expand Down Expand Up @@ -715,7 +714,7 @@ var defaultSettings =
, inputType: "number"
, minValue: -1
, maxValue: 8192
, label: "Maximum H.264 Kbps (10-8192, disabled if less than 10)"
, label: 'Maximum H.264 Kbps<div class="settingDesc">(10-8192, disabled if less than 10)</div>'
, hint: "Useful for slow connections. Audio streams are not affected by this setting."
, onChange: OnChange_ui3_streamingProfileBitRateMax
, preconditionFunc: Precondition_ui3_streamingProfileBitRateMax
Expand Down Expand Up @@ -1610,6 +1609,13 @@ var defaultSettings =
, onChange: OnChange_ui3_contextMenus_longPress
, category: "Extra"
}
, {
key: "ui3_openFirstRecording"
, value: "0"
, inputType: "checkbox"
, label: 'Automatically Open First Recording<div class="settingDesc">when loading Alerts or Clips tab</div>'
, category: "Extra"
}
, {
key: "ui3_system_name_button"
, value: "About This UI"
Expand Down Expand Up @@ -1735,7 +1741,6 @@ function GetDummyLocalStorage()
{
return (dummy[key] = value);
};
AttachDefaultSettingsProperties(dummy);
localStorageDummy = dummy;
}
return localStorageDummy;
Expand Down Expand Up @@ -1887,10 +1892,12 @@ $(function ()
//$("#layoutbottom").show();
$("#recordingsFilterByHeading").text("Filter " + tabDisplayName + " by:");
}
if (skipTabLoadClipLoad)
skipTabLoadClipLoad = false;
else
BI_CustomEvent.Invoke("TabLoaded_" + currentPrimaryTab);

if (settings.ui3_openFirstRecording === "1")
clipLoader.OpenFirstRecordingAfterNextClipListLoad();

BI_CustomEvent.Invoke("TabLoaded_" + currentPrimaryTab);

resized();
});
BI_CustomEvent.AddListener("TabLoaded_live", function () { videoPlayer.goLive(); });
Expand Down Expand Up @@ -2024,8 +2031,6 @@ $(function ()
sessionManager.Initialize();

$(window).resize(resized);
if (currentPrimaryTab == "alerts" || currentPrimaryTab == "clips")
skipTabLoadClipLoad = true; // Prevent one clip load, to keep from loading twice.
$('.topbar_tab[name="' + currentPrimaryTab + '"]').click(); // this calls resized()

BI_CustomEvent.Invoke("UI_Loading_End");
Expand Down Expand Up @@ -5659,6 +5664,8 @@ function ClipLoader(clipsBodySelector)
}
var loadClipsInternal = function (listName, cameraId, myDateStart, myDateEnd, isContinuationOfPreviousLoad, isUpdateOfExistingList, previousClipDate, flaggedOnly)
{
if (!videoPlayer.Loading().cam)
return; // UI hasn't loaded far enough yet.
if ((currentPrimaryTab != "clips" && currentPrimaryTab != "alerts") || self.suppressClipListLoad)
{
QueuedClipListLoad = null;
Expand Down Expand Up @@ -6390,6 +6397,37 @@ function ClipLoader(clipsBodySelector)
}
return false;
}
this.OpenFirstRecordingAfterNextClipListLoad = function ()
{
BI_CustomEvent.AddListener("ClipList_Loaded", openFirstRecordingCallback);
}
var openFirstRecordingCallback = function (response)
{
BI_CustomEvent.RemoveListener("ClipList_Loaded", openFirstRecordingCallback);
self.OpenFirstRecording();
}
var openFirstRecordingAfterUILoadCallback = function (response)
{
BI_CustomEvent.RemoveListener("FinishedLoading", openFirstRecordingAfterUILoadCallback);
self.OpenFirstRecording();
}
this.OpenFirstRecording = function ()
{
if (!loadingHelper.DidLoadingFinish())
{
BI_CustomEvent.AddListener("FinishedLoading", openFirstRecordingAfterUILoadCallback);
return;
}
if (loadedClipIds.length === 0)
return;

var recId = loadedClipIds[0];
var clipData = self.GetClipFromId(recId);
self.ScrollClipList(clipData.y, getClipTileHeight());
var $ele = $("#c" + recId);
if ($ele.length > 0)
self.OpenClip($ele.get(0), recId, true);
}
this.OpenClip = function (clipEle, recId, alsoLoadClip)
{
self.UnselectAllClips(true);
Expand Down Expand Up @@ -8927,10 +8965,7 @@ function VideoPlayerController()
ptzButtons.UpdatePtzControlDisplayState();
dropdownBoxes.setLabelText("currentGroup", CleanUpGroupName(clc.optionDisplay));

if (skipTabLoadClipLoad)
skipTabLoadClipLoad = false;
else
clipLoader.LoadClips(); // This method does nothing if not on the clips/alerts tabs.
clipLoader.LoadClips(); // This method does nothing if not on the clips/alerts tabs.

videoOverlayHelper.ShowLoadingOverlay(true);
if (playerModule)
Expand Down

0 comments on commit 59bc98a

Please sign in to comment.