import React, {Component, PureComponent} from 'react';
import {LoginForm, PostForm} from './UserAction';
import {TokenCtx} from './UserAction';
import {PromotionBar} from './Common';
import './Title.css';
const flag_re=/^\/\/setflag ([a-zA-Z0-9_]+)=(.+)$/;
const HELP_TEXT=(
使用提示:
- 为保证使用体验,请使用 Chrome 或 Mobile Safari 浏览器最新版
- 在搜索框输入 #472865 等可以查看指定 ID 的树洞
- 新的帖子会在左上角显示一个圆点
- 本网站支持 3D Touch,重压屏幕可以快速返回 / 刷新树洞
使用本网站时,您需要了解并同意:
- 所有数据来自 PKU Helper,本站不对其内容负责
-
不接受关于 UI 的建议,
功能建议请在 GitHub 提出
- 英梨梨是我的,你们都不要抢
By @xmcp
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
);
class ControlBar extends PureComponent {
constructor(props) {
super(props);
this.state={
search_text: '',
};
this.set_mode=props.set_mode;
this.on_change_bound=this.on_change.bind(this);
this.on_keypress_bound=this.on_keypress.bind(this);
this.do_refresh_bound=this.do_refresh.bind(this);
this.do_attention_bound=this.do_attention.bind(this);
}
componentDidMount() {
if(window.location.hash) {
let text=decodeURIComponent(window.location.hash).substr(1);
if(text.lastIndexOf('?')!==-1)
text=text.substr(0,text.lastIndexOf('?')); // fuck wechat '#param?nsukey=...'
this.setState({
search_text: text,
}, ()=>{
this.on_keypress({key: 'Enter'});
});
}
}
on_change(event) {
this.setState({
search_text: event.target.value,
});
}
on_keypress(event) {
if(event.key==='Enter') {
let flag_res=flag_re.exec(this.state.search_text);
if(flag_res) {
localStorage[flag_res[1]]=flag_res[2];
alert('Set Flag '+flag_res[1]+'='+flag_res[2]);
return;
}
const mode=this.state.search_text.startsWith('#') ? 'single' : 'search';
this.set_mode(mode,this.state.search_text||'');
}
}
do_refresh() {
window.scrollTo(0,0);
this.setState({
search_text: '',
});
this.set_mode('list',null);
}
do_attention() {
window.scrollTo(0,0);
this.setState({
search_text: '',
});
this.set_mode('attention',null);
}
render() {
return (
{({value: token})=>(
)}
)
}
}
export function Title(props) {
let date=new Date();
let is_eriri_birthday=(1+date.getMonth())===3 && date.getDate()===20;
return (
P大树洞
{ is_eriri_birthday ?
3月20日是看板娘英梨梨的生日 :
"非官方网页版 by @xmcp"
}
)
}