js-switcher

4.0.0 • Public • Published

switcherjs

a lightweight javascript framework to create single-page web application it converts your directory into a single html file.

uses

install switcherjs
create a folder anywhere
create subfolder and file in your folder
every subfolder will be a case with switch block
every file in the subfolder will be its cases
files in main folder will also be cases
files in every folder without extension of names
    top-- will place the containing code at the top of switch block (for main folder it will place code at top of script)
    bot-- will place the containing code at the bottom of switch block (for main folder it will place code at bottom of script)
    def-- the default condition code for specific folder
files in main folder
    style-- code to place at style tag in html.
    head-- code to place at head tag in html.
    body-- code to place at body tag in html.
if top,bot,def,style,head and body are gonna your cases then provide extention to them .js.
now the script in the file contain a giant function with switch blocks named as your main folder
and to use this function you have to use like
folder_name('path/of/code');
this will execute the respected code in provided path 
note:- '/' is the separator
ex.
i have a code console.log("hi"); in file bar.js in a subfolder foo in my main folder then to execute this i have to use
main_folder_name("foo/bar",other_arguments); //use arg[] to access arguments
note:- no need of providing file extentions

structure of output file

it will generate a file with name of your main folder with extention html in output folder
this file is just combination of your code in selected folder so errors may occure.

```
<html>
<head>
<title>main_folder_name</title>
<style type=text/css>
contents of main_folder_name/style file
</style>
<script type=text/javascript>
main_folder_top_file contents    
function main_folder_name(...arg){
switch(arg[0]?arg[0].split("/")[0]:"default"){
case 'subfolder_name':
subfolder_top_file contents
switch(arg[0]?arg[0].split("/")[1]:"default"){
case 'subfolder_file_name':
subfolder_file_name contents
break;
default:
subfolder_def_file contents
}
subfolder_bot_file contents
break;
case 'main_folder_file_name':
main_folder_file_name contents
break;
default:
main_folder_def_file contents
}
}
main_folder_bot_file contents    
</script>
main_folder_head_file contents
</head>
<body onload=main_folder_name();>
main_folder_body_file contents 
</body>
</html>

```

Installation

npm install switcherjs

Hello World Example on windows

open terminal

run command

```install switcherjs```
    
now copy app folder from node_modules/js-switcher to your main folder

now run 

```node node_modules/js-switcher/index,js``` 

after that it will open your output/app.html in browser

donation

donate via paytm using ID (+91 9595095401) to provide more features and maintain this project.

dependancies

this package has devloped using node's core modules fs , path and child_process.

Package Sidebar

Install

npm i js-switcher

Weekly Downloads

1

Version

4.0.0

License

ISC

Last publish

Collaborators

  • yashbora