TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,965
  • Latest: boruko
Stats
  • Total Posts: 195,980
  • Total Topics: 21,320
  • Online today: 795
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 191
  • Total: 191

HTML/Javascript Block editor issue

Started by Underdog, March 14, 2011, 10:42:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Underdog

My Site: Local testing of my own modification (Premiumbeat) and Tiny Portal HTML/Javascript Block
SMF Versions: SMF 1.1.13 and SMF 2.0 RC5
TP Version: 1.0 Rc1
Forum Language: English
Theme Name: Default Curve
Browser: Tested with Firefox 3.615, IE 7 32 bit, IE 8 64 bit, Google Chrome (I test mods in all these browsers)
Mods installed: For this test only Tiny Portal and Premiumbeat for SMF v1.8
Error Messages: None. It simply will not work with the latest TP version using HTML/Javascript block




HTML/Javascript Block editor issue:

When entering data in the block and then saving it... It executes the code from within the block.
This makes it very difficult as one can not view the code afterward for editing or trouble shooting. IMO - a preview button would work better.

Also: I am not sure if it was an option on an older version or if I just haven't figured out a setting but didn't there use to be a 'Scriptblock' option in the block list specifically aside from the html/javascript block option?
I have a mod that used the scriptblock which worked just fine but does not operate in the current html/javascript block.

Note: Scriptblock for version 0.983 works perfectly with the html/javascript code used with the mp3 player.
         If testing this using the Premiumbeat Player - Please download from SMF Main but use the HTML block code from the post/thread - not from the install as it has been modified/corrected.

IchBin

Thanks bringing this out of the bugtracker Underdog. The scriptbox is the same as HTML/JavaScript block. While it may not work for you at this time, I suspect it may be because of the changes in the way the data is handled between storing in the database and then pulling it out.

I'm not sure what you mean by "It executes the code from within the block". Can you explain that any better? When I put in some html, the code is saved just fine. Are you using the editor? If so, there is a little button that looks like this <> that you can click on to see the HTML. You can then click the "hide html" button to change it back to the editor.

If you are having some problems with a particular piece of code, please post that code using the BBC code tags in your next reply so we can test it.

lurkalot

Quote from: Underdog on March 14, 2011, 10:42:43 PM

When entering data in the block and then saving it... It executes the code from within the block.
This makes it very difficult as one can not view the code afterward for editing or trouble shooting. IMO - a preview button would work better.


Hi UD.  ;)

What happens when you you use the toggle view button?  <>  Does the code come back, or disappear completely?

EDIT: IchBin beat me to it.  ;)

Underdog

Quote from: IchBin on March 14, 2011, 11:21:56 PM
Thanks bringing this out of the bugtracker Underdog. The scriptbox is the same as HTML/JavaScript block. While it may not work for you at this time, I suspect it may be because of the changes in the way the data is handled between storing in the database and then pulling it out.

I'm not sure what you mean by "It executes the code from within the block". Can you explain that any better? When I put in some html, the code is saved just fine. Are you using the editor? If so, there is a little button that looks like this <> that you can click on to see the HTML. You can then click the "hide html" button to change it back to the editor.

If you are having some problems with a particular piece of code, please post that code using the BBC code tags in your next reply so we can test it.

The javascript code:




<div style="text-align: center; position: fixed; top: 2%; right: 1%;"><input src="http://i272.photobucket.com/albums/jj187/ginger_face/mymusic.gif" alt="Mp3 Player" title="Mp3 Player" onclick="mp3popup('index.php?action=customMusicPopup;playlist=11;','Premiumbeat','230','230','center','front');" type="image"></div>

<script type="text/javascript">
<!--
var mp3popupWindow=null;
function mp3popup(mypage,myname,w,h,pos,infocus){

if (pos == 'random')
{LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
else
{LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
settings='width='  w   ',height='  h   ',top='   TopPosition   ',left='   LeftPosition   ',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';mp3popupWindow=window.open('',myname,settings);
if(infocus=='front'){mp3popupWindow.focus();mp3popupWindow.location=mypage;}
if(infocus=='back'){mp3popupWindow.blur();mp3popupWindow.location=mypage;mp3popupWindow.blur();}

}
// -->
</script>


You were correct about that html button/link and I didn't know I had to press that to see the code. My apologies for not being aware of it but I am not familiar with the intricacies of this portal just yet.

The above code simply puts a fixed button in the top-right of the page which executes a popup function of the mp3 player.
This works fine using the other TP version with the scriptblock and also using SP's html/script block. However, I do not seem to be able to get it to work using your portal's latest version html/javascript block.


Underdog

#4
I figured out something even better!!

I just fixed the popup for the arcade the other day and decided to adapt the code I was using for it to use with the player.
The result is a PHP block where the user can easily adjust the playlist ID & dimensions from the top plus this will also allow me to use $SESSION to disallow unwanted use playing of the playlist (I will implement l8r)  ;D .. I am happy about that.

Here is the PHP code btw:

/* Adjustable variables */
$playlist ='1';
$width = '190';
$height = '230';

$url = 'index.php?action=customMusicPopup;playlist='.$playlist.';';
$icon = '<img src ="http://i272.photobucket.com/albums/jj187/ginger_face/mymusic.gif" style="position:fixed;top:0px;right:0px;" />';

/*  Do not adjust below this line  */

echo ' <script type="text/javascript">
<!--
var WindowObjectReference = null;
function myPremiumbeatPopup(strURL,strWidth,strHeight)
{
var strOptions="";
var strType = "console";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
WindowObjectReference = window.open(strURL, "newWin", strOptions);
WindowObjectReference.focus();
}
//-->
</script>';

$pop = '<a href="javascript:void(0)" onclick="myPremiumbeatPopup(\''.$url.'\',\''.$width.'\',\''.$height.'\')">'.$icon.'</a>';

echo $pop;


My apologies for the bother.. Sometimes I have brain farts.   :uglystupid2:

IchBin

It's a wisywig editor so you can't enter code directly into it when you're not in "code" mode. You can paste your code right into the textbox if you click the <> button and the code works just fine. Glad you figured out something better though. :)

This website is proudly hosted on Crocweb Cloud Website Hosting.