patternjavascriptMinor
Allowing simplified browsing of websites with a predictable URL structure
Viewed 0 times
allowingsimplifiedwebsiteswithpredictablebrowsingstructureurl
Problem
The code below has been a pet project of mine for some time. It allows simplified browsing of websites that have a predictable URL structure, namely TGP websites.
It has been greatly modified from it's original version to be effective on Android, and there is probably alot of room to improve on it. I'm not asking anyone to do my work for me, though.
```
window.onload = function() {
if(location.href.lastIndexOf('?')>0)(splitURL(location.href.substring(location.href.lastIndexOf('?')+1)))
BROWSEbar.style.display='none';
EDITbar.style.display='block';
};
window.onscroll = function() {
document.getElementById('fixdiv').style.top =
(window.pageYOffset) + 'px';
};
function splitURL(newURL)
{
EDITbar.fullURL.value=newURL;
EDITbar.splitURL.click();
EDITbar.goURL.click();
}
function combine(a,b,c,d,e,f,g){return a+b+c+d+e+f+g;}
function highlight(field) {field.focus();field.select();}
function minusone(a)
{
b = a.length;
a = Number(a);
a = ((a > 1) ? a - 1 : a);
a = String(a);
while(a.length
Filter-Kilter Browser
#fixdiv {filter: alpha(opacity=86); -moz-opacity: .86; background-color:#EEE;}
html, body { margin: 0; padding: 0; height: 100%; overflow:hidden;}
p, h1 {top-margin: 0; padding: 0;}
.button
{
color: #900;
border: 1px solid #900;
font-size: 24px;
font-weight: bold;
}
.browse
{
color: #862;
border: 2px solid #806020;
font-size: 240%;
font-weight: 900;
}
iframe
{
position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
border: none;
}
table,th,td
{
border-collapse : collapse;
padding:0;
}
th
{
background-color:green;
color:white;
}
input.groovybutton
{
font-size:46px;
font-family:Comic Sans MS,sans-serif;
font-weight:bold;
color:#ffffff;
width:990px;
height120px;
background-color:#800;
border-style:s
It has been greatly modified from it's original version to be effective on Android, and there is probably alot of room to improve on it. I'm not asking anyone to do my work for me, though.
```
window.onload = function() {
if(location.href.lastIndexOf('?')>0)(splitURL(location.href.substring(location.href.lastIndexOf('?')+1)))
BROWSEbar.style.display='none';
EDITbar.style.display='block';
};
window.onscroll = function() {
document.getElementById('fixdiv').style.top =
(window.pageYOffset) + 'px';
};
function splitURL(newURL)
{
EDITbar.fullURL.value=newURL;
EDITbar.splitURL.click();
EDITbar.goURL.click();
}
function combine(a,b,c,d,e,f,g){return a+b+c+d+e+f+g;}
function highlight(field) {field.focus();field.select();}
function minusone(a)
{
b = a.length;
a = Number(a);
a = ((a > 1) ? a - 1 : a);
a = String(a);
while(a.length
Filter-Kilter Browser
#fixdiv {filter: alpha(opacity=86); -moz-opacity: .86; background-color:#EEE;}
html, body { margin: 0; padding: 0; height: 100%; overflow:hidden;}
p, h1 {top-margin: 0; padding: 0;}
.button
{
color: #900;
border: 1px solid #900;
font-size: 24px;
font-weight: bold;
}
.browse
{
color: #862;
border: 2px solid #806020;
font-size: 240%;
font-weight: 900;
}
iframe
{
position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
border: none;
}
table,th,td
{
border-collapse : collapse;
padding:0;
}
th
{
background-color:green;
color:white;
}
input.groovybutton
{
font-size:46px;
font-family:Comic Sans MS,sans-serif;
font-weight:bold;
color:#ffffff;
width:990px;
height120px;
background-color:#800;
border-style:s
Solution
I will ignore the android specific parts. And i will fix/ignore the missing semicolons & unnecessary brackets
Ok .. here it goes.
-
it's 2012, please use HTML5 doctype.
-
english is not the only language on planet, you should be using UTF-8 for ages already
-
if possible, avoid meeing with style object. Each time you modify it, browser executed
-
this is just madness
-
you should learn how to use arrays in javascript
-
firefox and IE are not the only browsers
-
this is just nasty
-
you should not be using iframes just to create layout. Go and learn what XHR is.
-
please , stop using inline css
-
this tag is considered outdate , you have css for it
-
do not attach javascrit events in HTML tags
-
line breaks are not for layout
Essentially , it looks like your HTML/JS/CSS skills are at least 10 yours out of date.
Ok .. here it goes.
-
it's 2012, please use HTML5 doctype.
-
english is not the only language on planet, you should be using UTF-8 for ages already
-
if possible, avoid meeing with style object. Each time you modify it, browser executed
reflow stageBROWSEbar.style.display='none';
EDITbar.style.display='block';-
this is just madness
function minusone(a) {
b = a.length;
a = Number(a);
a = ((a > 1) ? a - 1 : a);
a = String(a);
while (a.length < b) {
a = "0" + a;
}
return a;
}
function plusone(a) {
b = a.length;
a = Number(a);
a++;
a = String(a);
while (a.length < b) {
a = "0" + a;
}
return a;
}-
you should learn how to use arrays in javascript
switch (j) {
case 1:
EDITbar.url2.value = EDITbar.url2.value + newURL.charAt(i);
if (testI == false){
j++;
}
break;
case 2:
EDITbar.url3.value = EDITbar.url3.value + newURL.charAt(i);
if(testI == true){
j++;
}
break;
case 3:
EDITbar.url4.value = EDITbar.url4.value + newURL.charAt(i);
if(testI == false){
j++;
}
break;
case 4:
EDITbar.url5.value = EDITbar.url5.value + newURL.charAt(i);
if(testI == true){
j++;
}
break;
case 5:
EDITbar.url6.value = EDITbar.url6.value + newURL.charAt(i);
if(newURL.charAt(i+1) == "."){
j++;
}
break;
case 6:
EDITbar.url7.value = EDITbar.url7.value + newURL.charAt(i);
break;
}-
firefox and IE are not the only browsers
#fixdiv {
filter: alpha(opacity=86);
-moz-opacity: .86;
background-color:#EEE;
}-
this is just nasty
font-family:Comic Sans MS,sans-serif;-
you should not be using iframes just to create layout. Go and learn what XHR is.
-
please , stop using inline css
-
this tag is considered outdate , you have css for it
-
do not attach javascrit events in HTML tags
-
line breaks are not for layout
Essentially , it looks like your HTML/JS/CSS skills are at least 10 yours out of date.
Code Snippets
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />BROWSEbar.style.display='none';
EDITbar.style.display='block';function minusone(a) {
b = a.length;
a = Number(a);
a = ((a > 1) ? a - 1 : a);
a = String(a);
while (a.length < b) {
a = "0" + a;
}
return a;
}
function plusone(a) {
b = a.length;
a = Number(a);
a++;
a = String(a);
while (a.length < b) {
a = "0" + a;
}
return a;
}switch (j) {
case 1:
EDITbar.url2.value = EDITbar.url2.value + newURL.charAt(i);
if (testI == false){
j++;
}
break;
case 2:
EDITbar.url3.value = EDITbar.url3.value + newURL.charAt(i);
if(testI == true){
j++;
}
break;
case 3:
EDITbar.url4.value = EDITbar.url4.value + newURL.charAt(i);
if(testI == false){
j++;
}
break;
case 4:
EDITbar.url5.value = EDITbar.url5.value + newURL.charAt(i);
if(testI == true){
j++;
}
break;
case 5:
EDITbar.url6.value = EDITbar.url6.value + newURL.charAt(i);
if(newURL.charAt(i+1) == "."){
j++;
}
break;
case 6:
EDITbar.url7.value = EDITbar.url7.value + newURL.charAt(i);
break;
}Context
StackExchange Code Review Q#8867, answer score: 4
Revisions (0)
No revisions yet.