1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Consistent coding style (jslint)

This commit is contained in:
Uwe L. Korn
2013-07-03 20:02:25 +02:00
parent a9bd4e82b4
commit 89a851194e

View File

@@ -18,25 +18,19 @@
*/ */
// if run in phantomjs add fake Tomahawk environment // if run in phantomjs add fake Tomahawk environment
if(window.Tomahawk === undefined) if (window.Tomahawk === undefined) {
{
// alert("PHANTOMJS ENVIRONMENT");
var Tomahawk = { var Tomahawk = {
fakeEnv: function() fakeEnv: function () {
{
return true; return true;
}, },
resolverData: function() resolverData: function () {
{
return { return {
scriptPath: function() scriptPath: function () {
{
return "/home/tomahawk/resolver.js"; return "/home/tomahawk/resolver.js";
} }
}; };
}, },
log: function( message ) log: function (message) {
{
console.log(message); console.log(message);
} }
}; };
@@ -52,12 +46,11 @@ Tomahawk.timestamp = function() {
}; };
Tomahawk.dumpResult = function (result) { Tomahawk.dumpResult = function (result) {
var results = result.results; var results = result.results,
i = 0;
Tomahawk.log("Dumping " + results.length + " results for query " + result.qid + "..."); Tomahawk.log("Dumping " + results.length + " results for query " + result.qid + "...");
for(var i=0; i<results.length;i++) for (i = 0; i < results.length; i++) {
{ Tomahawk.log(results[i].artist + " - " + results[i].track + " | " + results[i].url);
var result1 = results[i];
Tomahawk.log( result1.artist + " - " + result1.track + " | " + result1.url );
} }
Tomahawk.log("Done."); Tomahawk.log("Done.");
@@ -67,10 +60,9 @@ Tomahawk.dumpResult = function( result ) {
Tomahawk.extend = function (object, members) { Tomahawk.extend = function (object, members) {
var F = function () {}; var F = function () {};
F.prototype = object; F.prototype = object;
var newObject = new F; var newObject = new F();
for(var key in members) for (var key in members) {
{
newObject[key] = members[key]; newObject[key] = members[key];
} }
@@ -89,71 +81,48 @@ var TomahawkResolverCapability = {
// Resolver BaseObject, inherit it to implement your own resolver // Resolver BaseObject, inherit it to implement your own resolver
var TomahawkResolver = { var TomahawkResolver = {
init: function() init: function() {
{
}, },
scriptPath: function() scriptPath: function () {
{
return Tomahawk.resolverData().scriptPath; return Tomahawk.resolverData().scriptPath;
}, },
getConfigUi: function() getConfigUi: function () {
{
return {}; return {};
}, },
getUserConfig: function() getUserConfig: function () {
{ return JSON.parse(window.localStorage[this.scriptPath()] || "{}");
var configJson = window.localStorage[ this.scriptPath() ];
if( configJson === undefined )
{
configJson = "{}";
}
var config = JSON.parse( configJson );
return config;
}, },
saveUserConfig: function() saveUserConfig: function () {
{ var configJson = JSON.stringify(Tomahawk.resolverData().config);
var config = Tomahawk.resolverData().config;
var configJson = JSON.stringify( config );
window.localStorage[ this.scriptPath() ] = configJson; window.localStorage[ this.scriptPath() ] = configJson;
this.newConfigSaved(); this.newConfigSaved();
}, },
newConfigSaved: function() newConfigSaved: function () {
{
}, },
resolve: function( qid, artist, album, title ) resolve: function (qid, artist, album, title) {
{
return { return {
qid: qid qid: qid
}; };
}, },
search: function( qid, searchString ) search: function (qid, searchString) {
{
return this.resolve( qid, "", "", searchString ); return this.resolve( qid, "", "", searchString );
}, },
artists: function( qid ) artists: function (qid) {
{
return { return {
qid: qid qid: qid
}; };
}, },
albums: function( qid, artist ) albums: function (qid, artist) {
{
return { return {
qid: qid qid: qid
}; };
}, },
tracks: function( qid, artist, album ) tracks: function (qid, artist, album) {
{
return { return {
qid: qid qid: qid
}; };
}, },
collection: function() collection: function () {
{
return {}; return {};
} }
}; };
@@ -206,16 +175,13 @@ var TomahawkResolver = {
// help functions // help functions
Tomahawk.valueForSubNode = function(node, tag) Tomahawk.valueForSubNode = function (node, tag) {
{ if (node === undefined) {
if(node === undefined)
{
throw new Error("Tomahawk.valueForSubnode: node is undefined!"); throw new Error("Tomahawk.valueForSubnode: node is undefined!");
} }
var element = node.getElementsByTagName(tag)[0]; var element = node.getElementsByTagName(tag)[0];
if( element === undefined ) if (element === undefined) {
{
return undefined; return undefined;
} }
@@ -223,8 +189,7 @@ Tomahawk.valueForSubNode = function(node, tag)
}; };
Tomahawk.syncRequest = function(url) Tomahawk.syncRequest = function (url) {
{
var xmlHttpRequest = new XMLHttpRequest(); var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open('GET', url, false); xmlHttpRequest.open('GET', url, false);
xmlHttpRequest.send(null); xmlHttpRequest.send(null);
@@ -233,8 +198,7 @@ Tomahawk.syncRequest = function(url)
} }
}; };
Tomahawk.asyncRequest = function(url, callback, extraHeaders) Tomahawk.asyncRequest = function (url, callback, extraHeaders) {
{
var xmlHttpRequest = new XMLHttpRequest(); var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open('GET', url, true); xmlHttpRequest.open('GET', url, true);
if (extraHeaders) { if (extraHeaders) {
@@ -249,7 +213,7 @@ Tomahawk.asyncRequest = function(url, callback, extraHeaders)
Tomahawk.log("Failed to do GET request: to: " + url); Tomahawk.log("Failed to do GET request: to: " + url);
Tomahawk.log("Status Code was: " + xmlHttpRequest.status); Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
} }
} };
xmlHttpRequest.send(null); xmlHttpRequest.send(null);
}; };