Convert CSS to Javascript

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 38
Joined: Thu Dec 09, 2010 8:13 am

Convert CSS to Javascript

Postby mayhemiz » Wed Apr 27, 2011 12:11 pm

Hello,okay about the subject :)
I wrote a script what converts CSS to jquery css.
I mean this:


It's converts simple things what not containts :hover :active :etc.

Why i did this?
Because i hate the simple CSS,sometimes do big problem when i want to make a website for all browser :)
I wanted to do IF and browser checking.
I did my website without CSS,and looks nice,because it's compatible with Safari,Chrome,Mozilla,IE, i didn't tested the other ones.

How to use:
First upload it to your website or where u can open it.
Open it,and u will see 1 blank textarea,this is where u paste your css.
If u done,click on Convert.
After convert u will see TEXTAREA BUTTON TEXTAREA2
In textarea2 u will see the converted css.
Please report bugs :)

So here it is: (Sorry i don't know how to upload the script)

Code: Select all

<title>Convert CSS to Javascript</title>
html {
<link type='text/css' href='tiddy/cssparse.css' rel='stylesheet'>
<form method="post" action="<?php echo $PHP_SELF;?>">
      <textarea rows="50" style="float: left;   height: 100%;   width: 47.5%; " cols="70" name="jscontent" id="jscontent"></textarea>
      <input style='float:left;bottom:0px;left:0px;width:5%;height:100%;' type='submit' value='Convert'>
function dodo($jsc) {
   $element = explode('{',$jsc);
   $element[0] = preg_replace('/\s+/', '', $element[0]);
   $c = $element[1];
   $element = $element[0]; // ELEMENT(S)
   $hasa = explode(':',$element);
   $c = str_replace('}','',$c);
   $snum = explode(";",$c);
   $styles = $snum;
   $snum = count($snum);
   $i = 0;
   $content = "// ".strtoupper($element)."\n\tcssObj = {\n";
   while ($snum != $i && $snum > $i) {
      $style = explode(':',$styles[$i]);
      $style[0] = preg_replace('/\s+/', '', $style[0]);
      if ($snum == $i+1) { $content .= "\t\t'".$style[0]."' : '".$style[1]."'\n"; $i += 2;
      } else {
         $content .= "\t\t'".$style[0]."' : '".$style[1]."',\n";
   $content .= "\t};\n";
   $content .= "\t$('".$element."').css(cssObj);\n\n";
   return $content;

if (isset($_POST["jscontent"])) {
   //$css = new csstidy();
   //$jscontent = $css->print->plain();
   $jscontent = $_POST["jscontent"];
   $fcontent = "<textarea rows=\"50\" style=\"float: left;   height: 100%;   width: 47.5%; \" cols=\"70\" name=\"jscontent2\" id=\"jscontent2\">\n";
   $expes = explode("}",$jscontent);
   foreach ($expes as $a) {
   $fcontent .= dodo($a);
   $fcontent .= "</textarea>";
   echo $fcontent;

Return to “Your Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest