<?php
require_once(__DIR__.SLASH.'ReadmeType.class.php');
class JsType extends ReadmeType{

	public static function manifest(){
		return array(
			'uid' => 'js',
			'label' => 'Javascript',
			'icon' => 'fab fa-js',
			'color' => '#ffffff',
			'background' => '#f0db4f',
			'description' => 'Fichier contenant du langage Javascript',
			'fromExtension' => array('js'),
			'toExtension' => 'js',
			'default' => '',

		);
	}

	/* EDITION */
	public static function toHtml($resource,$sketch=null){
		$infos = self::manifest();
		return array(
			'html'=>'<textarea id="content" onblur="hackpoint_resource_save_content()" class="arduino-text">'.$resource->content.'</textarea>',
			'javascript' => "
				hackpoint_resource_mirrorify('.arduino-text',{
					mode : 'javascript',	
					lineNumbers : true,
					theme : 'monokai',
					readOnly : false
				});
			"
		);
	}

	//Export vers un fichier brut
	public static function toFile($resource){
		$infos = self::manifest();
		return array(
			'name'=> slugify($resource->label).'.'.$infos['toExtension'],
			'content' => html_entity_decode($resource->content)
		);
	}


	
}
?>