Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Alerts to give feedback when sharing/unsharing; add share in other la…
Browse files Browse the repository at this point in the history
…nguages; copy program link to clipboard. (hedyorg#484)
  • Loading branch information
fpereiro authored Jun 10, 2021
1 parent ce70221 commit 52a999c
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 6 deletions.
8 changes: 8 additions & 0 deletions coursedata/texts/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ Auth:
unsaved_changes: "Du hast ein nicht gespeichertes Programm. Möchtest du es verwerfen, ohne zu speichern?"
save_success: "Erfolgreich"
save_success_detail: "Programm erfolgreich gespeichert"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "Du kannst das Programm erst ausführen, nachdem du die Frage beantwortet hast."
Programs:
recent: "Zuletzt verwendete Programme"
Expand All @@ -139,5 +142,10 @@ Programs:
open: "Öffnen"
delete: "Löschen"
delete_confirm: "Bist du sicher, dass du das Programm löschen möchtest?"
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "Du hast noch kein Programm."
write_first: "Schreibe dein erstes Programm!"
8 changes: 8 additions & 0 deletions coursedata/texts/el.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ Auth:
unsaved_changes: 'Έχεις ένα μη αποθηκευμένο πρόγραμμα. Θέλεις να αποχωρήσεις χωρίς να το αποθηκεύσεις;'
save_success: 'Επιτυχία'
save_success_detail: 'Το πρόγραμμα αποθηκεύτηκε επιτυχώς'
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: 'Δεν μπορείς να εκτελέσεις το πρόγραμμα πριν να απαντήσεις την ερώτηση'
login_long: Συνδέσου στο λογαριασμό σου
Programs:
Expand All @@ -138,5 +141,10 @@ Programs:
open: 'Άνοιγμα'
delete: 'Διαγραφή'
delete_confirm: 'Είσαι σίγουρος/η ότι θέλεις να διαγράψεις το πρόγραμμα;'
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: 'Δεν έχεις προγράμματα ακόμα.'
write_first: 'Γράψε το πρώτο σου πρόγραμμα!'
3 changes: 3 additions & 0 deletions coursedata/texts/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ Auth:
save_success: "Success"
save_success_detail: "Program saved successfully"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "You can't run the program until you answer the question first"
Programs:
recent: "My recent programs"
Expand All @@ -144,5 +146,6 @@ Programs:
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "You have no programs yet."
write_first: "Write your first program!"
8 changes: 8 additions & 0 deletions coursedata/texts/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Auth:
unsaved_changes: "Tu programa no se ha salvado. ¿Deseas irte sin salvarlo?"
save_success: "Éxito"
save_success_detail: "Tu programa se ha salvado exitosamente"
share_success_detail: "Tu programa es ahora público"
unshare_success_detail: "Tu programa es ahora privado"
copy_clipboard: "Copiado al portapapeles"
answer_question: "No puedes ejecutar el programa hasta que hayas contestado la pregunta"
Programs:
recent: "Mis programas recientes"
Expand All @@ -138,5 +141,10 @@ Programs:
open: "Abrir"
delete: "Borrar"
delete_confirm: "Estás seguro de querer borrar este programa?"
share: "Compartir públicamente"
share_confirm: "Estás seguro/a de querer volver público tu programa?"
unshare: "Dejar de compartir"
unshare_confirm: "Estás seguro/a de querer volver privado tu programa?"
copy_link_to_share: "Copiar vínculo para compartir"
no_programs: "Todavía no tienes programas guardados."
write_first: "¡Escribe tu primer programa!"
8 changes: 8 additions & 0 deletions coursedata/texts/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Auth:
unsaved_changes: "Le programme en cours n'a pas été sauvegardé. Souhaites-tu vraiment quitter sans le sauvegarder ?"
save_success: "Succès"
save_success_detail: "Le programme a été sauvegardé avec succès"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "Tu ne peux pas exécuter le programme avant d'avoir répondu à la question."
Programs:
recent: "Mes programmes récents"
Expand All @@ -138,5 +141,10 @@ Programs:
open: "Ouvrir"
delete: "Supprimer"
delete_confirm: "Es-tu sûr de vouloir supprimer ce programme ?"
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "Tu n'as pas encore de programme."
write_first: "Écris ton premier programme !"
8 changes: 8 additions & 0 deletions coursedata/texts/hu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ Auth:
unsaved_changes: "Nem mentett programod van. El akarsz menni mentés nélkül?"
save_success: "Siker"
save_success_detail: "A programot sikeresen mentetted"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "Addig nem futtathatod a programot, amíg nem válaszolsz a kérdésre "
Programs:
recent: "Legutóbbi programjaim "
Expand All @@ -134,5 +137,10 @@ Programs:
open: "Nyitva"
delete: "Törlés"
delete_confirm: "Biztosan törlöd a programot?"
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "Még nincs programod."
write_first: "Írd meg az első programot!"
8 changes: 8 additions & 0 deletions coursedata/texts/it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Auth:
unsaved_changes: "Hai un programma non salvato. Vuoi uscire senza salvare?"
save_success: "Successo"
save_success_detail: "Programma salvato con successo"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "Non puoi eseguire il programma prima di rispondere alla domanda"
Programs:
recent: "I miei programmi recenti"
Expand All @@ -138,5 +141,10 @@ Programs:
open: "Apri"
delete: "Elimina"
delete_confirm: "Sei sicura\\o di voler eliminare questo programma?"
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "Non hai ancora nessun programma."
write_first: "Scrivi il tuo primo programma!"
10 changes: 9 additions & 1 deletion coursedata/texts/nl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Auth:
email_welcome_verify_subject: "Welkom bij Hedy"
email_welcome_verify_body: |-
Je Hedy account is aangemaakt. Welkom!
Klik op deze link om je email adres te bevestigen:
Klik op deze link om je email adres te bevestigen:
email_change_password_subject: "Je Hedy wachtwoord is veranderd"
email_change_password_body: |-
Je Hedy wachtwoord is veranderd. Heb jij dat zelf aangevraagd? Dan is alles in orde.
Expand All @@ -127,6 +127,9 @@ Auth:
unsaved_changes: "Jouw programma is niet opgeslagen. Wil je weggaan zonder het op te slaan?"
save_success: "Gelukt!"
save_success_detail: "Je programma is opgeslagen"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "Je kunt het programma pas uitvoeren als je de vraag hebt beantwoord."
Programs:
recent: "Mijn programma's"
Expand All @@ -139,5 +142,10 @@ Programs:
open: "Openen"
delete: "Verwijderen"
delete_confirm: "Weet je zeker dat je het programma wil verwijderen?"
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "Nog geen programma's."
write_first: "Schrijf je eerste programma!"
8 changes: 8 additions & 0 deletions coursedata/texts/pt_br.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Auth:
unsaved_changes: "You have an unsaved program. Do you want to leave without saving it?"
save_success: "Success"
save_success_detail: "Program saved successfully"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "You can't run the program until you answer the question first"
Programs:
recent: "My recent programs"
Expand All @@ -138,5 +141,10 @@ Programs:
open: "Open"
delete: "Delete"
delete_confirm: "Are you sure you want to delete the program?"
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "You have no programs yet."
write_first: "Write your first program!"
10 changes: 9 additions & 1 deletion coursedata/texts/sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ Auth:
unsaved_changes: "Una programu ambao haujahifadhiwa. Je! Unataka kuondoka bila kuiokoa?"
save_success: "Fanikio"
save_success_detail: "Programu imehifadhiwa kwa mafanikio"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "Huwezi kuendesha programu hadi ujibu swali kwanza"
Programs:
recent: "Programu zangu za hivi karibuni"
Expand All @@ -126,5 +129,10 @@ Programs:
open: "Fungua"
delete: "Futa"
delete_confirm: "Je! Una uhakika unataka kufuta programu?"
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "Bado hauna programu"
write_first: "Andika programu yako ya kwanza."
write_first: "Andika programu yako ya kwanza."
8 changes: 8 additions & 0 deletions coursedata/texts/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ Auth:
unsaved_changes: "你有一个未保存的程序. 你想不保存就离开吗?"
save_success: "成功"
save_success_detail: "程序保存成功"
share_success_detail: "Program shared successfully"
unshare_success_detail: "Program unshared successfully"
copy_clipboard: "Successfully copied to clipboard"
answer_question: "你要先回答问题,才能运行程序."
Programs:
recent: "我最近的程序"
Expand All @@ -134,5 +137,10 @@ Programs:
open: "打开"
delete: "删除"
delete_confirm: "你确定要删除这个程序吗?"
share: "Share"
share_confirm: "Are you sure you want to make the program public?"
unshare: "Unshare"
unshare_confirm: "Are you sure you want to make the program private?"
copy_link_to_share: "Copy link to share"
no_programs: "你还没有程序."
write_first: "编写你的第一个程序!"
32 changes: 28 additions & 4 deletions static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,40 @@ window.share_program = function share_program (id, Public, reload) {
contentType: 'application/json',
dataType: 'json'
}).done(function(response) {
$ ('#okbox').show ();
$ ('#okbox .caption').html (window.auth.texts.save_success);
$ ('#okbox .details').html (window.auth.texts.share_success_detail);
if (reload) location.reload ();
if ($ ('#okbox') && $ ('#okbox').length) {
$ ('#okbox').show ();
$ ('#okbox .caption').html (window.auth.texts.save_success);
$ ('#okbox .details').html (Public ? window.auth.texts.share_success_detail : window.auth.texts.unshare_success_detail);
}
else {
alert (Public ? window.auth.texts.share_success_detail : window.auth.texts.unshare_success_detail);
}
if (reload) setTimeout (function () {location.reload ()}, 1000);
}).fail(function(err) {
console.error(err);
error.show(ErrorMessages.Connection_error, JSON.stringify(err));
});
}

window.copy_to_clipboard = function copy_to_clipboard (string) {
// https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
var el = document.createElement ('textarea');
el.value = string;
el.setAttribute ('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild (el);
var selected = document.getSelection ().rangeCount > 0 ? document.getSelection ().getRangeAt (0) : false;
el.select ();
document.execCommand ('copy');
document.body.removeChild (el);
if (selected) {
document.getSelection ().removeAllRanges ();
document.getSelection ().addRange (selected);
}
alert (window.auth.texts.copy_clipboard);
}

/**
* Do a POST with the error to the server so we can log it
*/
Expand Down
1 change: 1 addition & 0 deletions templates/programs.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<a href="#" onclick="if (confirm ('{{ texts.delete_confirm }}')) window.open ('/programs/delete/{{program.id}}', '_self')">{{ texts.delete }}</a>
{% if program.public %}
<a href="#" onclick="if (confirm ('{{ texts.unshare_confirm }}')) window.share_program ('{{program.id}}', false, true)">{{ texts.unshare}}</a>
<a href="#" onclick="window.copy_to_clipboard (window.location.origin + '{{'/hedy/' + program.level|string + '/' + program.id}}')">{{ texts.copy_link_to_share }}</a>
{% else %}
<a href="#" onclick="if (confirm ('{{ texts.share_confirm }}')) window.share_program ('{{program.id}}', true, true)">{{ texts.share}}</a>
{% endif %}
Expand Down

0 comments on commit 52a999c

Please sign in to comment.