Spaces:
Sleeping
Sleeping
Daniel Idanan commited on
Commit ·
6a6fcbb
1
Parent(s): acdffdd
add waste map and about page
Browse filesFiles changed (5)
- app.py+66-178
- render.yaml+2-2
- static/css/style.css+322-586
- static/js/app.js+59-104
- templates/index.html+180
7 unmodified lines8910111213141516171819202122235 unmodified lines2930313233343536373839404142434445464748495051525354555657585960616225 unmodified lines8889909192935 unmodified lines991001011021031041051061071081091101111121131141151161171181191201216 unmodified lines1281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621 unmodified line1641651661671681691701711721731741753 unmodified lines1791801811821831841851861871881891901914 unmodified lines19619719819920020120220320420520620714 unmodified lines22222322422522622722822923023123225 unmodified lines2582592602612622632642 unmodified lines2672682692702712722732742752762772 unmodified lines2802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233 unmodified lines3273283293303313323333343353363373383393403413423433443451 unmodified line34734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738812 unmodified lines4014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374383 unmodified lines4424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904913 unmodified lines4954964974987 unmodified linesfrom tensorflow.keras.models import load_modelfrom tensorflow.keras.preprocessing import image as keras_image#os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" # only for local developmentapp = Flask(__name__)app.secret_key = "ecosort_secret_key"app.config['SESSION_TYPE'] = 'filesystem'app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=10)app.config['SESSION_COOKIE_SECURE'] = False # Set to True only for HTTPSapp.config['SESSION_COOKIE_HTTPONLY'] = Trueapp.config['SESSION_COOKIE_SAMESITE'] = 'Lax'@app.before_requestdef make_session_permanent():5 unmodified linesos.makedirs(app.config["UPLOAD_FOLDER"], exist_ok=True)# ========== MODIFIED MODEL LOADING ==========MODEL_PATH = "model/waste_model.h5"# Check if model exists, if not train itif not os.path.exists(MODEL_PATH):print("=" * 50)print("Model not found! Training new model...")print("=" * 50)# Create model directoryos.makedirs("model", exist_ok=True)# Run training scriptimport train_modelprint("=" * 50)print("Model training complete!")print("=" * 50)# Now load the modelmodel = load_model(MODEL_PATH)class_names = ["biodegradable", "non_recyclable", "recyclable"]# ========== END MODIFIED SECTION ==========def get_db_connection():conn = sqlite3.connect(DATABASE)return conndef init_db():25 unmodified linesconn.commit()conn.close()def predict_waste(image_path):img = keras_image.load_img(image_path, target_size=(224, 224))5 unmodified linesconfidence = float(np.max(predictions[0])) * 100label_map = {"biodegradable": ("Biodegradable","Place this item in the biodegradable waste bin."),"recyclable": ("Recyclable","Place this item in the recyclable waste bin."),"non_recyclable": ("Non-recyclable","Place this item in the non-recyclable waste bin.")}raw_label = class_names[predicted_index]prediction, tip = label_map[raw_label]return prediction, f"{confidence:.2f}%", tip6 unmodified linesconn = get_db_connection()cursor = conn.cursor()cursor.execute("""SELECT id, name, email, passwordFROM usersWHERE email = ?""", (email,))user = cursor.fetchone()if not user:placeholder_password = "oauth_user_no_local_password"cursor.execute("""INSERT INTO users (name, email, password)VALUES (?, ?, ?)""", (name, email, placeholder_password))conn.commit()cursor.execute("""SELECT id, name, email, passwordFROM usersWHERE email = ?""", (email,))user = cursor.fetchone()conn.close()return user# -------------------------# OAuth setup# -------------------------oauth = OAuth(app)google = oauth.register(1 unmodified lineclient_id=os.environ.get("GOOGLE_CLIENT_ID"),client_secret=os.environ.get("GOOGLE_CLIENT_SECRET"),server_metadata_url="https://accounts.google.com/.well-known/openid-configuration",client_kwargs={"scope": "openid email profile"})facebook = oauth.register (name="facebook",client_id=os.environ.get("FACEBOOK_CLIENT_ID"),client_secret=os.environ.get("FACEBOOK_CLIENT_SECRET"),3 unmodified linesuserinfo_endpoint="https://graph.facebook.com/me?fields=id,name,email",client_kwargs={"scope": "email public_profile","token_endpoint_auth_method": "client_secret_post"})print("GOOGLE_CLIENT_ID =", os.environ.get("GOOGLE_CLIENT_ID"))print("GOOGLE_CLIENT_SECRET exists =", bool(os.environ.get("GOOGLE_CLIENT_SECRET")))@app.route("/register", methods=["GET", "POST"])def register():4 unmodified linesconn = get_db_connection()cursor = conn.cursor()try:cursor.execute("""INSERT INTO users (name, email, password)VALUES (?, ?, ?)""", (name, email, password))conn.commit()conn.close()flash("Registration successful. You can now log in.", "success")14 unmodified linesconn = get_db_connection()cursor = conn.cursor()cursor.execute("""SELECT id, name, email, passwordFROM usersWHERE email = ?""", (email,))user = cursor.fetchone()conn.close()25 unmodified linesconn = get_db_connection()cursor = conn.cursor()cursor.execute("SELECT id FROM users WHERE email = ?", (email,))user = cursor.fetchone()2 unmodified linesflash("No account found with that email.", "error")return redirect(url_for("forgot_password"))cursor.execute("""UPDATE usersSET password = ?WHERE email = ?""", (new_password, email))conn.commit()conn.close()2 unmodified linesreturn render_template("forgot_password.html")# -------------------------# Google OAuth# -------------------------@app.route("/login/google")def google_login():if not os.environ.get("GOOGLE_CLIENT_ID") or not os.environ.get("GOOGLE_CLIENT_SECRET"):flash("Google OAuth credentials are missing.", "error")return redirect(url_for("login"))redirect_uri = url_for("google_callback", _external=True)state = os.urandom(16).hex()session['oauth_state'] = statesession.modified = True # FORCE SAVEprint(f"Storing state: {state}") # Debugreturn google.authorize_redirect(redirect_uri, state=state)@app.route("/login/google/callback")def google_callback():try:# Debug: Check what we received vs what we storedreceived_state = request.args.get('state')stored_state = session.get('oauth_state')print(f"DEBUG - Received state: {received_state}")print(f"DEBUG - Stored state: {stored_state}")# TEMPORARY: Skip state verification for debugging# Remove this check once session persistence is fixedif stored_state and received_state != stored_state:print("WARNING: State mismatch detected, but allowing login for debugging")# Clear state from sessionsession.pop('oauth_state', None)# Get access tokentoken = google.authorize_access_token()resp = google.get("https://www.googleapis.com/oauth2/v3/userinfo", token=token)user_info = resp.json()3 unmodified linesuser = find_or_create_oauth_user(name, email)login_user(user)flash(f"Welcome, {name}!", "success")return redirect(url_for("index"))except Exception as e:print(f"Google OAuth error: {e}")flash(f"Google login failed: {e}", "error")return redirect(url_for("login"))# -------------------------# Facebook OAuth# -------------------------@app.route("/login/facebook")def facebook_login():if not os.environ.get("FACEBOOK_CLIENT_ID") or not os.environ.get("FACEBOOK_CLIENT_SECRET"):1 unmodified linereturn redirect(url_for("login"))redirect_uri = url_for("facebook_callback", _external=True)session['oauth_state'] = os.urandom(16).hex()return facebook.authorize_redirect(redirect_uri)@app.route("/login/facebook/callback")def facebook_callback():try:received_state = request.args.get('state')stored_state = session.get('oauth_state')print(f"DEBUG - Received state: {received_state}")print(f"DEBUG - Stored state: {stored_state}")# TEMPORARY: Skip state verification for debuggingif stored_state and received_state != stored_state:print("WARNING: State mismatch detected, but allowing login for debugging")session.pop('oauth_state', None)token = facebook.authorize_access_token()resp = facebook.get("me?fields=id,name,email", token=token)profile = resp.json()email = profile.get("email")name = profile.get("name", "Facebook User")user = find_or_create_oauth_user(name, email)login_user(user)flash(f"Welcome, {name}!", "success")return redirect(url_for("index"))except Exception as e:print(f"Facebook OAuth error: {e}")flash(f"Facebook login failed: {e}", "error")return redirect(url_for("login"))@app.route("/logout")def logout():12 unmodified linesreturn redirect(url_for("index"))image = request.files["image"]if image.filename == "":flash("Please choose an image file.", "error")return redirect(url_for("index"))original_filename = image.filenamefile_ext = os.path.splitext(original_filename)[1].lower()unique_filename = f"{uuid4().hex}{file_ext}"saved_file_path = os.path.join(app.config["UPLOAD_FOLDER"], unique_filename)image.save(saved_file_path)db_image_path = f"uploads/{unique_filename}"prediction, confidence, tip = predict_waste(saved_file_path)conn = get_db_connection()cursor = conn.cursor()cursor.execute("""INSERT INTO scans (user_id, image_path, prediction, confidence, tip)VALUES (?, ?, ?, ?, ?)""", (session["user_id"], db_image_path, prediction, confidence, tip))conn.commit()conn.close()return render_template("result.html",prediction=prediction,confidence=confidence,tip=tip,image=db_image_path)return render_template("index.html", user_name=session["user_name"])3 unmodified linesif "user_id" not in session:return redirect(url_for("login"))# Get filter parameter from query stringfilter_type = request.args.get('filter', 'all')conn = get_db_connection()cursor = conn.cursor()# Build query based on filterif filter_type == 'reduce':# Non-recyclable items -> focus on reducingcursor.execute("""SELECT id, image_path, prediction, confidence, tip, scanned_atFROM scansWHERE user_id = ? AND (prediction LIKE '%non_recyclable%' OR prediction LIKE '%non-recyclable%' OR prediction LIKE '%Non-recyclable%')ORDER BY id DESC""", (session["user_id"],))filter_title = "Reduce History (Non-recyclable Items)"elif filter_type == 'reuse':# Biodegradable items -> can be composted/reusedcursor.execute("""SELECT id, image_path, prediction, confidence, tip, scanned_atFROM scansWHERE user_id = ? AND (prediction LIKE '%biodegradable%' OR prediction LIKE '%Biodegradable%')ORDER BY id DESC""", (session["user_id"],))filter_title = "Reuse History (Biodegradable Items)"elif filter_type == 'recycle':# Recyclable itemscursor.execute("""SELECT id, image_path, prediction, confidence, tip, scanned_atFROM scansWHERE user_id = ? AND (prediction LIKE '%recyclable%' OR prediction LIKE '%Recyclable%') AND prediction NOT LIKE '%non%'ORDER BY id DESC""", (session["user_id"],))filter_title = "Recycle History (Recyclable Items)"else:# All itemscursor.execute("""SELECT id, image_path, prediction, confidence, tip, scanned_atFROM scansWHERE user_id = ?ORDER BY id DESC""", (session["user_id"],))filter_title = "All Scan History"scans = cursor.fetchall()conn.close()3 unmodified linesif __name__ == "__main__":init_db()port = int(os.environ.get("PORT", 8000))app.run(host="0.0.0.0", port=port, debug=False)7 unmodified lines891011121314151617181920215 unmodified lines272829303132333435363738394041424344454647484925 unmodified lines757677787980815 unmodified lines878889909192939495969798996 unmodified lines1061071081091101111121131141151161171181191201211221231241251261271281 unmodified line1301311321331341351361371381393 unmodified lines1431441451461471481491501511521534 unmodified lines15815916016116216316416516616716814 unmodified lines18318418518618718818925 unmodified lines2152162172182192202 unmodified lines2232242252262272282292 unmodified lines2322332342352362372382392402412422432442452462472482492502512522532542552563 unmodified lines2602612622632642652662672682692702712722732741 unmodified line27627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931012 unmodified lines3233243253263273283293303313323333343353363373383393403413423433443453463473483493503 unmodified lines3543553563573583593603613623633643653663673683693703713723733743753763773783793 unmodified lines3833843853867 unmodified linesfrom tensorflow.keras.models import load_modelfrom tensorflow.keras.preprocessing import image as keras_imageapp = Flask(__name__)app.secret_key = "ecosort_secret_key"app.config["SESSION_TYPE"] = "filesystem"app.config["PERMANENT_SESSION_LIFETIME"] = timedelta(minutes=10)app.config["SESSION_COOKIE_SECURE"] = False # Set to True when using HTTPSapp.config["SESSION_COOKIE_HTTPONLY"] = Trueapp.config["SESSION_COOKIE_SAMESITE"] = "Lax"@app.before_requestdef make_session_permanent():5 unmodified linesos.makedirs(app.config["UPLOAD_FOLDER"], exist_ok=True)# ===================== MODEL LOADING =====================MODEL_PATH = "model/waste_model.h5"if not os.path.exists(MODEL_PATH):print("Model not found — training now...")os.makedirs("model", exist_ok=True)import train_modelprint("Model training complete.")model = load_model(MODEL_PATH)class_names = ["biodegradable", "non_recyclable", "recyclable"]# ===================== DATABASE =====================def get_db_connection():return sqlite3.connect(DATABASE)def init_db():25 unmodified linesconn.commit()conn.close()# ===================== HELPERS =====================def predict_waste(image_path):img = keras_image.load_img(image_path, target_size=(224, 224))5 unmodified linesconfidence = float(np.max(predictions[0])) * 100label_map = {"biodegradable": ("Biodegradable", "Place this item in the biodegradable waste bin."),"recyclable": ("Recyclable", "Place this item in the recyclable waste bin."),"non_recyclable": ("Non-recyclable", "Place this item in the non-recyclable waste bin."),}raw_label = class_names[predicted_index]prediction, tip = label_map[raw_label]return prediction, f"{confidence:.2f}%", tip6 unmodified linesconn = get_db_connection()cursor = conn.cursor()cursor.execute("SELECT id, name, email, password FROM users WHERE email = ?", (email,))user = cursor.fetchone()if not user:cursor.execute("INSERT INTO users (name, email, password) VALUES (?, ?, ?)",(name, email, "oauth_user_no_local_password"))conn.commit()cursor.execute("SELECT id, name, email, password FROM users WHERE email = ?", (email,))user = cursor.fetchone()conn.close()return user# ===================== OAUTH =====================oauth = OAuth(app)google = oauth.register(1 unmodified lineclient_id=os.environ.get("GOOGLE_CLIENT_ID"),client_secret=os.environ.get("GOOGLE_CLIENT_SECRET"),server_metadata_url="https://accounts.google.com/.well-known/openid-configuration",client_kwargs={"scope": "openid email profile"},)facebook = oauth.register(name="facebook",client_id=os.environ.get("FACEBOOK_CLIENT_ID"),client_secret=os.environ.get("FACEBOOK_CLIENT_SECRET"),3 unmodified linesuserinfo_endpoint="https://graph.facebook.com/me?fields=id,name,email",client_kwargs={"scope": "email public_profile","token_endpoint_auth_method": "client_secret_post",},)# ===================== AUTH ROUTES =====================@app.route("/register", methods=["GET", "POST"])def register():4 unmodified linesconn = get_db_connection()cursor = conn.cursor()try:cursor.execute("INSERT INTO users (name, email, password) VALUES (?, ?, ?)",(name, email, password))conn.commit()conn.close()flash("Registration successful. You can now log in.", "success")14 unmodified linesconn = get_db_connection()cursor = conn.cursor()cursor.execute("SELECT id, name, email, password FROM users WHERE email = ?", (email,))user = cursor.fetchone()conn.close()25 unmodified linesconn = get_db_connection()cursor = conn.cursor()cursor.execute("SELECT id FROM users WHERE email = ?", (email,))user = cursor.fetchone()2 unmodified linesflash("No account found with that email.", "error")return redirect(url_for("forgot_password"))cursor.execute("UPDATE users SET password = ? WHERE email = ?", (new_password, email))conn.commit()conn.close()2 unmodified linesreturn render_template("forgot_password.html")# ===================== GOOGLE OAUTH =====================@app.route("/login/google")def google_login():if not os.environ.get("GOOGLE_CLIENT_ID") or not os.environ.get("GOOGLE_CLIENT_SECRET"):flash("Google OAuth credentials are missing.", "error")return redirect(url_for("login"))redirect_uri = url_for("google_callback", _external=True)state = os.urandom(16).hex()session["oauth_state"] = statesession.modified = Truereturn google.authorize_redirect(redirect_uri, state=state)@app.route("/login/google/callback")def google_callback():try:session.pop("oauth_state", None)token = google.authorize_access_token()resp = google.get("https://www.googleapis.com/oauth2/v3/userinfo", token=token)user_info = resp.json()3 unmodified linesuser = find_or_create_oauth_user(name, email)login_user(user)flash(f"Welcome, {name}!", "success")return redirect(url_for("index"))except Exception as e:flash(f"Google login failed: {e}", "error")return redirect(url_for("login"))# ===================== FACEBOOK OAUTH =====================@app.route("/login/facebook")def facebook_login():if not os.environ.get("FACEBOOK_CLIENT_ID") or not os.environ.get("FACEBOOK_CLIENT_SECRET"):1 unmodified linereturn redirect(url_for("login"))redirect_uri = url_for("facebook_callback", _external=True)session["oauth_state"] = os.urandom(16).hex()return facebook.authorize_redirect(redirect_uri)@app.route("/login/facebook/callback")def facebook_callback():try:session.pop("oauth_state", None)token = facebook.authorize_access_token()resp = facebook.get("me?fields=id,name,email", token=token)profile = resp.json()if not profile or "email" not in profile:flash("Facebook login failed — email not provided.", "error")return redirect(url_for("login"))email = profile.get("email")name = profile.get("name", "Facebook User")user = find_or_create_oauth_user(name, email)login_user(user)flash(f"Welcome, {name}!", "success")return redirect(url_for("index"))except Exception as e:flash(f"Facebook login failed: {e}", "error")return redirect(url_for("login"))# ===================== MAIN ROUTES =====================@app.route("/logout")def logout():12 unmodified linesreturn redirect(url_for("index"))image = request.files["image"]if image.filename == "":flash("Please choose an image file.", "error")return redirect(url_for("index"))file_ext = os.path.splitext(image.filename)[1].lower()unique_filename = f"{uuid4().hex}{file_ext}"saved_file_path = os.path.join(app.config["UPLOAD_FOLDER"], unique_filename)image.save(saved_file_path)db_image_path = f"uploads/{unique_filename}"prediction, confidence, tip = predict_waste(saved_file_path)conn = get_db_connection()cursor = conn.cursor()cursor.execute("INSERT INTO scans (user_id, image_path, prediction, confidence, tip) VALUES (?, ?, ?, ?, ?)",(session["user_id"], db_image_path, prediction, confidence, tip))conn.commit()conn.close()return render_template("result.html", prediction=prediction, confidence=confidence, tip=tip, image=db_image_path)return render_template("index.html", user_name=session["user_name"])3 unmodified linesif "user_id" not in session:return redirect(url_for("login"))filter_type = request.args.get("filter", "all")conn = get_db_connection()cursor = conn.cursor()base_query = "SELECT id, image_path, prediction, confidence, tip, scanned_at FROM scans WHERE user_id = ? {condition} ORDER BY id DESC"if filter_type == "reduce":condition = "AND (prediction LIKE '%non_recyclable%' OR prediction LIKE '%non-recyclable%' OR prediction LIKE '%Non-recyclable%')"filter_title = "Reduce History (Non-recyclable Items)"elif filter_type == "reuse":condition = "AND (prediction LIKE '%biodegradable%' OR prediction LIKE '%Biodegradable%')"filter_title = "Reuse History (Biodegradable Items)"elif filter_type == "recycle":condition = "AND (prediction LIKE '%recyclable%' OR prediction LIKE '%Recyclable%') AND prediction NOT LIKE '%non%'"filter_title = "Recycle History (Recyclable Items)"else:condition = ""filter_title = "All Scan History"cursor.execute(base_query.format(condition=condition), (session["user_id"],))scans = cursor.fetchall()conn.close()3 unmodified linesif __name__ == "__main__":init_db()port = int(os.environ.get("PORT", 8000))app.run(host="localhost", port=port, debug=False)
3 unmodified lines456789103 unmodified linesruntime: pythonplan: freebuildCommand: pip install -r requirements.txtstartCommand: gunicorn app:appenvVars:- key: PYTHON_VERSIONvalue: 3.11.93 unmodified lines456789103 unmodified linesruntime: pythonplan: freebuildCommand: pip install -r requirements.txtstartCommand: gunicorn app:app --bind 0.0.0.0:$PORTenvVars:- key: PYTHON_VERSIONvalue: 3.11.9
14 unmodified lines1516171819202164 unmodified lines8687888990919223 unmodified lines11611711811912012112260 unmodified lines18318418518618718818921 unmodified lines21121221321421521621721821922022122275 unmodified lines29829930030130230312 unmodified lines31631731831932032132232332432532632732818 unmodified lines34734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643779 unmodified lines51751851952052152212 unmodified lines53553653753853954018 unmodified lines55956056156256356411 unmodified lines57657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094125 unmodified lines96796896997097197297323 unmodified lines997998999100010011002100310048 unmodified lines10131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117738 unmodified lines121612171218121912201221122210 unmodified lines12331234123512361237123812391 unmodified line12411242124312441245124612471 unmodified line12491250125112521253125412551 unmodified line1257125812591260126112621263126412651266126712681269127012711272127312741275127612776 unmodified lines1284128512861287128814 unmodified linescolor: white;}/* Splash Screen */#splash-screen {position: fixed;inset: 0;64 unmodified linesanimation: loadingBar 2.3s ease forwards;}/* Main page */.page-wrapper {width: 100%;min-height: 100vh;23 unmodified linesbox-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);}/* Left brand panel */.brand-panel {position: relative;background: linear-gradient(160deg, #22c55e, #15803d);60 unmodified linesmargin: 0 auto;}/* Right login panel */.login-panel {display: flex;justify-content: center;21 unmodified lines}.subtitle {text-align: center;color: rgba(255, 255, 255, 0.78);margin-bottom: 24px;font-size: 0.95rem;}.input-group {margin-bottom: 18px;}75 unmodified linesbox-shadow: 0 12px 22px rgba(34, 197, 94, 0.32);}.divider {margin: 22px 0 18px;text-align: center;12 unmodified linesbackground: rgba(255, 255, 255, 0.2);}.divider::before {left: 0;}.divider::after {right: 0;}.social-login {display: flex;18 unmodified linesbackground: rgba(255, 255, 255, 0.18);}/* Smooth entrance */.fade-up {animation: fadeUp 1s ease;}/* Animations */@keyframes spinSmooth {from {transform: rotate(0deg);}to {transform: rotate(360deg);}}@keyframes loadingBar {0% {width: 0%;}100% {width: 100%;}}@keyframes fadeUp {from {opacity: 0;transform: translateY(35px);}to {opacity: 1;transform: translateY(0);}}@keyframes fadeIn {from {opacity: 0;transform: scale(0.96);}to {opacity: 1;transform: scale(1);}}/* Responsive */@media (max-width: 768px) {body {overflow-y: auto;}.page-wrapper {padding: 16px;}.mobile-frame {grid-template-columns: 1fr;min-height: auto;max-width: 420px;border-radius: 26px;}.brand-panel {min-height: 260px;}.brand-content h1 {font-size: 2.2rem;}.login-panel {padding: 20px;}.login-card {max-width: 100%;padding: 24px 18px;}}.result-image-box {width: 100%;margin-bottom: 20px;79 unmodified linesflex-shrink: 0;}.history-card {max-width: 430px;}12 unmodified linesborder: 1px solid rgba(255, 255, 255, 0.1);border-radius: 18px;overflow: hidden;}.history-top img {18 unmodified linesmargin-bottom: 0;}.empty-state {text-align: center;padding: 28px 16px;11 unmodified linescolor: rgba(255, 255, 255, 0.8);}.dashboard-card {max-width: 420px;}.upload-box {width: 100%;margin-bottom: 18px;}.upload-label {width: 100%;min-height: 170px;border: 2px dashed rgba(255, 255, 255, 0.25);border-radius: 20px;background: rgba(255, 255, 255, 0.06);display: flex;flex-direction: column;justify-content: center;align-items: center;gap: 10px;text-align: center;padding: 20px;cursor: pointer;transition: all 0.3s ease;}.upload-label:hover {border-color: #22c55e;background: rgba(34, 197, 94, 0.08);transform: translateY(-2px);}.upload-label i {font-size: 2rem;color: #86efac;}.upload-label span {font-size: 1rem;font-weight: 700;color: white;}.upload-label small {color: rgba(255, 255, 255, 0.65);font-size: 0.85rem;}.preview-box {width: 100%;margin-bottom: 18px;border-radius: 18px;overflow: hidden;border: 1px solid rgba(255, 255, 255, 0.1);background: rgba(255, 255, 255, 0.06);}.preview-box img {width: 100%;height: 220px;object-fit: cover;display: block;}.scan-btn {display: flex;align-items: center;justify-content: center;gap: 8px;}.quick-actions {display: flex;justify-content: center;gap: 14px;margin-top: 18px;}.dashboard-tips {display: grid;grid-template-columns: repeat(3, 1fr);gap: 10px;margin-top: 22px;}.tip-mini {background: rgba(255, 255, 255, 0.08);border: 1px solid rgba(255, 255, 255, 0.08);border-radius: 14px;padding: 12px 10px;text-align: center;transition: all 0.3s ease;}.tip-mini:hover {transform: translateY(-2px);background: rgba(255, 255, 255, 0.12);}.tip-mini i {display: block;font-size: 1.1rem;margin-bottom: 8px;color: #86efac;}.tip-mini span {font-size: 0.84rem;color: white;font-weight: 600;}.flash-message {padding: 12px 14px;border-radius: 12px;margin-bottom: 16px;font-size: 0.92rem;text-align: center;font-weight: 600;animation: fadeUp 0.4s ease;}.flash-message.error {background: rgba(239, 68, 68, 0.16);border: 1px solid rgba(239, 68, 68, 0.35);color: #fecaca;}.flash-message.success {background: rgba(34, 197, 94, 0.14);border: 1px solid rgba(34, 197, 94, 0.35);color: #bbf7d0;}.register-link {margin-top: 18px;text-align: center;}.register-link p {font-size: 0.9rem;color: rgba(255, 255, 255, 0.78);}.register-link a {color: #86efac;font-weight: 700;text-decoration: none;}.register-link a:hover {text-decoration: underline;}.facebook-btn:hover {background: rgba(59, 130, 246, 0.18);}.google-btn:hover {background: rgba(255, 255, 255, 0.18);}.flash-message {padding: 12px 14px;border-radius: 12px;margin-bottom: 16px;font-size: 0.92rem;text-align: center;font-weight: 600;animation: fadeUp 0.4s ease;}.flash-message.error {background: rgba(239, 68, 68, 0.16);border: 1px solid rgba(239, 68, 68, 0.35);color: #fecaca;}.flash-message.success {background: rgba(34, 197, 94, 0.14);border: 1px solid rgba(34, 197, 94, 0.35);color: #bbf7d0;}.facebook-btn:hover {background: rgba(59, 130, 246, 0.18);}.google-btn:hover {background: rgba(255, 255, 255, 0.18);}.social-login-wide {display: flex;flex-direction: column;gap: 12px;margin-top: 4px;}.social-login-btn {width: 100%;min-height: 52px;border-radius: 14px;padding: 14px 16px;text-decoration: none;display: flex;align-items: center;justify-content: center;gap: 10px;font-weight: 700;transition: all 0.3s ease;border: 1px solid rgba(255, 255, 255, 0.14);}.social-login-btn i {font-size: 1rem;}.google-login-btn {background: rgba(255, 255, 255, 0.1);color: white;}.google-login-btn:hover {transform: translateY(-2px);background: rgba(255, 255, 255, 0.16);}.facebook-login-btn {background: rgba(37, 99, 235, 0.22);color: white;}.facebook-login-btn:hover {transform: translateY(-2px);background: rgba(37, 99, 235, 0.3);}.social-login-wide {display: flex;flex-direction: column;gap: 12px;}.social-login-btn {width: 100%;min-height: 52px;border-radius: 14px;padding: 14px 16px;text-decoration: none;display: flex;align-items: center;justify-content: center;gap: 10px;font-weight: 700;transition: all 0.3s ease;border: 1px solid rgba(255, 255, 255, 0.14);color: white;}.google-login-btn {background: rgba(255, 255, 255, 0.10);}.google-login-btn:hover {transform: translateY(-2px);background: rgba(255, 255, 255, 0.18);}.facebook-login-btn {background: rgba(37, 99, 235, 0.22);}.facebook-login-btn:hover {transform: translateY(-2px);background: rgba(37, 99, 235, 0.30);}.social-login-wide {display: flex;flex-direction: column;gap: 12px;}.social-login-btn {width: 100%;min-height: 52px;border-radius: 14px;padding: 14px 16px;text-decoration: none;display: flex;align-items: center;justify-content: center;gap: 10px;font-weight: 700;transition: all 0.3s ease;border: 1px solid rgba(255, 255, 255, 0.14);color: white;}.facebook-login-btn {background: rgba(37, 99, 235, 0.22);}.facebook-login-btn:hover {transform: translateY(-2px);background: rgba(37, 99, 235, 0.30);}.google-login-btn {background: rgba(255, 255, 255, 0.10);}.google-login-btn:hover {transform: translateY(-2px);background: rgba(255, 255, 255, 0.18);}/* --------------------------------------------------------------------------------------------------------------------- *//* History Page Specific Styles *//* Modal Styles */.modal {display: none;position: fixed;z-index: 10000;left: 0;top: 0;width: 100%;height: 100%;background-color: rgba(0, 0, 0, 0.8);backdrop-filter: blur(8px);}.modal-content {background: linear-gradient(135deg, #1e293b, #0f172a);margin: 5% auto;padding: 30px;border-radius: 24px;width: 90%;max-width: 500px;border: 1px solid rgba(255, 255, 255, 0.2);animation: modalSlideIn 0.3s ease;}@keyframes modalSlideIn {from {opacity: 0;transform: translateY(-50px);}to {opacity: 1;transform: translateY(0);}}.modal-header {display: flex;justify-content: space-between;align-items: center;margin-bottom: 20px;}25 unmodified linesmargin-bottom: 20px;}/* RRR Section Styles */.rrr-section {display: grid;grid-template-columns: repeat(3, 1fr);23 unmodified linesdisplay: block;}.rrr-card.reduce i { color: #f59e0b; }.rrr-card.reuse i { color: #3b82f6; }.rrr-card.recycle i { color: #22c55e; }.rrr-card h4 {8 unmodified linescolor: white;}/* History Item Styles */.history-item {cursor: pointer;transition: transform 0.3s ease;}.history-item:hover {transform: translateY(-5px);}.click-hint {position: absolute;top: 10px;right: 10px;background: rgba(0, 0, 0, 0.6);color: white;padding: 5px 10px;border-radius: 20px;font-size: 0.75rem;opacity: 0;transition: opacity 0.3s ease;}.history-item:hover .click-hint {opacity: 1;}.history-top {position: relative;}/* Filter Badge Styles */.filter-badge {display: inline-flex;align-items: center;gap: 8px;background: rgba(34, 197, 94, 0.2);border: 1px solid rgba(34, 197, 94, 0.4);color: #86efac;padding: 8px 16px;border-radius: 20px;font-size: 0.85rem;font-weight: 600;margin-bottom: 15px;}.filter-badge a {color: #86efac;text-decoration: none;margin-left: 8px;font-size: 1rem;}.clear-filter-btn {display: inline-flex;align-items: center;gap: 6px;background: rgba(255, 255, 255, 0.1);border: 1px solid rgba(255, 255, 255, 0.2);color: white;padding: 8px 14px;border-radius: 20px;font-size: 0.8rem;text-decoration: none;margin-left: 10px;transition: all 0.3s ease;}.clear-filter-btn:hover {background: rgba(255, 255, 255, 0.2);transform: translateY(-1px);}/* Subtitle spacing for filter display */.subtitle {display: flex;flex-wrap: wrap;align-items: center;gap: 10px;justify-content: center;}/* --------------------------------------------------------------------------------------------------------------------- *//* Dashboard/Index Page Specific Styles *//* RRR Button Styles */.tip-mini {cursor: pointer;transition: all 0.3s ease;position: relative;overflow: hidden;}.tip-mini:hover {transform: translateY(-5px) scale(1.02);box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);}/* Shine effect on hover */.tip-mini::after {content: '';position: absolute;top: 0;left: -100%;width: 100%;height: 100%;background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);transition: left 0.5s ease;}.tip-mini:hover::after {left: 100%;}/* Color-specific hover states */.tip-mini.reduce:hover {border-color: #f59e0b;background: rgba(245, 158, 11, 0.2);}.tip-mini.reuse:hover {border-color: #3b82f6;background: rgba(59, 130, 246, 0.2);}.tip-mini.recycle:hover {border-color: #22c55e;background: rgba(34, 197, 94, 0.2);}/* Click indicator arrow */.click-indicator {position: absolute;bottom: 5px;right: 5px;font-size: 0.7rem;opacity: 0;transition: opacity 0.3s ease;}.tip-mini:hover .click-indicator {opacity: 1;}/* Category label styling */.category-label {color: rgba(255,255,255,0.6);font-size: 0.7rem;display: block;margin-top: 4px;}/* Dashboard card specific adjustments */.dashboard-card {max-width: 420px;}/* Upload box enhancements */.upload-box {width: 100%;margin-bottom: 18px;38 unmodified linesfont-size: 0.85rem;}/* Preview box styles */.preview-box {width: 100%;margin-bottom: 18px;10 unmodified linesdisplay: block;}/* Scan button with icon */.scan-btn {display: flex;align-items: center;1 unmodified linegap: 8px;}/* Quick actions container */.quick-actions {display: flex;justify-content: center;1 unmodified linemargin-top: 18px;}/* Dashboard tips/RRR container */.dashboard-tips {display: grid;grid-template-columns: repeat(3, 1fr);1 unmodified linemargin-top: 22px;}/* RRR button base styles */.tip-mini {background: rgba(255, 255, 255, 0.08);border: 1px solid rgba(255, 255, 255, 0.08);border-radius: 14px;padding: 12px 10px;text-align: center;transition: all 0.3s ease;}.tip-mini:hover {transform: translateY(-2px);background: rgba(255, 255, 255, 0.12);}.tip-mini i {display: block;font-size: 1.1rem;6 unmodified linesfont-weight: 600;}/* --------------------------------------------------------------------------------------------------------------------- */14 unmodified lines151617181920212264 unmodified lines878889909192939423 unmodified lines11811912012112212312412560 unmodified lines18618718818919019119219321 unmodified lines21521621721821922022122222322422522622722822923023123223375 unmodified lines30931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934012 unmodified lines35335435535635735835936036136218 unmodified lines38138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445579 unmodified lines53553653753853954054154212 unmodified lines55555655755855956056156256356456556656756856957018 unmodified lines58959059159259359459559659759859960060160260360460560660760860961061111 unmodified lines62362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969025 unmodified lines71671771871972072172272323 unmodified lines7477487497507517527537548 unmodified lines76376476576676776876977077177277377438 unmodified lines81381481581681781810 unmodified lines8298308318328338341 unmodified line8368378388398408411 unmodified line8438448458468478481 unmodified line8508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918926 unmodified lines899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102414 unmodified linescolor: white;}/* ===================== SPLASH SCREEN ===================== */#splash-screen {position: fixed;inset: 0;64 unmodified linesanimation: loadingBar 2.3s ease forwards;}/* ===================== LAYOUT ===================== */.page-wrapper {width: 100%;min-height: 100vh;23 unmodified linesbox-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);}/* ===================== BRAND PANEL ===================== */.brand-panel {position: relative;background: linear-gradient(160deg, #22c55e, #15803d);60 unmodified linesmargin: 0 auto;}/* ===================== LOGIN PANEL ===================== */.login-panel {display: flex;justify-content: center;21 unmodified lines}.subtitle {display: flex;flex-wrap: wrap;align-items: center;gap: 10px;justify-content: center;text-align: center;color: rgba(255, 255, 255, 0.78);margin-bottom: 24px;font-size: 0.95rem;}/* ===================== FORM ELEMENTS ===================== */.input-group {margin-bottom: 18px;}75 unmodified linesbox-shadow: 0 12px 22px rgba(34, 197, 94, 0.32);}/* ===================== FLASH MESSAGES ===================== */.flash-message {padding: 12px 14px;border-radius: 12px;margin-bottom: 16px;font-size: 0.92rem;text-align: center;font-weight: 600;animation: fadeUp 0.4s ease;}.flash-message.error {background: rgba(239, 68, 68, 0.16);border: 1px solid rgba(239, 68, 68, 0.35);color: #fecaca;}.flash-message.success {background: rgba(34, 197, 94, 0.14);border: 1px solid rgba(34, 197, 94, 0.35);color: #bbf7d0;}/* ===================== DIVIDER ===================== */.divider {margin: 22px 0 18px;text-align: center;12 unmodified linesbackground: rgba(255, 255, 255, 0.2);}.divider::before { left: 0; }.divider::after { right: 0; }/* ===================== SOCIAL LOGIN ===================== */.social-login {display: flex;18 unmodified linesbackground: rgba(255, 255, 255, 0.18);}.social-login-wide {display: flex;flex-direction: column;gap: 12px;margin-top: 4px;}.social-login-btn {width: 100%;min-height: 52px;border-radius: 14px;padding: 14px 16px;text-decoration: none;display: flex;align-items: center;justify-content: center;gap: 10px;font-weight: 700;transition: all 0.3s ease;border: 1px solid rgba(255, 255, 255, 0.14);color: white;}.social-login-btn i {font-size: 1rem;}.google-login-btn {background: rgba(255, 255, 255, 0.1);}.google-login-btn:hover {transform: translateY(-2px);background: rgba(255, 255, 255, 0.18);}.facebook-login-btn {background: rgba(37, 99, 235, 0.22);}.facebook-login-btn:hover {transform: translateY(-2px);background: rgba(37, 99, 235, 0.3);}/* ===================== REGISTER LINK ===================== */.register-link {margin-top: 18px;text-align: center;}.register-link p {font-size: 0.9rem;color: rgba(255, 255, 255, 0.78);}.register-link a {color: #86efac;font-weight: 700;text-decoration: none;}.register-link a:hover {text-decoration: underline;}/* ===================== RESULT PAGE ===================== */.result-image-box {width: 100%;margin-bottom: 20px;79 unmodified linesflex-shrink: 0;}/* ===================== HISTORY PAGE ===================== */.history-card {max-width: 430px;}12 unmodified linesborder: 1px solid rgba(255, 255, 255, 0.1);border-radius: 18px;overflow: hidden;cursor: pointer;transition: transform 0.3s ease;}.history-item:hover {transform: translateY(-5px);}.history-top {position: relative;}.history-top img {18 unmodified linesmargin-bottom: 0;}.click-hint {position: absolute;top: 10px;right: 10px;background: rgba(0, 0, 0, 0.6);color: white;padding: 5px 10px;border-radius: 20px;font-size: 0.75rem;opacity: 0;transition: opacity 0.3s ease;}.history-item:hover .click-hint {opacity: 1;}.empty-state {text-align: center;padding: 28px 16px;11 unmodified linescolor: rgba(255, 255, 255, 0.8);}.filter-badge {display: inline-flex;align-items: center;gap: 8px;background: rgba(34, 197, 94, 0.2);border: 1px solid rgba(34, 197, 94, 0.4);color: #86efac;padding: 8px 16px;border-radius: 20px;font-size: 0.85rem;font-weight: 600;margin-bottom: 15px;}.clear-filter-btn {display: inline-flex;align-items: center;gap: 6px;background: rgba(255, 255, 255, 0.1);border: 1px solid rgba(255, 255, 255, 0.2);color: white;padding: 8px 14px;border-radius: 20px;font-size: 0.8rem;text-decoration: none;margin-left: 10px;transition: all 0.3s ease;}.clear-filter-btn:hover {background: rgba(255, 255, 255, 0.2);transform: translateY(-1px);}/* ===================== MODAL ===================== */.modal {display: none;position: fixed;z-index: 10000;left: 0;top: 0;width: 100%;height: 100%;background-color: rgba(0, 0, 0, 0.8);backdrop-filter: blur(8px);}.modal-content {background: linear-gradient(135deg, #1e293b, #0f172a);margin: 5% auto;padding: 30px;border-radius: 24px;width: 90%;max-width: 500px;border: 1px solid rgba(255, 255, 255, 0.2);animation: modalSlideIn 0.3s ease;}.modal-header {display: flex;justify-content: space-between;align-items: center;margin-bottom: 20px;}25 unmodified linesmargin-bottom: 20px;}/* ===================== RRR CARDS ===================== */.rrr-section {display: grid;grid-template-columns: repeat(3, 1fr);23 unmodified linesdisplay: block;}.rrr-card.reduce i { color: #f59e0b; }.rrr-card.reuse i { color: #3b82f6; }.rrr-card.recycle i { color: #22c55e; }.rrr-card h4 {8 unmodified linescolor: white;}/* ===================== DASHBOARD PAGE ===================== */.dashboard-card {max-width: 420px;}.upload-box {width: 100%;margin-bottom: 18px;38 unmodified linesfont-size: 0.85rem;}.preview-box {width: 100%;margin-bottom: 18px;10 unmodified linesdisplay: block;}.scan-btn {display: flex;align-items: center;1 unmodified linegap: 8px;}.quick-actions {display: flex;justify-content: center;1 unmodified linemargin-top: 18px;}.dashboard-tips {display: grid;grid-template-columns: repeat(3, 1fr);1 unmodified linemargin-top: 22px;}.tip-mini {background: rgba(255, 255, 255, 0.08);border: 1px solid rgba(255, 255, 255, 0.08);border-radius: 14px;padding: 12px 10px;text-align: center;cursor: pointer;position: relative;overflow: hidden;transition: all 0.3s ease;}.tip-mini:hover {transform: translateY(-5px) scale(1.02);box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);background: rgba(255, 255, 255, 0.12);}.tip-mini::after {content: '';position: absolute;top: 0;left: -100%;width: 100%;height: 100%;background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);transition: left 0.5s ease;}.tip-mini:hover::after {left: 100%;}.tip-mini.reduce:hover { border-color: #f59e0b; background: rgba(245, 158, 11, 0.2); }.tip-mini.reuse:hover { border-color: #3b82f6; background: rgba(59, 130, 246, 0.2); }.tip-mini.recycle:hover { border-color: #22c55e; background: rgba(34, 197, 94, 0.2); }.tip-mini i {display: block;font-size: 1.1rem;6 unmodified linesfont-weight: 600;}.click-indicator {position: absolute;bottom: 5px;right: 5px;font-size: 0.7rem;opacity: 0;transition: opacity 0.3s ease;}.tip-mini:hover .click-indicator {opacity: 1;}.category-label {color: rgba(255, 255, 255, 0.6);font-size: 0.7rem;display: block;margin-top: 4px;}/* ===================== ABOUT MODAL ===================== */.about-section {display: flex;flex-direction: column;gap: 14px;}.about-row {display: flex;align-items: flex-start;gap: 14px;background: rgba(255, 255, 255, 0.06);border: 1px solid rgba(255, 255, 255, 0.08);border-radius: 14px;padding: 14px;}.about-row i {font-size: 1.4rem;margin-top: 2px;flex-shrink: 0;}.about-row strong {display: block;font-size: 0.92rem;color: white;margin-bottom: 4px;}.about-row p {font-size: 0.82rem;color: rgba(255, 255, 255, 0.6);line-height: 1.5;}/* ===================== ANIMATIONS ===================== */.fade-up {animation: fadeUp 1s ease;}@keyframes spinSmooth {from { transform: rotate(0deg); }to { transform: rotate(360deg); }}@keyframes loadingBar {0% { width: 0%; }100% { width: 100%; }}@keyframes fadeUp {from { opacity: 0; transform: translateY(35px); }to { opacity: 1; transform: translateY(0); }}@keyframes fadeIn {from { opacity: 0; transform: scale(0.96); }to { opacity: 1; transform: scale(1); }}@keyframes modalSlideIn {from { opacity: 0; transform: translateY(-50px); }to { opacity: 1; transform: translateY(0); }}/* ===================== RESPONSIVE ===================== */@media (max-width: 768px) {body {overflow-y: auto;}.page-wrapper {padding: 16px;}.mobile-frame {grid-template-columns: 1fr;min-height: auto;max-width: 420px;border-radius: 26px;}.brand-panel {min-height: 260px;}.brand-content h1 {font-size: 2.2rem;}.login-panel {padding: 20px;}.login-card {max-width: 100%;padding: 24px 18px;}}
1236 unmodified lines101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475761 unmodified line787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281292 unmodified lines132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178window.addEventListener("load", () => {const splash = document.getElementById("splash-screen");const main = document.getElementById("main-content");6 unmodified lines}});/* --------------------------------------------------------------------------------------------------------------------- */// History Page JavaScript/*** Open modal with waste analysis details* @param {string} imagePath - Path to the scanned image* @param {string} prediction - AI prediction result* @param {string} confidence - Confidence percentage* @param {string} tip - Waste disposal tip* @param {string} date - Scan date*/function openModal(imagePath, prediction, confidence, tip, date) {const modal = document.getElementById('analysisModal');// Set modal contentdocument.getElementById('modalImage').src = '/static/' + imagePath;document.getElementById('modalPrediction').textContent = prediction;document.getElementById('modalConfidence').textContent = confidence;document.getElementById('modalDate').textContent = date;document.getElementById('modalTip').textContent = tip;// Calculate RRR percentages based on prediction typelet reduce, reuse, recycle;const predLower = prediction.toLowerCase();if (predLower.includes('non_recyclable') || predLower.includes('non-recyclable')) {// Non-recyclable: Focus on reducing wastereduce = 70;reuse = 20;recycle = 10;highlightCard('reduceCard');} else if (predLower.includes('recyclable')) {// Recyclable: Focus on recyclingreduce = 20;reuse = 30;recycle = 50;highlightCard('recycleCard');} else if (predLower.includes('biodegradable')) {// Biodegradable: Focus on reusing/compostingreduce = 30;reuse = 40;recycle = 30;highlightCard('reuseCard');} else {// Default equal distributionreduce = 33;reuse = 33;recycle = 34;highlightCard('recycleCard');}// Update percentage displaysdocument.getElementById('reducePercent').textContent = reduce + '%';document.getElementById('reusePercent').textContent = reuse + '%';document.getElementById('recyclePercent').textContent = recycle + '%';// Show modal and prevent background scrollingmodal.style.display = 'block';document.body.style.overflow = 'hidden';}/**1 unmodified line* @param {string} cardId - ID of the card to highlight*/function highlightCard(cardId) {// Remove active class from all cardsdocument.querySelectorAll('.rrr-card').forEach(card => {card.classList.remove('active');});// Add active class to specified cardconst activeCard = document.getElementById(cardId);if (activeCard) {activeCard.classList.add('active');}}/*** Close the analysis modal*/function closeModal() {const modal = document.getElementById('analysisModal');modal.style.display = 'none';document.body.style.overflow = 'auto';}// Event listener for clicking outside modal to closewindow.onclick = function(event) {const modal = document.getElementById('analysisModal');if (event.target === modal) {closeModal();}};// Keyboard support - ESC to close modaldocument.addEventListener('keydown', function(event) {if (event.key === 'Escape') {closeModal();}});/* --------------------------------------------------------------------------------------------------------------------- */// Dashboard/Index Page JavaScript/*** Initialize dashboard functionality when DOM is loadeddocument.addEventListener('DOMContentLoaded', function() {initializeImageUpload();});/*** Initialize image upload preview functionality*/2 unmodified linesconst previewBox = document.getElementById("previewBox");const previewImage = document.getElementById("previewImage");if (imageInput) {imageInput.addEventListener("change", function() {const file = this.files[0];if (file) {// Create object URL for previewconst objectUrl = URL.createObjectURL(file);previewImage.src = objectUrl;previewBox.style.display = "block";// Clean up object URL when image loads to prevent memory leakspreviewImage.onload = function() {URL.revokeObjectURL(objectUrl);};}});}}/*** Navigate to filtered history page* @param {string} filterType - 'reduce', 'reuse', or 'recycle'*/function navigateToFilteredHistory(filterType) {// Build URL with filter parameterconst baseUrl = "/history";const url = filterType ? `${baseUrl}?filter=${filterType}` : baseUrl;window.location.href = url;}/*** Handle RRR button clicks with visual feedback* @param {HTMLElement} element - The clicked button element* @param {string} filterType - Filter type for navigation*/function handleRRRButtonClick(element, filterType) {// Add click animationelement.style.transform = 'scale(0.95)';setTimeout(() => {element.style.transform = '';navigateToFilteredHistory(filterType);}, 150);}123456 unmodified lines1213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758591 unmodified line6162636465666768697071727374757677787980818283848586878889902 unmodified lines93949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133// ===================== SPLASH SCREEN =====================window.addEventListener("load", () => {const splash = document.getElementById("splash-screen");const main = document.getElementById("main-content");6 unmodified lines}});// ===================== HISTORY PAGE =====================/*** Open modal with waste analysis details* @param {string} imagePath - Path to the scanned image* @param {string} prediction - AI prediction result* @param {string} confidence - Confidence percentage* @param {string} tip - Waste disposal tip* @param {string} date - Scan date*/function openModal(imagePath, prediction, confidence, tip, date) {const modal = document.getElementById("analysisModal");document.getElementById("modalImage").src = "/static/" + imagePath;document.getElementById("modalPrediction").textContent = prediction;document.getElementById("modalConfidence").textContent = confidence;document.getElementById("modalDate").textContent = date;document.getElementById("modalTip").textContent = tip;let reduce, reuse, recycle;const predLower = prediction.toLowerCase();if (predLower.includes("non_recyclable") || predLower.includes("non-recyclable")) {reduce = 70; reuse = 20; recycle = 10;highlightCard("reduceCard");} else if (predLower.includes("recyclable")) {reduce = 20; reuse = 30; recycle = 50;highlightCard("recycleCard");} else if (predLower.includes("biodegradable")) {reduce = 30; reuse = 40; recycle = 30;highlightCard("reuseCard");} else {reduce = 33; reuse = 33; recycle = 34;highlightCard("recycleCard");}document.getElementById("reducePercent").textContent = reduce + "%";document.getElementById("reusePercent").textContent = reuse + "%";document.getElementById("recyclePercent").textContent = recycle + "%";modal.style.display = "block";document.body.style.overflow = "hidden";}/**1 unmodified line* @param {string} cardId - ID of the card to highlight*/function highlightCard(cardId) {document.querySelectorAll(".rrr-card").forEach(card => card.classList.remove("active"));const activeCard = document.getElementById(cardId);if (activeCard) activeCard.classList.add("active");}/*** Close the analysis modal*/function closeModal() {document.getElementById("analysisModal").style.display = "none";document.body.style.overflow = "auto";}// Close modal on backdrop click or ESC keywindow.addEventListener("click", function (event) {if (event.target === document.getElementById("analysisModal")) closeModal();});document.addEventListener("keydown", function (event) {if (event.key === "Escape") closeModal();});// ===================== DASHBOARD PAGE =====================/*** Initialize image upload preview functionality*/2 unmodified linesconst previewBox = document.getElementById("previewBox");const previewImage = document.getElementById("previewImage");if (!imageInput) return;imageInput.addEventListener("change", function () {const file = this.files[0];if (file) {const objectUrl = URL.createObjectURL(file);previewImage.src = objectUrl;previewBox.style.display = "block";previewImage.onload = function () {URL.revokeObjectURL(objectUrl);};}});}document.addEventListener("DOMContentLoaded", initializeImageUpload);/*** Navigate to filtered history page* @param {string} filterType - 'reduce', 'reuse', or 'recycle'*/function navigateToFilteredHistory(filterType) {const url = filterType ? `/history?filter=${filterType}` : "/history";window.location.href = url;}/*** Handle RRR button clicks with visual feedback* @param {HTMLElement} element - The clicked button element* @param {string} filterType - Filter type for navigation*/function handleRRRButtonClick(element, filterType) {element.style.transform = "scale(0.95)";setTimeout(() => {element.style.transform = "";navigateToFilteredHistory(filterType);}, 150);}
59 unmodified lines60616263646526 unmodified lines92939495969759 unmodified lines<i class="fa-solid fa-clock-rotate-left"></i></a><a href="{{ url_for('logout') }}" class="social-btn action-icon" title="Logout"><i class="fa-solid fa-right-from-bracket"></i></a>26 unmodified lines</div></div></body></html>59 unmodified lines606162636465666768697071727326 unmodified lines10010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627759 unmodified lines<i class="fa-solid fa-clock-rotate-left"></i></a><button class="social-btn action-icon" title="Junk Shop Map" onclick="openMapModal()"><i class="fa-solid fa-map-location-dot"></i></button><button class="social-btn action-icon" title="About EcoSort" onclick="openAboutModal()"><i class="fa-solid fa-circle-info"></i></button><a href="{{ url_for('logout') }}" class="social-btn action-icon" title="Logout"><i class="fa-solid fa-right-from-bracket"></i></a>26 unmodified lines</div></div><!-- ===== ABOUT MODAL ===== --><div id="aboutModal" class="modal"><div class="modal-content"><div class="modal-header"><h3><i class="fa-solid fa-leaf"></i> About EcoSort</h3><button class="close-btn" onclick="closeAboutModal()"><i class="fa-solid fa-xmark"></i></button></div><div style="text-align:center; margin-bottom:18px;"><div class="brand-logo-wrap" style="margin:0 auto 14px; width:80px; height:80px; background:rgba(34,197,94,0.18);"><i class="fa-solid fa-recycle rotating-logo" style="font-size:38px;"></i></div><h2 style="font-size:1.6rem; font-weight:800; margin-bottom:6px;">EcoSort</h2><p style="color:rgba(255,255,255,0.65); font-size:0.9rem; font-style:italic;">Reduce. Reuse. Recycle.</p></div><div class="about-section"><div class="about-row"><i class="fa-solid fa-brain" style="color:#22c55e;"></i><div><strong>AI-Powered Classification</strong><p>EcoSort uses a trained deep learning model to identify waste as Biodegradable, Recyclable, or Non-recyclable — just from a photo.</p></div></div><div class="about-row"><i class="fa-solid fa-recycle" style="color:#3b82f6;"></i><div><strong>The 3R Framework</strong><p>Every scan gives you actionable Reduce, Reuse, and Recycle guidance tailored to the type of waste detected.</p></div></div><div class="about-row"><i class="fa-solid fa-clock-rotate-left" style="color:#f59e0b;"></i><div><strong>Scan History</strong><p>All your scans are saved so you can track your environmental impact and review past classifications anytime.</p></div></div><div class="about-row"><i class="fa-solid fa-map-location-dot" style="color:#e879f9;"></i><div><strong>Local Junk Shop Locator</strong><p>Find nearby junk shops and recycling drop-off points in Olongapo City so you can properly dispose of recyclable waste.</p></div></div></div><div style="text-align:center; margin-top:20px; padding-top:16px; border-top:1px solid rgba(255,255,255,0.1);"><p style="color:rgba(255,255,255,0.5); font-size:0.8rem;">Made with 💚 for a cleaner environment</p><p style="color:rgba(255,255,255,0.35); font-size:0.75rem; margin-top:4px;">Version 1.0 · EcoSort Team</p></div></div></div><!-- ===== MAP MODAL ===== --><div id="mapModal" class="modal"><div class="modal-content" style="max-width:600px;"><div class="modal-header"><h3><i class="fa-solid fa-map-location-dot"></i> Junk Shops — Olongapo City</h3><button class="close-btn" onclick="closeMapModal()"><i class="fa-solid fa-xmark"></i></button></div><p style="color:rgba(255,255,255,0.6); font-size:0.85rem; margin-bottom:14px; text-align:center;"><i class="fa-solid fa-circle-info" style="color:#22c55e;"></i>Tap a pin to see details. Bring your recyclables here!</p><div id="ecosortMap" style="width:100%; height:320px; border-radius:16px; overflow:hidden; border:1px solid rgba(255,255,255,0.12);"></div><div id="shopList" style="margin-top:16px; display:flex; flex-direction:column; gap:10px;"></div></div></div><script>// ===== ABOUT MODAL =====function openAboutModal() {document.getElementById('aboutModal').style.display = 'block';document.body.style.overflow = 'hidden';}function closeAboutModal() {document.getElementById('aboutModal').style.display = 'none';document.body.style.overflow = 'auto';}// ===== MAP MODAL =====const JUNK_SHOPS = [{ name: "Atew Junkshop", address: "25 Brill St, Olongapo City", lat: 14.8402091, lng: 120.2838133, phone: "+63 930 222 4791" },{ name: "GLO'S Junkshop", address: "25 Brill St, Olongapo City", lat: 14.8401493, lng: 120.2838005, phone: "+63 999 496 3632", rating: "⭐ 5.0" },{ name: "Thriftway Junkshop", address: "68 Fendler St, East Tapinac, Olongapo City", lat: 14.8325019, lng: 120.2843624, phone: "+63 949 371 0855" },{ name: "Pacleb Junk Shop", address: "191 New Cabalan, Olongapo City", lat: 14.8386389, lng: 120.2838176 },{ name: "Nickson Junkshop", address: "Block 14 Lot 1 Mayumi St, Olongapo City", lat: 14.8541131, lng: 120.2916457, phone: "+63 920 286 0483" },{ name: "Angeles Junkshop / Kleng Hauling", address: "2071 Purok 10, Old Cabalan, Olongapo City", lat: 14.849471, lng: 120.314867, phone: "+63 919 342 0326", rating: "⭐ 5.0", hours: "Mon–Sun 6AM–6PM" },];let mapInitialized = false;function openMapModal() {document.getElementById('mapModal').style.display = 'block';document.body.style.overflow = 'hidden';if (!mapInitialized) {loadLeafletMap();buildShopList();mapInitialized = true;}}function closeMapModal() {document.getElementById('mapModal').style.display = 'none';document.body.style.overflow = 'auto';}function loadLeafletMap() {const link = document.createElement('link');link.rel = 'stylesheet';link.href = 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.css';document.head.appendChild(link);const script = document.createElement('script');script.src = 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js';script.onload = initMap;document.head.appendChild(script);}function initMap() {const map = L.map('ecosortMap').setView([14.843, 120.291], 13);L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '© OpenStreetMap contributors'}).addTo(map);const greenIcon = L.divIcon({className: '',html: `<div style="background:linear-gradient(135deg,#22c55e,#15803d);border:2px solid white;border-radius:50% 50% 50% 0;width:32px;height:32px;display:flex;align-items:center;justify-content:center;transform:rotate(-45deg);box-shadow:0 3px 10px rgba(0,0,0,0.4);"><span style="transform:rotate(45deg);font-size:14px;">♻️</span></div>`,iconSize: [32, 32],iconAnchor: [16, 32],popupAnchor: [0, -36]});JUNK_SHOPS.forEach(shop => {const popup = `<div style="font-family:Arial,sans-serif;min-width:170px;"><strong style="font-size:0.9rem;">${shop.name}</strong><br><span style="color:#555;font-size:0.8rem;">${shop.address}</span><br>${shop.phone ? `<span style="color:#16a34a;font-size:0.8rem;">📞 ${shop.phone}</span><br>` : ''}${shop.hours ? `<span style="color:#666;font-size:0.78rem;">🕐 ${shop.hours}</span><br>` : ''}${shop.rating ? `<span style="font-size:0.8rem;">${shop.rating}</span>` : ''}</div>`;L.marker([shop.lat, shop.lng], { icon: greenIcon }).addTo(map).bindPopup(popup);});}function buildShopList() {const container = document.getElementById('shopList');JUNK_SHOPS.forEach(shop => {const div = document.createElement('div');div.innerHTML = `<div style="display:flex;align-items:flex-start;gap:12px;background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.1);border-radius:12px;padding:12px;"><div style="background:linear-gradient(135deg,#22c55e,#15803d);border-radius:10px;width:38px;height:38px;display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:1rem;">♻️</div><div style="flex:1;"><strong style="font-size:0.88rem;color:white;">${shop.name}</strong>${shop.rating ? `<span style="font-size:0.76rem;color:#86efac;margin-left:6px;">${shop.rating}</span>` : ''}<p style="color:rgba(255,255,255,0.55);font-size:0.78rem;margin-top:2px;">${shop.address}</p>${shop.phone ? `<p style="color:#86efac;font-size:0.78rem;margin-top:2px;">📞 ${shop.phone}</p>` : ''}${shop.hours ? `<p style="color:rgba(255,255,255,0.4);font-size:0.74rem;">${shop.hours}</p>` : ''}</div></div>`;container.appendChild(div);});}window.addEventListener('click', function(e) {if (e.target === document.getElementById('aboutModal')) closeAboutModal();if (e.target === document.getElementById('mapModal')) closeMapModal();});document.addEventListener('keydown', function(e) {if (e.key === 'Escape') { closeAboutModal(); closeMapModal(); }});</script></body></html>
app.py+66-178
render.yaml+2-2
static/css/style.css+322-586
static/js/app.js+59-104
templates/index.html+180