```, *Adding the attribute* **cglink** *turns any element into a controller. Note: cglink binds the controller to a* **[stage]**
-* :new: To update any element dynamically, add the **cg-hot** class. This updates the element and its children every time the page changes.
+* To update any element dynamically, add the **cg-hot** class. This updates the element and its children every time the page changes.
* To add additional features, use a plug-in:
@@ -30,13 +30,38 @@
### Script
If the Stage is the Body, and the Core is the Mind, then Scripts are the Soul. The Script is a JSON file that sets up the configuration options and adds images for each page. [This is how to do it.](https://github.com/ogewan/comix-ngn/wiki/How-to-Script)
+#### Additive
+:new: an additive is a simplified JSON file that expedites the addition of comic pages.
+The following is the structure:
+``` js
+ {"p":[
+ imageurl 1, imageurl 2, imageurl 3, etc...
+ ]}
+ ```
+To enable the additive feature:
+Add the **additive** attribute to selected venue
+
+or
+Add an address to the additive option in the config section of the Script.JSON
### Attributes
For more fine-grain control, use the following additional attributes or class properties:
* __SPECIAL__ - These classes change the properties of whatever they are set on.
* __cgdate__ - This sets the elements [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) or inner text to the release date of Stage page.
* __cgtitle__ - This sets the elements [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) or inner text to the title of Stage page.
* __CORE__ - These attributes customizes settings and performance of comix-ngn.
+ * __fBox__ - fBox functions as a sort of fusebox that globally toggles many options:
+(*Note: fBox requires the following format "{'option': true/false}"*)
+
+ ``````
+
+ * __fstrun__ (bool): toggles stageInjection on page load
+ * __pgepsh__ (bool): toggles url change on slide change
+ * __pgesve__ (bool): toggles slide number saving in localStorage
+ * __protect__ (bool): by default, the comix(main comic) is set once, if protect is set to default, the comix is overwritten per stageInjection
+ * __noverwrite__ (bool): by default, stageInjection cannot overwrite already inserted comics, set to false to allow overwriting
+ * __arrow__ (bool): toggles arrow key navigation
+
* __comicID__ - This sets the ID of the comic which is allows the framework to save site specific settings to user's browsers, such as most recently viewed page. It will default to the website's host name if not given.
``````
diff --git a/additive.json b/additive.json
new file mode 100644
index 0000000..e628416
--- /dev/null
+++ b/additive.json
@@ -0,0 +1 @@
+{"p":["http://pre03.deviantart.net/fe47/th/pre/f/2014/301/8/3/how_to_po__page_06_by_ladisilverfox-d84ix3x.jpg","http://pre06.deviantart.net/0c7f/th/pre/f/2014/301/6/9/how_to_po__page_07_by_ladisilverfox-d84ix44.jpg","http://pre03.deviantart.net/9240/th/pre/f/2014/301/0/4/how_to_po__page_08_by_ladisilverfox-d84ix4e.jpg","http://pre04.deviantart.net/d793/th/pre/f/2014/301/c/1/how_to_po__page_09_by_ladisilverfox-d84ix4p.jpg","http://pre07.deviantart.net/f25b/th/pre/f/2014/301/3/7/how_to_po__page_10_by_ladisilverfox-d84ix4x.jpg","http://pre06.deviantart.net/b853/th/pre/f/2014/301/3/4/how_to_po__page_11_by_ladisilverfox-d84ix56.jpg","http://pre05.deviantart.net/48ee/th/pre/f/2014/301/e/2/how_to_po__page_12_by_ladisilverfox-d84ix5b.jpg","http://pre05.deviantart.net/7811/th/pre/f/2015/075/b/b/how_to_po__page_13_by_ladisilverfox-d8m13ky.jpg","http://pre01.deviantart.net/42c8/th/pre/f/2015/075/b/2/how_to_po__page_14_by_ladisilverfox-d8m12mn.jpg","http://pre11.deviantart.net/ad85/th/pre/f/2015/075/b/9/how_to_po__page_15_by_ladisilverfox-d8m12my.jpg","http://pre03.deviantart.net/a4d3/th/pre/f/2015/075/7/7/how_to_po__page_16_by_ladisilverfox-d8m12n8.jpg","http://pre04.deviantart.net/f7bc/th/pre/f/2015/075/4/f/how_to_po__page_17_by_ladisilverfox-d8m12nc.jpg","http://pre04.deviantart.net/d8d6/th/pre/f/2015/075/1/b/how_to_po__page_18_by_ladisilverfox-d8m12nn.jpg","http://pre03.deviantart.net/1492/th/pre/f/2015/075/9/0/how_to_po__page_19_by_ladisilverfox-d8m12nw.jpg","http://pre04.deviantart.net/ff2a/th/pre/f/2015/075/b/f/how_to_po__page_20_by_ladisilverfox-d8m12o8.jpg","http://pre00.deviantart.net/d0fd/th/pre/f/2015/075/d/0/how_to_po__page_21_by_ladisilverfox-d8m12od.jpg","http://pre05.deviantart.net/990a/th/pre/f/2015/075/1/b/how_to_po__page_22_by_ladisilverfox-d8m12oj.jpg","http://pre12.deviantart.net/6acc/th/pre/f/2015/075/b/b/how_to_po__page_23_by_ladisilverfox-d8m12oo.jpg","http://pre04.deviantart.net/f10b/th/pre/f/2015/075/6/8/how_to_po__page_24_by_ladisilverfox-d8m12ox.jpg","http://pre14.deviantart.net/5c7d/th/pre/f/2015/075/f/a/how_to_po__page_25_by_ladisilverfox-d8m12p0.jpg","http://pre13.deviantart.net/5d92/th/pre/f/2015/075/6/4/how_to_po__page_26_by_ladisilverfox-d8m12p8.jpg","http://pre14.deviantart.net/710a/th/pre/f/2015/099/a/7/how_to_po__page_27_by_ladisilverfox-d8p3ggk.jpg","http://pre04.deviantart.net/d0aa/th/pre/f/2015/099/b/3/how_to_po__page_28_by_ladisilverfox-d8p3gh2.jpg","http://pre14.deviantart.net/aadf/th/pre/f/2015/099/4/e/how_to_po__page_29_by_ladisilverfox-d8p3ghx.jpg","http://pre05.deviantart.net/f0e5/th/pre/f/2015/099/8/8/how_to_po__page_30_by_ladisilverfox-d8p3gi4.jpg","http://pre00.deviantart.net/8eb3/th/pre/f/2015/099/a/1/how_to_po__page_31_by_ladisilverfox-d8p3gic.jpg","http://pre11.deviantart.net/f04a/th/pre/f/2015/099/9/7/how_to_po__page_32_by_ladisilverfox-d8p3gis.jpg","http://pre04.deviantart.net/0e56/th/pre/f/2015/099/3/8/how_to_po__page_33_by_ladisilverfox-d8p3gj6.jpg","http://pre12.deviantart.net/411c/th/pre/f/2015/200/0/1/how_to_po__page_34_by_ladisilverfox-d91zcnc.jpg","http://pre03.deviantart.net/8e5c/th/pre/f/2015/200/1/0/how_to_po__page_35_by_ladisilverfox-d91zcnv.jpg","http://pre02.deviantart.net/086b/th/pre/f/2015/200/0/6/how_to_po__page_36_by_ladisilverfox-d91zco7.jpg","http://pre09.deviantart.net/cf1e/th/pre/f/2015/200/7/7/how_to_po__page_37_by_ladisilverfox-d91zcp6.jpg"]}
\ No newline at end of file
diff --git a/comixngn.js b/comixngn.js
index 4388be7..5a3b8a1 100644
--- a/comixngn.js
+++ b/comixngn.js
@@ -1,4 +1,4 @@
-/** @preserve comix-ngn v1.1.1 | (c) 2015 Oluwaseun Ogedengbe| ogewan.github.io/comix-ngn/ |License: MIT|
+/** @preserve comix-ngn v1.2.0 | (c) 2015 Oluwaseun Ogedengbe| ogewan.github.io/comix-ngn/ |License: MIT|
embeds domReady: github.com/ded/domready (MIT) (c) 2013 Dustin Diaz, pegasus: typicode.github.io/pegasus (MIT) (c) 2014 typicode, pathjs (MIT) (c) 2011 Mike Trpcic, direction.js*/
/*The namespace of comix-ngn
all variables should be properties of this to prevent global namespace pollution*/
@@ -9,7 +9,15 @@ cG.N =function(){return 0};/*null function*/
if(void 0===cG.$GPC){cG.$GPC=0;}/*Global Plugin Counter (no longer global)*/
cG.root = '';/*current default settings of cng, overwritten by plugins*/
cG.cPanel = cG.cPanel||{};/*cG control panel, all stages are stored here*/
-cG.info = {vix: "1.1.1",vwr: "0.5.0",vpr: "0.1.0"};/*version settings*/
+cG.fBox = cG.fBox||{fstrun: true, pgepsh: true, pgesve: true, rtepge: true, protect: true, noverwrite: true, arrow: true};/*cG fuse box, toggles various options
+* fstrun - toggles automatic stage injection on document ready
+* pgepsh - toggles page url push to urlbar and history
+* pgesve - toggles page saving in localstorage
+* rtepge - toggles routing
+* protect - toggles comix settings
+* noverwrite - by default, stageInjection cannot overwrite already inserted comics, set to false to allow overwriting
+* arrow - toggles arrow key navigation */
+cG.info = {vix: "1.2.0.",vwr: "1.0.0",vpr: "0.1.0"};/*version settings*/
cG.dis = cG.dis||{};//disables statistic and error reporting
cG.recyclebin = cG.recyclebin||{};//variables that are used in initialization, disposed at stage injection
cG.queue = cG.queue||{};//stores functions that are called incertain events
@@ -57,6 +65,9 @@ cG.controllers = cG.controllers||{};//stores all nav bars that control stages he
if(selfScript.getAttribute("air") !== void 0&&selfScript.getAttribute("air")!==null){
cG.recyclebin.air=selfScript.getAttribute("air");//asset path override
}
+ if(selfScript.getAttribute("fBox") !== void 0&&selfScript.getAttribute("fBox")!==null){
+ cG.fBox = JSON.parse(selfScript.getAttribute("fBox"));//asset path override
+ }
}
}()
@@ -142,21 +153,300 @@ cG.REPO.producer = {"def":cG.N};
///////
cG.REPO.stage = {"def":{id:"def",construct:function(name,scriptt,anchor,options){
- var direction=function(d,m,v,b){b=b||{};var l={parent:null,offset:0,loading:{lines:b.lines||16,rate:b.rate||1E3/30,diameter:b.diameter||250,back:b.loaderback||"#FFF",color:b.color||"#373737"},config:{dir:b.dir||"assets/",pagestartnum:!1,chapterstartnum:!1,imgprebuffer:b.imgprebuffer||5,imgpostbuffer:b.imgpostbuffer||5,startpage:0,back:b.back||"#FFF"},pages:[]};if(void 0===d)return-1;if("string"===typeof d)l.pages.push({alt:"",hover:"",title:"",url:[d],release:0,note:"",perm:!1,anim8:!1}),d=l;else if(Array.isArray(d)){for(b=
-0;b=b)b=400;0>a.y&&(a.y=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight);0>a.x&&(a.x=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth);var c={x:void 0!==window.pageXOffset?a.x-window.pageXOffset:a.x-document.documentElement.scrollLeft,y:void 0!==window.pageYOffset?a.y-window.pageYOffset:a.y-document.documentElement.scrollTop};if(c=={x:0,y:0})return c;var d=function(a,
-b,c){window.scrollBy(Math.floor(a.x)/b,Math.floor(a.y)/b);c+1<5*b&&window.setTimeout(d,5,a,b,c+1)};window.setTimeout(d,5,c,Math.floor(b/5),0);return c},l=function(){e[this.imaginaryID].loaded=!0},r=function(a,b){y=!0;window.setTimeout(F,p.rate,E);B();0>b&&(b=0);b>=h&&(b=h-1);e[b].loaded||A.clearRect(0,0,c[1].width,c[1].height);a.imaginaryID=b;a.src=q.dir+e[b].url[0];n=b;for(var d=0,f=b-1;f>b-q.imgprebuffer-1&&0<=f;f--)e[f].loaded||(u[d].imaginaryID=f,u[d].src=q.dir+e[f].url,d++);d=0;for(f=b+1;f=count) idd=count-1; //can not be equal to our higher than the amount of pages
+ if(!iimg[idd].loaded) context.clearRect(0, 0, layers[1].width, layers[1].height);
+ imagething.imaginaryID = idd;
+ console.log(config.dir+iimg[idd].url[0]);
+ imagething.src = config.dir+iimg[idd].url[0];
+ current = idd;//we change page as soon as it is assigned, so that page still changes even if it never loads
+ /*console.log("----");
+ for(var q = idd-1;q>idd-self.config.imgprebuffer-1&&q>=0;q--){
+ console.log(q);
+ }
+ console.log("//");
+ for(var q = idd+1;qidd-config.imgprebuffer-1&&q>=0;q--){
+ if(iimg[q].loaded) continue;
+ preload[r].imaginaryID = q;
+ preload[r].src = config.dir+iimg[q].url;
+ r++;
+ }
+ r = 0;
+ for(var q = idd+1;q0)?slidend:slidestart:sliding;
+ if(type)
+ if(type>0) slidend = callback;
+ else slidestart = callback;
+ else sliding = callback;
+ return 1;
+ }
+ this.go = function(to){
+ var sre = (to===null||void 0===to)?0:parseInt(to,10);
+ //console.log(sre);
+ sre = (isNaN(sre))?0:sre;
+ assign(master,(Math.floor(Math.max(0,Math.min(count-1,sre)))));
+ return sre;
+ }
+ this.prev = function(){
+ var sre = current-1;//avoids possible race condition, assign loads in new image which can call preloadMaster which can change self.current before it gets to the return call. storing it premptively will preserve the value
+ if(sre>=0) assign(master,sre);
+ return sre;
+ }
+ this.next = function(){
+ //console.log("Hello");
+ var sre = current+1;
+ if(sre=0) assign(master,0);
+ return 0;
+ }
+ this.last = function(){
+ assign(master,count-1);
+ return count-1;
+ }
+ this.rand = function(){
+ var sre = Math.floor(Math.random() * (count-1));
+ //console.log(sre);
+ assign(master,sre);
+ return sre;
+ }
+ this.data = function(to){//returns info about slide
+ var sre = (to===null||void 0===to)?current:parseInt(to,10);
+ return (isNaN(sre))?iimg[current]:iimg[(Math.floor(Math.max(0,Math.min(count-1,sre))))];
+ }
+ this.scroll = function(bool){//toggles Auto Scrolling
+ if(bool===null||void 0===bool) return skroll;
+ return skroll=bool;
+ }
+ this.scrollTo = function(to,time){return scrollit(to,time);}//public wrapper for scrollit
+ //LOADER - setup
+ layers[0].height=480;
+ //layers[0].width=640;
+ layers[0].style.background=spinner.back;
+ layers[0].style.paddingLeft="170px";
+ layers[0].style.zIndex=0;
+ layers[0].style.position="absolute";
+
+ //objref = object;
+ //console.log(layers[1]);
+ if(anchor) anchor.appendChild(layers[0]);
+ else document.body.appendChild(layers[0]);
+ //console.log(object);
+ //intervall=window.setInterval(spin, spinner.rate, object);
+ window.setTimeout(spin, spinner.rate, object);
+ //DISPLAY - setup
+ master = new Image();
+ master.imaginaryID = -1;//unset to an imaginary image
+ master.addEventListener("load", preloadMaster, false);
+ //console.log(this.master);
+ for(var q = 0;q0&&cG.avx[1]>0) cG.verbose(1,cG.comicID+"|"+name+"|curPage",":",get);
- else console.log(cG.comicID+"|"+name+"|curPage",":",get);
+ /*if(cG.avx[0]>0&&cG.avx[1]>0) */cG.verbose(1,cG.comicID+"|"+name+"|curPage",":",get);
+ /*else console.log(cG.comicID+"|"+name+"|curPage",":",get);*/
}
if(cG.comix===void 0&&cG.prePage>=0) get = cG.prePage;//prepage, which is from router, overwrites localStorage if over -1, only works on comix
var main = new direction(scriptt,anchor,get);
@@ -224,7 +514,7 @@ return a};this.frst=function(){0<=n&&r(k,0);return 0};this.last=function(){r(k,h
return main.go(main.internals.chapters[main.ch_count()-1][g]);
}
var lscurrent = function(){
- if(typeof(Storage) !== void 0) {
+ if(typeof(Storage) !== void 0&&cG.fBox.pgesve) {
localStorage.setItem(cG.comicID+"|"+name+"|curPage",cG.cPanel[/*"def_"+*/name].current().toString());
}
if(cG.comix===cG.cPanel[/*"def_"+*/name]){//if comic is the comix, then push its state
@@ -253,7 +543,7 @@ return a};this.frst=function(){0<=n&&r(k,0);return 0};this.last=function(){r(k,h
}
//if(cG.avx[0]>0&&cG.avx[1]>0)
cG.verbose(1,name,"Pushing state:",result);
- history.pushState({}, null, "#/"+result);
+ if(cG.fBox.pgepsh) history.pushState({}, null, "#/"+result);
}
if(cG.queue.stageChange!==void 0)
for(var ftn in cG.queue.stageChange){
@@ -281,7 +571,9 @@ return a};this.frst=function(){0<=n&&r(k,0);return 0};this.last=function(){r(k,h
}
}
main.callback(1,lscurrent);
- cG.comix = cG.comix||main;//this should only set the comix on the first call
+ cG.comix = (cG.fBox.protect)?cG.comix||main:main;
+ //if protect is true - set the comix on the first call
+ //else always overwrite comix
return main;
}}};
///////
@@ -414,9 +706,58 @@ cG.queue.stageChange.controller=function(target){
}
}
};
+cG.addRender = function(addme,dest,name){
+ //dest = script obj
+ var pushonpages = function(tget){
+ //convert data to page array
+ var work;
+ for(var i =0;i',
+ antictrl = '