Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*namespace BaseReality\Model*/
- /*use Intahwebz\Utils as Utils*/
- function ContentFilterData() {
- this.clearAllTags = function (){
- this.tags = {};
- this.withoutTags = {};
- };
- this.getPath = function (){
- var result = "" + "" + this.page;
- var separator = "?";
- for (var tagKey in this.tags) {
- var tag = this.tags[tagKey];
- if(tag == null){
- tag = '';
- }
- result += separator + "" + "tags[]=" + "" + tag;
- separator = "&";
- }
- debugger;
- for (var withoutTagKey in this.withoutTags) {
- var withoutTag = this.withoutTags[withoutTagKey];
- if(withoutTag == null){
- withoutTag = '';
- }
- result += separator + "" + "withoutTags[]=" + "" + withoutTag;
- separator = "&";
- }
- return result;
- };
- this.addFilterTag = function (newTag){
- for (var tagKey in this.tags) {
- var tag = this.tags[tagKey];
- if(tag == newTag){
- return;
- }
- }
- array_push(this.tags, newTag);
- this.page = 1;
- };
- this.removeFilterTag = function (tagText){
- var newArray = {};
- for (var tagKey in this.tags) {
- var tag = this.tags[tagKey];
- if(tag != tagText){
- array_push(newArray, tag);
- }
- }
- this.tags = newArray;
- this.page = 1;
- };
- this.addWithoutTag = function (newTag){
- for (var withoutTagKey in this.withoutTags) {
- var withoutTag = this.withoutTags[withoutTagKey];
- if(withoutTag == newTag){
- return;
- }
- }
- array_push(this.withoutTags, newTag);
- this.page = 1;
- };
- this.removeWithoutTag = function (tagText){
- var newArray = {};
- for (var tagKey in this.withoutTags) {
- var tag = this.withoutTags[tagKey];
- if(tag != tagText){
- array_push(newArray, tag);
- }
- }
- this.tags = newArray;
- this.page = 1;
- };
- // function setMode($mode){
- // switch($mode){
- // case('withoutTag'):{
- // $withoutTags = array();
- // break;
- // }
- //
- // default:{
- // throw new \Exception("Unknown mode in ContentFilterData [". $mode."]");
- // }
- // }
- // }
- this.nextPage = function (){
- if(this.page < this.maxPages){
- this.page += 1;
- }
- };
- this.previousPage = function (){
- if(this.page > 1){
- this.page -= 1;
- }
- };
- this.firstPage = function (){
- this.page = 1;
- };
- this.lastPage = function (){
- this.page = this.maxPages;
- };
- this.goToPage = function (newPage){
- /** @noinspection PhpSillyAssignmentInspection */
- newPage = +newPage;
- if(newPage < 1){
- newPage = 1;
- }
- if(newPage > this.maxPages){
- newPage = this.maxPages;
- }
- this.page = newPage;
- };
- this.page = null;
- this.maxPages = null;
- this.itemsPerPage = null;
- this.tags = null;
- this.withoutTags = null;
- this.page = 1;
- this.maxPages = 1;
- this.tags = {};
- this.withoutTags = {};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement