Skip to content

Commit

Permalink
Updated version to 1.5.2.
Browse files Browse the repository at this point in the history
Fixed bug when checking network connection status (resolves #161).
Fixed bug in metadata collection where description displays encoded characters.
  • Loading branch information
nero120 committed Feb 14, 2020
1 parent 063917f commit 1913534
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 145 deletions.
3 changes: 1 addition & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1486,8 +1486,7 @@ xBrowserSync.App.Controller = function ($q, $timeout, platform, globals, api, ut
vm.sync.passwordComplexity = {};
$q.all([
platform.LocalStorage.Set(globals.CacheKeys.Password),
syncId ? platform.LocalStorage.Set(globals.CacheKeys.SyncId, syncId) : $q.resolve(),
serviceUrl ? platform.LocalStorage.Set(globals.CacheKeys.ServiceUrl, serviceUrl) : $q.resolve()
syncId ? platform.LocalStorage.Set(globals.CacheKeys.SyncId, syncId) : $q.resolve()
])
.then(function () {
// Update the service URL if supplied
Expand Down
94 changes: 54 additions & 40 deletions js/getPageMetadata.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,77 @@
(function () {
var getPageMetadata = function () {
var metaTagsArr = document.getElementsByTagName('meta');
var txt = document.createElement('textarea');

var getPageDescription = function () {
for (var i = 0; i < metaTagsArr.length; i++) {
var currentTag = metaTagsArr[i];
if ((currentTag.getAttribute('property') && currentTag.getAttribute('property').toUpperCase().trim() === 'OG:DESCRIPTION' && currentTag.getAttribute('content')) ||
(currentTag.getAttribute('name') && currentTag.getAttribute('name').toUpperCase().trim() === 'TWITTER:DESCRIPTION' && currentTag.getAttribute('content')) ||
(currentTag.getAttribute('name') && currentTag.getAttribute('name').toUpperCase().trim() === 'DESCRIPTION' && currentTag.getAttribute('content'))) {
return (currentTag.getAttribute('content')) ? currentTag.getAttribute('content').trim() : '';
}
var ogDescription = document.querySelector('meta[property="OG:DESCRIPTION"]') || document.querySelector('meta[property="og:description"]');
if (ogDescription && ogDescription.content) {
txt.innerHTML = ogDescription.content.trim();
return txt.value;
}

return null;
var twitterDescription = document.querySelector('meta[name="TWITTER:DESCRIPTION"]') || document.querySelector('meta[name="twitter:description"]');
if (twitterDescription && twitterDescription.content) {
txt.innerHTML = twitterDescription.content.trim();
return txt.value;
}

var defaultDescription = document.querySelector('meta[name="DESCRIPTION"]') || document.querySelector('meta[name="description"]');
if (defaultDescription && defaultDescription.content) {
txt.innerHTML = defaultDescription.content.trim();
return txt.value;
}

return '';
};

var getPageKeywords = function () {
// Get open graph tag values
var currentTag, i, keywords = [];
for (i = 0; i < metaTagsArr.length; i++) {
currentTag = metaTagsArr[i];
if (currentTag.getAttribute('property') &&
currentTag.getAttribute('property').trim().match(/VIDEO\:TAG$/i) &&
currentTag.getAttribute('content')) {
keywords.push(currentTag.getAttribute('content').trim());
var keywords = [];

// Get open graph tag values
document.querySelectorAll('meta[property="OG:VIDEO:TAG"]').forEach(function (tag) {
if (tag && tag.content) {
keywords.push(tag.content.trim());
}
}
});
document.querySelectorAll('meta[property="og:video:tag"]').forEach(function (tag) {
if (tag && tag.content) {
keywords.push(tag.content.trim());
}
});

// Get meta tag values
for (i = 0; i < metaTagsArr.length; i++) {
currentTag = metaTagsArr[i];
if (currentTag.getAttribute('name') &&
currentTag.getAttribute('name').toUpperCase().trim() === 'KEYWORDS' &&
currentTag.getAttribute('content')) {
var metaKeywords = currentTag.getAttribute('content').split(',');
for (i = 0; i < metaKeywords.length; i++) {
var currentKeyword = metaKeywords[i];
if (currentKeyword && currentKeyword.trim()) {
keywords.push(currentKeyword.trim());
}
// Get meta tag values
var metaKeywords = document.querySelector('meta[name="KEYWORDS"]') || document.querySelector('meta[name="keywords"]');
if (metaKeywords && metaKeywords.content) {
metaKeywords.content.split(',').forEach(function (keyword) {
if (keyword) {
keywords.push(keyword.trim());
}
break;
}
});
}

if (keywords.length > 0) {
return keywords.join();
// Remove duplicates
var uniqueKeywords = keywords.filter(function (value, index, self) {
return self.indexOf(value) === index;
});

if (uniqueKeywords.length > 0) {
return uniqueKeywords.join();
}

return null;
};

var getPageTitle = function () {
for (var i = 0; i < metaTagsArr.length; i++) {
var tag = metaTagsArr[i];
if ((tag.getAttribute('property') && tag.getAttribute('property').toUpperCase().trim() === 'OG:TITLE' && tag.getAttribute('content')) ||
(tag.getAttribute('name') && tag.getAttribute('name').toUpperCase().trim() === 'TWITTER:TITLE' && tag.getAttribute('content'))) {
return (tag.getAttribute('content')) ? tag.getAttribute('content').trim() : '';
}
var ogTitle = document.querySelector('meta[property="OG:TITLE"]') || document.querySelector('meta[property="og:title"]');
if (ogTitle && ogTitle.content) {
txt.innerHTML = ogTitle.content.trim();
return txt.value;
}

var twitterTitle = document.querySelector('meta[name="TWITTER:TITLE"]') || document.querySelector('meta[name="twitter:title"]');
if (twitterTitle && twitterTitle.content) {
txt.innerHTML = twitterTitle.content.trim();
return txt.value;
}

return document.title;
Expand Down
4 changes: 2 additions & 2 deletions js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ xBrowserSync.App.Global = function (platform) {
Name: 'xBrowserSync-alarm',
Period: 1
},
AppVersion: '1.5.1',
AppVersion: '1.5.2-beta1',
Bookmarks: {
ContainerPrefix: '[xbs]',
DescriptionMaxLength: 300,
Expand Down Expand Up @@ -391,7 +391,7 @@ xBrowserSync.App.Global = function (platform) {
URL: {
Bookmarks: '/bookmarks',
Current: '/current',
DefaultServiceUrl: 'https://api.xbrowsersync.org',
DefaultServiceUrl: 'https://api-test.xbrowsersync.org',
HttpRegex: '^https?:\/\/\\w+',
LastUpdated: '/lastUpdated',
ProtocolRegex: '^[\\w\-]+:',
Expand Down
6 changes: 3 additions & 3 deletions js/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ xBrowserSync.App.Utility = function ($q, platform, globals) {
};

var isNetworkConnected = function () {
return window.navigator.connection && window.navigator.connection.type ?
(window.navigator.connection.type !== Connection.NONE &&
window.navigator.connection.type !== Connection.UNKNOWN) :
return window.Connection && window.navigator.connection && window.navigator.connection.type ?
(window.navigator.connection.type !== window.Connection.NONE &&
window.navigator.connection.type !== window.Connection.UNKNOWN) :
window.navigator.onLine;
};

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xbrowsersync-app",
"description": "The xBrowserSync client app.",
"version": "1.5.1",
"version": "1.5.2",
"author": "xBrowserSync",
"license": "GPL-3.0-only",
"repository": {
Expand Down Expand Up @@ -67,4 +67,4 @@
"androidbuildsteps": "npm run bundlemobiledependencies && n-concat build/js/app-dependencies.min.js build/js/app-scripts.min.js | n-pipe build/js/app.min.js && n-copy --source build --destination build/cordova/www --ignore cordova/** \"*\" \"**/*\"",
"postandroidbuildsteps": "echo Build complete."
}
}
}
2 changes: 1 addition & 1 deletion platform/android/cordova/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.xBrowserSync.android" android-versionCode="15101" version="1.5.1"
<widget id="com.xBrowserSync.android" android-versionCode="15201" version="1.5.2"
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
Expand Down
4 changes: 2 additions & 2 deletions platform/android/cordova/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions platform/android/cordova/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.xbrowsersync.android",
"displayName": "xBrowserSync",
"version": "1.5.1",
"version": "1.5.2",
"description": "xBrowserSync mobile app for Android.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down Expand Up @@ -55,4 +55,4 @@
"android"
]
}
}
}
Loading

0 comments on commit 1913534

Please sign in to comment.