Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

May 31, 2020, 07:08:07 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 190049
  • Total Topics: 20834
  • Online Today: 105
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 2
Guests: 99
Total: 101

Author Topic: HTML/Javascript Block editor issue  (Read 5389 times)

0 Members and 1 Guest are viewing this topic.

Offline Underdog

  • Newbie
  • *
  • Posts: 3
HTML/Javascript Block editor issue
« on: March 14, 2011, 04:42:43 PM »
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.
 

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: HTML/Javascript Block editor issue
« Reply #1 on: March 14, 2011, 05: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.

Online lurkalot

  • Administrator
  • *
  • Posts: 6624
    • Camera Craniums
Re: HTML/Javascript Block editor issue
« Reply #2 on: March 14, 2011, 05:32:36 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.  ;)

Offline Underdog

  • Newbie
  • *
  • Posts: 3
Re: HTML/Javascript Block editor issue
« Reply #3 on: March 14, 2011, 05:48:21 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:

Code: [Select]


<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.


Offline Underdog

  • Newbie
  • *
  • Posts: 3
Re: HTML/Javascript Block editor issue
« Reply #4 on: March 14, 2011, 06:59:32 PM »
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:
Code: [Select]
/* 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:
« Last Edit: March 14, 2011, 09:03:53 PM by Underdog »

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: HTML/Javascript Block editor issue
« Reply #5 on: March 15, 2011, 08:01:57 AM »
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. :)