#!/bin/bash

#reqd_long="iam-summary sv-platform-profession happy-summary easy-summary prog--multichoice vamp-summary"

reqd_imageonly="response-count-quarterly-nonnorm iam-quarterly location-summary sv-platform-summary sv-platform-quarterly location-platform ua-summary ua-quarterly ua-platform sv-version-summary sv-version-quarterly sv-version-platform feature--multichoice feature-image-layer-respondents sv-plugs--multichoice prog-by-profession otherlang--multichoice"

reqd_imageonly="$reqd_imageonly iam-summary sv-platform-profession happy-summary easy-summary prog--multichoice vamp-summary"

for x in $reqd_long; do
    pic_url="http://code.soundsoftware.ac.uk/projects/sv-survey-output/repository/raw/1/charts/formatted/$x.png"
    short="$x"
    case "$x" in *nonnorm) short=`echo $x|sed 's/-nonnorm//'` ;; esac
    cat textout/"$short".txt | sed -e 's,^,<tr><td>,' -e 's,|,</td><td>,g' -e 's,$,</td></tr>,' -e '1i<table><tr><td><img src="'$pic_url'"></td><td><table>' -e '$a</table></td></tr></table>'> html/"$x".html
done

for x in $reqd_imageonly; do
    pic_url="http://code.soundsoftware.ac.uk/projects/sv-survey-output/repository/raw/1/charts/formatted/$x.png"
    short="$x"
    case "$x" in *nonnorm) short=`echo $x|sed 's/-nonnorm//'` ;; esac
    text_url="http://code.soundsoftware.ac.uk/projects/sv-survey-output/repository/entry/1/textout/$short.txt"
    echo '<a href="'$text_url'"><img src="'$pic_url'"></a>' > html/"$x".html
done

