44
55![ video] ( https://github.com/user-attachments/assets/c59884bf-e87a-4a47-a028-e18eaf783d4a )
66
7+ ## New Version 1.1.0
8+
9+ The new update adds the following feature:
10+
11+ 1 . Feature to update the problem details of problems already added to your spreadsheet
12+
13+ Requirements for this new update:
14+
15+ 1 . Update AppScript
16+ 2 . New Version of chrome-extension
17+
18+ ## How to update AppScript:
19+
20+ - Your web app url remains the same even after updating your deploy
21+
22+ https://github.com/user-attachments/assets/84484cb1-668b-4abb-afa9-b84a803c4d82
23+
724## Contribute
825
9- Want to contribute to this chrom-extension? Go to this repo :[ My Codeforces Journal Development] ( https://github.com/Dev-Code24/My-Codeforces-Journal-Development )
26+ Want to contribute to this Chrome extension? Check out the repository here: [ My Codeforces Journal Development] ( https://github.com/Dev-Code24/My-Codeforces-Journal-Development ) .
27+
28+ ### Steps to Get Started:
29+
30+ 1 . ** Clone the Repository**
31+ Clone this repo to your local machine:
32+
33+ ``` bash
34+ git clone https://github.com/Dev-Code24/My-Codeforces-Journal-Development.git
35+ ```
36+
37+ 2 . ** Navigate to the Repository Directory**
38+ Open the directory where the repo is cloned and ensure you are at the root:
39+
40+ ``` bash
41+ cd My-Codeforces-Journal-Development
42+ ```
43+
44+ 3 . ** Create a Development Environment File**
45+ Run the following command to create an ` .env.development ` file:
46+
47+ ``` bash
48+ touch .env.development
49+ ```
50+
51+ 4 . ** Add Environment Variables**
52+ Open the ` .env.development ` file and add the following configuration:
53+
54+ ``` env
55+ VITE_DEV_OR_PROD="development"
56+ DEV_CODEFORCES_ID="your codeforces profile URL"
57+ DEV_APPSCRIPT_URL="your appscript URL"
58+ ```
59+
60+ - Replace ` your codeforces profile URL ` with the URL of your Codeforces profile.
61+ - Replace ` your appscript URL ` with your Apps Script URL.
62+
63+ 5 . ** Run the Development Server**
64+ Start the development server:
65+
66+ ``` bash
67+ npm run dev:chrome
68+ ```
69+
70+ 6 . ** Load the Extension in Chrome/Brave**
71+ - Open Chrome or Brave and go to ` chrome://extensions ` .
72+ - Turn on ** Developer Mode** (toggle in the top-right corner).
73+ - Click on ** Load unpacked** and select the ` dist ` folder located in the root of the repo you cloned.
1074
1175## Features
1276
@@ -63,10 +127,9 @@ Before you can use the extension, make sure you have the following:
63127#### App Script Code
64128
65129``` javascript
130+ var sheet = SpreadsheetApp .getActiveSpreadsheet ().getSheets ()[0 ];
66131function doPost (e ) {
67132 try {
68- var sheet = SpreadsheetApp .getActiveSpreadsheet ().getSheets ()[0 ];
69-
70133 // Parse the incoming request data
71134 var data;
72135 try {
@@ -86,7 +149,7 @@ function doPost(e) {
86149 return ContentService .createTextOutput (JSON .stringify ({ status: " success" , exists: problemExists })).setMimeType (ContentService .MimeType .JSON );
87150 }
88151
89- // (Your existing 'initialize' and 'addProblem' logic here)
152+ // Existing 'initialize' and 'addProblem' logic here
90153 if (data .action === " initialize" ) {
91154 var headers = [" Rating" , " Problem" , " Status" , " Remarks" , " Date" , " Takeaway" , " Topics" ];
92155 if (sheet .getLastRow () === 0 || sheet .getRange (" A1" ).getValue () === " " ) {
@@ -124,7 +187,7 @@ function doPost(e) {
124187 ' {"status":"success","message":"Headers initialized with formatting, custom column widths, and row added."}'
125188 ).setMimeType (ContentService .MimeType .TEXT );
126189 } else {
127- return ContentService .createTextOutput (' {"status":"success","message":"Headers already exist ."}' ).setMimeType (ContentService .MimeType .TEXT );
190+ return ContentService .createTextOutput (' {"status":"success","message":"Verified ! ."}' ).setMimeType (ContentService .MimeType .TEXT );
128191 }
129192 } else if (data .action === " addProblem" ) {
130193 try {
@@ -146,10 +209,59 @@ function doPost(e) {
146209 );
147210 }
148211 }
212+
213+ // New feature: Update problem data
214+ if (data .action === " updateProblem" ) {
215+ const rows = sheet .getDataRange ().getValues ();
216+ const problemName = data .problemName ;
217+
218+ // Find the row with the matching problem name
219+ for (let i = 0 ; i < rows .length ; i++ ) {
220+ if (rows[i][1 ] === problemName) {
221+ // Assuming column B has the problem name
222+ sheet .getRange (i + 1 , 3 ).setValue (data .problemStatus ); // Update "Status" in column C
223+ sheet .getRange (i + 1 , 4 ).setValue (data .remarks ); // Update "Remarks" in column D
224+ sheet .getRange (i + 1 , 6 ).setValue (data .takeaways ); // Update "Takeaway" in column F
225+
226+ return ContentService .createTextOutput (JSON .stringify ({ status: " success" , message: " Problem data updated successfully." })).setMimeType (
227+ ContentService .MimeType .JSON
228+ );
229+ }
230+ }
231+
232+ return ContentService .createTextOutput (JSON .stringify ({ status: " error" , message: " Problem not found." })).setMimeType (
233+ ContentService .MimeType .JSON
234+ );
235+ }
149236 } catch (error) {
150237 return ContentService .createTextOutput (' {"status":"error","message":"' + error .message + ' "}' ).setMimeType (ContentService .MimeType .TEXT );
151238 }
152239}
240+
241+ // New feature: Handle GET requests for fetching problem data
242+ function doGet (e ) {
243+ const problemName = e .parameter .problemName ;
244+ const data = sheet .getDataRange ().getValues ();
245+
246+ // Find the row with the matching problem name
247+ const row = data .find ((row ) => row[1 ] === problemName); // Assuming column B has the problem name
248+ if (row) {
249+ return ContentService .createTextOutput (
250+ JSON .stringify ({
251+ status: " success" ,
252+ problem: {
253+ status: row[2 ], // Assuming "Status" is column C
254+ remarks: row[3 ], // Assuming "Remarks" is column D
255+ takeaways: row[5 ], // Assuming "Takeaway" is column F
256+ },
257+ })
258+ ).setMimeType (ContentService .MimeType .JSON );
259+ } else {
260+ return ContentService .createTextOutput (JSON .stringify ({ status: " error" , message: " Problem not found." })).setMimeType (
261+ ContentService .MimeType .JSON
262+ );
263+ }
264+ }
153265```
154266
155267## Usage
0 commit comments