|
@@ -1,66 +1,54 @@
|
|
|
-console.log('popup.js is doing something');
|
|
|
|
|
-window.tempData = {
|
|
|
|
|
- temp: 'howdy temp',
|
|
|
|
|
|
|
+document.addEventListener("alpine:init", () => {
|
|
|
|
|
+ Alpine.data("playlistManager", () => ({
|
|
|
|
|
+ playlists: {},
|
|
|
|
|
+
|
|
|
init() {
|
|
init() {
|
|
|
- console.log('temp init function');
|
|
|
|
|
- this.temp = 'seeya temp'
|
|
|
|
|
|
|
+ this.loadPlaylists();
|
|
|
},
|
|
},
|
|
|
-}
|
|
|
|
|
-console.log('popup.js is CONTINUING');
|
|
|
|
|
-document.addEventListener('alpine:init', () => {
|
|
|
|
|
- console.log('doing MORE');
|
|
|
|
|
- console.log('doing MORE', Alpine);
|
|
|
|
|
- Alpine.data('playlistManager', () => ({
|
|
|
|
|
- temp: "hey temp",
|
|
|
|
|
- playlists: {},
|
|
|
|
|
-
|
|
|
|
|
- init() {
|
|
|
|
|
- this.loadPlaylists();
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- async loadPlaylists() {
|
|
|
|
|
- try {
|
|
|
|
|
- const result = await browser.storage.local.get("playlists");
|
|
|
|
|
- console.log('LOAD RESULT', result);
|
|
|
|
|
- this.playlists = result.playlists || {};
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error("Error loading playlists:", error);
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- formatPlaylistName(name) {
|
|
|
|
|
- // Convert "listening-1" to "Listening - 1"
|
|
|
|
|
- return name
|
|
|
|
|
- .split('-')
|
|
|
|
|
- .map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
|
|
|
- .join(' - ');
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- openVideo(url) {
|
|
|
|
|
- browser.tabs.create({ url });
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- async removeVideo(playlistName, index) {
|
|
|
|
|
- // Make a copy of the current playlist
|
|
|
|
|
- const playlist = [...this.playlists[playlistName]];
|
|
|
|
|
-
|
|
|
|
|
- // Remove the video at the specified index
|
|
|
|
|
- playlist.splice(index, 1);
|
|
|
|
|
-
|
|
|
|
|
- // Create an updated playlists object with the remaining playlists unchanged
|
|
|
|
|
- const updatedPlaylists = {
|
|
|
|
|
- ...this.playlists,
|
|
|
|
|
- [playlistName]: playlist
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // Update the playlists in storage
|
|
|
|
|
- try {
|
|
|
|
|
- await browser.storage.local.set({ playlists: updatedPlaylists });
|
|
|
|
|
- this.playlists = updatedPlaylists;
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error("Error removing video:", error);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ async loadPlaylists() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const result = await browser.storage.local.get("playlists");
|
|
|
|
|
+ console.log("LOAD RESULT", result.playlists);
|
|
|
|
|
+ this.playlists = result.playlists || {};
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error("Error loading playlists:", error);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ formatPlaylistName(name) {
|
|
|
|
|
+ // Convert "listening-1" to "Listening - 1"
|
|
|
|
|
+ return name
|
|
|
|
|
+ .split("-")
|
|
|
|
|
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
|
|
|
+ .join(" - ");
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ openVideo(url) {
|
|
|
|
|
+ browser.tabs.create({ url });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ async removeVideo(playlistName, index) {
|
|
|
|
|
+ // Make a copy of the current playlist
|
|
|
|
|
+ const playlist = [...this.playlists[playlistName]];
|
|
|
|
|
+
|
|
|
|
|
+ // Remove the video at the specified index
|
|
|
|
|
+ playlist.splice(index, 1);
|
|
|
|
|
+
|
|
|
|
|
+ // Create an updated playlists object with the remaining playlists unchanged
|
|
|
|
|
+ const updatedPlaylists = {
|
|
|
|
|
+ ...this.playlists,
|
|
|
|
|
+ [playlistName]: playlist,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // Update the playlists in storage
|
|
|
|
|
+ try {
|
|
|
|
|
+ await browser.storage.local.set({ playlists: updatedPlaylists });
|
|
|
|
|
+ this.playlists = updatedPlaylists;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error("Error removing video:", error);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ }));
|
|
|
});
|
|
});
|
|
|
-console.log('popup.js FINISHED doing something');
|
|
|
|
|
|
|
+console.log("popup.js FINISHED doing something");
|