View Full Version : Javascript and Mysidia
Abronsyth
07-22-2014, 09:33 AM
I know that when I first started working with Mysidia, I was able to create some pretty entertaining games and an explore feature by incorporating Javascript into it.
I haven't been able to actually work with the script in ages now, because I haven't been able to even get it to function and allow me to login, but hoping that someday it will work for me, does anyone know how javascript compatable Mysidia is?
IntoRain
08-12-2014, 09:22 PM
It works normally with mysidia once you get the hang of it, including jquery and ajax (though ajax is a bit more awkward if you don't use the widget option, like Kyttias does (http://www.mysidiaadoptables.com/forum/showthread.php?t=4600)). If you want to put the js code in the .php pages, use Comment() objects, they take html and javascript
Abronsyth
08-21-2014, 09:39 AM
Or rather, if I am wanting to create a game of pure javascript, and I simply want it to be surrounded by the site theme so it looks like part of the content, how would I go about doing that?
IntoRain
08-21-2014, 02:21 PM
Just write the whole script inside Comment(), like
$document->add(new Comment("<script>your javascript here</script>")); (if you are on 1.3.4, do this on the view file and not in the controller file)
Abronsyth
09-06-2014, 05:38 PM
I must be doing something pretty wrong here XD Used to be so simple *sigh*
Can't get this to work;
<?php
class BlankController extends AppController{
private $view;
private $subController;
public function __construct(){
parent::__construct();
}
public function index(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
}
$document->add(new Comment("<script language="JavaScript">
// ==============================================
// Copyright 2004 by CodeLifter.com
// Free for all; but please leave in this header.
// ==============================================
var Quotation=new Array() // do not change this!
// Set up the quotations to be shown, below.
// To add more quotations, continue with the
// pattern, adding to the array. Remember
// to increment the Quotation[x] index!
Quotation[0] = "Quote 1";
// ======================================
// Do not change anything below this line
// ======================================
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();</script>"));
}
?>
IntoRain
09-06-2014, 07:22 PM
See the change of color? The " is closing the comment here:
$document->add(new Comment("<script language=" <-- this closed it
Inside comments, try to use '' instead of quotation marks, try this:
$document->add(new Comment("<script language='JavaScript'>
// ==============================================
// Copyright 2004 by CodeLifter.com
// Free for all; but please leave in this header.
// ==============================================
var Quotation=new Array() // do not change this!
// Set up the quotations to be shown, below.
// To add more quotations, continue with the
// pattern, adding to the array. Remember
// to increment the Quotation[x] index!
Quotation[0] = 'Quote 1';
// ======================================
// Do not change anything below this line
// ======================================
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();</script>"));
Also, I'm not sure if document.write will write the sentence in the right place. If it doesn't, you will have to add an element with Comment() (like $document->add(new Comment("<p class='quote'></p>")) or something) and then in the javascript fill the element with what you want
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.