Skip to content

Commit

Permalink
[Google Play] Minor tweaks. Update tests.
Browse files Browse the repository at this point in the history
Closes #680
  • Loading branch information
aurimasv committed Feb 12, 2015
1 parent 2b78a14 commit 97642f7
Showing 1 changed file with 29 additions and 48 deletions.
77 changes: 29 additions & 48 deletions Google Play.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"translatorID": "abc89357-6185-4ddd-8583-80034b754832",
"label": "Google Play",
"creator": "Avram Lyon",
"target": "^https?://play\\.google\\.[^/]+/",
"minVersion": "3.0",
"target": "^https?://play\\.google\\.com/",
"minVersion": "4.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsib",
"lastUpdated": "2014-02-24 09:20:33"
"lastUpdated": "2015-02-12 08:57:37"
}

/*
Expand All @@ -31,9 +31,9 @@
*/

function detectWeb(doc, url) {
var cardListParent = cardList(doc);
if (cardListParent.length > 0) {
Z.monitorDOMChanges(cardListParent[0], {childList: true, subtree: true});
var bodyContent = doc.getElementById('body-content');
if (bodyContent) {
Z.monitorDOMChanges(bodyContent, {childList: true});
}

if (url.indexOf('/apps/details?id=') !== -1) {
Expand All @@ -42,34 +42,27 @@ function detectWeb(doc, url) {

if (url.indexOf('/store/apps') !== -1
|| url.indexOf('&c=apps') !== -1) {
return (cardListFindCards(doc).length > 0) ? "multiple" : false;
return cardListFindCards(doc).length ? "multiple" : false;
}

return false;
}

function doWeb(doc, url) {

var detectedType = detectWeb(doc, url);

if (detectedType !== "multiple") {
if (detectWeb(doc, url) !== "multiple") {
saveIndividual(doc, url);
return;
}

var cells = cardListFindCards(doc);
var items = new Object();

for (var index = 0; index < cells.length; index++) {
items[cells[index].href] = cells[index].textContent;
items[cells[index].href] = ZU.trimInternal(cells[index].textContent);
}

Z.selectItems(items, function(items) {
if (!items) {
return true;
}
if (!items) return true;

var articles = new Array();
for (var article in articles) {
for (var i in items) {
articles.push(i);
}

Expand Down Expand Up @@ -115,19 +108,15 @@ function saveIndividual(doc, url) {

// We exclude "Varies with device"
var os = findProperty(doc, "operatingSystems").trim();
item.system = os.match(/.*\d.*/) ? "Android " + os : "Android";
item.system = /\d/.test(os) ? "Android " + os : "Android";

var version = findProperty(doc, "softwareVersion");
// We exlide "Varies with device"
if (version.match(/.*\d.*/)) {
if (/\d/.test(version)) {
item.version = version;
}

item.company = author;
item.creators.push({
lastName: author,
fieldMode: "single",
creatorType: "author"
});

item.complete();
}
Expand All @@ -140,18 +129,15 @@ var testCases = [
"items": [
{
"itemType": "computerProgram",
"creators": [
{
"lastName": "Avram Lyon",
"fieldMode": "single",
"creatorType": "author"
}
],
"notes": [],
"tags": [
"New"
],
"seeAlso": [],
"title": "Zandy",
"creators": [],
"date": "October 1, 2014",
"abstractNote": "Access your Zotero library from your mobile device! Edit and view your library, sync, and work offline. Zandy provides a simple interface to all your research. Browse and modify the items in your library, add new items, view attachments, take and edit item notes, search your library, and add webpages from the Android browser, with more features coming soon!See http://www.gimranov.com/avram/w/zandy-user-guide for a complete guide to using Zandy. If you have Zandy 1.0 already, see the update note, http://wp.me/p1i2jM-2UFor more information on the Zotero project, the premier system for managing research and bibliographic data, see the project site at http://www.zotero.org/. Zandy is a free software project, licensed under the Affero GPL v3. By buying the paid application on Google Play, you support the future development of this app and ensure its further improvement. All future releases of the software will be free updates bringing new capabilities and bugfixes.To file bug reports or feature requests, please see the project repository at https://github.com/ajlyon/zandy/. The full source code is also available at that address.If you find that Zandy doesn't fit your needs, satisfaction is guaranteed: just send me an email at zandy@gimranov.com, and I'll refund the purchase price.Please note that Zandy has no official connection to the Zotero project and its home institution at the Center for History and New Media at George Mason University.",
"company": "Avram Lyon",
"libraryCatalog": "Google Play",
"system": "Android 2.1 and up",
"url": "https://play.google.com/store/apps/details?id=com.gimranov.zandy.app",
"version": "1.4.4",
"attachments": [
{
"title": "App Screenshot"
Expand All @@ -169,22 +155,17 @@ var testCases = [
"title": "App Screenshot"
}
],
"title": "Zandy",
"url": "https://play.google.com/store/apps/details?id=com.gimranov.zandy.app",
"date": "January 25, 2014",
"abstractNote": "Access your Zotero library from your mobile device! Edit and view your library, sync, and work offline. Zandy provides a simple interface to all your research. Browse and modify the items in your library, add new items, view attachments, take and edit item notes, search your library, and add webpages from the Android browser, with more features coming soon!See http://www.gimranov.com/avram/w/zandy-user-guide for a complete guide to using Zandy. If you have Zandy 1.0 already, see the update note, http://wp.me/p1i2jM-2UFor more information on the Zotero project, the premier system for managing research and bibliographic data, see the project site at http://www.zotero.org/. Zandy is a free software project, licensed under the Affero GPL v3. By buying the paid application on Google Play, you support the future development of this app and ensure its further improvement. All future releases of the software will be free updates bringing new capabilities and bugfixes.To file bug reports or feature requests, please see the project repository at https://github.com/ajlyon/zandy/. The full source code is also available at that address.If you find that Zandy doesn't fit your needs, satisfaction is guaranteed: just send me an email at zandy@gimranov.com, and I'll refund the purchase price.Please note that Zandy has no official connection to the Zotero project and its home institution at the Center for History and New Media at George Mason University.",
"system": "Android 2.1 and up",
"version": "1.4.1",
"company": "Avram Lyon",
"libraryCatalog": "Google Play",
"accessDate": "CURRENT_TIMESTAMP"
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://play.google.com/store/search?q=research&c=apps",
"items": "multiple"
"defer": true,
"items": "multiple"
}
]
/** END TEST CASES **/

0 comments on commit 97642f7

Please sign in to comment.