Iterate links and anchors for next/ previous labels

This commit is contained in:
Christian Dywan 2010-06-08 22:27:57 +02:00
parent b747f00e26
commit 61add83eeb

View file

@ -4680,9 +4680,11 @@ midori_view_get_previous_page (MidoriView* view)
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)); web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
js_context = webkit_web_frame_get_global_context (web_frame); js_context = webkit_web_frame_get_global_context (web_frame);
katze_assign (uri, sokoke_js_script_eval (js_context, katze_assign (uri, sokoke_js_script_eval (js_context,
"(function (l) {" "(function (g) {"
"var ind = ['prev','←','«','<'];" "var ind = ['prev','←','«','<'];"
"var nind = ['next','→','»','>'];" "var nind = ['next','→','»','>'];"
"for (h in g) {"
"l = g[h];"
"for (i in l)" "for (i in l)"
"if (l[i].rel && (l[i].rel == ind[0]))" "if (l[i].rel && (l[i].rel == ind[0]))"
"return l[i].href;" "return l[i].href;"
@ -4708,10 +4710,12 @@ midori_view_get_previous_page (MidoriView* view)
"}" "}"
"for (j in cand)" "for (j in cand)"
"for (i in l)" "for (i in l)"
"if (l[i].href && (l[i].href.indexOf (cand[j]) == 0))" "if (cand[j].length && l[i].href && (l[i].href.indexOf (cand[j]) == 0))"
"return l[i].href;" "return l[i].href;"
"}"
"return 0;" "return 0;"
"}) (document.getElementsByTagName ('a'));", NULL)); "}) ([document.getElementsByTagName ('link'),"
"document.getElementsByTagName ('a')]);", NULL));
return uri && uri[0] != '0' ? uri : NULL; return uri && uri[0] != '0' ? uri : NULL;
} }
@ -4740,9 +4744,11 @@ midori_view_get_next_page (MidoriView* view)
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)); web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
js_context = webkit_web_frame_get_global_context (web_frame); js_context = webkit_web_frame_get_global_context (web_frame);
katze_assign (uri, sokoke_js_script_eval (js_context, katze_assign (uri, sokoke_js_script_eval (js_context,
"(function (l) {" "(function (g) {"
"var ind = ['next','→','»','>'];" "var ind = ['next','→','»','>'];"
"var nind = ['prev','←','«','<'];" "var nind = ['prev','←','«','<'];"
"for (h in g) {"
"l = g[h];"
"for (i in l)" "for (i in l)"
"if (l[i].rel && (l[i].rel == ind[0]))" "if (l[i].rel && (l[i].rel == ind[0]))"
"return l[i].href;" "return l[i].href;"
@ -4768,10 +4774,12 @@ midori_view_get_next_page (MidoriView* view)
"}" "}"
"for (j in cand)" "for (j in cand)"
"for (i in l)" "for (i in l)"
"if (l[i].href && (l[i].href.indexOf (cand[j]) == 0))" "if (cand[j].length && l[i].href && (l[i].href.indexOf (cand[j]) == 0))"
"return l[i].href;" "return l[i].href;"
"}"
"return 0;" "return 0;"
"}) (document.getElementsByTagName ('a'));", NULL)); "}) ([document.getElementsByTagName ('link'),"
"document.getElementsByTagName ('a')]);", NULL));
return uri && uri[0] != '0' ? uri : NULL; return uri && uri[0] != '0' ? uri : NULL;
} }
#if WEBKIT_CHECK_VERSION (1, 1, 5) #if WEBKIT_CHECK_VERSION (1, 1, 5)