Skip to content

Commit

Permalink
fix to 'startsWith' javascript error when using IE
Browse files Browse the repository at this point in the history
  • Loading branch information
genemars committed May 14, 2016
1 parent 04e73d9 commit 1d44189
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
3 changes: 3 additions & 0 deletions BaseFiles/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3552,6 +3552,9 @@
<None Include="html\js\app\homegenie.webapp.utility.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="html\js\startswith.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="dummy.cs" />
Expand Down
1 change: 1 addition & 0 deletions BaseFiles/Common/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<script src="js/jquery.knob.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script src="js/marked.min.js"></script>
<script src="js/startswith.js"></script>

<!-- custom css includes -->
<link rel="stylesheet" href="css/homegenie.min.css" />
Expand Down
55 changes: 55 additions & 0 deletions BaseFiles/Common/html/js/startswith.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*! https://mths.be/startswith v0.2.0 by @mathias */
if (!String.prototype.startsWith) {
(function() {
'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
var defineProperty = (function() {
// IE 8 only supports `Object.defineProperty` on DOM elements
try {
var object = {};
var $defineProperty = Object.defineProperty;
var result = $defineProperty(object, object, object) && $defineProperty;
} catch(error) {}
return result;
}());
var toString = {}.toString;
var startsWith = function(search) {
if (this == null) {
throw TypeError();
}
var string = String(this);
if (search && toString.call(search) == '[object RegExp]') {
throw TypeError();
}
var stringLength = string.length;
var searchString = String(search);
var searchLength = searchString.length;
var position = arguments.length > 1 ? arguments[1] : undefined;
// `ToInteger`
var pos = position ? Number(position) : 0;
if (pos != pos) { // better `isNaN`
pos = 0;
}
var start = Math.min(Math.max(pos, 0), stringLength);
// Avoid the `indexOf` call if no match is possible
if (searchLength + start > stringLength) {
return false;
}
var index = -1;
while (++index < searchLength) {
if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {
return false;
}
}
return true;
};
if (defineProperty) {
defineProperty(String.prototype, 'startsWith', {
'value': startsWith,
'configurable': true,
'writable': true
});
} else {
String.prototype.startsWith = startsWith;
}
}());
}
3 changes: 2 additions & 1 deletion HomeGenie_Linux/Packager/DEBIAN/md5sums
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ eb79ebea6322b95f5bab19facbbd1f28 usr/local/bin/homegenie/html/js/jquery.notify.
b314901465a83bf5fdd08d17409d5fce usr/local/bin/homegenie/html/js/homegenie.api.js
5d60cc1f7b4b7abeecbd3ab2b6bd498e usr/local/bin/homegenie/html/js/jquery.ui.touch-punch.min.js
c6512bc70dcbf5ac8b7c2721cbd52351 usr/local/bin/homegenie/html/js/colorwheel.js
8d4223896ddbb9cd132aceef6882cb04 usr/local/bin/homegenie/html/js/startswith.js
c5980a2ab542f1faf296b7cf46520d43 usr/local/bin/homegenie/html/js/eventsource.js
75eb6e399fae4de18c26d44ef239e7e5 usr/local/bin/homegenie/html/pages/events/_events.js
d427dfc02f1f6277e41bd22f0462b618 usr/local/bin/homegenie/html/pages/events/main.html
Expand Down Expand Up @@ -1093,7 +1094,7 @@ d311329f6b7f6588be49094a592492c9 usr/local/bin/homegenie/html/images/genie.png
b488b97ca1f19753a9f38d1e0144b115 usr/local/bin/homegenie/html/images/event_on.png
11e6aed03a9856f09de50c12d6f5379c usr/local/bin/homegenie/html/images/configure.png
ecaa88f7fa0bf610a5a26cf545dcd3aa usr/local/bin/homegenie/html/blank.html
a7f97366f9fb32d862b09b9066beb289 usr/local/bin/homegenie/html/index.html
745560094fa3ce8b4617c132101b30a8 usr/local/bin/homegenie/html/index.html
69338ffa66f8af999156761d486f763b usr/local/bin/homegenie/html/README.RestoreP513.md
a4e8c938edacd5e8c55c5441054dcf9a usr/local/bin/homegenie/html/icons.html
9e90aad43d8acc5b45729f2296cb5907 usr/local/bin/homegenie/Raspberry.IO.SerialPeripheralInterface.dll
Expand Down

0 comments on commit 1d44189

Please sign in to comment.