File tree Expand file tree Collapse file tree 5 files changed +49
-2
lines changed Expand file tree Collapse file tree 5 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -585,17 +585,19 @@ class WriteItNode {
585585 }
586586}
587587const WriteItJS = new WriteIt ( ) ;
588+
588589// Automatically start Animation if writeit-auto-start attribute is present,
589590// this is not related with the animation of node
590591// but, it starts parsing each node which has "writeit-animate"
591592if ( document . querySelector ( "*[" + WriteItJS . WRITEIT_AUTO_START + "]" ) ) {
592593 WriteItJS . startAnimation ( ) ;
593594}
595+
594596// add other WriteItJS function as an array object so they don't get ignored by Closure ADVANCE settings.
595597window [ "WriteItJS" ] = WriteItJS ;
596598window [ "WriteItJS" ] [ "startAnimation" ] = WriteItJS . startAnimation ;
597599window [ "WriteItJS" ] [ "pauseAnimation" ] = WriteItJS . pauseAnimation ;
598600window [ "WriteItJS" ] [ "resumeAnimation" ] = WriteItJS . resumeAnimation ;
599601window [ "WriteItJS" ] [ "startAnimationOfNode" ] = WriteItJS . startAnimationOfNode ;
600602// other functions are not necessary for users[programmers].
601- console . log ( "WriteIt.js v2.0 loaded!👍 , visit https://github.com/khushit-shah/WriteIt.js" ) ;
603+ console . log ( "WriteIt.js v2.0 loaded!, visit https://github.com/khushit-shah/WriteIt.js" ) ;
Original file line number Diff line number Diff line change 244244 < script src ="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js "> </ script >
245245 < script src ="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/easing/EasePack.min.js "> </ script >
246246 < script src ="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenLite.min.js "> </ script >
247+
247248 < script src ="https://cdn.jsdelivr.net/gh/khushit-shah/WriteIt.js@latest/WriteIt.js "> </ script >
249+ <!-- DEVELOPMENT <script src="/WriteIt.js"></script> -->
248250 < script src ="js/script.min.js "> </ script >
249251 < script >
250252 let scroll = ( ) => { window . scroll ( 0 , 10000 ) ; }
Original file line number Diff line number Diff line change 1+ """
2+ On Every change:
3+ send request to google closure compiler!
4+ download the compiled script and write it to WriteIt.min.js
5+ """
6+ import os
7+ import time
8+ import requests
9+
10+ FILE_PATH = "../WriteIt.js"
11+ OUT_FILE_PATH = "../WriteIt.min.js"
12+ CLOSURE_API_URL = "https://closure-compiler.appspot.com/compile"
13+ COMPILATION_LEVEL = "ADVANCED_OPTIMIZATIONS"
14+
15+
16+ def getCompiledCode (jscode ):
17+ params = {
18+ "js_code" : jscode ,
19+ "compilation_level" : COMPILATION_LEVEL ,
20+ "output_format" : "text" ,
21+ "output_info" : "compiled_code"
22+ }
23+ result = requests .post (CLOSURE_API_URL , data = params )
24+
25+ if (result .status_code < 200 or result .status_code >= 300 ):
26+ print (result .status_code , result .text )
27+ raise Exception ("Some Error Occured!" )
28+
29+ return result .text
30+
31+
32+ def compileAndSave ():
33+ jscode = open (FILE_PATH , 'r+' ).read ()
34+ compiledCode = getCompiledCode (jscode )
35+ open (OUT_FILE_PATH , "w+" ).write (compiledCode )
36+
37+ fileStamp = os .stat (FILE_PATH ).st_mtime
38+
39+ while True :
40+ time .sleep (1 )
41+ if fileStamp != os .stat (FILE_PATH ).st_mtime :
42+ compileAndSave ()
43+ fileStamp = os .stat (FILE_PATH ).st_mtime
You can’t perform that action at this time.
0 commit comments