Htm source editor with preview

Share your advanced PureBasic knowledge/code with the community.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Htm source editor with preview

Post by utopiomania »

Here's another program I wrote for my own use. I mainly use notepad for editing simple html for things like the webgadget,
but wrote this to replace it. It's basically the same, but has two tabs, one for for the htm source and
one for preview.
It has a few extra items in the menus, and particularly in the context menu. With Explore and ftp in My Network places you
could easily use it to tweak your site and upload for example. :)

Code: Select all

code is in the last two posts ->
Last edited by utopiomania on Tue Jan 29, 2013 9:05 pm, edited 13 times in total.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

looks interesting - right now I have to resolve a library conflict (or maybe more) before I can test.

cheers,
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

There an [url=http://www.utopiomania.com\gate\htmeditor.exe]exe (42Kb) available here[/url], so that you can check out if the conflicts are worth resolving. :)

And heres some source to load in tab2 to check it out. Save as source.htm, rclick open. Credit to the man in line one.

Code: Select all

<html><head><meta name="Author" content="Gerard Ferrandez at http://www.dhteumeuleu.com">
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
	body {cursor:crosshair;margin:0; padding:0; position:absolute; overflow:hidden; background:#000; left:0; top:0; width:100%; height:100%;}
	span {position: absolute; font-family: verdana; text-align: center; font-weight: bold;}
</style>

<script type="text/javascript"><!--
window.onerror = new Function("return true");
document.onselectstart = new Function("return false");
screen.bufferDepth = 16; object = new Array();

function zOOm(){
	with (this) {
		k += .1;
		for(i=0;i<obj.length;i++){
			t = mini + maxi + Math.cos(k + i / amp) * maxi;
			with(obj[i].style){
				zIndex = Math.round(t*10); top = Math.round(-t/chu); fontSize = Math.round(t);
				c = t*200/(2*maxi+mini);
				if(inv)c = 255-c;
				color = "RGB("+Math.round(c*cR)+","+Math.round(c*cG)+","+Math.round(c*cB)+")";
			}
		}
		setTimeout(sto,16);
	}
}

function CObj(N,obj,txt,amp,mini,maxi,cR,cG,cB,inv,chu){
	this.N = N;
	for(i=0;i<txt.length;i++){
		c = txt.charAt(i);
		o = document.createElement("span"); o.onmousedown = new Function("return false");
		o.style.left = Math.round(mini * i * 1.5); b = document.createElement("div");
		b.innerHTML = c; b.style.position = "absolute"; b.style.left = -250;
		b.style.width = 300; o.appendChild(b); obj.appendChild(o);
	}
	this.obj  = obj.getElementsByTagName("span");
	this.k    = 0; this.cR   = cR; this.cG   = cG; this.cB   = cB; this.inv  = inv; this.amp  = amp;
	this.mini = mini;	this.maxi = maxi;	this.chu  = chu; this.sto  = "object["+N+"].zOOm();";
	this.zOOm = zOOm;	setTimeout(this.sto,32);
}

onload = function() {
	object[0] = new CObj(0,document.getElementById("T1"),"P*U*R*E*B*A*S*I*C",1.2,25,50,2,0,2,1,0.8);
	object[1] = new CObj(1,document.getElementById("T2"),"H*T*M*E*D*I*T*O*R",1.2,25,50,3,1,0,1,6.4);
}
//-->
</script></head>

<body><span style="position:absolute;left:50%;top:50%">
	<span id="T1" style="position: absolute; top: 0px; left:-200px; width: 400px"></span>
	<span id="T2" style="position: absolute; top: 0px; left:-200px; width: 400px"></span>
</span></body></html>
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Many thanks.

definately worth resolving the conflict(s).

That source is WILD 8)

cheers


Hmm - may need some way to stop the preview - it's eating my cpu :D
thefool
Always Here
Always Here
Posts: 5881
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

cant download..
:/
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

:?: Try again, there should be PLENTY of bandwith available, I can dl it everytime.
thefool
Always Here
Always Here
Posts: 5881
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

cant.. dunno why
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Good programmers don't comment their code. It was hard to write, should be hard to read.
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

why HTM when it's HTML? :lol:
Anyway, let the user see a preview with out having to save the script (dont ask for any input, if its not saved, save a temp one then erase when the preview has finished)..
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

dagcrack wrote:why HTM when it's HTML? :lol:
For additional discussion try
http://jeremy.zawodny.com/blog/archives/000481.html

let's not turn this forum into a debate area :)


"Kim said:
File extensions?

Do some work and stop wasting time.

;) "

cheers
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Uh I'm sure the "lol" emoticon was placed in there for some reason...
In my case I use .fck ;) http://www.gushh.com.ar/hit/hello.fck
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

@dagcrack, it recognises both htm and html extensions. If you save a new file without an extension, it will
use .htm for 8.3 compatibility and to save one byte. :?

As for save preview, saving to a temp file can mess up page navigation, and since it was written to replace
Notepad and the Ctrl-s, Exit, click IExplorer, refresh sequence I think this is ok.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

Hmm - may need some way to stop the preview - it's eating my cpu
Fixed.
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

Perhaps code editors shouldn't default to a proportional font, in my case it's Times Roman that gets used. Otherwise, great work!

Thanks!
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Hmm - line 1019 closegadgetlist() without opengadgetlist() :?

Clean 3.94 install.

Any ideas what I've done wrong?

cheers
Post Reply