Skip to content
This repository was archived by the owner on Aug 20, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion assets/www/android/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ function sharePage() {
);
}

function showAudio() {
if (audioPlayer.isAvailable()) {
audioPlayer.createMenuArray();
}else {
chrome.showNotification("audio unavailable for this page");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be localized. Otherwise it looks good though, but we should talk it over at our next meeting if this is how we want to address this issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be merged if @hy-cheng isnt going to be fixing this. Someone else can then do the l10n.

}
}

chrome.showNotification = function(text) {
// Using PhoneGap-Toast plugin for Android's lightweight "Toast" style notifications.
// https://github.com/m00sey/PhoneGap-Toast
Expand All @@ -160,7 +168,7 @@ function updateMenuState() {
'go-forward': function() { chrome.goForward(); },
'select-text': function() { selectText(); },
'view-settings': function() { appSettings.showSettings(); },
'listen-sound': function() { audioPlayer.createMenuArray(); },
'listen-sound': function() { showAudio(); },
'word-of-the-day': function() { chrome.loadWordoftheDay(); },
};
$('#appMenu command').each(function() {
Expand Down
2 changes: 1 addition & 1 deletion assets/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@

<menu id="appMenu" type="context">
<command type="command" id="languageCmd" icon="optionLanguage.png" disabled="true" action="read-in" />
<command type="command" id="soundCmd" icon="optionListen.png" disabled="true" action="listen-sound" />
<command type="command" id="soundCmd" icon="optionListen.png" disabled="false" action="listen-sound" />
<command type="command" id="sharePageCmd" icon="optionSharePage.png" disabled="false" action="share-page" />
<command type="command" id="savePageCmd" icon="optionAddBookmark.png" disabled="false" action="save-page" />
<command type="command" id="savedPagesCmd" icon="optionReadLater.png" disabled="false" action="view-saved-pages" />
Expand Down
20 changes: 6 additions & 14 deletions assets/www/js/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ window.audioPlayer = function() {
var availableMedia = [];
var availableUrl = [];
var menuArray = [];
var lastMenuStatus = false;

/**
* Function called with URL of file to be played.
Expand Down Expand Up @@ -37,12 +36,6 @@ window.audioPlayer = function() {
var term = app.getCurrentTitle();
var requestUrl = app.baseURL + "/w/api.php";

if (lastMenuStatus){
setMenuItemState('listen-sound',false, false);
console.log("disabling listen-in menu");
lastMenuStatus = false;
}

var ending = ".*\.ogg";

$.ajax({
Expand Down Expand Up @@ -101,13 +94,7 @@ window.audioPlayer = function() {
format: 'json'
},
success: function(data) {

if(!lastMenuStatus){
setMenuItemState('listen-sound', true, false);
console.log("enabling listen-in menu");
lastMenuStatus = true;
}


for(var id in data.query.pages){
for (var im in data.query.pages[id].imageinfo){

Expand Down Expand Up @@ -160,6 +147,10 @@ window.audioPlayer = function() {
menuArray = [];
}

function isAvailable() {
return (availableUrl.length != 0);
}


/**
* plays file that is clicked in the menu
Expand All @@ -180,6 +171,7 @@ window.audioPlayer = function() {
playAudio: playAudio,
releaseMedia: releaseMedia,
getMediaList: getMediaList,
isAvailable: isAvailable,
createMenuArray: createMenuArray,
clearMenuArray: clearMenuArray
};
Expand Down