Wednesday 29 February 2012

Javascript: Function's Parent is DomWindow when referring to 'this'

If you have created an eventlistener or a setInterval and passed in a function which belongs to an Object you may find that the function does not refer to it parent object with 'this but it refers to the DomWindow.

To fix this you need to wrap the function with another function and pass in the parent object:

Example: {
str:"hello world",
start: function() {
var t = this;
this.timer = setInterval(function(){t.todo();},1000);
},

todo : function() {
alert(this.str);
}
};

In this Example I create an object which has a string with the value 'hello world'. I then create a setInterval and pass 'this' (parent object) to the 'todo' function via a wrapper function.

Tuesday 28 February 2012

Dingo CMS: Setup and HowTo


Dingo CMS Alpha Release


Instructions:


1. place the dingo folder into the root of your website.






2. navigate to www.your-website.com/dingo/admin/


3. the username and password is 'admin'



4. Setup pages and labels for your CMS.




4a. you must provide a page ID and if the Element ID is blank you must provide that too.


5. Click on a folder and assign it for image uploading.






5. navigate to www.your-website.com/dingo/


6. the username and password is 'client'



7. update your site.






8. queries/issue contact me at:


fahim@gmx.co.uk 

Monday 27 February 2012

PHP Fix: file_get_contents Not Working

If you are try to load contents of a page using the following functions you maybe suprised to find it not working.


$page =urldecode ($_POST["url"]);
$file = file_get_contents($page, true);
echo rawurlencode($file);

I order to make it work you need to add a file within the folder where the php script is sitting. This file is called 'php.ini'.

In this file add the following line to enable you to use the function above:

allow_url_fopen = On

Thats it!


Basic JavaScript Framework


I always wrap my code within a function which creates a local instance of the window. This is then executed when the Javascript file is loaded.

wrapping the window:
( function(window) {
//
}(window));

Create a function to called 'Main' to set-up variables and event listeners prior to the page loading. Here I will add an event listener to check when the webpage has loaded. You need to create a function called 'loadComplete' to execute when the page is loaded. Finally you will need to call the 'Main' function.

( function(window) {
function Main() {
  if(window.addEventListener) {
   window.addEventListener("load", loadComplete);


  } else {
   window.attachEvent("onload", loadComplete);
  }
 }
   function loadComplete(event) {
  //
    }    
Main();
}(window));

This is the basic framework required to start coding an app or a game.

Tuesday 21 February 2012

DINGO CMS: The Simple CMS

There are hundreds of CMS out there and a few well know ones such as WordPress.

Tho I'm a developer I find them hard to grasp; they are over complicated, template based and you need time to learn how it all works. Don't get me wrong its great for bloggers and article writers but for maintain websites it can be a pain and a burden.

All I want from a CMS  is to update content as quickly and as easily as possible. These days everyone has a website and no one really likes the templates provided by the CMS companies and most people just use a template and pay someone to change it. Not so practical. 

What is required is a CMS which can manage and existing or new site without having to get a developer to put tags onto all of the pages. Also it has to be easy to use, roughly five minutes to figure out how it works.

So that got me thinking and I decided to create yet another CMS but this time with the goal to make is simple,easy to use and can handle and site.

I started working on this idea and a have final completed Dingo CMS. Still in Alpha and a few things left to add but the core functionality is ready. Add me on twitter to keep upto date with the release of version 1. 

What does it offer?

  • Easy to use with two pages; admin and client.
  • Very easy to install, just dump it into your root folder.
  • Set up Labels through the admin panel for each page element.
  • Clients edit content for each label you create.
  • It's Free!

Simple right!

here is some initial screenshots.

Admin Screen:



Client Screen:



Tuesday 14 February 2012

SWF Object Detect the Flash Player Version

var playerVersion = swfobject.getFlashPlayerVersion();

var versionNumber = playerVersion.major;


if ( parseInt(versionNumber) > 9 )
 {
   embedSWF("Main.swf", "flashContent", "754", "426", "10.1",         flashvars, params, attributes, false);
}else{
//Wrong Flash Player Version
}