campaign: Change video of the day to Jason Reich.
[gnupg-doc.git] / web / share / campaign / campaign.js
index 4936204..2c05d66 100644 (file)
@@ -58,12 +58,13 @@ $(document).ready(function() {
   for (let idx = 0; idx < vals.length; ++idx) {
     let value = vals[idx];
     $(".amount-btn-" + value.toString()).attr("href", "#");
   for (let idx = 0; idx < vals.length; ++idx) {
     let value = vals[idx];
     $(".amount-btn-" + value.toString()).attr("href", "#");
-    $(".amount-btn-" + value.toString()).on("click", function() {
-      $("#amountother").attr("value", value.toString());
-      $("#currency option").attr("selected", false);
-      $("#currency option[value='EUR']").attr("selected", true);
-      $("#recur option").attr("selected", false);
-      $("#recur option[value='12']").attr("selected", true);
+    $(".amount-btn-" + value.toString()).on("click", function(event) {
+      $("#amountother").prop("value", value.toString());
+      $("#currency option").prop("selected", false);
+      $("#currency option[value='EUR']").prop("selected", true);
+      //$("#recur option").prop("selected", false);
+      //$("#recur option[value='12']").prop("selected", true);
+      event.preventDefault();
     });
   }
 });
     });
   }
 });
@@ -86,6 +87,33 @@ function get_param_from_url(name) {
 
 /* Defer loading Youtube iframe until the user clicks on the video.  */
 $(document).ready(function() {
 
 /* Defer loading Youtube iframe until the user clicks on the video.  */
 $(document).ready(function() {
+
+    // VOTD: Update VOTD here.
+    let VIDLIST = "jason,sze,rysiek,ksenia,cindy,matt,thenmozhi,alex,andre,benjamin";
+
+    let YTID = { "main": "wNHhkntqklg",
+                "thenmozhi": "sQMj332dgIE",
+                "sze": "OpeFuKRYGVA",
+                "sheera": "zwPaVA4vhDM",
+                "seanus": "H6iO_MkOICM",
+                "noah": "neibFsqgxgw",
+                "michael": "w4PY1ihLm0w",
+                "matt": "5MCGTd8pOG4",
+                "lisa": "Vd8sz5X-1og",
+                "john": "xdVHQhWrIro",
+                "jason": "oQvP9SXm-ek",
+                "geoffrey": "Y4yat43CvEc",
+                "daniel": "coFFCJlMRjk",
+                "cindy": "IdCiJMc3q80",
+                "benjamin": "atFz16nInIs",
+                "arthur": "Js_OqRLm9F4",
+                "andrew": "DXiU9wewjn4",
+                "andre": "bcNLlWqZ9d0",
+                "alex": "1OMJWpdl0DA",
+                 "ksenia": "Qqg3_a72aEw",
+                 "rysiek": "6DqfWz-KHSI"
+              };
+
     /* For the video preview, we use this for devices without hover events.  */
     if ("ontouchstart" in document.documentElement) {
        $("body").addClass("touch");
     /* For the video preview, we use this for devices without hover events.  */
     if ("ontouchstart" in document.documentElement) {
        $("body").addClass("touch");
@@ -93,13 +121,17 @@ $(document).ready(function() {
 
     let wanted_yt_id = get_param_from_url('play');
     $(".camp-video").each(function() {
 
     let wanted_yt_id = get_param_from_url('play');
     $(".camp-video").each(function() {
-       let yt_ids = $(this).data("embed").split(",");
+       let embed = $(this).data("embed");
+       if (embed != 'votd') {
+           return;
+       }
+       let yt_ids = VIDLIST.split(",");
        let yt_id_idx = yt_ids.indexOf(wanted_yt_id);
        let yt_id_idx = yt_ids.indexOf(wanted_yt_id);
-       if (yt_id_idx != -1) {
-           $(this).data("embed", wanted_yt_id);
-           $(this).children("img").attr("src", "/share/campaign/img/thumbs/" + wanted_yt_id + ".jpg");
-           break;
+       if (yt_id_idx == -1) {
+           wanted_yt_id = yt_ids[0];
        }
        }
+       $(this).data("embed", wanted_yt_id);
+       $(this).children("img").attr("src", "/share/campaign/img/thumbs/" + wanted_yt_id + ".jpg");
     });
 
     /* To download the thumbs in share/campaign/img/thumbs:
     });
 
     /* To download the thumbs in share/campaign/img/thumbs:
@@ -107,13 +139,34 @@ $(document).ready(function() {
 
     /* Click handler for all videos.  */
     $(".camp-video").one("click", function() {
 
     /* Click handler for all videos.  */
     $(".camp-video").one("click", function() {
-       let yt_id = $(this).data("embed").split(",")[0];
+       let embed = $(this).data("embed");
+       if (embed == 'votd') {
+           embed = VIDLIST;
+       }
+       let yt_id = embed.split(",")[0];
+       yt_id = YTID[yt_id]; // What if key does not exist?
        let yt_list = $(this).data("embed-list");
        let extra_parms = "";
        if (yt_list) {
            extra_parms = "&list=" + yt_list;
        }
        let yt_list = $(this).data("embed-list");
        let extra_parms = "";
        if (yt_list) {
            extra_parms = "&list=" + yt_list;
        }
+       if (screen.width < 768) {
+           extra_parms = extra_parms + "&cc_load_policy=1"
+       }
        $(this).html('<iframe class="embed-responsive-item" allowfullscreen src="https://www.youtube.com/embed/'
                     + yt_id + '?autoplay=1&modestbranding=1&rel=0' + extra_parms + '"></iframe>');
     });
 });
        $(this).html('<iframe class="embed-responsive-item" allowfullscreen src="https://www.youtube.com/embed/'
                     + yt_id + '?autoplay=1&modestbranding=1&rel=0' + extra_parms + '"></iframe>');
     });
 });
+
+/* hide the note about recurring donations under the Paypal option.  */
+$(document).ready(function() {
+  $("#recur").change(function() {
+    console.log
+    if (this.value === "0") {
+      $("#paypal-note").hide();
+    }
+    else {
+      $("#paypal-note").show();
+    }
+  });
+});