Raspberry Pi - MCP Daily Briefing Browser

instructions to build rpi image for TV in MCP workroom

new version - Raspberry Pi 3

install raspbian using stretch netinst
ssh in using root/raspbian
passwd (set root password)
> /etc/motd
echo rpi-briefing > /etc/hostname
sed -i s/pi/rpi-briefing/g /etc/hosts
apt-get --no-install-recommends install aptitude

systemctl disable ssh.service && systemctl enable ssh.socket

echo "America/Chicago" > /etc/timezone
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
sed -i -e 's/^# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
dpkg-reconfigure -f noninteractive locales

aptitude update
aptitude full-upgrade

sed -i 's/#hdmi_group=1/hdmi_group=2/g' /boot/config.txt
sed -i 's/#hdmi_mode=1/hdmi_mode=82/g' /boot/config.txt
sed -i 's/#hdmi_drive=2/hdmi_drive=2/g' /boot/config.txt
sed -i 's/#hdmi_force_hotplug=1/hdmi_force_hotplug=1/g' /boot/config.txt
sed -i 's/hdmi_mode=16/hdmi_mode=16\n\nhdmi_force_mode=1/g' /boot/config.txt

aptitude install netcat-traditional screen rsync psmisc file patch ethtool strace tcpdump vim bzip2 xz-utils
aptitude --without-recommends install dnsutils

aptitude install watchdog
sed -i -e 's/^#watchdog-device/watchdog-device/g' /etc/watchdog.conf
sed -i -e 's/^#max-load-1\t/max-load-1\t/g' /etc/watchdog.conf
echo "# Raspberry Pi doesn't work with the default timeout of 60; set it to 10 instead" >> /etc/watchdog.conf
echo $'watchdog-timeout\t= 10' >> /etc/watchdog.conf

adduser tdobes
adduser tdobes adm
adduser tdobes systemd-journal

# Browser
aptitude install xserver-xorg-video-fbturbo xserver-xorg-input-evdev
aptitude install xinit evilwm xdotool x11vnc unclutter x11-xserver-utils
sed -i -e 's/^allowed_users=console/allowed_users=anybody/g' /etc/X11/Xwrapper.config
aptitude install python-pyside.qtwebkit
aptitude install fonts-symbola # takes care of emoji

sed -i 's/START_UNCLUTTER="true"/START_UNCLUTTER="false"/g' /etc/default/unclutter
sed -i -e 's/^use-ssh-agent$/#use-ssh-agent/g' /etc/X11/Xsession.options

echo '#!/usr/bin/env python' > /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'import sys' >> /usr/local/bin/simplebrowser.py
echo 'from PySide.QtCore import *' >> /usr/local/bin/simplebrowser.py
echo 'from PySide.QtGui import *' >> /usr/local/bin/simplebrowser.py
echo 'from PySide.QtWebKit import *' >> /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'app = QApplication(sys.argv)' >> /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'if len(sys.argv) == 2:' >> /usr/local/bin/simplebrowser.py
echo '  url = QUrl(sys.argv[1])' >> /usr/local/bin/simplebrowser.py
echo 'else:' >> /usr/local/bin/simplebrowser.py
echo "  url = QUrl('http://www.google.com/')" >> /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'web = QWebView()' >> /usr/local/bin/simplebrowser.py
echo 'web.load(url)' >> /usr/local/bin/simplebrowser.py
echo 'web.show()' >> /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'sys.exit(app.exec_())' >> /usr/local/bin/simplebrowser.py
chmod +x /usr/local/bin/simplebrowser.py

adduser --shell /bin/false --gecos "Browser" --disabled-password browser

echo '#!/bin/sh' > /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo 'pkill -9 evilwm' >> /usr/local/bin/browser-xsession.sh
echo 'pkill -9 x11vnc' >> /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo 'x11vnc -q -usepw -N -ncache 0 -shared -forever &' >> /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo 'xset s off #disable screensaver' >> /usr/local/bin/browser-xsession.sh
echo 'xset dpms 0 0 0 #disable automatic power saving' >> /usr/local/bin/browser-xsession.sh
echo 'unclutter -grab -idle 2 & #daemon to auto-hide mouse' >> /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo '#SHELL=/bin/bash xterm &' >> /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo "exec evilwm -fn '*-clean-*'" >> /usr/local/bin/browser-xsession.sh
chmod +x /usr/local/bin/browser-xsession.sh
ln -s /usr/local/bin/browser-xsession.sh /home/browser/.xsession

mkdir ~browser/.vnc
x11vnc -storepasswd **PASSWORD** ~browser/.vnc/passwd
chown -R browser:browser ~browser/.vnc
chmod 0600 ~browser/.vnc/passwd

echo '#!/bin/sh' > /usr/local/bin/browser.sh
echo >> /usr/local/bin/browser.sh
echo 'NETWORK_CHECK=router' >> /usr/local/bin/browser.sh
echo 'URL=/opt/student_assistant_thing.html' >> /usr/local/bin/browser.sh
echo >> /usr/local/bin/browser.sh
echo 'echo -n waiting for network' >> /usr/local/bin/browser.sh
echo 'while ! ping -c 1 $NETWORK_CHECK > /dev/null 2> /dev/null ; do' >> /usr/local/bin/browser.sh
echo '  echo -n .' >> /usr/local/bin/browser.sh
echo '  sleep 1' >> /usr/local/bin/browser.sh
echo 'done' >> /usr/local/bin/browser.sh
echo 'echo done!' >> /usr/local/bin/browser.sh
echo >> /usr/local/bin/browser.sh
echo '# move the window to appropriate location' >> /usr/local/bin/browser.sh
echo 'sh -c '"'"'sleep 1 ; echo -n attempting to move simplebrowser ; while ! xdotool search --onlyvisible --name simplebrowser.py windowmove 0 0 windowsize 1918 1078; do echo -n . ; sleep 1 ; done ; echo done!'"'"' &' >> /usr/local/bin/browser.sh
echo >> /usr/local/bin/browser.sh
echo '# start simplebrowser' >> /usr/local/bin/browser.sh
echo 'exec nice -n 1 simplebrowser.py $URL' >> /usr/local/bin/browser.sh
chmod +x /usr/local/bin/browser.sh

echo '[Unit]' > /etc/systemd/system/startx.service
echo 'Description=Start Xorg for HDMI' >> /etc/systemd/system/startx.service
echo >> /etc/systemd/system/startx.service
echo '[Service]' >> /etc/systemd/system/startx.service
echo 'ExecStart=-/usr/bin/startx -- :0 -nolisten tcp vt2' >> /etc/systemd/system/startx.service
echo 'ExecStopPost=-/usr/bin/pkill -9 -U browser evilwm' >> /etc/systemd/system/startx.service
echo 'User=browser' >> /etc/systemd/system/startx.service
echo 'Restart=always' >> /etc/systemd/system/startx.service
echo 'RestartSec=1' >> /etc/systemd/system/startx.service
echo 'StartLimitInterval=10s' >> /etc/systemd/system/startx.service
echo 'StartLimitBurst=10' >> /etc/systemd/system/startx.service
echo >> /etc/systemd/system/startx.service
echo '[Install]' >> /etc/systemd/system/startx.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/startx.service

systemctl enable startx.service

echo '[Unit]' > /etc/systemd/system/browser.service
echo 'Description=Browser' >> /etc/systemd/system/browser.service
echo 'After=startx.service' >> /etc/systemd/system/browser.service
echo 'Requires=startx.service' >> /etc/systemd/system/browser.service
echo >> /etc/systemd/system/browser.service
echo '[Service]' >> /etc/systemd/system/browser.service
echo 'ExecStart=-/usr/local/bin/browser.sh' >> /etc/systemd/system/browser.service
echo 'User=browser' >> /etc/systemd/system/browser.service
echo 'Environment=DISPLAY=:0' >> /etc/systemd/system/browser.service
echo 'Restart=always' >> /etc/systemd/system/browser.service
echo 'RestartSec=1' >> /etc/systemd/system/browser.service
echo 'StartLimitInterval=10s' >> /etc/systemd/system/browser.service
echo 'StartLimitBurst=10' >> /etc/systemd/system/browser.service
echo >> /etc/systemd/system/browser.service
echo '[Install]' >> /etc/systemd/system/browser.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/browser.service

systemctl enable browser.service

# Clean-up and optimization

systemctl disable rsyslog.service
systemctl disable rsync.service
systemctl disable sshswitch.service
systemctl stop rsyslog.service
rm /var/log/auth.log* /var/log/daemon.log* /var/log/debug /var/log/kern.log* /var/log/messages /var/log/user.log* /var/log/syslog

cat > /opt/student_assistant_thing.html
<html>
<head>
<title>Student Assistant Thing</title>
<style type="text/css">
body {
  background: #000;
  color: #fff;
  margin: 0;
  overflow: hidden;
}
iframe.leftframe {
  width: 50%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: block;
}
iframe.rightframe {
  width: 50%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
}
iframe#frame1 {
  opacity: 1.0;
  /* height: 50%;
  top: 0; */
}
iframe#frame2 {
  opacity: 0;
  /* height: 50%;
  top: 50%; */
}
</style>
<script type="text/javascript">
var right_pages = [
  "https://docs.google.com/drawings/d/1D8xJUS0c0bk5JLqLP9vxuTpGHVbdC4xflCnX7QfmsCE/edit?rm=minimal", // week ahead (drawing)
  "https://docs.google.com/drawings/d/1xqRrcb_ljyuNhLqWUGjuuaUM2lYVKjAkTuFjkNXBEiE/edit?rm=minimal", // future events (drawing)
  "https://docs.google.com/drawings/d/1QRmBNxwlnKb-10zu74_Mj7CDtIhX-VF6fqDZ4HZPCq0/edit?rm=minimal", // discussion (drawing)
  //"https://docs.google.com/document/d/1O8W_j-Qrsrce21iiNhfqojPBoJODP_UsEjjlPNJ6A_I/edit?rm=minimal", // week ahead (doc)
  //"https://docs.google.com/document/d/1pyIYMMrua4vpiBoH1ZZ8mGuuZu3-riL236YfTXFE82A/edit?rm=minimal", // future events (doc)
  //"https://docs.google.com/document/d/11dnYM5KuHGc6rznF9uxd9yv0nAgIvtuxQl06cZcbb_g/edit?rm=minimal", // discussion (doc)
]
var page_delay = 10000;

var current_page = null;

function _get_frames() {
  var one = document.getElementById("frame1");
  var two = document.getElementById("frame2");
  if (parseInt(two.style.opacity) == 1) {
    return [two, one];
  } else {
    return [one, two];
  }
}

function _get_next_page() {
  var next_page = current_page + 1;
  if (next_page >= right_pages.length) {
    next_page = 0;
  }
  return next_page;
}

function cycle_pages() {
  console.log("running cycle_pages");
  if (current_page == null) {
    init_pages();
    return;
  }
  var next_page = _get_next_page();
  var pages = _get_frames();
  pages[1].style.opacity = "1.0";
  pages[0].style.opacity = "0";
  current_page = next_page;
  /* pages[0].src = right_pages[_get_next_page()]; */
  load_next_page(); /* put this in after a delay once we add a crossfade */
  setTimeout(cycle_pages, page_delay);
}

function load_next_page() {
  var pages = _get_frames();
  pages[1].src = right_pages[_get_next_page()];
}

function init_pages() {
  var pages = _get_frames();
  pages[0].src = right_pages[0];
  pages[1].src = right_pages[1];
  current_page = 0;
  setTimeout(cycle_pages, page_delay);
}
</script>
</head>
<body>
<!-- <iframe src="https://docs.google.com/document/d/1EUKfdu3HgBirUMrVqkz7YMyWtPfNOexaaHgA186wcqc/edit?rm=minimal" class="leftframe" id="left"></iframe> -->
<iframe src="https://docs.google.com/drawings/d/1e1c7XKsp64_ygcC2k7vw0Tx3geUqBk9DsAVEj4fPzsQ/edit?rm=minimal" class="leftframe" id="left"></iframe>
<iframe class="rightframe" id="frame1"></iframe>
<iframe class="rightframe" id="frame2"></iframe>
<script type="text/javascript">
init_pages();
</script>
</body>
</html>
^D

reboot

old version - Raspberry Pi 1

install raspbian lite image (sadly, netinst for stretch doesn't work on 256 MB RAM RPi's yet)
login: pi - raspberry
sudo su -
passwd (set root password)
edit /etc/hostname and /etc/hosts to change hostname (rpi-briefing)
edit /etc/ssh/sshd_config - uncomment PermitRootLogin line and set to "yes"
systemctl enable ssh.socket
raspi-config
6 - overclock, High (1 GHz)
4 - locale, change locale, enable (only) en_US.UTF-8, set as default
4 - locale, change timezone, America, Chicago
4 - locale, change keyboard layout, generic 101-key, english (US), default, no compose
reboot

connect with ssh, login as root
aptitude update
aptitude purge apt-listchanges avahi-daemon libnss-mdns blends-tasks pi-bluetooth bluez bluez-firmware debconf-i18n debconf-utils distro-info-data dmidecode dphys-swapfile ed gdb geoip-database libpam-chksshpwd gettext-base htop mountall plymouth initramfs-tools initramfs-tools-core info install-info iptables iso-codes nfs-common keyutils raspberrypi-net-mods klibc-utils linux-base lsb-release raspi-config lua5.1 luajit makedev nano ncdu ncurses-term netcat-openbsd openresolv parted paxctld python3 cifs-utils samba-common xml-core sgml-base shared-mime-info tasksel tasksel-data tcpd traceroute triggerhappy unzip usb-modeswitch usb-modeswitch-data v4l-utils xauth xdg-user-dirs isc-dhcp-client isc-dhcp-common
# note: whiptail used instead of dialog
aptitude -o Aptitude::Delete-Unused=1 install 
aptitude purge '~c'
rm -r /var/run/avahi-daemon

swapoff -a
rm /var/swap

echo >> /boot/config.txt
echo 'gpu_mem_256=16' >> /boot/config.txt

aptitude forget-new
aptitude full-upgrade

> /etc/motd
sed -i 's/#hdmi_group=1/hdmi_group=2/g' /boot/config.txt
sed -i 's/#hdmi_mode=1/hdmi_mode=82/g' /boot/config.txt
sed -i 's/#hdmi_drive=2/hdmi_drive=2/g' /boot/config.txt
sed -i 's/#hdmi_force_hotplug=1/hdmi_force_hotplug=1/g' /boot/config.txt
sed -i 's/hdmi_mode=16/hdmi_mode=16\n\nhdmi_force_mode=1/g' /boot/config.txt

aptitude install screen ethtool tcpdump vim
aptitude install rng-tools
aptitude --without-recommends install dnsutils

aptitude install watchdog
sed -i -e 's/^#watchdog-device/watchdog-device/g' /etc/watchdog.conf
sed -i -e 's/^#max-load-1\t/max-load-1\t/g' /etc/watchdog.conf
echo "# Raspberry Pi doesn't work with the default timeout of 60; set it to 10 instead" >> /etc/watchdog.conf
echo $'watchdog-timeout\t= 10' >> /etc/watchdog.conf

usermod -l tdobes -d /home/tdobes -m pi
groupmod -n tdobes pi
passwd tdobes
chfn -f "Tom Dobes" tdobes
adduser tdobes systemd-journal

# Browser
aptitude install xserver-xorg-video-fbturbo xserver-xorg-input-evdev
aptitude install xinit evilwm xdotool x11vnc unclutter x11-xserver-utils
sed -i -e 's/^allowed_users=console/allowed_users=anybody/g' /etc/X11/Xwrapper.config
aptitude install python-pyside.qtwebkit

sed -i 's/START_UNCLUTTER="true"/START_UNCLUTTER="false"/g' /etc/default/unclutter
sed -i -e 's/^use-ssh-agent$/#use-ssh-agent/g' /etc/X11/Xsession.options

echo '#!/usr/bin/env python' > /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'import sys' >> /usr/local/bin/simplebrowser.py
echo 'from PySide.QtCore import *' >> /usr/local/bin/simplebrowser.py
echo 'from PySide.QtGui import *' >> /usr/local/bin/simplebrowser.py
echo 'from PySide.QtWebKit import *' >> /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'app = QApplication(sys.argv)' >> /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'if len(sys.argv) == 2:' >> /usr/local/bin/simplebrowser.py
echo '  url = QUrl(sys.argv[1])' >> /usr/local/bin/simplebrowser.py
echo 'else:' >> /usr/local/bin/simplebrowser.py
echo "  url = QUrl('http://www.google.com/')" >> /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'web = QWebView()' >> /usr/local/bin/simplebrowser.py
echo 'web.load(url)' >> /usr/local/bin/simplebrowser.py
echo 'web.show()' >> /usr/local/bin/simplebrowser.py
echo >> /usr/local/bin/simplebrowser.py
echo 'sys.exit(app.exec_())' >> /usr/local/bin/simplebrowser.py
chmod +x /usr/local/bin/simplebrowser.py

adduser --shell /bin/false --gecos "Browser" --disabled-password browser

echo '#!/bin/sh' > /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo 'pkill -9 evilwm' >> /usr/local/bin/browser-xsession.sh
echo 'pkill -9 x11vnc' >> /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo 'x11vnc -q -usepw -N -ncache 0 -shared -forever &' >> /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo 'xset s off #disable screensaver' >> /usr/local/bin/browser-xsession.sh
echo 'xset dpms 0 0 0 #disable automatic power saving' >> /usr/local/bin/browser-xsession.sh
echo 'unclutter -grab -idle 2 & #daemon to auto-hide mouse' >> /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo '#SHELL=/bin/bash xterm &' >> /usr/local/bin/browser-xsession.sh
echo >> /usr/local/bin/browser-xsession.sh
echo "exec evilwm -fn '*-clean-*'" >> /usr/local/bin/browser-xsession.sh
chmod +x /usr/local/bin/browser-xsession.sh
ln -s /usr/local/bin/browser-xsession.sh /home/browser/.xsession

mkdir ~browser/.vnc
x11vnc -storepasswd **PASSWORD** ~browser/.vnc/passwd
chown -R browser:browser ~browser/.vnc
chmod 0600 ~browser/.vnc/passwd

echo '#!/bin/sh' > /usr/local/bin/browser.sh
echo >> /usr/local/bin/browser.sh
echo 'NETWORK_CHECK=router' >> /usr/local/bin/browser.sh
echo 'URL=/opt/student_assistant_thing.html' >> /usr/local/bin/browser.sh
echo >> /usr/local/bin/browser.sh
echo 'echo -n waiting for network' >> /usr/local/bin/browser.sh
echo 'while ! ping -c 1 $NETWORK_CHECK > /dev/null 2> /dev/null ; do' >> /usr/local/bin/browser.sh
echo '  echo -n .' >> /usr/local/bin/browser.sh
echo '  sleep 1' >> /usr/local/bin/browser.sh
echo 'done' >> /usr/local/bin/browser.sh
echo 'echo done!' >> /usr/local/bin/browser.sh
echo >> /usr/local/bin/browser.sh
echo '# move the window to appropriate location' >> /usr/local/bin/browser.sh
echo 'sh -c '"'"'sleep 1 ; echo -n attempting to move simplebrowser ; while ! xdotool search --onlyvisible --name simplebrowser.py windowmove 0 0 windowsize 1920 1080; do echo -n . ; sleep 1 ; done ; echo done!'"'"' &' >> /usr/local/bin/browser.sh
echo >> /usr/local/bin/browser.sh
echo '# start simplebrowser' >> /usr/local/bin/browser.sh
echo 'exec nice -n 1 simplebrowser.py $URL' >> /usr/local/bin/browser.sh
chmod +x /usr/local/bin/browser.sh

echo '[Unit]' > /etc/systemd/system/startx.service
echo 'Description=Start Xorg for HDMI' >> /etc/systemd/system/startx.service
echo >> /etc/systemd/system/startx.service
echo '[Service]' >> /etc/systemd/system/startx.service
echo 'ExecStart=-/usr/bin/startx -- :0 -nolisten tcp vt2' >> /etc/systemd/system/startx.service
echo 'ExecStopPost=-/usr/bin/pkill -9 -U browser evilwm' >> /etc/systemd/system/startx.service
echo 'User=browser' >> /etc/systemd/system/startx.service
echo 'Restart=always' >> /etc/systemd/system/startx.service
echo 'RestartSec=1' >> /etc/systemd/system/startx.service
echo 'StartLimitInterval=10s' >> /etc/systemd/system/startx.service
echo 'StartLimitBurst=10' >> /etc/systemd/system/startx.service
echo >> /etc/systemd/system/startx.service
echo '[Install]' >> /etc/systemd/system/startx.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/startx.service

systemctl enable startx.service

echo '[Unit]' > /etc/systemd/system/browser.service
echo 'Description=Browser' >> /etc/systemd/system/browser.service
echo 'After=startx.service' >> /etc/systemd/system/browser.service
echo 'Requires=startx.service' >> /etc/systemd/system/browser.service
echo >> /etc/systemd/system/browser.service
echo '[Service]' >> /etc/systemd/system/browser.service
echo 'ExecStart=-/usr/local/bin/browser.sh' >> /etc/systemd/system/browser.service
echo 'User=browser' >> /etc/systemd/system/browser.service
echo 'Environment=DISPLAY=:0' >> /etc/systemd/system/browser.service
echo 'Restart=always' >> /etc/systemd/system/browser.service
echo 'RestartSec=1' >> /etc/systemd/system/browser.service
echo 'StartLimitInterval=10s' >> /etc/systemd/system/browser.service
echo 'StartLimitBurst=10' >> /etc/systemd/system/browser.service
echo >> /etc/systemd/system/browser.service
echo '[Install]' >> /etc/systemd/system/browser.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/browser.service

systemctl enable browser.service

# Clean-up and optimization

systemctl disable rsyslog.service
systemctl disable rsync.service
systemctl disable sshswitch.service
systemctl stop rsyslog.service
rm /var/log/auth.log* /var/log/daemon.log* /var/log/debug /var/log/kern.log* /var/log/messages /var/log/user.log* /var/log/syslog

cat > /opt/student_assistant_thing.html
<html>
<head>
<title>Student Assistant Thing</title>
<style type="text/css">
body {
  background: #000;
  color: #fff;
  margin: 0;
  overflow: hidden;
}
iframe.leftframe {
  width: 50%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: block;
}
iframe.rightframe {
  width: 50%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
}
iframe#frame1 {
  opacity: 1.0;
  /* height: 50%;
  top: 0; */
}
iframe#frame2 {
  opacity: 0;
  /* height: 50%;
  top: 50%; */
}
</style>
<script type="text/javascript">
var right_pages = [
  "https://docs.google.com/document/d/1O8W_j-Qrsrce21iiNhfqojPBoJODP_UsEjjlPNJ6A_I/edit?rm=minimal", // week ahead
  "https://docs.google.com/document/d/1pyIYMMrua4vpiBoH1ZZ8mGuuZu3-riL236YfTXFE82A/edit?rm=minimal", // future events
  "https://docs.google.com/document/d/11dnYM5KuHGc6rznF9uxd9yv0nAgIvtuxQl06cZcbb_g/edit?rm=minimal", // discussion
]
var page_delay = 10000;

var current_page = null;

function _get_frames() {
  var one = document.getElementById("frame1");
  var two = document.getElementById("frame2");
  if (parseInt(two.style.opacity) == 1) {
    return [two, one];
  } else {
    return [one, two];
  }
}

function _get_next_page() {
  var next_page = current_page + 1;
  if (next_page >= right_pages.length) {
    next_page = 0;
  }
  return next_page;
}

function cycle_pages() {
  console.log("running cycle_pages");
  if (current_page == null) {
    init_pages();
    return;
  }
  var next_page = _get_next_page();
  var pages = _get_frames();
  pages[1].style.opacity = "1.0";
  pages[0].style.opacity = "0";
  current_page = next_page;
  /* pages[0].src = right_pages[_get_next_page()]; */
  load_next_page(); /* put this in after a delay once we add a crossfade */
  setTimeout(cycle_pages, page_delay);
}

function load_next_page() {
  var pages = _get_frames();
  pages[1].src = right_pages[_get_next_page()];
}

function init_pages() {
  var pages = _get_frames();
  pages[0].src = right_pages[0];
  pages[1].src = right_pages[1];
  current_page = 0;
  setTimeout(cycle_pages, page_delay);
}
</script>
</head>
<body>
<iframe src="https://docs.google.com/document/d/1EUKfdu3HgBirUMrVqkz7YMyWtPfNOexaaHgA186wcqc/edit?rm=minimal" class="leftframe" id="left"></iframe>
<iframe class="rightframe" id="frame1"></iframe>
<iframe class="rightframe" id="frame2"></iframe>
<script type="text/javascript">
init_pages();
</script>
</body>
</html>
^D

reboot
computer/raspberry_pi_daily_briefing.txt · Last modified: 2017/11/11 22:15 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS