/*
This file is part of Bolixo.
Bolixo 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.
Bolixo 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.
You should have received a copy of the GNU General Public License
along with Bolixo. If not, see .
*/
/*
This file hold various test done to figure out how to use html and javascript
*/
// To learn and experiment with HTML
#include
#include
#include
#include "../instrument.h"
extern "C" void tlmp_initmod()
{
translat_load ("bolixo");
}
static void do_webtable(const WEBID &id, int nbrow, unsigned &cur)
{
glocal int nbrow = nbrow;
(id,cur,0,5);
sethead ("title1\ttitle2\ttitle3\ttitle4");
setrowstyle ("white","bgcolor=white");
setrowstyle ("white+current","bgcolor=lightblue");
setclickopt(true,"","");
for (int i=0; i
}
static void do_webtable(const WEBID &id, int nbrow)
{
unsigned cur = 0;
do_webtable (id,nbrow,cur);
}
static void layout (int width, int toprep, int middlerep)
{
//DIV main; main.w(width).h(100).disp("table").print();
DIV main; main.w(width).disp("flex").flowcol().print();
if (0){
DIV tb; tb.w(100).h(100).disp("flex").flowrow().print();
DIV c1; c1.flex("0 1 auto").print();
/- allo
c1.end();
DIV c2; c2.flex("0 1 auto").print();
/- comment ca va
c2.end();
}else if (0){
DIV tb; tb.h(5).disp("table-row").flex("0 1 auto").print();
DIV c1; c1.disp("table-cell").print();
/- allo
c1.end();
DIV c2; c2.disp("table-cell").print();
/- comment ca va
c2.end();
}
if (0){
DIV tb; tb.h(95).disp("table-row").flex("1 1 auto").print();
DIV c1; c1.disp("table-cell").print();
/- Une autre ligne
c1.end();
DIV c2; c2.disp("table-cell").print();
DIV col; col.bg("red").disp("flex").flowcol().print();
}
DIV to; to.bg("gray").disp("flex").flex("0 1 auto").print();
for (int i=0; i
Button4
Button5
/-
}
to.end();
DIV mi; mi.bg("yellow").w(100).disp("flex").flex("1 1 auto").print();
static int level = 0;
if (level == 0){
level++;
DIV d; d.w(100).disp("flex").flowrow().print();
layout(50,1,10);
layout(50,2,10);
level--;
}else{
DIV d; d.w(100).disp("flex").flowrow().print();
DIV dd; dd.w(30).flex("0 1 auto").print();
(WEBID("titi"));
for (int i=0; i<20; i++) setrow("white",0,"a\tb\tc");
dd.end();
DIV ddd; ddd.flex("1 1 auto").print();
/-
for (int i=0; i
field-%d\n",i);
}
/-
}
mi.end();
DIV bo; bo.bg("pink").flex("0 1 auto").print();
/- toto
bo.end();
//col.end();
/-
}
/*
This test was done to experiment with div inside div, to learn how it behave
*/
void test1()
{
tlmpweb_title ("This is the start of a long long journey");
?>
tlmpweb_body("white",NULL);
allo le monde
bababa
babababa
abababba
?>
layout(40,1,10);
layout(40,2,10);
/-
}
/*
This is replicating the complete layout of bolixo
*/
void bolixo()
{
?>
tlmpweb_body("white",NULL);
DIV main("main"); main.dispflex().flowcol().w(100).h(100).print();
{ // The title
DIV b0("main0","main0"); b0.w(100).flexfixe().print();
DIV banner; banner.w(100).dispflex().flowrow().bg("lightgray").print();
// Put some items
DIV it;
it.flexfixe().content("Bolixo.org");
it.flexgrow().content("
Welcome
");
it.flexfixe().content("
About
Logout
");
}
WEBID table1("table1");
WEBID table2("table2");
{
DIV body("main1"); body.flexgrow().w(100).bg("red").print();
DIV tabs("tabs"); tabs.w(100).dispflex().flowrow().bg("gray").align("stretch").print();
DIV t("tab","tab");
t.w(20).flexfixe().bg("yellow").print();
{
do_webtable(table1,20);
//DIV grow; grow.dispflex().flowcol().print();
//DIV b0; b0.bg("black").flexgrow().content("This is a test");
}
t.w(40).flexfixe().bg("lightblue").print();
{
DIV t; t.dispflex().flowcol().print();
DIV tab21("tab2","tab2"); tab21.bg("blue").flexfixe().print();
/-
THIS IS T2
tab21.end();
DIV tab22; tab22.flexgrow().print();
do_webtable(table2,20);
}
t.w(40).flexfixe().bg("pink").print();
/-
THIS IS T2
t.end();
/-
}
main.end();
?>
}
/*
Try to understand why a form creates some vertical spaces in a layout
The trick was "margin-bottom:0;"
*/
void form_space()
{
tlmpweb_body("white",NULL);
DIV d; d.h(100).dispflex().flowcol().print();
DIV sub; sub.h(10).bg("yellow").print();
/- 111111
{
DIV s; s.w(100).bg("blue").print();
// /-
return true;
sub.h(60).bg("green").print();
/- End
}
/*
Simple test to see the new HTML 5 tags section and friends
*/
void newtags()
{
?>
tlmpweb_body("white",NULL);
Main content: first in source order
?>
}
void scrollbar()
{
tlmpweb_body("white",NULL);
DIV d; d.dispflex().flowcol().print();
/-
static void index_script(unsigned scrollid1, unsigned scrollid2)
{
// Script to make sure the webtabs tabs use the full height of the screen
// Then it takes the webtables and grows them too.
?>
}
static void journey_setscroll()
{
();
tlmpweb_setscripts();
tlmpweb_body("white",NULL);
WEBID id1 ("id1");
WEBID id2 ("id2");
{
DIV m("","main"); m.w(100).h(100).print();
DIV d("","head"); d.w(100).h(10).print();
/- Hello
d.end();
unsigned cur1 = 10;
unsigned cur2 = 20;
d.id("body").w(100).dispflex().flowrow().print();
{
DIV tab("tabs"); tab.flexfixe().w(40).bg("lightblue").margins(5,5).vmargins(5,5).border(1,"black").print();
do_webtable(id1, 100,cur1);
}
{
DIV tab("tabs"); tab.flexfixe().w(60).bg("lightred").margins(5,5).vmargins(5,5).border(1,"black").print();
do_webtable(id2, 100,cur2);
}
}
unsigned w,h,l,scroll_top1=100,scroll_top2=400;
tlmpweb_gettablegeometry (id1,w,h,scroll_top1,l);
tlmpweb_gettablegeometry (id2,w,h,scroll_top2,l);
tlmp_error ("top %u %u\n",scroll_top1,scroll_top2);
index_script(scroll_top1,scroll_top2);
}
void util_endscript(PARAM_STRING);
static void journey_subtabs()
{
();
tlmpweb_setscripts();
tlmpweb_body("white",NULL);
WEBID id1 ("id1");
WEBID id2 ("id2");
{
DIV m("","main"); m.w(100).h(100).print();
DIV d("","head"); d.w(100).h(10).print();
/- Hello
d.end();
d.cls("tabs").id("body").w(100).dispflex().flowrow().print();
DIV d1("subtabs","d1"); d1.w(50).vpaddings(10,10).bg("pink").print();
DIV d2("subtabs","d2"); d2.w(95).vpaddings(10,10).bg("white").print();
DIV d3("subtabs","d3"); d3.w(95).vpaddings(10,10).bg("pink").print();
}
util_endscript("");
}
/*
When you click on a link, it jumps to a new tab.
If you click with the middle mouse button, it opens in a new tab, but stay in the current one (like normal).
*/
static void journey_click()
{
();
tlmpweb_setscripts();
htmlout (
"\n"
);
tlmpweb_body("white",NULL);
const char *url = "http://test1.bolixo.org/talk1.jpg";
htmlprintf ("",url);
htmlprintf ("\n",url);
htmlout ("\n");
}
extern "C" void webmain()
{
tlmpweb_title ("This is the start of a long long journey");
//test1();
//bolixo();
//newtags();
//form_space();
//scrollbar();
//tabs();
//popup();
//webtable_dropdown();
//webtable_popup();
//journey_setscroll();
//journey_subtabs();
journey_click();
}