Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #10487 from frsela/Bug884745
Browse files Browse the repository at this point in the history
Bug 884745 - Change debug() method to the new window.DUMP in icc*.js, r=kaze
  • Loading branch information
Fernando Rodríguez Sela committed Jun 27, 2013
2 parents ae9a288 + 32a2c6c commit 08c9cf5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 48 deletions.
3 changes: 3 additions & 0 deletions apps/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<meta http-equiv="pragma" content="no-cache"/>
<title>Settings</title>

<!-- Debug/DUMP method support -->
<script defer src="/shared/js/dump.js"></script>

<!-- multi-resolution support -->
<link rel="stylesheet" href="/shared/style/responsive.css">

Expand Down
42 changes: 21 additions & 21 deletions apps/settings/js/icc.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@
*/
function responseSTKCommand(response, force) {
if (!force && (!iccLastCommand || !iccLastCommandProcessed)) {
debug('sendStkResponse NO COMMAND TO RESPONSE. Ignoring');
DUMP('sendStkResponse NO COMMAND TO RESPONSE. Ignoring');
return;
}

debug('sendStkResponse to command: ', iccLastCommand);
debug('sendStkResponse -- # response = ', response);
DUMP('sendStkResponse to command: ', iccLastCommand);
DUMP('sendStkResponse -- # response = ', response);

icc.sendStkResponse(iccLastCommand, response);
iccLastCommand = null;
Expand All @@ -175,7 +175,7 @@
* Handle ICC Commands
*/
function handleSTKCommand(command) {
debug('STK Proactive Command:', command);
DUMP('STK Proactive Command:', command);
iccLastCommand = command;
var options = command.options;

Expand All @@ -200,7 +200,7 @@
break;

default:
debug('STK Message not managed... response OK');
DUMP('STK Message not managed... response OK');
iccLastCommandProcessed = true;
responseSTKCommand({
resultCode: icc.STK_RESULT_OK
Expand All @@ -212,7 +212,7 @@
* Navigate through all available STK applications
*/
function updateMenu() {
debug('Showing STK main menu');
DUMP('Showing STK main menu');
stkOpenAppName = null;

stkCancelGoBack();
Expand All @@ -228,19 +228,19 @@

if (!menu || !menu.items ||
(menu.items.length == 1 && menu.items[0] === null)) {
debug('No STK available - hide & exit');
DUMP('No STK available - hide & exit');
document.getElementById('icc-mainheader').hidden = true;
document.getElementById('icc-mainentry').hidden = true;
return;
}

debug('STK Main App Menu title: ' + menu.title);
debug('STK Main App Menu default item: ' + menu.defaultItem);
DUMP('STK Main App Menu title: ' + menu.title);
DUMP('STK Main App Menu default item: ' + menu.defaultItem);

iccMenuItem.textContent = menu.title;
showTitle(menu.title);
menu.items.forEach(function(menuItem) {
debug('STK Main App Menu item: ' + menuItem.text + ' # ' +
DUMP('STK Main App Menu item: ' + menuItem.text + ' # ' +
menuItem.identifier);
iccStkList.appendChild(buildMenuEntry({
id: 'stk-menuitem-' + menuItem.identifier,
Expand All @@ -265,14 +265,14 @@

function onMainMenuItemClick(event) {
var identifier = event.target.getAttribute('stk-menu-item-identifier');
debug('sendStkMenuSelection: ', identifier);
DUMP('sendStkMenuSelection: ', identifier);
icc.sendStkMenuSelection(identifier, false);
stkLastSelectedTest = event.target.textContent;
stkOpenAppName = stkLastSelectedTest;
}

function showHelpMenu(event) {
debug('Showing STK help menu');
DUMP('Showing STK help menu');
stkOpenAppName = null;

var reqApplications =
Expand All @@ -286,7 +286,7 @@
iccMenuItem.textContent = menu.title;
showTitle(_('operatorServices-helpmenu'));
menu.items.forEach(function(menuItem) {
debug('STK Main App Help item: ' + menuItem.text + ' # ' +
DUMP('STK Main App Help item: ' + menuItem.text + ' # ' +
menuItem.identifier);
iccStkList.appendChild(buildMenuEntry({
id: 'stk-helpitem-' + menuItem.identifier,
Expand All @@ -300,7 +300,7 @@

function onMainMenuHelpItemClick(event) {
var identifier = event.target.getAttribute('stk-help-item-identifier');
debug('sendStkHelpMenuSelection: ', identifier);
DUMP('sendStkHelpMenuSelection: ', identifier);
icc.sendStkMenuSelection(identifier, true);
stkLastSelectedTest = event.target.textContent;
stkOpenAppName = stkLastSelectedTest;
Expand All @@ -312,15 +312,15 @@
function updateSelection(command) {
var menu = command.options;

debug('Showing STK menu');
DUMP('Showing STK menu');
clearList();

debug('STK App Menu title: ' + menu.title);
debug('STK App Menu default item: ' + menu.defaultItem);
DUMP('STK App Menu title: ' + menu.title);
DUMP('STK App Menu default item: ' + menu.defaultItem);

showTitle(menu.title);
menu.items.forEach(function(menuItem) {
debug('STK App Menu item: ' + menuItem.text + ' # ' +
DUMP('STK App Menu item: ' + menuItem.text + ' # ' +
menuItem.identifier);
iccStkList.appendChild(buildMenuEntry({
id: 'stk-menuitem-' + menuItem.identifier,
Expand Down Expand Up @@ -366,19 +366,19 @@
function updateInput(command) {
var options = command.options;

debug('Showing STK input box');
DUMP('Showing STK input box');
clearList();
showTitle(stkLastSelectedTest);

debug('STK Input title: ' + options.text);
DUMP('STK Input title: ' + options.text);

document.addEventListener('mozvisibilitychange',
sendSessionEndTROnFocusLose, true);

// AutoClose
var timeoutInUse = options.duration;
var inputTimeOutID = setTimeout(function() {
debug('No response from user (Timeout)');
DUMP('No response from user (Timeout)');
responseSTKCommand({
resultCode: icc.STK_RESULT_NO_RESPONSE_FROM_USER
});
Expand Down
14 changes: 7 additions & 7 deletions apps/settings/js/icc_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
'icc.data': null
});
reqIccData.onsuccess = function icc_getIccData() {
debug('ICC Cache cleared');
DUMP('ICC Cache cleared');
};

// Open ICC section
debug('ICC command to execute: ', iccCommand);
DUMP('ICC command to execute: ', iccCommand);
Settings.currentPanel = '#icc';

setTimeout(function() {
Expand All @@ -29,7 +29,7 @@
}

setTimeout(function updateStkMenu() {
debug('Showing STK main menu');
DUMP('Showing STK main menu');
// XXX https://bugzilla.mozilla.org/show_bug.cgi?id=844727
// We should use Settings.settingsCache first
var settings = Settings.mozSettings;
Expand All @@ -41,14 +41,14 @@
var menu = json && JSON.parse(json);
if (!menu || !menu.items ||
(menu.items.length == 1 && menu.items[0] === null)) {
debug('No STK available - exit');
DUMP('No STK available - exit');
document.getElementById('icc-mainheader').hidden = true;
document.getElementById('icc-mainentry').hidden = true;
return;
}

// update and show the entry in settings
debug('STK Main App Menu title: ' + menu.title);
DUMP('STK Main App Menu title: ' + menu.title);
document.getElementById('menuItem-icc').textContent = menu.title;
document.getElementById('icc-mainheader').hidden = false;
document.getElementById('icc-mainentry').hidden = false;
Expand All @@ -58,15 +58,15 @@
reqIccData.onsuccess = function icc_getIccData() {
var cmd = reqIccData.result['icc.data'];
if (cmd) {
debug('ICC async command (launcher)');
DUMP('ICC async command (launcher)');
executeICCCmd(JSON.parse(cmd));
}
};

settings.addObserver('icc.data', function(event) {
var value = event.settingValue;
if (value) {
debug('ICC async command while settings running: ', value);
DUMP('ICC async command while settings running: ', value);
executeICCCmd(JSON.parse(value));
}
});
Expand Down
20 changes: 0 additions & 20 deletions apps/settings/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,6 @@

'use strict';

/**
* Constants
*/

var DEBUG = false;

/**
* Debug method
*/

function debug(msg, optObject) {
if (DEBUG) {
var output = '[DEBUG # Settings] ' + msg;
if (optObject) {
output += JSON.stringify(optObject);
}
console.log(output);
}
}

/**
* Move settings to foreground
*/
Expand Down

0 comments on commit 08c9cf5

Please sign in to comment.