diff --git a/coursedata/texts/de.yaml b/coursedata/texts/de.yaml
index ba13022bda5..e306b878c47 100644
--- a/coursedata/texts/de.yaml
+++ b/coursedata/texts/de.yaml
@@ -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"
@@ -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!"
diff --git a/coursedata/texts/el.yaml b/coursedata/texts/el.yaml
index 1a0a4e2b406..ead017fb1cf 100644
--- a/coursedata/texts/el.yaml
+++ b/coursedata/texts/el.yaml
@@ -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:
@@ -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: 'Γράψε το πρώτο σου πρόγραμμα!'
diff --git a/coursedata/texts/en.yaml b/coursedata/texts/en.yaml
index 2bb4b7b5e74..b5299cb0a41 100644
--- a/coursedata/texts/en.yaml
+++ b/coursedata/texts/en.yaml
@@ -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"
@@ -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!"
diff --git a/coursedata/texts/es.yaml b/coursedata/texts/es.yaml
index 6d32e53b3e4..ffd671613f8 100644
--- a/coursedata/texts/es.yaml
+++ b/coursedata/texts/es.yaml
@@ -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"
@@ -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!"
diff --git a/coursedata/texts/fr.yaml b/coursedata/texts/fr.yaml
index 12aa95ea185..331d1dbf362 100644
--- a/coursedata/texts/fr.yaml
+++ b/coursedata/texts/fr.yaml
@@ -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"
@@ -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 !"
diff --git a/coursedata/texts/hu.yaml b/coursedata/texts/hu.yaml
index b27772251cc..c57c918d2b3 100644
--- a/coursedata/texts/hu.yaml
+++ b/coursedata/texts/hu.yaml
@@ -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 "
@@ -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!"
diff --git a/coursedata/texts/it.yaml b/coursedata/texts/it.yaml
index 172bf3ef314..02d846146c4 100644
--- a/coursedata/texts/it.yaml
+++ b/coursedata/texts/it.yaml
@@ -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"
@@ -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!"
diff --git a/coursedata/texts/nl.yaml b/coursedata/texts/nl.yaml
index 7d585412939..a1102672d30 100644
--- a/coursedata/texts/nl.yaml
+++ b/coursedata/texts/nl.yaml
@@ -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.
@@ -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"
@@ -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!"
diff --git a/coursedata/texts/pt_br.yaml b/coursedata/texts/pt_br.yaml
index c0afc733c96..e89c0dd8f75 100644
--- a/coursedata/texts/pt_br.yaml
+++ b/coursedata/texts/pt_br.yaml
@@ -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"
@@ -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!"
diff --git a/coursedata/texts/sw.yaml b/coursedata/texts/sw.yaml
index 007682c953d..2c92ee68867 100644
--- a/coursedata/texts/sw.yaml
+++ b/coursedata/texts/sw.yaml
@@ -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"
@@ -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."
\ No newline at end of file
+ write_first: "Andika programu yako ya kwanza."
diff --git a/coursedata/texts/zh.yaml b/coursedata/texts/zh.yaml
index 25d6efa096f..88adf2ef3a2 100644
--- a/coursedata/texts/zh.yaml
+++ b/coursedata/texts/zh.yaml
@@ -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: "我最近的程序"
@@ -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: "编写你的第一个程序!"
diff --git a/static/js/app.js b/static/js/app.js
index 5e5e7f1a7e8..a6aced7473b 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -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
*/
diff --git a/templates/programs.html b/templates/programs.html
index bfe0593a946..b59fcb6100e 100644
--- a/templates/programs.html
+++ b/templates/programs.html
@@ -20,6 +20,7 @@
{{ texts.delete }}
{% if program.public %}
{{ texts.unshare}}
+ {{ texts.copy_link_to_share }}
{% else %}
{{ texts.share}}
{% endif %}