Recommend this page to a friend! |
Top level forums | > | PHP Specialists | > | General | > | Php and JavaScript |
|
Jud - 2009-06-16 08:41:55
Hello
I have a JavaScript file. This file runs flash banners and on top of them is a scrolling HTML marquee. The text for the marquee is entered from a PHP file with a text input. In order for me to write the text from the input into the JavaScript file I have 2 text files. In the PHP file that receives the text for the marquee I concatenate the first part of the JavaScript with the text for the marquee and then I add the last part of the JavaScript file, writing it to the server as anew JavaScript file. It seems I have a problem with either the Unicode of it all or with the server formatting the JavaScript file when it's written… Does any one have any idea??? Php concat file: <?php if($_POST){ writetofile(); } else uploadForm(); //The form hsa a dynamic file uploader function uploadForm() { ?> <HTML> <HEAD> <META NAME='Author' CONTENT='Yehuda Udi Melamed'> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type='text/javascript' src='roll.js'></script> <link rel='StyleSheet' href='style.css' type='text/css' /> </HEAD> <BODY BGCOLOR='#FFFFFF' scroll='no'> <table width=220px align=center cellpadding=4 cellspacing=0 bgcolor='#EDEDED'> <TR class='tblSubHead'><TD colspan=2 align=center>טעינת כתוביות</TD></TR> <form action='' method='POST'> <TR class='txt'><TD align=center colspan=2><INPUT TYPE=text NAME=txtline SIZE=100 MAXLENGTH=250></TD></TR> <TR class='tblSubHead'><TD align=center width=50%><INPUT TYPE=reset value='אפס'></TD> <TD align=center width=50%><INPUT TYPE=submit value='טען'></TD></TR> </form> </table> </body> </html> <?php } function writetofile() { $file = file_get_contents ('jspart1.txt'); $file1 = file_get_contents ('jspart2.txt'); $temp = $_POST[txtline]; $content = $file . $temp . "</STRONG></MARQUEE></FONT>'\n" . $file1; $filename = 'roll.js'; if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $content will go when we fwrite() it. if (!$handle = fopen($filename, 'w')) { echo "($filename)��� �槠Ạ帥ⵠ"; exit; } // Write $content to opene file. if (fwrite($handle, $content) === FALSE) { echo "($filename)��� �桠�ⵠ"; exit; } echo "<CENTER>($temp) הצלחתי לכתוב ($filename) לקובץ</CENTER>\n"; echo "<FONT color='#000080' size='+7'><MARQUEE bgcolor='' direction='left' loop='20' width='100%'><STRONG>".$temp."</STRONG></MARQUEE></FONT>\n"; echo "</b></font></DIV>\n"; fclose($handle); } else { echo "��� �桠�ⵠ$filename "; } } ?> JUST A REMARK ============= THE TEXT PUT IN TO THE $temp is in Hebrew! On most cases I use utf-8.... THE PROBLEM: =========== It all works great, but when the JavaScript file is being read, it does not scroll the marquee.... JavaScript File: ============ // ROLL OBJECT function roll(objName){ this.obj = objName; this.aNodes = []; this.currentroll = 0; this.changeOnRefresh = false; }; // ADD NEW ROLL roll.prototype.add = function(rollType, rollPath, rollDuration, height, width, hyperlink) { this.aNodes[this.aNodes.length] = new Node(this.obj +"_"+ this.aNodes.length, rollType, rollPath, rollDuration, height, width, hyperlink); }; // Node object function Node(name, rollType, rollPath, rollDuration, height, width, hyperlink) { this.name = name; this.rollType = rollType; this.rollPath = rollPath; this.rollDuration = rollDuration; this.height = height this.width = width; this.hyperlink= hyperlink; }; // Outputs the roll to the page roll.prototype.toString = function() { var str = ""; var irollIndex = 0; if(this.changeOnRefresh == true){ // Read the cookie var rollName = this.obj; var lastrollIndex = readCookie(rollName); if(isNaN(lastrollIndex) == true || lastrollIndex == null){ irollIndex = 0; }else if(lastrollIndex == '' || parseInt(lastrollIndex) >= this.aNodes.length - 1){ irollIndex = 0; }else{ irollIndex = parseInt(lastrollIndex) + 1; } // Set the new value createCookie(rollName,irollIndex,7); } for (var iCtr=0; iCtr < this.aNodes.length; iCtr++){ if(this.changeOnRefresh == true && irollIndex != iCtr){ continue; } if (iCtr==0){ str = str + '<DIV STYLE="z-index: 1; position:absolute; left:0; top:780;"><b><font color=blue><FONT color="#000080" size="+7">' str = str + '<MARQUEE bgcolor="" direction="left" loop="20" width="100%"><STRONG>דודודודודודודודו</STRONG></MARQUEE></FONT>' str = str + '</b></font></DIV> ' } str = str + '<DIV STYLE="z-index: 0 position:absolute"> ' str = str + '<span name="'+this.aNodes[iCtr].name+'" ' str = str + 'id="'+this.aNodes[iCtr].name+'" '; if(this.changeOnRefresh == true && irollIndex == iCtr){ str = str + 'class="m_roll_show" '; }else{ str = str + 'class="m_roll_hide" '; } str = str + 'bgcolor="#FFFFFF" '; // CHANGE ROLL COLOR HERE str = str + 'align="center" '; str = str + 'valign="top" >\n'; if (this.aNodes[iCtr].hyperlink != ""){ str = str + '<a href="'+this.aNodes[iCtr].hyperlink+'">'; } if ( this.aNodes[iCtr].rollType == "FLASH" ){ str = str + '<OBJECT ' str = str + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' str = str + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' str = str + 'WIDTH="100%" ' str = str + 'HEIGHT="100%" ' str = str + 'id="bnr_'+this.aNodes[iCtr].name+'" ' str = str + 'ALIGN="CENTER" ' str = str + 'VIEWASTEXT>' str = str + '<PARAM NAME=movie VALUE="'+ this.aNodes[iCtr].rollPath + '">' str = str + '<PARAM NAME=loop VALUE=true>' str = str + '<PARAM NAME=menu VALUE=true>' str = str + '<PARAM NAME=quality VALUE=high>' str = str + '<PARAM NAME=bgcolor VALUE=#FFFFFF>' str = str + '<PARAM NAME=allowfullscreen VALUE=true>' str = str + '<PARAM NAME=wmode VALUE=transparent> ' str = str + '<EMBED '; str = str + 'src="'+this.aNodes[iCtr].rollPath+'" ' str = str + 'quality=high ' // str = str + 'bgcolor=#FFFFFF ' str = str + 'WIDTH="'+this.aNodes[iCtr].width+'" ' str = str + 'HEIGHT="'+this.aNodes[iCtr].height+'" ' str = str + 'NAME="bnr_'+this.aNodes[iCtr].name+'" ' str = str + 'ALIGN="center" ' str = str + 'PARAM NAME=menu VALUE=true' str = str + 'PARAM NAME=allowfullscreen VALUE=true' str = str + 'TYPE="application/x-shockwave-flash" ' str = str + 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">' str = str + '</EMBED>' str = str + '</OBJECT>' str = str + '</DIV>' } if (this.aNodes[iCtr].hyperlink != ""){ str = str + '</a>'; } str += '</span>'; } return str; }; // START THE ROLL ROTATION roll.prototype.start = function(){ if(this.changeOnRefresh == false){ this.changeroll(); var thisrollObj = this.obj; // CURRENT ROLL IS ALREADY INCREMENTED IN changeroll() FUNCTION setTimeout(thisrollObj+".start()", this.aNodes[this.currentroll].rollDuration * 1000); } } // CHANGE ROLL roll.prototype.changeroll = function(){ var thisroll; var prevroll = -1; if (this.currentroll < this.aNodes.length ){ thisroll = this.currentroll; if (this.aNodes.length > 1){ if ( thisroll > 0 ){ prevroll = thisroll - 1; }else{ prevroll = this.aNodes.length-1; } } if (this.currentroll < this.aNodes.length - 1){ this.currentroll = this.currentroll + 1; }else{ this.currentroll = 0; } } if (prevroll >= 0){ document.getElementById(this.aNodes[prevroll].name).className = "m_roll_hide"; } document.getElementById(this.aNodes[thisroll].name).className = "m_roll_show"; } HHHHHHHHHHHHHHHHEEEEEEEEEEEEELLLLLLLLLLLLLLLLLPPPPPPPPPPPPPPPPPPP! Thanx, Jud. There are 2 replies in this thread, which are not being displayed. |
info at phpclasses dot org
.