Javascript and Mysidia

Forum
Last Post
Threads / Messages

Abronsyth

A Headache Embodied
Member
Joined
Aug 25, 2011
Messages
1,012
Points
36
Location
NY
Mysidian Dollar
73,285
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?
 
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). If you want to put the js code in the .php pages, use Comment() objects, they take html and javascript
 
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?
 
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)
 
I must be doing something pretty wrong here XD Used to be so simple *sigh*

Can't get this to work;
PHP:
<?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>"));
}
?>
 
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:

PHP:
$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
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,132
Members
1,603
Latest member
Monako
BETA

Latest Threads

Top