1// Copyright (C) 2018 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import * as m from 'mithril'; 16 17import {channelChanged, getNextChannel, setChannel} from '../common/channels'; 18 19import {globals} from './globals'; 20import {createPage} from './pages'; 21 22 23export const HomePage = createPage({ 24 view() { 25 return m( 26 '.page.home-page', 27 m( 28 '.home-page-center', 29 m('.home-page-title', 'Perfetto'), 30 m(`img.logo[src=${globals.root}assets/logo-3d.png]`), 31 m( 32 'div.channel-select', 33 m('div', 34 'Feeling adventurous? Try our bleeding edge Canary version'), 35 m( 36 'fieldset', 37 mkChan('stable'), 38 mkChan('canary'), 39 m('.highlight'), 40 ), 41 m(`.home-page-reload${channelChanged() ? '.show' : ''}`, 42 'You need to reload the page for the changes to have effect'), 43 ), 44 ), 45 m('a.privacy', 46 {href: 'https://policies.google.com/privacy', target: '_blank'}, 47 'Privacy policy')); 48 } 49}); 50 51function mkChan(chan: string) { 52 const checked = getNextChannel() === chan ? '[checked=true]' : ''; 53 return [ 54 m(`input[type=radio][name=chan][id=chan_${chan}]${checked}`, { 55 onchange: () => { 56 setChannel(chan); 57 } 58 }), 59 m(`label[for=chan_${chan}]`, chan), 60 ]; 61} 62