Location: PHPKode > projects > Hobby Works > programs/notepad/notepad.php
<?

$TITLE = 'NOTEPAD';	// Set page title

$INC_GENERAL_FILE_ROUTINES_AS = 'ADMIN';	// Include jscript routines

define('DEF_np_01', 'Dynamic HTML database');
define('DEF_nP_02', 'Loading ...');
define('DEF_np_03', 'Select a file to alter ...');
define('DEF_np_04', 'Cursor position. [Click] to set ...');
define('DEF_np_05', 'Search a word ...');
define('DEF_np_06', 'Find');

$menu =
	// Alter file
'&nbsp;<img name="MENU_ICON" id="alter" style="height: '.DEF_menu_icon_size.
 'px;" OnClick="open_FM_menu(event);" title="'.DEF_np_03.'" />&nbsp;'.
'&nbsp;<img name="MENU_ICON" id="html_fm_img" style="height: '.
 DEF_menu_icon_size.'px;" OnClick="open_DHTML_DBASE_menu(event);" title="'.DEF_np_01.'" />&nbsp;'.
 // Text position
'&nbsp;<b><span title="'.DEF_np_04.'" onmousedown="dispCursorPosDialog(this); return true" >[<span id="CURSOR_POS_ID">0</span>]</span></b>&nbsp;'.
''; 

$end_menu =
'&nbsp;<img name="MENU_ICON" id="search_img" style="height: '.DEF_menu_icon_size.'px;" OnClick="searchText(this);" title="'.
 DEF_np_05.'" />&nbsp;'.
''; 

$setCursorMenu =
 '<font size="1"><TABLE border=0>'.
 '<TR><TD><input id="set_cursor_id" type="text" size="2" onkeydown="return setNewCursorPos(event)" value="\' + js_world.selection_start + \'"></TD></TR>'.
 '</TABLE></font>'.
 '';

$searchTextMenu1 =
 '<font size="1"><TABLE border=0>'.
 '<TR><TD><input type="button" value="'.DEF_np_06.'" onclick="findText()" ondblclick="findText()">&nbsp;</TD><TD><input type="text" size="15" id="find_text_id" maxlength="25" value="'.
 '';
$searchTextMenu2 =
 '" ></TD><TD><img id="fd_close_img" OnClick="js_world.forgetLastPopup();" '.
  ' style="height: 14px;" /></TD></TR>'.
 '</TABLE></font>'.
 '';

// Menu functions
$javascript .= 
'	function initialize_program() { '.
'		js_world.disp_this_menu(\''.$menu.'\', \''.$end_menu.'\'); '.
'		js_world.removeBGImage(); '.
'		js_world.disp_this_content(\'<div id="textarea_div" style="HEIGHT: 99%; WIDTH: 99%; ">'.DEF_np_02.'</div>\'); '.

'		js_world.set_img_cache({"alter" : Slash_programs_base_url + "images/32x32/filemanager_32.png", "html_fm_img" : Slash_programs_base_url + "images/32x32/dictionary_32.png", "search_img" : Slash_programs_base_url + "images/32x32/search_32.png", "fd_close_img" : Slash_programs_base_url + "images/others/blocked.png"}, '.
'		 {"alter" : "alter", "html_fm_img" : "html_fm_img", "search_img" : "search_img"}, '.
'		 {}); '.
'	} '.

'	function open_FM_menu(evt) { js_world.removePopup(); js_world.selectDirElementToAlter(evt); } '.
'	function open_DHTML_DBASE_menu(evt) { js_world.removePopup(); js_world.selectDirElementToAlter(evt, "cms/temp/html", true, true); } '.

// Displays input object to set cursor position
'	function dispCursorPosDialog(ref_elmt) { '.
'		var TextElement = document.getElementById("txt_to_save"); '.
'		TextElement.focus(); '.
'		js_world.getSelection(TextElement); '. // Update selection variables
'		js_world.removePopup(); '.
'		js_world.displayPopupAv(\''.$setCursorMenu.'\', ref_elmt, 0, "%"); '.
'		setTimeout(\'var inputObj = document.getElementById("set_cursor_id"); inputObj.focus(); inputObj.select(); \', 0); '.
'	} '.
'	function setNewCursorPos(evt) { '.
'		if (evt == undefined) { evt = window.event; } '.
'		var keycode = evt.charCode || evt.keyCode; '.
'		if (keycode == 13) { '.
'			var inputObj = document.getElementById("set_cursor_id"); '.
'			js_world.selection_start = inputObj.value; '.
'			js_world.selection_range = 0; '.
'			var TextElement = document.getElementById("txt_to_save"); '.
'			js_world.setSelection(TextElement); '.
'			js_world.removePopup(); '.
'			update_cursor_pos(TextElement); '.
'		return false; '.
'		} '.
'	return true; '.
'	} '.
'	function update_cursor_pos(TextElement) { '.
'		js_world.getSelection(TextElement); '. // Update selection variables
'		if (js_world.selection_start == -1) { return false; } '.
'		if (js_world.selection_range) { document.getElementById("CURSOR_POS_ID").innerHTML = js_world.selection_start + "(" + js_world.selection_range + ")"; } '.
'		else { document.getElementById("CURSOR_POS_ID").innerHTML = js_world.selection_start; } '.
'	} '.
'	function searchText(ref_elmt) { '.
'		js_world.removePopup(); '.
'		js_world.displayPopupAv(\''.$searchTextMenu1.'\' + js_world.getHighlightedText() + \''.$searchTextMenu2.'\', ref_elmt, 200, "px"); '.
'		js_world.set_img_cache({}, '.
'		 {"fd_close_img" : "fd_close_img"}, '.
'		 {}); '.
'		setTimeout(\'var inputObj = document.getElementById("find_text_id"); inputObj.focus(); inputObj.select(); \', 0); '.
'	} '.
'	function findText() { '.
'		var TextElement = document.getElementById("txt_to_save"); '.
'		js_world.findTextNextFrom(TextElement, (js_world.selection_start + js_world.selection_range), document.getElementById("find_text_id").value); '.
'		update_cursor_pos(TextElement); '.
'	} '.

'';

//*********************************************************
// Include CMS after defining variable for program path ...
// The variable $javascript will be run in HEAD of HTML as jscript
// And the jscript function initialize_program() will be run when GSF has loaded
// To use jscript support functions: set infront of calls > js_world. < which will address the IFRAME window with isolated jscript functions (GSF)
include(dirname(__FILE__).'/../cms/cms.php'); 

?>
Return current item: Hobby Works