Monday, May 23, 2011

Link Master - Jquery Print function

Saturday, May 21, 2011

Jquery Simple print script

http://plugins.jquery.com/node/13673

/*


* Simple Print Plugin 1.0

*

* Copyright (c) 2010 Alejandro Robles Ortega

*

* jQuery plugin page : http://plugins.jquery.com/project/simplePrint

*

* Dual licensed under the MIT and GPL licenses:

* http://www.opensource.org/licenses/mit-license.php

* http://www.gnu.org/licenses/gpl.html

*/

$.simplePrint = function(selector)

{

// Crea un nuevo elemento iframe

printArea = document.createElement('iframe');



// Applies styles to hide the item set

$(printArea).attr({style: 'border:0;position:absolute;width:0px;height:0px;left:0px;top:0px;'});



// Add the element to document

document.body.appendChild(printArea);



// Applies the content

printArea.doc = printArea.contentWindow.document;



// Starts the document, writes data and closes

printArea.doc.open();

printArea.doc.write($(selector).html());

printArea.doc.close();



// Focuses on the item and print launches

printArea.contentWindow.focus();

printArea.contentWindow.print();



// Return

return false;



// Remove the element to document

document.body.removeChild(printArea);

}
 
 
 
$('.myPrintLink').click(function()


{

$.simplePrint('#content');

});

Jquery print funciton

http://trevordavis.net/blog/unobtrusive-javascript-print-link-with-jquery

$(document).ready(function() {


$('ul#tools').prepend('
  • Click me to print

  • ');

    $('ul#tools li.print a').click(function() {

    window.print();

    return false;

    });

    });

    Friday, May 20, 2011

    Javascript printout function

    <script language="javascript" type="text/javascript">

    function Clickheretoprint()

    {

    var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";

    disp_setting+="scrollbars=yes,width=450, height=auto, left=0, top=1";

    var content_vlue = document.getElementById("in_print").innerHTML;



    var docprint=window.open("","",disp_setting);

    docprint.document.open();

    docprint.document.write('<html><head><title>Untitled Page</title>');

    docprint.document.write('</head><body onLoad="self.print()"><center>');

    docprint.document.write(content_vlue);

    docprint.document.write('</center></body></html>');

    docprint.document.close();

    docprint.focus();

    }

    </script>



    <div style="height: auto; margin-left: 75px; margin-top:25px" id="in_print" runat="server">

    <p>Add Some more tag and text</p>

    <div>

    Thursday, May 19, 2011

    Conditional for IE6, or just IE? -- Jquery

    if (jQuery.browser.msie) {


    if(parseInt(jQuery.browser.version) == 6) {

    $('#couponTop, #couponBottom').css('background',"none");

    }

    Wednesday, May 18, 2011

    500 - JDatabaseMySQL::query: 1064 error

    I know this is an old one, but I didn't see an easy response anywhere out there. In my case I had a similar problem to Rhand, I enabled debug mode and got the 500 error on the entire site, including the admin login page - so I couldn't disable it. I had to go digging and I found the debug setting myself.
    Go to configuration.ini and set line 7 to :
    var $debug = '0';

    PHP unzip script




    function unzipnew($src_file, $dest_dir=false, $create_zip_name_dir=true, $overwrite=true, $delzip=false)

    {

    if ($zip = zip_open($src_file))

    {

    if ($zip)

    {

    $splitter = ($create_zip_name_dir === true) ? "." : "/";

    if ($dest_dir === false) $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter))."/";

    // else $dest_dir = $desdir."/";



    // Create the directories to the destination dir if they don’t already exist

    create_dirs($dest_dir);



    // For every file in the zip-packet

    while ($zip_entry = zip_read($zip))

    {

    // Now we’re going to create the directories in the destination directories

    // If the file is not in the root dir

    $pos_last_slash = strrpos(zip_entry_name($zip_entry), "/");

    if ($pos_last_slash !== false)

    {

    // Create the directory where the zip-entry should be saved (with a "/" at the end)

    create_dirs($dest_dir.substr(zip_entry_name($zip_entry), 0, $pos_last_slash+1));

    }

    // Open the entry

    if (zip_entry_open($zip,$zip_entry,"r"))

    {



    // The name of the file to save on the disk

    $file_name = $dest_dir.zip_entry_name($zip_entry);

    // Check if the files should be overwritten or not

    if ($overwrite === true

    $overwrite === false && !is_file($file_name))

    {

    // Get the content of the zip entry

    $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));



    file_put_contents($file_name, $fstream );

    // Set the rights

    chmod($file_name, 0777);

    echo "save: ".$file_name."
    ";

    }

    // Close the entry

    zip_entry_close($zip_entry);

    }

    }

    // Close the zip-file

    zip_close($zip);

    if($delzip) unlink($src_file);

    }

    }

    else

    {

    return false;

    }

    return true;

    }



    /** * This function creates recursive directories if it doesn’t already exist

    * * @param String The path that should be created * * @return void */

    function create_dirs($path)

    {

    if (!is_dir($path))

    {

    $directory_path = "";

    $directories = explode("/",$path);

    array_pop($directories);



    foreach($directories as $directory)

    {

    $directory_path .= $directory."/";

    if (!is_dir($directory_path))

    {

    mkdir($directory_path);

    @chmod($directory_path, 0777);

    }

    }

    }

    }





    $dirLocal ='ex23.zip';

    unzipnew($dirLocal, false, true, true,false)



    ?>