Ejemplo n.º 1
0
MapArea *
retrieveCurrentMapArea(Buffer *buf)
{
    Anchor *a_img, *a_form;
    FormItemList *fi;
    MapList *ml;
    ListItem *al;
    MapArea *a;
    int i, n;

    a_img = retrieveCurrentImg(buf);
    if (!(a_img && a_img->image && a_img->image->map))
	return NULL;
    a_form = retrieveCurrentForm(buf);
    if (!(a_form && a_form->url))
	return NULL;
    fi = (FormItemList *)a_form->url;
    if (!(fi && fi->parent && fi->parent->item))
	return NULL;
    fi = fi->parent->item;
    ml = searchMapList(buf, fi->value ? fi->value->ptr : NULL);
    if (!ml)
	return NULL;
    n = searchMapArea(buf, ml, a_img);
    if (n < 0)
	return NULL;
    for (i = 0, al = ml->area->first; al != NULL; i++, al = al->next) {
	a = (MapArea *) al->ptr;
	if (a && i == n)
	    return a;
    }
    return NULL;
}
Ejemplo n.º 2
0
MapArea *
follow_map_menu(Buffer *buf, char *name, Anchor *a_img, int x, int y)
{
    MapList *ml;
    ListItem *al;
    int i, selected = -1;
    int initial = 0;
#ifdef MENU_MAP
    MapArea *a;
    char **label;
#endif

    ml = searchMapList(buf, name);
    if (ml == NULL || ml->area == NULL || ml->area->nitem == 0)
	return NULL;

#ifdef USE_IMAGE
    initial = searchMapArea(buf, ml, a_img);
    if (initial < 0)
	initial = 0;
    else if (!image_map_list) {
	selected = initial;
	goto map_end;
    }
#endif

#ifdef MENU_MAP
    label = New_N(char *, ml->area->nitem + 1);
    for (i = 0, al = ml->area->first; al != NULL; i++, al = al->next) {
	a = (MapArea *) al->ptr;
	if (a)
	    label[i] = *a->alt ? a->alt : a->url;
	else
	    label[i] = "";
    }
    label[ml->area->nitem] = NULL;

    optionMenu(x, y, label, &selected, initial, NULL);
#endif

#ifdef USE_IMAGE
  map_end:
#endif
    if (selected >= 0) {
	for (i = 0, al = ml->area->first; al != NULL; i++, al = al->next) {
	    if (al->ptr && i == selected)
		return (MapArea *) al->ptr;
	}
    }
    return NULL;
}
Ejemplo n.º 3
0
Buffer *
follow_map_panel(Buffer *buf, char *name)
{
    Str mappage;
    MapList *ml;
    ListItem *al;
    MapArea *a;
    ParsedURL pu;
    char *p, *q;
    Buffer *newbuf;

    ml = searchMapList(buf, name);
    if (ml == NULL)
	return NULL;

    mappage = Strnew_charp(map1);
    for (al = ml->area->first; al != NULL; al = al->next) {
	a = (MapArea *) al->ptr;
	if (!a)
	    continue;
	parseURL2(a->url, &pu, baseURL(buf));
	p = parsedURL2Str(&pu)->ptr;
	q = html_quote(p);
	if (DecodeURL)
	    p = html_quote(url_unquote_conv(p, buf->document_charset));
	else
	    p = q;
	Strcat_m_charp(mappage, "<tr valign=top><td><a href=\"", q, "\">",
		       html_quote(*a->alt ? a->alt : mybasename(a->url)),
		       "</a><td>", p, NULL);
    }
    Strcat_charp(mappage, "</table></body></html>");

    newbuf = loadHTMLString(mappage);
#ifdef USE_M17N
    if (newbuf)
	newbuf->document_charset = buf->document_charset;
#endif
    return newbuf;
}
Ejemplo n.º 4
0
Archivo: anchor.c Proyecto: yujiabe/w3m
Buffer *
link_list_panel(Buffer *buf)
{
    LinkList *l;
    AnchorList *al;
    Anchor *a;
    FormItemList *fi;
    int i;
    char *t, *u, *p;
    ParsedURL pu;
    /* FIXME: gettextize? */
    Str tmp = Strnew_charp("<title>Link List</title>\
<h1 align=center>Link List</h1>\n");

    if (buf->bufferprop & BP_INTERNAL ||
	(buf->linklist == NULL && buf->href == NULL && buf->img == NULL)) {
	return NULL;
    }

    if (buf->linklist) {
	Strcat_charp(tmp, "<hr><h2>Links</h2>\n<ol>\n");
	for (l = buf->linklist; l; l = l->next) {
	    if (l->url) {
		parseURL2(l->url, &pu, baseURL(buf));
		p = parsedURL2Str(&pu)->ptr;
		u = html_quote(p);
		if (DecodeURL)
		    p = html_quote(url_decode2(p, buf));
		else
		    p = u;
	    }
	    else
		u = p = "";
	    if (l->type == LINK_TYPE_REL)
		t = " [Rel]";
	    else if (l->type == LINK_TYPE_REV)
		t = " [Rev]";
	    else
		t = "";
	    t = Sprintf("%s%s\n", l->title ? l->title : "", t)->ptr;
	    t = html_quote(t);
	    Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t, "</a><br>", p,
			   "\n", NULL);
	}
	Strcat_charp(tmp, "</ol>\n");
    }

    if (buf->href) {
	Strcat_charp(tmp, "<hr><h2>Anchors</h2>\n<ol>\n");
	al = buf->href;
	for (i = 0; i < al->nanchor; i++) {
	    a = &al->anchors[i];
	    if (a->hseq < 0 || a->slave)
		continue;
	    parseURL2(a->url, &pu, baseURL(buf));
	    p = parsedURL2Str(&pu)->ptr;
	    u = html_quote(p);
	    if (DecodeURL)
		p = html_quote(url_decode2(p, buf));
	    else
		p = u;
	    t = getAnchorText(buf, al, a);
	    t = t ? html_quote(t) : "";
	    Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t, "</a><br>", p,
			   "\n", NULL);
	}
	Strcat_charp(tmp, "</ol>\n");
    }

    if (buf->img) {
	Strcat_charp(tmp, "<hr><h2>Images</h2>\n<ol>\n");
	al = buf->img;
	for (i = 0; i < al->nanchor; i++) {
	    a = &al->anchors[i];
	    if (a->slave)
		continue;
	    parseURL2(a->url, &pu, baseURL(buf));
	    p = parsedURL2Str(&pu)->ptr;
	    u = html_quote(p);
	    if (DecodeURL)
		p = html_quote(url_decode2(p, buf));
	    else
		p = u;
	    if (a->title && *a->title)
		t = html_quote(a->title);
	    else
		t = html_quote(url_decode2(a->url, buf));
	    Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t, "</a><br>", p,
			   "\n", NULL);
	    a = retrieveAnchor(buf->formitem, a->start.line, a->start.pos);
	    if (!a)
		continue;
	    fi = (FormItemList *)a->url;
	    fi = fi->parent->item;
	    if (fi->parent->method == FORM_METHOD_INTERNAL &&
		!Strcmp_charp(fi->parent->action, "map") && fi->value) {
		MapList *ml = searchMapList(buf, fi->value->ptr);
		ListItem *mi;
		MapArea *m;
		if (!ml)
		    continue;
		Strcat_charp(tmp, "<br>\n<b>Image map</b>\n<ol>\n");
		for (mi = ml->area->first; mi != NULL; mi = mi->next) {
		    m = (MapArea *) mi->ptr;
		    if (!m)
			continue;
		    parseURL2(m->url, &pu, baseURL(buf));
		    p = parsedURL2Str(&pu)->ptr;
		    u = html_quote(p);
		    if (DecodeURL)
			p = html_quote(url_decode2(p, buf));
		    else
			p = u;
		    if (m->alt && *m->alt)
			t = html_quote(m->alt);
		    else
			t = html_quote(url_decode2(m->url, buf));
		    Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t,
				   "</a><br>", p, "\n", NULL);
		}
		Strcat_charp(tmp, "</ol>\n");
	    }
	}
	Strcat_charp(tmp, "</ol>\n");
    }

    return loadHTMLString(tmp);
}