Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

credentials not needed anymore; lfm API has its own authorization mec…

…hanism
  • Loading branch information...
commit b368469b73e27eb68cb97631efc56dfd54e8ae47 1 parent b35ae4c
@david-sabata authored
Showing with 20 additions and 66 deletions.
  1. +6 −27 options.html
  2. +7 −36 options.js
  3. +7 −3 scrobbler.js
View
33 options.html
@@ -6,33 +6,8 @@
<script type="text/javascript" src="options.js"></script>
<link rel="stylesheet" type="text/css" href="options.css" />
</head>
-<body onload="getCurrentUser()">
-
-<div class="container">
- <h1>Chrome Scrobbler</h1>
- <form action="#" onSubmit="saveCredentials();return false;">
- <p>
- <label for="username">Username:</label>
- <input type="text" id="username">
- </p>
- <p>
- <label for="password">Password:</label>
- <input type="password" id="password">
- </p>
- <p class="buttons">
- <input type="submit" onclick="saveCredentials()" value="Save" />
- <input type="button" onclick="deleteCredentials()" value="Delete" />
- </p>
- </form>
- <p id="cred-status">&nbsp;</p>
- <p>
- Enter your last.fm username and password, and then press save.
- </p>
- <p>
- To permanently delete your saved username/password, press the delete button.
- </p>
-</div>
-
+<body>
+
<div class="container options">
<h1>Options</h1>
@@ -42,6 +17,10 @@
<label for="use-notifications">Use desktop notifications (global)</label>
</li>
<li>
+ <input type="checkbox" id="use-autocorrect">
+ <label for="use-autocorrect">Use autocorrect (global)</label>
+ </li>
+ <li>
<input type="checkbox" id="use-youtube-inpage">
<label for="use-youtube-inpage" title="Since there is an info icon in the omnibox, there is no need to keep a separate YT notifying. But you're the boss here.">Use YouTube <em>status box</em></label>
</li>
View
43 options.js
@@ -1,36 +1,3 @@
-// credentials -----------------------------------------------------------------
-function saveCredentials() {
- localStorage.username = document.getElementById("username").value;
- localStorage.password = MD5(document.getElementById("password").value);
- chrome.extension.sendRequest({type: "newSession"});
-
- //Update status box in options page to let user know their username and pass has been taken.
- updateCredentialsStatus("Will now scrobble using "+localStorage.username+".");
- return false;
-}
-
-function deleteCredentials() {
- delete localStorage.username;
- delete localStorage.password;
- chrome.extension.sendRequest({type: "newSession"});
-
- updateCredentialsStatus("Account deleted.");
-}
-
-
-function updateCredentialsStatus(msg) {
- // Updates the status box
- document.getElementById("cred-status").style.display="block";
- document.getElementById("cred-status").innerHTML=msg;
-}
-
-function getCurrentUser() {
- if (localStorage.username != null) {
- updateCredentialsStatus('Using '+localStorage.username+' to scrobble.')
- }
-}
-
-
// options ---------------------------------------------------------------------
$(function(){
@@ -41,12 +8,16 @@ $(function(){
localStorage['useNotifications'] = this.checked ? 1 : 0;
});
+ $('#use-autocorrect').click(function(){
+ localStorage['useAutocorrect'] = this.checked ? 1 : 0;
+ });
+
$('#use-youtube-inpage').click(function(){
localStorage['useYTInpage'] = this.checked ? 1 : 0;
});
-
+
// preload options
$('#use-notifications').attr('checked', (localStorage['useNotifications'] == 1));
- $('#use-youtube-inpage').attr('checked', (localStorage['useYTInpage'] == 1));
-
+ $('#use-autocorrect').attr('checked', (localStorage['useAutocorrect'] == 1));
+ $('#use-youtube-inpage').attr('checked', (localStorage['useYTInpage'] == 1));
});
View
10 scrobbler.js
@@ -68,9 +68,12 @@ const ACTION_UPDATED = 4;
localStorage.useYTInpage = 0;
// show update popup - based on different version
- if (localStorage.appVersion != APP_VERSION) {
- alert('updated!');
+ if (localStorage.appVersion != APP_VERSION) {
//localStorage.appVersion = APP_VERSION;
+
+ // introduce new options if not already set
+ if (typeof localStorage.useAutocorrect == 'undefined')
+ localStorage.useAutocorrect = 0;
}
}
@@ -279,7 +282,8 @@ function getSessionID() {
* @return object/false
*/
function validate(artist, track) {
- var validationURL = "http://ws.audioscrobbler.com/2.0/?method=track.getinfo&api_key=" + apiKey + "&autocorrect=0&artist=" + encodeURIComponent(artist) + "&track=" + encodeURIComponent(track);
+ var autocorrect = localStorage.useAutocorrect ? localStorage.useAutocorrect : 0;
+ var validationURL = "http://ws.audioscrobbler.com/2.0/?method=track.getinfo&api_key=" + apiKey + "&autocorrect="+ autocorrect +"&artist=" + encodeUtf8(artist) + "&track=" + encodeUtf8(track);
console.log('validating %s - %s', artist, track);
var req = new XMLHttpRequest();
Please sign in to comment.
Something went wrong with that request. Please try again.